Compare commits
3 Commits
8703dff7d5
...
835fa8fd00
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
835fa8fd00 | ||
|
|
8dcbfd8bc4 | ||
|
|
d0cb41d13d |
@ -5,6 +5,7 @@ using APT.BaseData.Domain.IServices.BI;
|
|||||||
using APT.BaseData.Domain.IServices.BS;
|
using APT.BaseData.Domain.IServices.BS;
|
||||||
using APT.BaseData.Domain.IServices.EX;
|
using APT.BaseData.Domain.IServices.EX;
|
||||||
using APT.BaseData.Domain.IServices.FM;
|
using APT.BaseData.Domain.IServices.FM;
|
||||||
|
using APT.BaseData.Domain.IServices.OP;
|
||||||
using APT.BaseData.Domain.IServices.Platform;
|
using APT.BaseData.Domain.IServices.Platform;
|
||||||
using APT.BaseData.Services.DomainServices;
|
using APT.BaseData.Services.DomainServices;
|
||||||
using APT.BaseData.Services.Services.AE;
|
using APT.BaseData.Services.Services.AE;
|
||||||
@ -13,6 +14,7 @@ using APT.BaseData.Services.Services.BI;
|
|||||||
using APT.BaseData.Services.Services.BS;
|
using APT.BaseData.Services.Services.BS;
|
||||||
using APT.BaseData.Services.Services.EX;
|
using APT.BaseData.Services.Services.EX;
|
||||||
using APT.BaseData.Services.Services.FM;
|
using APT.BaseData.Services.Services.FM;
|
||||||
|
using APT.BaseData.Services.Services.OP;
|
||||||
using APT.BaseData.Services.Services.Platform;
|
using APT.BaseData.Services.Services.Platform;
|
||||||
using APT.BaseData.Services.Sys;
|
using APT.BaseData.Services.Sys;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
@ -66,6 +68,7 @@ namespace APT.HM.WebApi.App_Start
|
|||||||
builder.RegisterType<BIHomeService>().As<IBIHomeService>().InstancePerLifetimeScope();
|
builder.RegisterType<BIHomeService>().As<IBIHomeService>().InstancePerLifetimeScope();
|
||||||
builder.RegisterType<FMNoticeService>().As<IFMNoticeService>().InstancePerLifetimeScope();
|
builder.RegisterType<FMNoticeService>().As<IFMNoticeService>().InstancePerLifetimeScope();
|
||||||
builder.RegisterType<SENewUserService>().As<ISENewUserService>().InstancePerLifetimeScope();
|
builder.RegisterType<SENewUserService>().As<ISENewUserService>().InstancePerLifetimeScope();
|
||||||
|
builder.RegisterType<OPTenantDBConnService>().As<IOPTenantDBConnService>().InstancePerLifetimeScope();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using APT.BaseData.Domain.Entities.FM;
|
|||||||
using APT.BaseData.Domain.Entities.OP;
|
using APT.BaseData.Domain.Entities.OP;
|
||||||
using APT.BaseData.Domain.Enums;
|
using APT.BaseData.Domain.Enums;
|
||||||
using APT.BaseData.Domain.IServices.FM;
|
using APT.BaseData.Domain.IServices.FM;
|
||||||
|
using APT.BaseData.Domain.IServices.OP;
|
||||||
using APT.BaseData.Services.Services.FM;
|
using APT.BaseData.Services.Services.FM;
|
||||||
using APT.Infrastructure.Api;
|
using APT.Infrastructure.Api;
|
||||||
using APT.Infrastructure.Core;
|
using APT.Infrastructure.Core;
|
||||||
@ -25,7 +26,6 @@ using System.Collections.Generic;
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using static APT.SC.WebApi.Controllers.Api.BI.BIKanBanController;
|
|
||||||
using static Google.Protobuf.WireFormat;
|
using static Google.Protobuf.WireFormat;
|
||||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
||||||
using static NPOI.HSSF.Util.HSSFColor;
|
using static NPOI.HSSF.Util.HSSFColor;
|
||||||
@ -38,6 +38,11 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
|||||||
[Route("api/BI/BIKanBanController")]
|
[Route("api/BI/BIKanBanController")]
|
||||||
public class BIKanBanController : APTApiController<T_FM_NOTIFICATION_TASK>
|
public class BIKanBanController : APTApiController<T_FM_NOTIFICATION_TASK>
|
||||||
{
|
{
|
||||||
|
IOPTenantDBConnService OPTenantDBConnService { get; set; }
|
||||||
|
public BIKanBanController(IOPTenantDBConnService opTenantDBConnService)
|
||||||
|
{
|
||||||
|
OPTenantDBConnService = opTenantDBConnService;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 返回所有
|
/// 返回所有
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -55,8 +60,10 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
|||||||
public List<JobFinishRate> jobFinishRate { get; set; }
|
public List<JobFinishRate> jobFinishRate { get; set; }
|
||||||
//各公司安全检查统计
|
//各公司安全检查统计
|
||||||
public List<SafeCheckSum> safeCheckSum { get; set; }
|
public List<SafeCheckSum> safeCheckSum { get; set; }
|
||||||
//各公司危险作业统计
|
/// <summary>
|
||||||
public List<LinkSum> linkSum { get; set; }
|
/// 培训教育
|
||||||
|
/// </summary>
|
||||||
|
public List<SETRAINSHOW> listSETrainSum { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -136,84 +143,153 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
|||||||
public int qty { get; set; }
|
public int qty { get; set; }
|
||||||
public int num { get; set; }
|
public int num { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 各公司危险作业统计
|
/// 培训教育学时获取
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class LinkSum
|
public class SETRAIN
|
||||||
{
|
{
|
||||||
public string name { get; set; }
|
/// <summary>
|
||||||
public int qty { get; set; }
|
/// 公司名称
|
||||||
|
/// </summary>
|
||||||
|
public string CN { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public Guid ORG_ID { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 培训时长
|
||||||
|
/// </summary>
|
||||||
|
public decimal TRAIN_HOUR { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开始时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime START_TIME { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SETRAINSHOW
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 公司名称
|
||||||
|
/// </summary>
|
||||||
|
public string CN { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public Guid ORG_ID { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前年月
|
||||||
|
/// </summary>
|
||||||
|
public DateTime dtNowYM { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 当前年月-1
|
||||||
|
/// </summary>
|
||||||
|
public DateTime dtNowYM_1 { get; set; }
|
||||||
|
public DateTime dtNowYM_2 { get; set; }
|
||||||
|
public DateTime dtNowYM_3 { get; set; }
|
||||||
|
public DateTime dtNowYM_4 { get; set; }
|
||||||
|
public DateTime dtNowYM_5 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前月 培训时长总和
|
||||||
|
/// </summary>
|
||||||
|
public decimal SUM_TRAIN_HOUR { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前月-1 培训时长总和
|
||||||
|
/// </summary>
|
||||||
|
public decimal SUM_TRAIN_HOUR_1 { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 当前月-2 培训时长总和
|
||||||
|
/// </summary>
|
||||||
|
public decimal SUM_TRAIN_HOUR_2 { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 当前月-3 培训时长总和
|
||||||
|
/// </summary>
|
||||||
|
public decimal SUM_TRAIN_HOUR_3 { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 当前月-4 培训时长总和
|
||||||
|
/// </summary>
|
||||||
|
public decimal SUM_TRAIN_HOUR_4 { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 当前月-5 培训时长总和
|
||||||
|
/// </summary>
|
||||||
|
public decimal SUM_TRAIN_HOUR_5 { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 返回看板所有接口
|
/// 返回看板所有接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filter">分页过滤实体</param>
|
/// <param name="filter">分页过滤实体</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost, Route("ReturnAllData")]
|
[HttpPost, Route("ReturnAllData")]
|
||||||
public JsonActionResult<ReturnAll> ReturnAllData([FromBody] KeywordFilter filter)
|
public ReturnAll ReturnAllData([FromBody] KeywordFilter filter)
|
||||||
{
|
{
|
||||||
string connhead = ConfigurationManager.ConnectionStrings["head"];
|
ReturnAll result = new ReturnAll();
|
||||||
JsonActionResult<ReturnAll> result = new JsonActionResult<ReturnAll>();
|
var ListAllORG = GetEntities<T_FM_ORGANIZATION>(e => !e.IS_DELETED && e.CODE != "003", null, null).OrderBy(e => e.TENANT_CODE).ToList();
|
||||||
result.Data = new ReturnAll();
|
string strConn = OPTenantDBConnService.GetConnByORGID(filter.OrgId.Value);//获取数据库链接
|
||||||
DataTable tableRisk = new DataTable();
|
|
||||||
DataTable tableJob = new DataTable();
|
|
||||||
DataTable tableJobGroup = new DataTable();
|
List<string> listVNAME = new List<string>() { "vhome_Train_Hour" };//, "vhome_risk_type_data"
|
||||||
DataTable tableHidden = new DataTable();
|
DataSet ds = new DataSet();
|
||||||
DataTable tableTask = new DataTable();
|
GETDBDATA(strConn, listVNAME, ref ds);//获取视图 数据 listVNAME 与 ds.Tables 一一对应
|
||||||
DataTable tableJobRate = new DataTable();
|
|
||||||
DataTable tableSafeCheck = new DataTable();
|
//培训教育 对应统计
|
||||||
DataTable tableLink = new DataTable();
|
result.listSETrainSum = GetTrainInfo(ds.Tables[0], ListAllORG);
|
||||||
using (SqlConnection connection = new SqlConnection(connhead))
|
|
||||||
|
|
||||||
|
|
||||||
|
string connhead = ConfigurationManager.ConnectionStrings["head"];//删除吧 TPM是没有相对于配置
|
||||||
|
//风险等级占比
|
||||||
|
result.riskTypeRate = RiskTypeRateData(connhead);
|
||||||
|
//当日工作票排名前三
|
||||||
|
result.jobTodayTop3 = JobTodayTopData(connhead, filter.OrgId.Value);
|
||||||
|
//隐患整改率
|
||||||
|
result.hiddenRectify = HiddenRectifyData(connhead);
|
||||||
|
//各事项排名前三
|
||||||
|
result.taskTop3 = TaskTopData(connhead);
|
||||||
|
//作业现场完成情况统计
|
||||||
|
result.jobFinishRate = jobFinishRateData(connhead);
|
||||||
|
//各公司安全检查统计
|
||||||
|
result.safeCheckSum = safeCheckSumData(connhead);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取视图数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="conn"></param>
|
||||||
|
/// <param name="listVNAME"></param>
|
||||||
|
/// <param name="DataADP">数据集</param>
|
||||||
|
/// <exception cref="Exception"></exception>
|
||||||
|
private void GETDBDATA(string conn, List<string> listVNAME, ref DataSet ds)
|
||||||
|
{
|
||||||
|
List<RiskTypeRate> result = new List<RiskTypeRate>();
|
||||||
|
//DataTable Table = new DataTable();
|
||||||
|
ds = new DataSet();
|
||||||
|
using (SqlConnection connection = new SqlConnection(conn))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connection.Open();
|
connection.Open();
|
||||||
//风险等级占比
|
string sql = string.Empty;
|
||||||
string sqlRisk = "select * from vhome_risk_type_data ";
|
foreach (var item in listVNAME)
|
||||||
SqlCommand comRisk = new SqlCommand(sqlRisk, connection);
|
{
|
||||||
SqlDataAdapter riskData = new SqlDataAdapter(comRisk);
|
sql += string.Format(" select * from {0} ", item);
|
||||||
riskData.Fill(tableRisk);
|
}
|
||||||
result.Data.riskTypeRate = RiskTypeRateData(connhead, tableRisk);
|
|
||||||
//当日工作票排名前三
|
using (SqlCommand Com = new SqlCommand(sql, connection))
|
||||||
string sqlJob = "select * from vhome_jobtop3_today ";
|
{
|
||||||
SqlCommand comJob = new SqlCommand(sqlJob, connection);
|
SqlDataAdapter DataADP = new SqlDataAdapter(Com);
|
||||||
SqlDataAdapter jobData = new SqlDataAdapter(comJob);
|
DataADP.Fill(ds);
|
||||||
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.Data.jobTodayTop3 = JobTodayTopData(connhead, filter.OrgId.Value, tableJob,tableJobGroup);
|
|
||||||
//隐患整改率
|
|
||||||
string sqlHidden = "select * from vhome_hidden_data_result ";
|
|
||||||
SqlCommand comHidden = new SqlCommand(sqlHidden, connection);
|
|
||||||
SqlDataAdapter hiddenData = new SqlDataAdapter(comHidden);
|
|
||||||
hiddenData.Fill(tableHidden);
|
|
||||||
result.Data.hiddenRectify = HiddenRectifyData(connhead, tableHidden);
|
|
||||||
//各事项排名前三
|
|
||||||
string sqlTask = "select * from vhome_task_data_result ";
|
|
||||||
SqlCommand comTask = new SqlCommand(sqlTask, connection);
|
|
||||||
SqlDataAdapter taskData = new SqlDataAdapter(comTask);
|
|
||||||
taskData.Fill(tableTask);
|
|
||||||
result.Data.taskTop3 = TaskTopData(connhead, tableTask);
|
|
||||||
//作业现场完成情况统计
|
|
||||||
string sqlJobRate = "select * from vhome_jobrecord_data ";
|
|
||||||
SqlCommand comJobRate = new SqlCommand(sqlJobRate, connection);
|
|
||||||
SqlDataAdapter jobRateData = new SqlDataAdapter(comJobRate);
|
|
||||||
jobRateData.Fill(tableJobRate);
|
|
||||||
result.Data.jobFinishRate = jobFinishRateData(connhead, tableJobRate);
|
|
||||||
//各公司安全检查统计
|
|
||||||
string sqlSafecCheck= "select * from vhome_check_total ";
|
|
||||||
SqlCommand comSafecCheck = new SqlCommand(sqlSafecCheck, connection);
|
|
||||||
SqlDataAdapter safecCheckData = new SqlDataAdapter(comSafecCheck);
|
|
||||||
safecCheckData.Fill(tableSafeCheck);
|
|
||||||
result.Data.safeCheckSum = safeCheckSumData(connhead, tableSafeCheck);
|
|
||||||
//各公司危险分类统计
|
|
||||||
string sqlLink = "select * from vhome_operationLink_data ";
|
|
||||||
SqlCommand comLink = new SqlCommand(sqlLink, connection);
|
|
||||||
SqlDataAdapter linkData = new SqlDataAdapter(comLink);
|
|
||||||
linkData.Fill(tableLink);
|
|
||||||
result.Data.linkSum = linkSumData(connhead, tableLink);
|
|
||||||
connection.Close();
|
connection.Close();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -224,15 +300,33 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
|||||||
throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
|
throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 风险等级占比
|
/// 风险等级占比
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filter">分页过滤实体</param>
|
/// <param name="filter">分页过滤实体</param>
|
||||||
public List<RiskTypeRate> RiskTypeRateData(string connhead, DataTable Table)
|
public List<RiskTypeRate> RiskTypeRateData(string connhead)
|
||||||
{
|
{
|
||||||
List<RiskTypeRate> result = new List<RiskTypeRate>();
|
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)
|
if (Table != null && Table.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (DataRow item in Table.Rows)
|
foreach (DataRow item in Table.Rows)
|
||||||
@ -245,6 +339,15 @@ 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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,10 +356,40 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filter">参数</param>
|
/// <param name="filter">参数</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<JobTodayTop3> JobTodayTopData(string connhead,Guid orgId, DataTable Table, DataTable Table2)
|
public List<JobTodayTop3> JobTodayTopData(string connhead, Guid orgId)
|
||||||
{
|
{
|
||||||
List<JobTodayTop3> result = new List<JobTodayTop3>();
|
List<JobTodayTop3> result = new List<JobTodayTop3>();
|
||||||
var details = new List<JobTodayDetail>();
|
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(sql, connection))
|
||||||
|
{
|
||||||
|
SqlDataAdapter Data = new SqlDataAdapter(Com);
|
||||||
|
Data.Fill(Table2);
|
||||||
|
}
|
||||||
|
connection.Close();
|
||||||
if (Table != null && Table.Rows.Count > 0)
|
if (Table != null && Table.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (DataRow item in Table.Rows)
|
foreach (DataRow item in Table.Rows)
|
||||||
@ -300,6 +433,15 @@ 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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,9 +450,27 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filter">参数</param>
|
/// <param name="filter">参数</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public HiddenRectify HiddenRectifyData(string connhead, DataTable Table)
|
public HiddenRectify HiddenRectifyData(string connhead)
|
||||||
{
|
{
|
||||||
HiddenRectify result = new HiddenRectify();
|
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)
|
if (Table != null && Table.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
result.qty = int.Parse(Table.Rows[0]["隐患数"].ToString()) != 0 ? int.Parse(Table.Rows[0]["隐患数"].ToString()) : 0;
|
result.qty = int.Parse(Table.Rows[0]["隐患数"].ToString()) != 0 ? int.Parse(Table.Rows[0]["隐患数"].ToString()) : 0;
|
||||||
@ -318,6 +478,15 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
|||||||
result.delayQty = int.Parse(Table.Rows[0]["延期整改数"].ToString()) != 0 ? int.Parse(Table.Rows[0]["延期整改数"].ToString()) : 0;
|
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;
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,10 +495,28 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filter">参数</param>
|
/// <param name="filter">参数</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<TaskTop3> TaskTopData(string connhead, DataTable Table)
|
public List<TaskTop3> TaskTopData(string connhead)
|
||||||
{
|
{
|
||||||
List<TaskTop3> result = new List<TaskTop3>();
|
List<TaskTop3> result = new List<TaskTop3>();
|
||||||
var dataTemps = new List<TaskTopTemp>();
|
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)
|
if (Table != null && Table.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (DataRow item in Table.Rows)
|
foreach (DataRow item in Table.Rows)
|
||||||
@ -366,6 +553,15 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
|||||||
result.Add(TaskTop3);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,9 +571,27 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filter">参数</param>
|
/// <param name="filter">参数</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<JobFinishRate> jobFinishRateData(string connhead, DataTable Table)
|
public List<JobFinishRate> jobFinishRateData(string connhead)
|
||||||
{
|
{
|
||||||
List<JobFinishRate> result = new List<JobFinishRate>();
|
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)
|
if (Table != null && Table.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (DataRow item in Table.Rows)
|
foreach (DataRow item in Table.Rows)
|
||||||
@ -391,6 +605,15 @@ 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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,9 +623,27 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filter">参数</param>
|
/// <param name="filter">参数</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<SafeCheckSum> safeCheckSumData(string connhead, DataTable Table)
|
public List<SafeCheckSum> safeCheckSumData(string connhead)
|
||||||
{
|
{
|
||||||
List<SafeCheckSum> result = new List<SafeCheckSum>();
|
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)
|
if (Table != null && Table.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (DataRow item in Table.Rows)
|
foreach (DataRow item in Table.Rows)
|
||||||
@ -415,28 +656,55 @@ 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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 各公司危险作业统计
|
/// 数据整理 培训教育
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filter">参数</param>
|
/// <param name="dtTRAIN"></param>
|
||||||
|
/// <param name="listORG"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<LinkSum> linkSumData(string connhead, DataTable Table)
|
private List<SETRAINSHOW> GetTrainInfo(DataTable dtTRAIN, List<T_FM_ORGANIZATION> listORG)
|
||||||
{
|
{
|
||||||
List<LinkSum> result = new List<LinkSum>();
|
List<SETRAIN> ListTRAIN = DataHelper.TableToList<SETRAIN>(dtTRAIN);
|
||||||
if (Table != null && Table.Rows.Count > 0)
|
List<SETRAINSHOW> dtInfo = new List<SETRAINSHOW>();
|
||||||
|
//所有公司 按月 倒推 6 个月的数据
|
||||||
|
List<DateTime> listDate = new List<DateTime>();
|
||||||
|
DateTime dtNowYM = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-01 00:00:00"));
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
foreach (DataRow item in Table.Rows)
|
listDate.Add(dtNowYM.AddMonths(-1 * i));
|
||||||
|
}
|
||||||
|
foreach (var item in listORG)
|
||||||
{
|
{
|
||||||
result.Add(new LinkSum()
|
SETRAINSHOW SUMCNPer = new SETRAINSHOW();
|
||||||
{
|
SUMCNPer.ORG_ID = item.ORG_ID.Value;
|
||||||
name = item["NAME"] != null ? item["NAME"].ToString() : null,
|
SUMCNPer.CN = item.NAME;
|
||||||
qty = !string.IsNullOrEmpty(item["cnt"].ToString()) && int.Parse(item["cnt"].ToString()) != 0 ? int.Parse(item["cnt"].ToString()) : 0
|
SUMCNPer.dtNowYM = dtNowYM;
|
||||||
});
|
SUMCNPer.dtNowYM_1 = listDate[1];
|
||||||
|
SUMCNPer.dtNowYM_2 = listDate[2];
|
||||||
|
SUMCNPer.dtNowYM_3 = listDate[3];
|
||||||
|
SUMCNPer.dtNowYM_4 = listDate[4];
|
||||||
|
SUMCNPer.dtNowYM_5 = listDate[5];
|
||||||
|
SUMCNPer.SUM_TRAIN_HOUR = ListTRAIN.Where(e => e.ORG_ID == SUMCNPer.ORG_ID && e.START_TIME.Year == listDate[0].Year && e.START_TIME.Month == listDate[0].Month).Sum(e => e.TRAIN_HOUR);
|
||||||
|
SUMCNPer.SUM_TRAIN_HOUR_1 = ListTRAIN.Where(e => e.ORG_ID == SUMCNPer.ORG_ID && e.START_TIME.Year == listDate[1].Year && e.START_TIME.Month == listDate[1].Month).Sum(e => e.TRAIN_HOUR);
|
||||||
|
SUMCNPer.SUM_TRAIN_HOUR_2 = ListTRAIN.Where(e => e.ORG_ID == SUMCNPer.ORG_ID && e.START_TIME.Year == listDate[2].Year && e.START_TIME.Month == listDate[2].Month).Sum(e => e.TRAIN_HOUR);
|
||||||
|
SUMCNPer.SUM_TRAIN_HOUR_3 = ListTRAIN.Where(e => e.ORG_ID == SUMCNPer.ORG_ID && e.START_TIME.Year == listDate[3].Year && e.START_TIME.Month == listDate[3].Month).Sum(e => e.TRAIN_HOUR);
|
||||||
|
SUMCNPer.SUM_TRAIN_HOUR_4 = ListTRAIN.Where(e => e.ORG_ID == SUMCNPer.ORG_ID && e.START_TIME.Year == listDate[4].Year && e.START_TIME.Month == listDate[4].Month).Sum(e => e.TRAIN_HOUR);
|
||||||
|
SUMCNPer.SUM_TRAIN_HOUR_5 = ListTRAIN.Where(e => e.ORG_ID == SUMCNPer.ORG_ID && e.START_TIME.Year == listDate[5].Year && e.START_TIME.Month == listDate[5].Month).Sum(e => e.TRAIN_HOUR);
|
||||||
|
dtInfo.Add(SUMCNPer);
|
||||||
}
|
}
|
||||||
}
|
return dtInfo;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Http;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@ -1198,6 +1199,38 @@ namespace APT.Utility
|
|||||||
}
|
}
|
||||||
return age;
|
return age;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DataTable 转 List
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="dt"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<T> TableToList<T>(DataTable dt) where T : new()
|
||||||
|
{
|
||||||
|
List<T> ts = new List<T>();
|
||||||
|
Type type = typeof(T);
|
||||||
|
string tempName = "";
|
||||||
|
|
||||||
|
foreach (DataRow dr in dt.Rows)
|
||||||
|
{
|
||||||
|
T t = new T();
|
||||||
|
PropertyInfo[] propertys = t.GetType().GetProperties();
|
||||||
|
foreach (PropertyInfo pi in propertys)
|
||||||
|
{
|
||||||
|
tempName = pi.Name;
|
||||||
|
if (dt.Columns.Contains(tempName))
|
||||||
|
{
|
||||||
|
if (!pi.CanWrite) continue;
|
||||||
|
object value = dr[tempName];
|
||||||
|
if (value != DBNull.Value)
|
||||||
|
pi.SetValue(t, value, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ts.Add(t);
|
||||||
|
}
|
||||||
|
return ts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public class BitAnd
|
public class BitAnd
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user