diff --git a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIKanBanController.cs b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIKanBanController.cs index ceaa2fc..8666fc4 100644 --- a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIKanBanController.cs +++ b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIKanBanController.cs @@ -3,8 +3,8 @@ 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.BaseData.Services.Services.OP; using APT.Infrastructure.Api; using APT.Infrastructure.Core; using APT.Migrations; @@ -26,6 +26,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data; using System.Linq; +using static APT.SC.WebApi.Controllers.Api.BI.BIKanBanController; using static Google.Protobuf.WireFormat; using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; using static NPOI.HSSF.Util.HSSFColor; @@ -38,11 +39,6 @@ namespace APT.SC.WebApi.Controllers.Api.BI [Route("api/BI/BIKanBanController")] public class BIKanBanController : APTApiController { - IOPTenantDBConnService OPTenantDBConnService { get; set; } - public BIKanBanController(IOPTenantDBConnService opTenantDBConnService) - { - OPTenantDBConnService = opTenantDBConnService; - } /// /// 返回所有 /// @@ -60,9 +56,9 @@ namespace APT.SC.WebApi.Controllers.Api.BI public List jobFinishRate { get; set; } //各公司安全检查统计 public List safeCheckSum { get; set; } - /// - /// 培训教育 - /// + //各公司危险作业统计 + public List linkSum { get; set; } + public List listSETrainSum { get; set; } } @@ -143,9 +139,14 @@ namespace APT.SC.WebApi.Controllers.Api.BI public int qty { get; set; } public int num { get; set; } } - - - + /// + /// 各公司危险作业统计 + /// + public class LinkSum + { + public string name { get; set; } + public int qty { get; set; } + } /// /// 培训教育学时获取 /// @@ -170,7 +171,6 @@ namespace APT.SC.WebApi.Controllers.Api.BI /// public DateTime START_TIME { get; set; } } - public class SETRAINSHOW { /// @@ -222,46 +222,100 @@ namespace APT.SC.WebApi.Controllers.Api.BI public decimal SUM_TRAIN_HOUR_5 { get; set; } } - /// /// 返回看板所有接口 /// /// 分页过滤实体 /// [HttpPost, Route("ReturnAllData")] - public ReturnAll ReturnAllData([FromBody] KeywordFilter filter) + public JsonActionResult ReturnAllData([FromBody] KeywordFilter filter) { - ReturnAll result = new ReturnAll(); - var ListAllORG = GetEntities(e => !e.IS_DELETED && e.CODE != "003", null, null).OrderBy(e => e.TENANT_CODE).ToList(); - string strConn = OPTenantDBConnService.GetConnByORGID(filter.OrgId.Value);//获取数据库链接 + string connhead = ConfigurationManager.ConnectionStrings["head"]; + JsonActionResult result = new JsonActionResult(); + result.Data = 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(); + DataTable tableLink = new DataTable(); + using (SqlConnection connection = new SqlConnection(connhead)) + { + try + { + connection.Open(); + //风险等级占比 + string sqlRisk = "select * from vhome_risk_type_data "; + SqlCommand comRisk = new SqlCommand(sqlRisk, connection); + SqlDataAdapter riskData = new SqlDataAdapter(comRisk); + riskData.Fill(tableRisk); + result.Data.riskTypeRate = RiskTypeRateData(connhead, tableRisk); + //当日工作票排名前三 + 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.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); - List listVNAME = new List() { "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); + //培训教育 对应统计 + var ListAllORG = GetEntities(e => !e.IS_DELETED && e.CODE != "003", null, null).OrderBy(e => e.TENANT_CODE).ToList(); + string strConn = OPTenantDBConnService.GetConnByORGID(filter.OrgId.Value);//获取数据库链接 + List listVNAME = new List() { "vhome_Train_Hour" };//, "vhome_risk_type_data" + DataSet ds = new DataSet(); + GETDBDATA(strConn, listVNAME, ref ds);//获取视图 数据 listVNAME 与 ds.Tables 一一对应 + result.Data.listSETrainSum = GetTrainInfo(ds.Tables[0], ListAllORG); - 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); - + 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; } - /// /// 获取视图数据 /// @@ -301,51 +355,23 @@ namespace APT.SC.WebApi.Controllers.Api.BI } } } - /// /// 风险等级占比 /// /// 分页过滤实体 - public List RiskTypeRateData(string connhead) + public List RiskTypeRateData(string connhead, DataTable Table) { List result = new List(); - DataTable Table = new DataTable(); - using (SqlConnection connection = new SqlConnection(connhead)) + if (Table != null && Table.Rows.Count > 0) { - try + foreach (DataRow item in Table.Rows) { - 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)) + result.Add(new RiskTypeRate() { - SqlDataAdapter Data = new SqlDataAdapter(Com); - Data.Fill(Table); - } - connection.Close(); - if (Table != null && Table.Rows.Count > 0) - { - foreach (DataRow item in Table.Rows) - { - result.Add(new RiskTypeRate() - { - riskType = item["风险类别"] != null ? item["风险类别"].ToString() : null, - count = int.Parse(item["数量"].ToString()) != 0 ? int.Parse(item["数量"].ToString()) : 0, - rate = item["占比"] != null ? item["占比"].ToString() : "0" - }); - } - } - } - catch (Exception ex) - { - if (!string.IsNullOrEmpty(ex.StackTrace)) - throw new Exception("错误日志:[StackTrace]" + ex.StackTrace); - else - throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message); + riskType = item["风险类别"] != null ? item["风险类别"].ToString() : null, + count = int.Parse(item["数量"].ToString()) != 0 ? int.Parse(item["数量"].ToString()) : 0, + rate = item["占比"] != null ? item["占比"].ToString() : "0" + }); } } return result; @@ -356,90 +382,51 @@ namespace APT.SC.WebApi.Controllers.Api.BI /// /// 参数 /// - public List JobTodayTopData(string connhead, Guid orgId) + public List JobTodayTopData(string connhead, Guid orgId, DataTable Table, DataTable Table2) { List result = new List(); var details = new List(); - DataTable Table = new DataTable(); - DataTable Table2 = new DataTable(); - using (SqlConnection connection = new SqlConnection(connhead)) + if (Table != null && Table.Rows.Count > 0) { - try + foreach (DataRow item in Table.Rows) { - 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)) + var JobTodayTop3 = new JobTodayTop3(); + JobTodayTop3.totalQty = int.Parse(item["今日总数"].ToString()) != 0 ? int.Parse(item["今日总数"].ToString()) : 0; + JobTodayTop3.num = int.Parse(item["排名"].ToString()) != 0 ? int.Parse(item["排名"].ToString()) : 0; + JobTodayTop3.company = item["公司名称"] != null ? item["公司名称"].ToString() : ""; + result.Add(JobTodayTop3); + } + } + if (Table2 != null && Table2.Rows.Count > 0) + { + foreach (DataRow item2 in Table2.Rows) + { + var JobTodayDetail = new JobTodayDetail(); + JobTodayDetail.qty = int.Parse(item2["cnt"].ToString()) != 0 ? int.Parse(item2["cnt"].ToString()) : 0; + JobTodayDetail.jobName = item2["stepid"] != null ? item2["stepid"].ToString() : null; + JobTodayDetail.company = item2["db_name"] != null ? item2["db_name"].ToString() : null; + details.Add(JobTodayDetail); + } + } + if (result != null && result.Any()) + { + var steps = this.GetEntities(t => !t.IS_DELETED, new BaseFilter(orgId)); + foreach (var da in result) + { + var temps = details.Where(t => t.company == da.company).ToList(); + if (temps.Any()) { - 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) - { - foreach (DataRow item in Table.Rows) - { - var JobTodayTop3 = new JobTodayTop3(); - JobTodayTop3.totalQty = int.Parse(item["今日总数"].ToString()) != 0 ? int.Parse(item["今日总数"].ToString()) : 0; - JobTodayTop3.num = int.Parse(item["排名"].ToString()) != 0 ? int.Parse(item["排名"].ToString()) : 0; - JobTodayTop3.company = item["公司名称"] != null ? item["公司名称"].ToString() : ""; - result.Add(JobTodayTop3); - } - } - if (Table2 != null && Table2.Rows.Count > 0) - { - foreach (DataRow item2 in Table2.Rows) + var detailTemps = new List(); + foreach (var de in temps) { var JobTodayDetail = new JobTodayDetail(); - JobTodayDetail.qty = int.Parse(item2["cnt"].ToString()) != 0 ? int.Parse(item2["cnt"].ToString()) : 0; - JobTodayDetail.jobName = item2["stepid"] != null ? item2["stepid"].ToString() : null; - JobTodayDetail.company = item2["db_name"] != null ? item2["db_name"].ToString() : null; - details.Add(JobTodayDetail); + JobTodayDetail.qty = de.qty; + JobTodayDetail.jobName = steps.FirstOrDefault(t => t.ID == Guid.Parse(de.jobName))?.NAME; + JobTodayDetail.company = de.company; + detailTemps.Add(JobTodayDetail); } + da.details = detailTemps; } - if (result != null && result.Any()) - { - var steps = this.GetEntities(t => !t.IS_DELETED, new BaseFilter(orgId)); - foreach (var da in result) - { - var temps = details.Where(t => t.company == da.company).ToList(); - if (temps.Any()) - { - var detailTemps = new List(); - foreach (var de in temps) - { - var JobTodayDetail = new JobTodayDetail(); - JobTodayDetail.qty = de.qty; - JobTodayDetail.jobName = steps.FirstOrDefault(t => t.ID == Guid.Parse(de.jobName))?.NAME; - JobTodayDetail.company = de.company; - detailTemps.Add(JobTodayDetail); - } - da.details = detailTemps; - } - } - } - } - 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; @@ -450,42 +437,15 @@ namespace APT.SC.WebApi.Controllers.Api.BI /// /// 参数 /// - 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)) + if (Table != null && Table.Rows.Count > 0) { - 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; - result.ontimeQty = 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; - } - } - catch (Exception ex) - { - if (!string.IsNullOrEmpty(ex.StackTrace)) - throw new Exception("错误日志:[StackTrace]" + ex.StackTrace); - else - throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message); - } + result.qty = int.Parse(Table.Rows[0]["隐患数"].ToString()) != 0 ? int.Parse(Table.Rows[0]["隐患数"].ToString()) : 0; + result.ontimeQty = 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; } return result; } @@ -495,71 +455,44 @@ namespace APT.SC.WebApi.Controllers.Api.BI /// /// 参数 /// - public List TaskTopData(string connhead) + public List TaskTopData(string connhead, DataTable Table) { List result = new List(); var dataTemps = new List(); - DataTable Table = new DataTable(); - using (SqlConnection connection = new SqlConnection(connhead)) + if (Table != null && Table.Rows.Count > 0) { - try + foreach (DataRow item in Table.Rows) { - 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) - { - var JobTodayTop3 = new TaskTopTemp(); - JobTodayTop3.totalQty = int.Parse(item["待办总数"].ToString()) != 0 ? int.Parse(item["待办总数"].ToString()) : 0; - JobTodayTop3.qty = int.Parse(item["数量"].ToString()) != 0 ? int.Parse(item["数量"].ToString()) : 0; - JobTodayTop3.company = item["公司名称"] != null ? item["公司名称"].ToString() : ""; - JobTodayTop3.type = item["类型"] != null ? item["类型"].ToString() : ""; - dataTemps.Add(JobTodayTop3); - } - } - if (dataTemps != null && dataTemps.Any()) - { - var dataGroup = dataTemps.GroupBy(t => new { t.company, t.totalQty }).ToList(); - foreach (var da in dataGroup) - { - var TaskTop3 = new TaskTop3(); - TaskTop3.company = da.Key.company; - TaskTop3.totalQty = da.Key.totalQty; - var temps = dataTemps.Where(t => t.company == da.Key.company).ToList(); - if (temps.Any()) - { - var detailTemps = new List(); - foreach (var de in temps) - { - var JobTodayDetail = new TaskTopDetail(); - JobTodayDetail.qty = de.qty; - JobTodayDetail.name = de.type; - detailTemps.Add(JobTodayDetail); - } - TaskTop3.details = detailTemps; - } - result.Add(TaskTop3); - } - } + var JobTodayTop3 = new TaskTopTemp(); + JobTodayTop3.totalQty = int.Parse(item["待办总数"].ToString()) != 0 ? int.Parse(item["待办总数"].ToString()) : 0; + JobTodayTop3.qty = int.Parse(item["数量"].ToString()) != 0 ? int.Parse(item["数量"].ToString()) : 0; + JobTodayTop3.company = item["公司名称"] != null ? item["公司名称"].ToString() : ""; + JobTodayTop3.type = item["类型"] != null ? item["类型"].ToString() : ""; + dataTemps.Add(JobTodayTop3); } - catch (Exception ex) + } + if (dataTemps != null && dataTemps.Any()) + { + var dataGroup = dataTemps.GroupBy(t => new { t.company, t.totalQty }).ToList(); + foreach (var da in dataGroup) { - if (!string.IsNullOrEmpty(ex.StackTrace)) - throw new Exception("错误日志:[StackTrace]" + ex.StackTrace); - else - throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message); + var TaskTop3 = new TaskTop3(); + TaskTop3.company = da.Key.company; + TaskTop3.totalQty = da.Key.totalQty; + var temps = dataTemps.Where(t => t.company == da.Key.company).ToList(); + if (temps.Any()) + { + var detailTemps = new List(); + foreach (var de in temps) + { + var JobTodayDetail = new TaskTopDetail(); + JobTodayDetail.qty = de.qty; + JobTodayDetail.name = de.type; + detailTemps.Add(JobTodayDetail); + } + TaskTop3.details = detailTemps; + } + result.Add(TaskTop3); } } return result; @@ -571,47 +504,20 @@ namespace APT.SC.WebApi.Controllers.Api.BI /// /// 参数 /// - public List jobFinishRateData(string connhead) + public List jobFinishRateData(string connhead, DataTable Table) { List result = new List(); - DataTable Table = new DataTable(); - using (SqlConnection connection = new SqlConnection(connhead)) + if (Table != null && Table.Rows.Count > 0) { - try + foreach (DataRow item in Table.Rows) { - 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)) + result.Add(new JobFinishRate() { - SqlDataAdapter Data = new SqlDataAdapter(Com); - Data.Fill(Table); - } - connection.Close(); - if (Table != null && Table.Rows.Count > 0) - { - foreach (DataRow item in Table.Rows) - { - result.Add(new JobFinishRate() - { - name = item["表单名称"] != null ? item["表单名称"].ToString() : null, - qty = int.Parse(item["总数"].ToString()) != 0 ? int.Parse(item["总数"].ToString()) : 0, - finishQty = int.Parse(item["完成数"].ToString()) != 0 ? int.Parse(item["完成数"].ToString()) : 0, - rate = item["完成率"] != null ? item["完成率"].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); + name = item["表单名称"] != null ? item["表单名称"].ToString() : null, + qty = int.Parse(item["总数"].ToString()) != 0 ? int.Parse(item["总数"].ToString()) : 0, + finishQty = int.Parse(item["完成数"].ToString()) != 0 ? int.Parse(item["完成数"].ToString()) : 0, + rate = item["完成率"] != null ? item["完成率"].ToString() : null, + }); } } return result; @@ -623,51 +529,44 @@ namespace APT.SC.WebApi.Controllers.Api.BI /// /// 参数 /// - public List safeCheckSumData(string connhead) + public List safeCheckSumData(string connhead, DataTable Table) { List result = new List(); - DataTable Table = new DataTable(); - using (SqlConnection connection = new SqlConnection(connhead)) + if (Table != null && Table.Rows.Count > 0) { - try + foreach (DataRow item in Table.Rows) { - 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)) + result.Add(new SafeCheckSum() { - SqlDataAdapter Data = new SqlDataAdapter(Com); - Data.Fill(Table); - } - connection.Close(); - if (Table != null && Table.Rows.Count > 0) - { - foreach (DataRow item in Table.Rows) - { - result.Add(new SafeCheckSum() - { - company = item["公司名称"] != null ? item["公司名称"].ToString() : null, - qty = int.Parse(item["数量"].ToString()) != 0 ? int.Parse(item["数量"].ToString()) : 0, - num = int.Parse(item["排名"].ToString()) != 0 ? int.Parse(item["排名"].ToString()) : 0, - }); - } - } - } - catch (Exception ex) - { - if (!string.IsNullOrEmpty(ex.StackTrace)) - throw new Exception("错误日志:[StackTrace]" + ex.StackTrace); - else - throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message); + company = item["公司名称"] != null ? item["公司名称"].ToString() : null, + qty = int.Parse(item["数量"].ToString()) != 0 ? int.Parse(item["数量"].ToString()) : 0, + num = int.Parse(item["排名"].ToString()) != 0 ? int.Parse(item["排名"].ToString()) : 0, + }); + } + } + return result; + } + /// + /// 各公司危险作业统计 + /// + /// 参数 + /// + public List linkSumData(string connhead, DataTable Table) + { + List result = new List(); + if (Table != null && Table.Rows.Count > 0) + { + foreach (DataRow item in Table.Rows) + { + result.Add(new LinkSum() + { + name = item["NAME"] != null ? item["NAME"].ToString() : null, + qty = !string.IsNullOrEmpty(item["cnt"].ToString()) && int.Parse(item["cnt"].ToString()) != 0 ? int.Parse(item["cnt"].ToString()) : 0 + }); } } return result; } - /// /// 数据整理 培训教育 /// @@ -706,5 +605,6 @@ namespace APT.SC.WebApi.Controllers.Api.BI } return dtInfo; } + } }