using DAL;
|
using DBUtility;
|
using Model;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Linq;
|
using SQLHelper;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Net;
|
using System.Net.Http;
|
using System.Web.Http;
|
using WebAPI;
|
using WebAPI.Models;
|
using WebAPI.Service;
|
|
namespace WebAPI.Controllers
|
{
|
public class PM_ReportController : ApiController
|
{
|
public string sWhere = "";
|
public DataSet ds = new DataSet();
|
private json objJsonResult = new json();
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
|
#region 报表数据获取方法
|
|
#region 项目人天耗用明细分析报表
|
|
/// <summary>
|
/// 项目人天耗用明细分析报表
|
/// </summary>
|
/// <returns></returns>
|
[Route("PM_ReportController/GetPM_ProjectWorkDaysEntryReport_Json")]
|
[HttpGet]
|
public object GetPM_ProjectWorkDaysEntryReport_Json(string sWhere)
|
{
|
try
|
{
|
ds = oCn.RunProcReturn("exec h_p_PM_ProjectWorkDaysEntryReport " + sWhere, "h_p_PM_ProjectWorkDaysEntryReport");
|
//if (ds == null || ds.Tables[0].Rows.Count == 0)
|
//{
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "当前所输入过滤条件,没有返回任何结果!";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
//else
|
//{
|
List<object> columnNameList = new List<object>();
|
//添加列名
|
foreach (DataColumn col in ds.Tables[0].Columns)
|
{
|
Type dataType = col.DataType;
|
string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
|
columnNameList.Add(JsonConvert.DeserializeObject(ColmString)); //获取到DataColumn列对象的列名
|
}
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "成功!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
//}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "返回报表信息失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
#endregion
|
|
#region 项目人天耗用统计分析报表
|
|
/// <summary>
|
/// 项目人天耗用统计分析报表
|
/// </summary>
|
/// <returns></returns>
|
[Route("PM_ReportController/GetPM_ProjectWorkDaysSumReport_Json")]
|
[HttpGet]
|
public object GetPM_ProjectWorkDaysSumReport_Json(string sWhere)
|
{
|
try
|
{
|
ds = oCn.RunProcReturn("exec h_p_PM_ProjectWorkDaysSumReport " + sWhere, "h_p_PM_ProjectWorkDaysSumReport");
|
//if (ds == null || ds.Tables[0].Rows.Count == 0)
|
//{
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "当前所输入过滤条件,没有返回任何结果!";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
//else
|
//{
|
List<object> columnNameList = new List<object>();
|
//添加列名
|
foreach (DataColumn col in ds.Tables[0].Columns)
|
{
|
Type dataType = col.DataType;
|
string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
|
columnNameList.Add(JsonConvert.DeserializeObject(ColmString)); //获取到DataColumn列对象的列名
|
}
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "成功!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
//}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "返回报表信息失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
#endregion
|
|
#region 月度汇报统计表
|
|
/// <summary>
|
/// 月度汇报统计表
|
/// </summary>
|
/// <returns></returns>
|
[Route("PM_ReportController/GetPM_WorkTaskReportMonthSumReport_Json")]
|
[HttpGet]
|
public object GetPM_WorkTaskReportMonthSumReport_Json(string sWhere)
|
{
|
try
|
{
|
ds = oCn.RunProcReturn("exec h_p_PM_WorkTaskReportMonthSumReport " + sWhere, "h_p_PM_WorkTaskReportMonthSumReport");
|
//if (ds == null || ds.Tables[0].Rows.Count == 0)
|
//{
|
// objJsonResult.code = "0";
|
// objJsonResult.count = 0;
|
// objJsonResult.Message = "当前所输入过滤条件,没有返回任何结果!";
|
// objJsonResult.data = null;
|
// return objJsonResult;
|
//}
|
//else
|
//{
|
List<object> columnNameList = new List<object>();
|
//添加列名
|
foreach (DataColumn col in ds.Tables[0].Columns)
|
{
|
Type dataType = col.DataType;
|
string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
|
columnNameList.Add(JsonConvert.DeserializeObject(ColmString)); //获取到DataColumn列对象的列名
|
}
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "成功!";
|
objJsonResult.data = ds.Tables[0];
|
objJsonResult.list = columnNameList;
|
return objJsonResult;
|
//}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "返回报表信息失败!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
|
#endregion
|
|
|
#endregion
|
|
|
}
|
}
|