From 82ce41eac67a03aed2ae67522938757b865c45f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=BE=8E=E8=8D=A3?= <10755671+mei-rong-he@user.noreply.gitee.com> Date: Mon, 26 Jan 2026 14:32:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=BF=90=E8=A1=8C=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BIStatiscialAnalysisController.cs | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIStatiscialAnalysisController.cs b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIStatiscialAnalysisController.cs index 3c20e35..a29c02d 100644 --- a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIStatiscialAnalysisController.cs +++ b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIStatiscialAnalysisController.cs @@ -8,6 +8,7 @@ using APT.BaseData.Domain.IServices; using APT.BaseData.Domain.IServices.FM; using APT.BaseData.Services.DomainServices; using APT.BaseData.Services.Services.FM; +using APT.Infrastructure.Api; using APT.Infrastructure.Api.Redis; using APT.Infrastructure.Core; using APT.MS.Domain.Entities.BI; @@ -32,6 +33,7 @@ using InfluxData.Net.Kapacitor.Models; using log4net.Filter; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Data.SqlClient; using MySqlX.XDevAPI.Common; using NPOI.SS.Formula.Functions; using Renci.SshNet.Common; @@ -46,6 +48,7 @@ using System.Linq.Expressions; using System.Net.NetworkInformation; using System.Runtime.CompilerServices; using System.Threading.Tasks; +using static APT.SC.WebApi.Controllers.Api.BI.BIKanBanController; namespace APT.SC.WebApi.Controllers.Api.BIController { @@ -139,6 +142,37 @@ namespace APT.SC.WebApi.Controllers.Api.BIController public string departmentName { get; set; } public int num { get; set; } public List deptInfos { get; set; } + } + public class TaskViewInfo + { + public string MOULD_NAME { get; set; } + public string FORM_NAME { get; set; } + + public string COMPANY_NAME { get; set; } + public int TOTAL_QTY { get; set; } + public int NORMAL_FINISH { get; set; } + public int OVER_FINISH { get; set; } + public int DOING { get; set; } + public int UNFINISH { get; set; } + public int OVER_UNFINISH { get; set; } + public string FINISH_RATE { get; set; } + public string NORMAL_RATE { get; set; } + public List details { get; set; } + } + public class TaskViewInfoDetail + { + public string MOULD_NAME { get; set; } + public string FORM_NAME { get; set; } + + public string COMPANY_NAME { get; set; } + public string NOTICE_TITLE { get; set; } + public DateTime? TASK_STARTDT { get; set; } + + public DateTime? TASK_ENDDT { get; set; } + + public DateTime? TASK_DT { get; set; } + public string NOTICE_STATUS { get; set; } + public string USER_NAME { get; set; } } /// /// @@ -11140,6 +11174,80 @@ namespace APT.SC.WebApi.Controllers.Api.BIController /// 存储信息 /// public List result { get; set; } + } + /// + /// 系统运行情况报表 + /// + /// + /// + [HttpPost, Route("GetTaskViewInfo")] + public JsonActionResult> GetTaskViewInfo([FromBody] KeywordFilter filter) + { + string connhead = ConfigurationManager.ConnectionStrings["head"]; + JsonActionResult> result = new JsonActionResult>(); + result.Data = new List(); + DataTable Table = new DataTable(); + using (SqlConnection connection = new SqlConnection(connhead)) + { + try + { + connection.Open(); + //各公司待办明细 + string sql = "select * from vhome_task_data_form "; + SqlCommand com = new SqlCommand(sql, connection); + SqlDataAdapter Data = new SqlDataAdapter(com); + Data.Fill(Table); + 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); + } + if (Table != null && Table.Rows.Count > 0) + { + List listAddNew = new List(); + + foreach (DataRow item in Table.Rows) + { + listAddNew.Add(new TaskViewInfoDetail() + { + COMPANY_NAME = item["db_name"] != null ? item["db_name"].ToString() : null, + MOULD_NAME = item["MODEL_NAME"] != null ? item["MODEL_NAME"].ToString() : null, + FORM_NAME = item["FORM_NAME"] != null ? item["FORM_NAME"].ToString() : null, + NOTICE_TITLE = item["NOTICE_TITLE"] != null ? item["NOTICE_TITLE"].ToString() : null, + NOTICE_STATUS = item["NOTICE_STATUS"] != null ? item["NOTICE_STATUS"].ToString() : null, + TASK_DT = item["TASK_DT"] != null ? Convert.ToDateTime(item["TASK_DT"].ToString()) : null, + TASK_STARTDT = item["TASK_STARTDT"] != null ? Convert.ToDateTime(item["TASK_STARTDT"].ToString()) : null, + TASK_ENDDT = item["TASK_ENDDT"] != null ? Convert.ToDateTime(item["TASK_ENDDT"].ToString()) : null, + USER_NAME = item["USER_NAME"] != null ? item["USER_NAME"].ToString() : null + }); + } + var taskGroup = listAddNew.GroupBy(t => new { t.COMPANY_NAME, t.MOULD_NAME, t.FORM_NAME }).ToList(); + if (taskGroup != null && taskGroup.Any()) + { + foreach (var item in taskGroup) + { + TaskViewInfo info = new TaskViewInfo(); + info.COMPANY_NAME = item.Key.COMPANY_NAME; + info.MOULD_NAME = item.Key.MOULD_NAME; + info.FORM_NAME = item.Key.FORM_NAME; + info.TOTAL_QTY = listAddNew.Count(t => t.COMPANY_NAME == item.Key.COMPANY_NAME && t.MOULD_NAME == item.Key.MOULD_NAME && t.FORM_NAME == item.Key.FORM_NAME); + info.NORMAL_FINISH = listAddNew.Count(t => t.COMPANY_NAME == item.Key.COMPANY_NAME && t.MOULD_NAME == item.Key.MOULD_NAME && t.FORM_NAME == item.Key.FORM_NAME && t.NOTICE_STATUS == "1"); + info.OVER_FINISH = listAddNew.Count(t => t.COMPANY_NAME == item.Key.COMPANY_NAME && t.MOULD_NAME == item.Key.MOULD_NAME && t.FORM_NAME == item.Key.FORM_NAME && t.NOTICE_STATUS == "2"); + info.DOING = listAddNew.Count(t => t.COMPANY_NAME == item.Key.COMPANY_NAME && t.MOULD_NAME == item.Key.MOULD_NAME && t.FORM_NAME == item.Key.FORM_NAME && t.NOTICE_STATUS == "0" && t.TASK_ENDDT >=DateTime.Now); + info.UNFINISH = listAddNew.Count(t => t.COMPANY_NAME == item.Key.COMPANY_NAME && t.MOULD_NAME == item.Key.MOULD_NAME && t.FORM_NAME == item.Key.FORM_NAME && t.NOTICE_STATUS == "0"); + info.OVER_UNFINISH = listAddNew.Count(t => t.COMPANY_NAME == item.Key.COMPANY_NAME && t.MOULD_NAME == item.Key.MOULD_NAME && t.FORM_NAME == item.Key.FORM_NAME && t.NOTICE_STATUS == "0" && t.TASK_ENDDT < DateTime.Now); + info.FINISH_RATE = info.TOTAL_QTY == 0 ? "0" : ((info.NORMAL_FINISH + info.OVER_FINISH) / info.TOTAL_QTY * 100).ToString(); + info.NORMAL_RATE = info.TOTAL_QTY == 0 ? "0" : (info.NORMAL_FINISH / info.TOTAL_QTY * 100).ToString(); + result.Data.Add(info); + } + } + } + } + return result; } } }