焕美平板增加通用功能页面,可以使用朋乐的部分pda页面功能(pda存储过程更改,平板同步更新)
已添加3个文件
479 ■■■■■ 文件已修改
StandardInterface/MES.Service/Dto/service/UserPermission.cs 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MES.Service/service/SysUserService.cs 330 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MESApplication/Controllers/BasicData/ModulesController.cs 132 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MES.Service/Dto/service/UserPermission.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MES.Service.Dto.service
{
    public class UserPermission
    {
        public string Name { get; set; }
        public string IconType { get; set; }
        public string Category { get; set; }
        public string Path { get; set; }
        public string Color { get; set; }
    }
}
StandardInterface/MES.Service/service/SysUserService.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,330 @@
using MES.Service.DB;
using MES.Service.Dto.service;
using MES.Service.Dto.webApi;
using MES.Service.Modes;
using MES.Service.util;
using Microsoft.Data.SqlClient;
using SqlSugar;
using System.Data;
using System.Dynamic;
namespace MES.Service.service
{
    public class SysUserService : Repository<SysUser>
    {
            public List<UserPermission> QueryPurview(string userNo)
            {
                // èŽ·å–ç”¨æˆ·æƒé™åˆ—è¡¨
                List<string> purviewData = this.DoPurview(userNo);
                List<UserPermission> resultList = new List<UserPermission>();
                if (purviewData.Count > 0)
                {
                    string purviewString = purviewData[0];
                    string[] splitResult = purviewString.Split(new string[] { "[" }, StringSplitOptions.None);
                    if (splitResult.Length > 2)
                    {
                        for (int i = 2; i < splitResult.Length; i++)
                        {
                            string trimmedStr = splitResult[i].Trim(); // åŽ»æŽ‰ç©ºæ ¼
                            string[] itemArray = trimmedStr.Split(new char[] { '#' });
                            UserPermission permission = new UserPermission
                            {
                                Name = itemArray[0],
                                Category = "全部应用",
                                IconType = itemArray[1],
                                Path = "input" ,
                                Color = itemArray[2]
                            };
                            resultList.Add(permission);
                        }
                    }
                }
                // æ·»åŠ é€€å‡ºé€‰é¡¹
               /* resultList.Add(new UserPermission
                {
                    Name = "退出",
                    Category = "全部应用",
                    IconType = "close",
                    Path = "/logout",
                    Color = "red"
                });*/
                return resultList;
            }
        private List<string> DoPurview(string userNo)
        {
            List<string> resultList = new List<string>();
            try
            {
                // å®šä¹‰è¾“入参数
                var inputParam1 = new SugarParameter("c_User_No", userNo.ToUpper());
                var inputParam2 = new SugarParameter("c_MachType", "AN");
                // å®šä¹‰è¾“出参数
                var outParam = new SugarParameter("c_Result", null, true);
                // ä½¿ç”¨SqlSugar执行存储过程
                Db.Ado.ExecuteCommand("BEGIN Prc_rf_j2_user_login(:c_User_No, :c_MachType, :c_Result); END;",
                    inputParam1, inputParam2, outParam);
                // èŽ·å–è¾“å‡ºå‚æ•°çš„å€¼
                string result = outParam.Value == DBNull.Value ? string.Empty : (string)outParam.Value;
                // æ·»åŠ åˆ°ç»“æžœåˆ—è¡¨
                if (!string.IsNullOrEmpty(result))
                {
                    resultList.Add(result);
                }
            }
            catch (Exception ex)
            {
                // è®°å½•异常
                Console.WriteLine($"获取用户权限失败: {ex.Message}");
                // å¯ä»¥é€‰æ‹©æŠ›å‡ºå¼‚常或返回空列表
            }
            return resultList;
        }
        /// <summary>
        /// èŽ·å–åŠŸèƒ½ç•Œé¢è®¾ç½®
        /// </summary>
        /// <param name="functionName">功能名称</param>
        /// <summary>
        /// èŽ·å–åŠŸèƒ½ç•Œé¢è®¾ç½®
        /// </summary>
        /// <param name="functionName">功能名称</param>
        /// <returns>功能界面设置信息</returns>
        public ResponseResult GetRfSetup(string functionName)
        {
            try
            {
                List<string> setupData = DoRfSetup(functionName);
                if (setupData.Count > 0 && !string.IsNullOrEmpty(setupData[0]))
                {
                    dynamic resultInfos = new ExpandoObject();
                    resultInfos.setupData = setupData[0];
                    return new ResponseResult
                    {
                        status = 0,
                        message = "查询功能界面成功!",
                        data = resultInfos
                    };
                }
                else
                {
                    return new ResponseResult
                    {
                        status = 1,
                        message = "未找到功能界面设置!"
                    };
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return new ResponseResult
                {
                    status = 1,
                    message = "查询功能界面失败!"
                };
            }
        }
        /// <summary>
        /// èŽ·å–åŠŸèƒ½ç•Œé¢è®¾ç½®æ•°æ®
        /// </summary>
        /// <param name="functionName">功能名称</param>
        /// <returns>功能界面设置数据列表</returns>
        private List<string> DoRfSetup(string functionName)
        {
            List<string> resultList = new List<string>();
            try
            {
                // å®šä¹‰è¾“入参数
                var inputParam1 = new SugarParameter("functionName", functionName);
                var inputParam2 = new SugarParameter("deviceType", "AN");
                // å®šä¹‰è¾“出参数
                var outParam = new SugarParameter("result", null, true);
                // ä½¿ç”¨SqlSugar执行存储过程
                Db.Ado.ExecuteCommand("BEGIN Prc_rf_setup(:functionName, :deviceType, :result); END;",
                    inputParam1, inputParam2, outParam);
                // èŽ·å–è¾“å‡ºå‚æ•°çš„å€¼
                string result = outParam.Value == DBNull.Value ? string.Empty : (string)outParam.Value;
                // æ·»åŠ åˆ°ç»“æžœåˆ—è¡¨
                if (!string.IsNullOrEmpty(result))
                {
                    resultList.Add(result);
                }
            }
            catch (Exception ex)
            {
                // è®°å½•异常
                Console.WriteLine($"获取功能界面设置失败: {ex.Message}");
                // å¯ä»¥é€‰æ‹©æŠ›å‡ºå¼‚常或返回空列表
            }
            return resultList;
        }
        public ResponseResult GetExcProc(string functionName, string fileName, string pmachtype, string fileValue, string outFiles)
        {
            try
            {
                List<string> resultList = DoExcProc(functionName, fileName, pmachtype, fileValue);
                Console.WriteLine(string.Join(", ", resultList));
                if (resultList.Count > 0)
                {
                    string s = resultList[0];
                    string[] strs = s.Split('[');
                    if (strs.Length < 1)
                    {
                        return new ResponseResult
                        {
                            status = 1,
                            message = "返回值的格式不正确!" + string.Join(", ", resultList)
                        };
                    }
                    // åˆ¤æ–­å–值是否成功
                    string str = strs[0];
                    if (str.Equals("002"))
                    {
                        return new ResponseResult
                        {
                            status = 1,
                            message = strs[1]
                        };
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(outFiles))
                        {
                            if (strs.Length < 2)
                            {
                                return new ResponseResult
                                {
                                    status = 0,
                                    data = ""
                                };
                            }
                            return new ResponseResult
                            {
                                status = 0,
                                data = strs[1]
                            };
                        }
                        else
                        {
                            List<string[]> at = new List<string[]>();
                            // [001[4500108372,80000123,100,物料80000123今日已收货 100]
                            string[] files = outFiles.Split(',');
                            string[] res = strs[1].Split(new char[] { ',' }, StringSplitOptions.None);
                            for (int i = 0; i < files.Length; i++)
                            {
                                string[] temp = new string[2];
                                temp[0] = files[i];
                                temp[1] = res[i];
                                at.Add(temp);
                            }
                            return new ResponseResult
                            {
                                status = 0,
                                data = at
                            };
                        }
                    }
                }
                return new ResponseResult
                {
                    status = 0,
                    data = resultList
                };
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return new ResponseResult
                {
                    status = 1,
                    message = "执行存储过程失败:" + ex.Message
                };
            }
        }
        /// <summary>
        /// æ‰§è¡Œå­˜å‚¨è¿‡ç¨‹
        /// </summary>
        /// <param name="functionName">功能名称</param>
        /// <param name="fileName">字段名</param>
        /// <param name="pmachtype">设备类型</param>
        /// <param name="fileValue">参数值</param>
        /// <returns>存储过程执行结果</returns>
        private List<string> DoExcProc(string functionName, string fileName, string pmachtype, string fileValue)
        {
            List<string> resultList = new List<string>();
            try
            {
                // å®šä¹‰è¾“入参数
                var inputParam1 = new SugarParameter("functionName", functionName);
                var inputParam2 = new SugarParameter("fileName", fileName?.Trim());
                var inputParam3 = new SugarParameter("pmachtype", "AN"); // è®¾å¤‡ç±»åž‹ wince5,wmb5,wmb6
                var inputParam4 = new SugarParameter("fileValue", fileValue); // å‚数值[第一位是用户]
                // å®šä¹‰è¾“出参数
                var outParam = new SugarParameter("result", null, true);
                // ä½¿ç”¨SqlSugar执行存储过程
                Db.Ado.ExecuteCommand("BEGIN Prc_rf_setup_ExcProc(:functionName, :fileName, :pmachtype, :fileValue, :result); END;",
                    inputParam1, inputParam2, inputParam3, inputParam4, outParam);
                // èŽ·å–è¾“å‡ºå‚æ•°çš„å€¼
                string result = outParam.Value == DBNull.Value ? string.Empty : (string)outParam.Value;
                // æ·»åŠ åˆ°ç»“æžœåˆ—è¡¨
                if (!string.IsNullOrEmpty(result))
                {
                    resultList.Add(result);
                }
            }
            catch (Exception ex)
            {
                // è®°å½•异常
                Console.WriteLine($"执行存储过程失败: {ex.Message}");
                // å¯ä»¥é€‰æ‹©æŠ›å‡ºå¼‚常或返回空列表
            }
            return resultList;
        }
    }
}
StandardInterface/MESApplication/Controllers/BasicData/ModulesController.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,132 @@

