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 项目人天耗用明细分析报表
///
/// 项目人天耗用明细分析报表
///
///
[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 columnNameList = new List();
//添加列名
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 项目人天耗用统计分析报表
///
/// 项目人天耗用统计分析报表
///
///
[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 columnNameList = new List();
//添加列名
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 月度汇报统计表
///
/// 月度汇报统计表
///
///
[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 columnNameList = new List();
//添加列名
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 我的项目 查询
///
/// 我的项目查询
///
///
///
///
[Route("PM_ReportController/PM_ProjectBillMYList")]
[HttpGet]
public object PM_ProjectBillMYList(string sWhere, string user)
{
try
{
List columnNameList = new List();
//查看权限
if (!DBUtility.ClsPub.Security_Log("PM_ProjectBillMainMy_Query", 1, false, user))
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "无查看权限!";
objJsonResult.data = null;
return objJsonResult;
}
string sql = "exec h_p_My_PM_ProjectReportBill " + user+",0,''";
ds=oCn.RunProcReturn(sql, "h_p_My_PM_ProjectReportBill");
//添加列名
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;
objJsonResult.list = columnNameList;
return objJsonResult;
}
catch (Exception e)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "Exception!" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
}
#endregion
#region 抢修附属工费报表 查询
[Route("PM_ReportController/GetPM_ProjectRepairTaskOtherMoneyReport")]
[HttpGet]
public object GetPM_ProjectRepairTaskOtherMoneyReport(string sWhere, string user)
{
try
{
List columnNameList = new List();
Dictionary dic = Newtonsoft.Json.JsonConvert.DeserializeObject>(sWhere);
string HBeginDate = dic["HBeginDate"].ToString();
string HEndDate = dic["HEndDate"].ToString();
string HProjectID = dic["HProjectID"].ToString();//工程项目ID
ds = oCn.RunProcReturn("exec h_p_PM_ProjectRepairTaskOtherMoneyReport '" + HBeginDate + "','" + HEndDate + "','" + HProjectID + "'", "h_p_PM_ProjectRepairTaskOtherMoneyReport");
//添加列名
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 = "Exception!" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
}
#endregion
#region 抢修费用汇总表 查询
[Route("PM_ReportController/GetPM_ProjectRepairTaskSumMoneyReport")]
[HttpGet]
public object GetPM_ProjectRepairTaskSumMoneyReport(string sWhere, string user)
{
try
{
List columnNameList = new List();
Dictionary dic = Newtonsoft.Json.JsonConvert.DeserializeObject>(sWhere);
string HBeginDate = dic["HBeginDate"].ToString();
string HEndDate = dic["HEndDate"].ToString();
string HProjectID = dic["HProjectID"].ToString();//工程项目ID
ds = oCn.RunProcReturn("exec h_p_PM_ProjectRepairTaskSumMoneyReport '" + HBeginDate + "','" + HEndDate + "','" + HProjectID + "'", "h_p_PM_ProjectRepairTaskSumMoneyReport");
//添加列名
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 = "Exception!" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
}
#endregion
#region 抢修汇总表 查询
[Route("PM_ReportController/GetPM_ProjectRepairTaskSumReport")]
[HttpGet]
public object GetPM_ProjectRepairTaskSumReport(string sWhere, string user)
{
try
{
List columnNameList = new List();
Dictionary dic = Newtonsoft.Json.JsonConvert.DeserializeObject>(sWhere);
string HBeginDate = dic["HBeginDate"].ToString();
string HEndDate = dic["HEndDate"].ToString();
ds = oCn.RunProcReturn("exec h_p_PM_ProjectRepairTaskSumReport '" + HBeginDate + "','" + HEndDate + "'", "h_p_PM_ProjectRepairTaskSumReport");
//添加列名
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 = "Exception!" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
}
#endregion
#region 抢修考核出勤明细表 查询
[Route("PM_ReportController/GetPM_ProjectRepairTaskExamMoneyReport")]
[HttpGet]
public object GetPM_ProjectRepairTaskExamMoneyReport(string sWhere, string user)
{
try
{
List columnNameList = new List();
Dictionary dic = Newtonsoft.Json.JsonConvert.DeserializeObject>(sWhere);
string HBeginDate = dic["HBeginDate"].ToString();
string HEndDate = dic["HEndDate"].ToString();
string HProjectID = dic["HProjectID"].ToString();//工程项目ID
ds = oCn.RunProcReturn("exec h_p_PM_ProjectRepairTaskExamMoneyReport '" + HBeginDate + "','" + HEndDate + "','" + HProjectID + "'", "h_p_PM_ProjectRepairTaskExamMoneyReport");
//添加列名
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 = "Exception!" + e.ToString();
objJsonResult.data = null;
return objJsonResult;
}
}
#endregion
#endregion
}
}