1
This commit is contained in:
parent
560304c716
commit
0ed4841adc
@ -143,46 +143,77 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
{
|
||||
string connhead = ConfigurationManager.ConnectionStrings["head"];
|
||||
ReturnAll result = new ReturnAll();
|
||||
DataTable tableRisk = new DataTable();
|
||||
DataTable tableJob = new DataTable();
|
||||
DataTable tableJobGroup = new DataTable();
|
||||
DataTable tableHidden = new DataTable();
|
||||
DataTable tableTask = new DataTable();
|
||||
DataTable tableJobRate = new DataTable();
|
||||
DataTable tableSafeCheck = new DataTable();
|
||||
using (SqlConnection connection = new SqlConnection(connhead))
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
//风险等级占比
|
||||
result.riskTypeRate = RiskTypeRateData(connhead);
|
||||
string sqlRisk = "select * from vhome_risk_type_data ";
|
||||
SqlCommand comRisk = new SqlCommand(sqlRisk, connection);
|
||||
SqlDataAdapter riskData = new SqlDataAdapter(comRisk);
|
||||
riskData.Fill(tableRisk);
|
||||
result.riskTypeRate = RiskTypeRateData(connhead, tableRisk);
|
||||
//当日工作票排名前三
|
||||
result.jobTodayTop3 = JobTodayTopData(connhead,filter.OrgId.Value);
|
||||
string sqlJob = "select * from vhome_jobtop3_today ";
|
||||
SqlCommand comJob = new SqlCommand(sqlJob, connection);
|
||||
SqlDataAdapter jobData = new SqlDataAdapter(comJob);
|
||||
jobData.Fill(tableJob);
|
||||
string sqlJobGroup = "select* from vhome_jobdata_today_group";
|
||||
SqlCommand comJobGroup = new SqlCommand(sqlJobGroup, connection);
|
||||
SqlDataAdapter jobGroupData = new SqlDataAdapter(comJobGroup);
|
||||
jobGroupData.Fill(tableJobGroup);
|
||||
result.jobTodayTop3 = JobTodayTopData(connhead, filter.OrgId.Value, tableJob,tableJobGroup);
|
||||
//隐患整改率
|
||||
result.hiddenRectify = HiddenRectifyData(connhead);
|
||||
string sqlHidden = "select * from vhome_hidden_data_result ";
|
||||
SqlCommand comHidden = new SqlCommand(sqlHidden, connection);
|
||||
SqlDataAdapter hiddenData = new SqlDataAdapter(comHidden);
|
||||
hiddenData.Fill(tableHidden);
|
||||
result.hiddenRectify = HiddenRectifyData(connhead, tableHidden);
|
||||
//各事项排名前三
|
||||
result.taskTop3 = TaskTopData(connhead);
|
||||
string sqlTask = "select * from vhome_task_data_result ";
|
||||
SqlCommand comTask = new SqlCommand(sqlTask, connection);
|
||||
SqlDataAdapter taskData = new SqlDataAdapter(comTask);
|
||||
taskData.Fill(tableTask);
|
||||
result.taskTop3 = TaskTopData(connhead, tableTask);
|
||||
//作业现场完成情况统计
|
||||
result.jobFinishRate = jobFinishRateData(connhead);
|
||||
string sqlJobRate = "select * from vhome_jobrecord_data ";
|
||||
SqlCommand comJobRate = new SqlCommand(sqlJobRate, connection);
|
||||
SqlDataAdapter jobRateData = new SqlDataAdapter(comJobRate);
|
||||
jobRateData.Fill(tableJobRate);
|
||||
result.jobFinishRate = jobFinishRateData(connhead, tableJobRate);
|
||||
//各公司安全检查统计
|
||||
result.safeCheckSum = safeCheckSumData(connhead);
|
||||
|
||||
string sqlSafecCheck= "select * from vhome_check_total ";
|
||||
SqlCommand comSafecCheck = new SqlCommand(sqlSafecCheck, connection);
|
||||
SqlDataAdapter safecCheckData = new SqlDataAdapter(comSafecCheck);
|
||||
safecCheckData.Fill(tableSafeCheck);
|
||||
result.safeCheckSum = safeCheckSumData(connhead, tableSafeCheck);
|
||||
connection.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ex.StackTrace))
|
||||
throw new Exception("错误日志:[StackTrace]" + ex.StackTrace);
|
||||
else
|
||||
throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 风险等级占比
|
||||
/// </summary>
|
||||
/// <param name="filter">分页过滤实体</param>
|
||||
public List<RiskTypeRate> RiskTypeRateData(string connhead)
|
||||
public List<RiskTypeRate> RiskTypeRateData(string connhead, DataTable Table)
|
||||
{
|
||||
List<RiskTypeRate> result = new List<RiskTypeRate>();
|
||||
DataTable Table = new DataTable();
|
||||
using (SqlConnection connection = new SqlConnection(connhead))
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
string sql = "select * from vhome_risk_type_data ";
|
||||
//if (dt != DateTime.Now.Date)
|
||||
//{
|
||||
// sql += " and crdate>='" + dt + "'";
|
||||
//}
|
||||
//sql += " order by crdate desc";
|
||||
using (SqlCommand Com = new SqlCommand(sql, connection))
|
||||
{
|
||||
SqlDataAdapter Data = new SqlDataAdapter(Com);
|
||||
Data.Fill(Table);
|
||||
}
|
||||
connection.Close();
|
||||
if (Table != null && Table.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow item in Table.Rows)
|
||||
@ -195,15 +226,6 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ex.StackTrace))
|
||||
throw new Exception("错误日志:[StackTrace]" + ex.StackTrace);
|
||||
else
|
||||
throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -212,40 +234,10 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
/// </summary>
|
||||
/// <param name="filter">参数</param>
|
||||
/// <returns></returns>
|
||||
public List<JobTodayTop3> JobTodayTopData(string connhead,Guid orgId)
|
||||
public List<JobTodayTop3> JobTodayTopData(string connhead,Guid orgId, DataTable Table, DataTable Table2)
|
||||
{
|
||||
List<JobTodayTop3> result = new List<JobTodayTop3>();
|
||||
var details = new List<JobTodayDetail>();
|
||||
DataTable Table = new DataTable();
|
||||
DataTable Table2 = new DataTable();
|
||||
using (SqlConnection connection = new SqlConnection(connhead))
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
string sql = "select * from vhome_jobtop3_today ";
|
||||
//if (dt != DateTime.Now.Date)
|
||||
//{
|
||||
// sql += " and crdate>='" + dt + "'";
|
||||
//}
|
||||
//sql += " order by crdate desc";
|
||||
using (SqlCommand Com = new SqlCommand(sql, connection))
|
||||
{
|
||||
SqlDataAdapter Data = new SqlDataAdapter(Com);
|
||||
Data.Fill(Table);
|
||||
}
|
||||
string sql2 = "select * from vhome_jobdata_today_group ";
|
||||
//if (dt != DateTime.Now.Date)
|
||||
//{
|
||||
// sql += " and crdate>='" + dt + "'";
|
||||
//}
|
||||
//sql += " order by crdate desc";
|
||||
using (SqlCommand Com = new SqlCommand(sql2, connection))
|
||||
{
|
||||
SqlDataAdapter Data = new SqlDataAdapter(Com);
|
||||
Data.Fill(Table2);
|
||||
}
|
||||
connection.Close();
|
||||
if (Table != null && Table.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow item in Table.Rows)
|
||||
@ -289,15 +281,6 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ex.StackTrace))
|
||||
throw new Exception("错误日志:[StackTrace]" + ex.StackTrace);
|
||||
else
|
||||
throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -306,27 +289,9 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
/// </summary>
|
||||
/// <param name="filter">参数</param>
|
||||
/// <returns></returns>
|
||||
public HiddenRectify HiddenRectifyData(string connhead)
|
||||
public HiddenRectify HiddenRectifyData(string connhead, DataTable Table)
|
||||
{
|
||||
HiddenRectify result = new HiddenRectify();
|
||||
DataTable Table = new DataTable();
|
||||
using (SqlConnection connection = new SqlConnection(connhead))
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
string sql = "select * from vhome_hidden_data_result ";
|
||||
//if (dt != DateTime.Now.Date)
|
||||
//{
|
||||
// sql += " and crdate>='" + dt + "'";
|
||||
//}
|
||||
//sql += " order by crdate desc";
|
||||
using (SqlCommand Com = new SqlCommand(sql, connection))
|
||||
{
|
||||
SqlDataAdapter Data = new SqlDataAdapter(Com);
|
||||
Data.Fill(Table);
|
||||
}
|
||||
connection.Close();
|
||||
if (Table != null && Table.Rows.Count > 0)
|
||||
{
|
||||
result.qty = int.Parse(Table.Rows[0]["隐患数"].ToString()) != 0 ? int.Parse(Table.Rows[0]["隐患数"].ToString()) : 0;
|
||||
@ -334,15 +299,6 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
result.delayQty = int.Parse(Table.Rows[0]["延期整改数"].ToString()) != 0 ? int.Parse(Table.Rows[0]["延期整改数"].ToString()) : 0;
|
||||
result.rate = Table.Rows[0]["整改率"] != null ? Table.Rows[0]["整改率"].ToString() : null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ex.StackTrace))
|
||||
throw new Exception("错误日志:[StackTrace]" + ex.StackTrace);
|
||||
else
|
||||
throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -351,28 +307,10 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
/// </summary>
|
||||
/// <param name="filter">参数</param>
|
||||
/// <returns></returns>
|
||||
public List<TaskTop3> TaskTopData(string connhead)
|
||||
public List<TaskTop3> TaskTopData(string connhead, DataTable Table)
|
||||
{
|
||||
List<TaskTop3> result = new List<TaskTop3>();
|
||||
var dataTemps = new List<TaskTopTemp>();
|
||||
DataTable Table = new DataTable();
|
||||
using (SqlConnection connection = new SqlConnection(connhead))
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
string sql = "select * from vhome_task_data_result ";
|
||||
//if (dt != DateTime.Now.Date)
|
||||
//{
|
||||
// sql += " and crdate>='" + dt + "'";
|
||||
//}
|
||||
//sql += " order by crdate desc";
|
||||
using (SqlCommand Com = new SqlCommand(sql, connection))
|
||||
{
|
||||
SqlDataAdapter Data = new SqlDataAdapter(Com);
|
||||
Data.Fill(Table);
|
||||
}
|
||||
connection.Close();
|
||||
if (Table != null && Table.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow item in Table.Rows)
|
||||
@ -409,15 +347,6 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
result.Add(TaskTop3);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ex.StackTrace))
|
||||
throw new Exception("错误日志:[StackTrace]" + ex.StackTrace);
|
||||
else
|
||||
throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -427,27 +356,9 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
/// </summary>
|
||||
/// <param name="filter">参数</param>
|
||||
/// <returns></returns>
|
||||
public List<JobFinishRate> jobFinishRateData(string connhead)
|
||||
public List<JobFinishRate> jobFinishRateData(string connhead, DataTable Table)
|
||||
{
|
||||
List<JobFinishRate> result = new List<JobFinishRate>();
|
||||
DataTable Table = new DataTable();
|
||||
using (SqlConnection connection = new SqlConnection(connhead))
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
string sql = "select * from vhome_jobrecord_data ";
|
||||
//if (dt != DateTime.Now.Date)
|
||||
//{
|
||||
// sql += " and crdate>='" + dt + "'";
|
||||
//}
|
||||
//sql += " order by crdate desc";
|
||||
using (SqlCommand Com = new SqlCommand(sql, connection))
|
||||
{
|
||||
SqlDataAdapter Data = new SqlDataAdapter(Com);
|
||||
Data.Fill(Table);
|
||||
}
|
||||
connection.Close();
|
||||
if (Table != null && Table.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow item in Table.Rows)
|
||||
@ -461,15 +372,6 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ex.StackTrace))
|
||||
throw new Exception("错误日志:[StackTrace]" + ex.StackTrace);
|
||||
else
|
||||
throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -479,27 +381,9 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
/// </summary>
|
||||
/// <param name="filter">参数</param>
|
||||
/// <returns></returns>
|
||||
public List<SafeCheckSum> safeCheckSumData(string connhead)
|
||||
public List<SafeCheckSum> safeCheckSumData(string connhead, DataTable Table)
|
||||
{
|
||||
List<SafeCheckSum> result = new List<SafeCheckSum>();
|
||||
DataTable Table = new DataTable();
|
||||
using (SqlConnection connection = new SqlConnection(connhead))
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
string sql = "select * from vhome_check_total ";
|
||||
//if (dt != DateTime.Now.Date)
|
||||
//{
|
||||
// sql += " and crdate>='" + dt + "'";
|
||||
//}
|
||||
//sql += " order by crdate desc";
|
||||
using (SqlCommand Com = new SqlCommand(sql, connection))
|
||||
{
|
||||
SqlDataAdapter Data = new SqlDataAdapter(Com);
|
||||
Data.Fill(Table);
|
||||
}
|
||||
connection.Close();
|
||||
if (Table != null && Table.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow item in Table.Rows)
|
||||
@ -512,15 +396,6 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ex.StackTrace))
|
||||
throw new Exception("错误日志:[StackTrace]" + ex.StackTrace);
|
||||
else
|
||||
throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user