using System.Dynamic;
using System.Net;
using MES.Service.Dto.service;
using MES.Service.Modes;
using MES.Service.service;
using MES.Service.util;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
namespace MESApplication.Controllers.BasicData;
    [Route("api/[controller]")]
    [ApiController]
    public class ModulesController : ControllerBase
    {
        private readonly SysUserService _sysUserService = new SysUserService();
        /// <summary>
        /// æŸ¥è¯¢æƒé™
        /// </summary>
        /// <param name="userno">用户Id</param>
        /// <returns>权限信息</returns>
        [HttpPost("queryPurview")]
        public ResponseResult QueryPurview([FromBody] JObject data)
        {
            var userno = data["userno"]?.ToString();
            try
            {
                List<UserPermission> userForBase = _sysUserService.QueryPurview(userno);
                if (userForBase.Count == 0)
                {
                    return new ResponseResult
                    {
                        status = 1,
                        message = "权限不存在!"
                    };
                }
                else
                {
                    dynamic resultInfos = new ExpandoObject();
                    resultInfos.tbBillList = userForBase;
                    return new ResponseResult
                    {
                        status = 0,
                        message = "查询权限成功!",
                        data = resultInfos
                    };
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return new ResponseResult
                {
                    status = 1,
                    message = "查询权限失败!"
                };
            }
        }
            /// <summary>
            /// åŠŸèƒ½ç•Œé¢
            /// </summary>
            /// <param name="functionName">方法名称</param>
            /// <returns>功能界面信息</returns>
            [HttpPost("getRfSetup")]
            public ResponseResult GetRfSetup([FromBody] JObject data)
            {
              var functionName = data["functionName"]?.ToString();
            try
                {
                    Console.WriteLine(functionName);
                    string decodedFunctionName = WebUtility.UrlDecode(functionName);
                    return _sysUserService.GetRfSetup(functionName);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    return new ResponseResult
                    {
                        status = 1,
                        message = "查询功能界面失败!"
                    };
                }
            }
            /// <summary>
            /// åŠŸèƒ½æ‰§è¡Œå­˜å‚¨è¿‡ç¨‹
            /// </summary>
            /// <param name="data">请求参数</param>
            /// <returns>API响应结果</returns>
            [HttpPost("getExcProc")]
            public ResponseResult GetExcProc([FromBody] JObject data)
            {
                var functionName = data["functionName"]?.ToString();
                var fileName = data["fileName"]?.ToString();
                var pmachtype = data["pmachtype"]?.ToString();
                var fileValue = data["fileValue"]?.ToString();
                var outFiles = data["outFiles"]?.ToString();
                try
                {
                    Console.WriteLine(functionName);
                    string decodedFunctionName = WebUtility.UrlDecode(functionName);
                    return _sysUserService.GetExcProc(decodedFunctionName, fileName, pmachtype, fileValue, outFiles);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    return new ResponseResult
                    {
                        status = 1,
                        message = "查询功能界面失败!"
                    };
                }
            }
}