yl
2023-12-06 95ebcda020d56269890b2653a9461e96d34d1469
1.App智能分析,生产看板
已添加8个文件
已修改2个文件
220 ■■■■■ 文件已修改
VueWebCoreApi/ApiGroup/OpenApiGroup.cs 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/Controllers/AppAnalyticsController.cs 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/DLL/BLL/AppAnalyticsBLL.cs 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/DLL/DAL/AppAnalyticsDAL.cs 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/DLL/DAL/AppPersonalDAL.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/Tools/TOrganizationRecursion.cs 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/wwwroot/AppMenuImage/app_1.png 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/wwwroot/AppMenuImage/app_1_1.png 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/wwwroot/AppMenuImage/app_2.png 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/wwwroot/AppMenuImage/app_2_1.png 补丁 | 查看 | 原始文档 | blame | 历史
VueWebCoreApi/ApiGroup/OpenApiGroup.cs
@@ -41,6 +41,8 @@
        [Description("看板管理")]
        çœ‹æ¿ç®¡ç†=16,
        [Description("App个人中心")]
        App个人中心 = 20
        App个人中心 = 20,
        [Description("App智能分析")]
        App智能分析 = 21
    }
}
VueWebCoreApi/Controllers/AppAnalyticsController.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,46 @@
using 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
    }
}
VueWebCoreApi/DLL/BLL/AppAnalyticsBLL.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
using 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
    }
}
VueWebCoreApi/DLL/DAL/AppAnalyticsDAL.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,82 @@
using 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分割转string[]
                //存储过程名
                // --------------查询工单任务数、报工数、计算工资收入--------------
                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
    }
}
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);
VueWebCoreApi/Tools/TOrganizationRecursion.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,64 @@
using 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
    }
}
VueWebCoreApi/wwwroot/AppMenuImage/app_1.png
VueWebCoreApi/wwwroot/AppMenuImage/app_1_1.png
VueWebCoreApi/wwwroot/AppMenuImage/app_2.png
VueWebCoreApi/wwwroot/AppMenuImage/app_2_1.png