视图 查看
This commit is contained in:
parent
4c1d921db2
commit
d0cb41d13d
@ -5,6 +5,7 @@ using APT.BaseData.Domain.IServices.BI;
|
||||
using APT.BaseData.Domain.IServices.BS;
|
||||
using APT.BaseData.Domain.IServices.EX;
|
||||
using APT.BaseData.Domain.IServices.FM;
|
||||
using APT.BaseData.Domain.IServices.OP;
|
||||
using APT.BaseData.Domain.IServices.Platform;
|
||||
using APT.BaseData.Services.DomainServices;
|
||||
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.EX;
|
||||
using APT.BaseData.Services.Services.FM;
|
||||
using APT.BaseData.Services.Services.OP;
|
||||
using APT.BaseData.Services.Services.Platform;
|
||||
using APT.BaseData.Services.Sys;
|
||||
using Autofac;
|
||||
@ -66,6 +68,7 @@ namespace APT.HM.WebApi.App_Start
|
||||
builder.RegisterType<BIHomeService>().As<IBIHomeService>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<FMNoticeService>().As<IFMNoticeService>().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.Enums;
|
||||
using APT.BaseData.Domain.IServices.FM;
|
||||
using APT.BaseData.Domain.IServices.OP;
|
||||
using APT.BaseData.Services.Services.FM;
|
||||
using APT.Infrastructure.Api;
|
||||
using APT.Infrastructure.Core;
|
||||
@ -24,7 +25,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using static Google.Protobuf.WireFormat;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
||||
using static NPOI.HSSF.Util.HSSFColor;
|
||||
@ -37,6 +38,14 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
[Route("api/BI/BIKanBanController")]
|
||||
public class BIKanBanController : APTApiController<T_FM_NOTIFICATION_TASK>
|
||||
{
|
||||
IOPTenantDBConnService OPTenantDBConnService { get; set; }
|
||||
public BIKanBanController(IOPTenantDBConnService opTenantDBConnService)
|
||||
{
|
||||
OPTenantDBConnService = opTenantDBConnService;
|
||||
}
|
||||
|
||||
#region 属性定义
|
||||
|
||||
/// <summary>
|
||||
/// 返回所有
|
||||
/// </summary>
|
||||
@ -54,6 +63,9 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
public List<JobFinishRate> jobFinishRate { get; set; }
|
||||
//各公司安全检查统计
|
||||
public List<SafeCheckSum> safeCheckSum { get; set; }
|
||||
|
||||
public List<SETRAINSHOW> listSETrainSum { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -133,6 +145,87 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
public int qty { get; set; }
|
||||
public int num { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 培训教育学时获取
|
||||
/// </summary>
|
||||
public class SETRAIN
|
||||
{
|
||||
/// <summary>
|
||||
/// 公司名称
|
||||
/// </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; }
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 返回看板所有接口
|
||||
/// </summary>
|
||||
@ -140,13 +233,27 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("ReturnAllData")]
|
||||
public ReturnAll ReturnAllData([FromBody] KeywordFilter filter)
|
||||
{
|
||||
string connhead = ConfigurationManager.ConnectionStrings["head"];
|
||||
{
|
||||
ReturnAll result = new ReturnAll();
|
||||
var ListAllORG = GetEntities<T_FM_ORGANIZATION>(e => !e.IS_DELETED && e.CODE != "003", null, null).OrderBy(e => e.TENANT_CODE).ToList();
|
||||
string strConn = OPTenantDBConnService.GetConnByORGID(filter.OrgId.Value);//获取数据库链接
|
||||
|
||||
|
||||
List<string> listVNAME = new List<string>() { "vhome_Train_Hour" };//, "vhome_risk_type_data"
|
||||
DataSet ds = new DataSet();
|
||||
GETDBDATA(strConn, listVNAME, ref ds);//获取视图 数据 listVNAME 与 ds.Tables 一一对应
|
||||
|
||||
//培训教育 对应统计
|
||||
result.listSETrainSum = GetTrainInfo(ds.Tables[0], ListAllORG);
|
||||
|
||||
|
||||
|
||||
string connhead = ConfigurationManager.ConnectionStrings["head"];//删除吧 TPM是没有相对于配置
|
||||
//风险等级占比
|
||||
result.riskTypeRate = RiskTypeRateData(connhead);
|
||||
result.riskTypeRate = RiskTypeRateData(strConn);
|
||||
|
||||
//当日工作票排名前三
|
||||
result.jobTodayTop3 = JobTodayTopData(connhead,filter.OrgId.Value);
|
||||
result.jobTodayTop3 = JobTodayTopData(connhead, filter.OrgId.Value);
|
||||
//隐患整改率
|
||||
result.hiddenRectify = HiddenRectifyData(connhead);
|
||||
//各事项排名前三
|
||||
@ -158,6 +265,50 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
|
||||
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
|
||||
{
|
||||
connection.Open();
|
||||
string sql = string.Empty;
|
||||
foreach (var item in listVNAME)
|
||||
{
|
||||
sql += string.Format(" select * from {0} ", item);
|
||||
}
|
||||
|
||||
using (SqlCommand Com = new SqlCommand(sql, connection))
|
||||
{
|
||||
SqlDataAdapter DataADP = new SqlDataAdapter(Com);
|
||||
DataADP.Fill(ds);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region 子方法
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 风险等级占比
|
||||
/// </summary>
|
||||
@ -206,13 +357,13 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当日工作票排名前三
|
||||
/// </summary>
|
||||
/// <param name="filter">参数</param>
|
||||
/// <returns></returns>
|
||||
public List<JobTodayTop3> JobTodayTopData(string connhead,Guid orgId)
|
||||
public List<JobTodayTop3> JobTodayTopData(string connhead, Guid orgId)
|
||||
{
|
||||
List<JobTodayTop3> result = new List<JobTodayTop3>();
|
||||
var details = new List<JobTodayDetail>();
|
||||
@ -271,7 +422,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
if (result != null && result.Any())
|
||||
{
|
||||
var steps = this.GetEntities<T_HM_OPERATION_STEP>(t => !t.IS_DELETED, new BaseFilter(orgId));
|
||||
foreach (var da in result)
|
||||
foreach (var da in result)
|
||||
{
|
||||
var temps = details.Where(t => t.company == da.company).ToList();
|
||||
if (temps.Any())
|
||||
@ -281,7 +432,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
{
|
||||
var JobTodayDetail = new JobTodayDetail();
|
||||
JobTodayDetail.qty = de.qty;
|
||||
JobTodayDetail.jobName = steps.FirstOrDefault(t=>t.ID == Guid.Parse(de.jobName))?.NAME;
|
||||
JobTodayDetail.jobName = steps.FirstOrDefault(t => t.ID == Guid.Parse(de.jobName))?.NAME;
|
||||
JobTodayDetail.company = de.company;
|
||||
detailTemps.Add(JobTodayDetail);
|
||||
}
|
||||
@ -300,7 +451,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 隐患整改率
|
||||
/// </summary>
|
||||
@ -345,7 +496,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 各事项排名前三
|
||||
/// </summary>
|
||||
@ -387,7 +538,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
}
|
||||
if (dataTemps != null && dataTemps.Any())
|
||||
{
|
||||
var dataGroup = dataTemps.GroupBy(t => new { t.company,t.totalQty }).ToList();
|
||||
var dataGroup = dataTemps.GroupBy(t => new { t.company, t.totalQty }).ToList();
|
||||
foreach (var da in dataGroup)
|
||||
{
|
||||
var TaskTop3 = new TaskTop3();
|
||||
@ -419,8 +570,8 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 作业现场完成情况统计
|
||||
@ -472,7 +623,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 各公司安全检查统计
|
||||
@ -522,6 +673,48 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据整理 培训教育
|
||||
/// </summary>
|
||||
/// <param name="dtTRAIN"></param>
|
||||
/// <param name="listORG"></param>
|
||||
/// <returns></returns>
|
||||
private List<SETRAINSHOW> GetTrainInfo(DataTable dtTRAIN, List<T_FM_ORGANIZATION> listORG)
|
||||
{
|
||||
List<SETRAIN> ListTRAIN = DataHelper.TableToList<SETRAIN>(dtTRAIN);
|
||||
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++)
|
||||
{
|
||||
listDate.Add(dtNowYM.AddMonths(-1 * i));
|
||||
}
|
||||
foreach (var item in listORG)
|
||||
{
|
||||
SETRAINSHOW SUMCNPer = new SETRAINSHOW();
|
||||
SUMCNPer.ORG_ID = item.ORG_ID.Value;
|
||||
SUMCNPer.CN = item.NAME;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@ -1198,6 +1199,38 @@ namespace APT.Utility
|
||||
}
|
||||
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
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user