From 95ebcda020d56269890b2653a9461e96d34d1469 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期三, 06 十二月 2023 17:25:29 +0800
Subject: [PATCH] 1.App智能分析,生产看板
---
VueWebCoreApi/ApiGroup/OpenApiGroup.cs | 4
VueWebCoreApi/Tools/TOrganizationRecursion.cs | 64 ++++++++++++++++
VueWebCoreApi/wwwroot/AppMenuImage/app_1_1.png | 0
VueWebCoreApi/wwwroot/AppMenuImage/app_1.png | 0
VueWebCoreApi/DLL/DAL/AppPersonalDAL.cs | 4
VueWebCoreApi/wwwroot/AppMenuImage/app_2.png | 0
VueWebCoreApi/Controllers/AppAnalyticsController.cs | 46 +++++++++++
VueWebCoreApi/DLL/BLL/AppAnalyticsBLL.cs | 20 +++++
VueWebCoreApi/wwwroot/AppMenuImage/app_2_1.png | 0
VueWebCoreApi/DLL/DAL/AppAnalyticsDAL.cs | 82 ++++++++++++++++++++
10 files changed, 217 insertions(+), 3 deletions(-)
diff --git a/VueWebCoreApi/ApiGroup/OpenApiGroup.cs b/VueWebCoreApi/ApiGroup/OpenApiGroup.cs
index 76370c8..8c813a8 100644
--- a/VueWebCoreApi/ApiGroup/OpenApiGroup.cs
+++ b/VueWebCoreApi/ApiGroup/OpenApiGroup.cs
@@ -41,6 +41,8 @@
[Description("鐪嬫澘绠$悊")]
鐪嬫澘绠$悊=16,
[Description("App涓汉涓績")]
- App涓汉涓績 = 20
+ App涓汉涓績 = 20,
+ [Description("App鏅鸿兘鍒嗘瀽")]
+ App鏅鸿兘鍒嗘瀽 = 21
}
}
diff --git a/VueWebCoreApi/Controllers/AppAnalyticsController.cs b/VueWebCoreApi/Controllers/AppAnalyticsController.cs
new file mode 100644
index 0000000..ed1b268
--- /dev/null
+++ b/VueWebCoreApi/Controllers/AppAnalyticsController.cs
@@ -0,0 +1,46 @@
+锘縰sing Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.BLL;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.Controllers
+{
+ [ApiExplorerSettings(GroupName = "App鏅鸿兘鍒嗘瀽")]
+ [ApiController]
+ [Route("api/[controller]")]
+ public class AppAnalyticsController : Controller
+ {
+ //瀹氫箟鍏ㄥ眬淇℃伅杩斿洖鍙橀噺
+ ToMessage mes = new ToMessage();
+ RedisHelper redis = new RedisHelper();
+
+ #region[App鐢熶骇鐪嬫澘]
+ /// <summary>
+ /// App鐢熶骇鐪嬫澘
+ /// </summary>
+ /// <param name="Ratetime">鏃堕棿</param>
+ /// <param name="defecttype">缂洪櫡缁熻绫诲瀷</param>
+ /// <returns></returns>
+ [Route(template: "ProductionKanban")]
+ [HttpGet]
+ public JsonResult ProductionKanban(string Ratetime, string defecttype)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ string startopendate = ""; //寮�濮嬫椂闂�
+ string endclosedate = ""; //缁撴潫鏃堕棿
+ if (Ratetime != "" && Ratetime != null)
+ {
+ startopendate = Ratetime.Split('~')[0].ToString();
+ endclosedate = Ratetime.Split('~')[1].ToString();
+ }
+ mes = AppAnalyticsBLL.ProductionKanban(us, startopendate, endclosedate, defecttype);
+ return Json(mes);
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/DLL/BLL/AppAnalyticsBLL.cs b/VueWebCoreApi/DLL/BLL/AppAnalyticsBLL.cs
new file mode 100644
index 0000000..243e66c
--- /dev/null
+++ b/VueWebCoreApi/DLL/BLL/AppAnalyticsBLL.cs
@@ -0,0 +1,20 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.DAL;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.DLL.BLL
+{
+ public class AppAnalyticsBLL
+ {
+ #region[App鐢熶骇鐪嬫澘]
+ public static ToMessage ProductionKanban(User us, string startopendate, string endclosedate, string defecttype)
+ {
+ return AppAnalyticsDAL.ProductionKanban(us, startopendate, endclosedate,defecttype);
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/DLL/DAL/AppAnalyticsDAL.cs b/VueWebCoreApi/DLL/DAL/AppAnalyticsDAL.cs
new file mode 100644
index 0000000..5e3289f
--- /dev/null
+++ b/VueWebCoreApi/DLL/DAL/AppAnalyticsDAL.cs
@@ -0,0 +1,82 @@
+锘縰sing Dapper;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.DLL.DAL
+{
+ public class AppAnalyticsDAL
+ {
+ public static DataTable dt; //瀹氫箟鍏ㄥ眬鍙橀噺dt
+ public static bool res; //瀹氫箟鍏ㄥ眬鍙橀噺dt
+
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+ public static string strProcName = ""; //瀹氫箟鍏ㄥ眬sql鍙橀噺
+ public static List<SqlParameter> listStr = new List<SqlParameter>(); //瀹氫箟鍏ㄥ眬鍙傛暟闆嗗悎
+ public static SqlParameter[] parameters; //瀹氫箟鍏ㄥ眬SqlParameter鍙傛暟鏁扮粍
+
+
+ #region[App鐢熶骇鐪嬫澘]
+ public static ToMessage ProductionKanban(User us, string startopendate, string endclosedate, string defecttype)
+ {
+ Dictionary<object, object> dList = new Dictionary<object, object>();
+ var dynamicParams = new DynamicParameters();
+ string search = "", torg_codelist = "", sql = "";
+ try
+ {
+ //鑾峰彇褰撳墠鐢ㄦ埛鎵�灞炵粍缁囧強鎵�鏈夊瓙鑺傜偣缁勭粐
+ mes = TOrganizationRecursion.TOrgCodeSeach("SCB");
+ if (mes.code == "300")
+ {
+ return mes;
+ }
+ else
+ {
+ torg_codelist = mes.data.ToString(); //鑾峰彇缁勭粐闆嗗悎
+ }
+ // --------------鐢熶骇鎬昏--------------
+ string[] torglist = Array.ConvertAll<string, string>(torg_codelist.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString()); //string鍒嗗壊杞瑂tring[]
+ //瀛樺偍杩囩▼鍚�
+ // --------------鏌ヨ宸ュ崟浠诲姟鏁般�佹姤宸ユ暟銆佽绠楀伐璧勬敹鍏�--------------
+ sql = @"h_p_JLApp_ProductAnalysisTop";
+ dynamicParams.Add("@torglist", mes.data.ToString());
+ dynamicParams.Add("@startopendate", startopendate + " 00:00:00");
+ dynamicParams.Add("@endclosedate", endclosedate + " 23:59:59");
+ var data0 = DapperHelper.selectProcedure(sql, dynamicParams);
+ dList.Add("dt0", data0);
+ // --------------鐢熶骇宸ュ崟--------------
+ sql = @"h_p_JLApp_ProductAnalysisCenter";
+ dynamicParams.Add("@torglist", mes.data.ToString());
+ dynamicParams.Add("@startopendate", startopendate + " 00:00:00");
+ dynamicParams.Add("@endclosedate", endclosedate + " 23:59:59");
+ var data1 = DapperHelper.selectProcedure(sql, dynamicParams);
+ dList.Add("dt1", data1);
+ // --------------缂洪櫡缁熻--------------
+ sql = @"h_p_JLApp_ProductAnalysisBottom";
+ dynamicParams.Add("@compute", defecttype);
+ dynamicParams.Add("@torglist", mes.data.ToString());
+ dynamicParams.Add("@startopendate", startopendate + " 00:00:00");
+ dynamicParams.Add("@endclosedate", endclosedate + " 23:59:59");
+ var data2 = DapperHelper.selectProcedure(sql, dynamicParams);
+ dList.Add("dt2", data2);
+ mes.code = "200";
+ mes.message = "鏌ヨ鎴愬姛!";
+ mes.data = dList;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/DLL/DAL/AppPersonalDAL.cs b/VueWebCoreApi/DLL/DAL/AppPersonalDAL.cs
index 4c080d7..7c9a8c9 100644
--- a/VueWebCoreApi/DLL/DAL/AppPersonalDAL.cs
+++ b/VueWebCoreApi/DLL/DAL/AppPersonalDAL.cs
@@ -35,7 +35,7 @@
// --------------鏌ヨ鎶ュ伐鏁般�佽壇鍝佹墸闄ゃ�佽绠楀伐璧勬敹鍏�--------------
sql = @"h_p_JLApp_PieceRateWageSummary";
dynamicParams.Add("@compute", compute);
- dynamicParams.Add("@usercode", "998");
+ dynamicParams.Add("@usercode", us.usercode);
dynamicParams.Add("@startopendate", startopendate + " 00:00:00");
dynamicParams.Add("@endclosedate", endclosedate + " 23:59:59");
var data0 = DapperHelper.selectProcedure(sql, dynamicParams);
@@ -44,7 +44,7 @@
// --------------鏌ヨ鎶ュ伐鏄庣粏(鎸夌収宸ュ崟銆佷骇鍝併�佸伐搴忓垎缁�)--------------
sql = @"h_p_JLApp_PieceRateWageDetailed";
dynamicParams.Add("@compute", compute);
- dynamicParams.Add("@usercode", "998");
+ dynamicParams.Add("@usercode", us.usercode);
dynamicParams.Add("@startopendate", startopendate + " 00:00:00");
dynamicParams.Add("@endclosedate", endclosedate + " 23:59:59");
var data1 = DapperHelper.selectProcedure(sql, dynamicParams);
diff --git a/VueWebCoreApi/Tools/TOrganizationRecursion.cs b/VueWebCoreApi/Tools/TOrganizationRecursion.cs
new file mode 100644
index 0000000..c5d7706
--- /dev/null
+++ b/VueWebCoreApi/Tools/TOrganizationRecursion.cs
@@ -0,0 +1,64 @@
+锘縰sing Dapper;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Tools
+{
+ public class TOrganizationRecursion
+ {
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+
+ #region [鏍规嵁褰撳墠缁勭粐缂栫爜鑾峰彇鎵�鏈夊瓙鑺傜偣缁勭粐(鍖呭惈鑷韩)]
+ /// <summary>
+ /// 鏍规嵁褰撳墠缁勭粐缂栫爜鑾峰彇鎵�鏈夊瓙鑺傜偣缁勭粐(鍖呭惈鑷韩)
+ /// </summary>
+ /// <param name="torg_code">缁勭粐缂栫爜</param>
+ /// <returns></returns>
+ public static ToMessage TOrgCodeSeach(string torg_code)
+ {
+ string sql;
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @" WITH RecursiveCTE AS (
+ SELECT id, parent_id, torg_code, torg_name, status, leve, torg_seq
+ FROM TOrganization
+ WHERE torg_code = @torg_code
+ UNION ALL
+ SELECT o.id, o.parent_id, o.torg_code, o.torg_name, o.status, o.leve, o.torg_seq
+ FROM TOrganization o
+ INNER JOIN RecursiveCTE r ON r.torg_code = o.parent_id
+ )
+ SELECT STUFF((SELECT ',' + QUOTENAME(torg_code, '''') FROM RecursiveCTE
+ FOR XML PATH('')), 1, 1, '') AS torg_codelist";
+ dynamicParams.Add("@torg_code", torg_code);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0&&data.Rows[0]["torg_codelist"].ToString()!=null)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.message = "鏌ヨ鎴愬姛!";
+ mes.data = data.Rows[0]["torg_codelist"].ToString();
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠鐢ㄦ埛鎵�灞炵粍缁囩紪鐮併��" + torg_code + "銆戜笉瀛樺湪!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/wwwroot/AppMenuImage/app_1.png b/VueWebCoreApi/wwwroot/AppMenuImage/app_1.png
new file mode 100644
index 0000000..d19d940
--- /dev/null
+++ b/VueWebCoreApi/wwwroot/AppMenuImage/app_1.png
Binary files differ
diff --git a/VueWebCoreApi/wwwroot/AppMenuImage/app_1_1.png b/VueWebCoreApi/wwwroot/AppMenuImage/app_1_1.png
new file mode 100644
index 0000000..12e078c
--- /dev/null
+++ b/VueWebCoreApi/wwwroot/AppMenuImage/app_1_1.png
Binary files differ
diff --git a/VueWebCoreApi/wwwroot/AppMenuImage/app_2.png b/VueWebCoreApi/wwwroot/AppMenuImage/app_2.png
new file mode 100644
index 0000000..a2a072b
--- /dev/null
+++ b/VueWebCoreApi/wwwroot/AppMenuImage/app_2.png
Binary files differ
diff --git a/VueWebCoreApi/wwwroot/AppMenuImage/app_2_1.png b/VueWebCoreApi/wwwroot/AppMenuImage/app_2_1.png
new file mode 100644
index 0000000..cc16800
--- /dev/null
+++ b/VueWebCoreApi/wwwroot/AppMenuImage/app_2_1.png
Binary files differ
--
Gitblit v1.9.3