From 87336b96ba0a03cb461a5f5cbd13f4d6dfdae876 Mon Sep 17 00:00:00 2001
From: wbc <2597324127@qq.com>
Date: 星期一, 08 十二月 2025 15:32:46 +0800
Subject: [PATCH] 焕美平板增加通用功能页面,可以使用朋乐的部分pda页面功能(pda存储过程更改,平板同步更新)
---
StandardInterface/MES.Service/Dto/service/UserPermission.cs | 17 ++
StandardInterface/MES.Service/service/SysUserService.cs | 330 +++++++++++++++++++++++++++++++++++++++++
StandardInterface/MESApplication/Controllers/BasicData/ModulesController.cs | 132 ++++++++++++++++
3 files changed, 479 insertions(+), 0 deletions(-)
diff --git a/StandardInterface/MES.Service/Dto/service/UserPermission.cs b/StandardInterface/MES.Service/Dto/service/UserPermission.cs
new file mode 100644
index 0000000..48b6ef0
--- /dev/null
+++ b/StandardInterface/MES.Service/Dto/service/UserPermission.cs
@@ -0,0 +1,17 @@
+锘縰sing 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; }
+ }
+}
diff --git a/StandardInterface/MES.Service/service/SysUserService.cs b/StandardInterface/MES.Service/service/SysUserService.cs
new file mode 100644
index 0000000..849dc9c
--- /dev/null
+++ b/StandardInterface/MES.Service/service/SysUserService.cs
@@ -0,0 +1,330 @@
+锘縰sing 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;
+ }
+
+ }
+}
diff --git a/StandardInterface/MESApplication/Controllers/BasicData/ModulesController.cs b/StandardInterface/MESApplication/Controllers/BasicData/ModulesController.cs
new file mode 100644
index 0000000..cc10287
--- /dev/null
+++ b/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 = "鏌ヨ鍔熻兘鐣岄潰澶辫触锛�"
+ };
+ }
+ }
+
+}
+
+
+
--
Gitblit v1.9.3