From 00e25e4a9c9bd2fc91558c3c1a68f47db6d08b1d Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期一, 08 七月 2024 18:57:35 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API
---
WebAPI/Controllers/BLL/Xt_UserGroupController.cs | 261 ++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 233 insertions(+), 28 deletions(-)
diff --git a/WebAPI/Controllers/BLL/Xt_UserGroupController.cs b/WebAPI/Controllers/BLL/Xt_UserGroupController.cs
index daa2ab8..2a9191c 100644
--- a/WebAPI/Controllers/BLL/Xt_UserGroupController.cs
+++ b/WebAPI/Controllers/BLL/Xt_UserGroupController.cs
@@ -17,7 +17,7 @@
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
DataSet ds;
-
+ #region 瑙掕壊鍒楄〃
/// <summary>
/// 杩斿洖鐢ㄦ埛瑙掕壊鍒楄〃
///鍙傛暟锛歴tring sql銆�
@@ -29,32 +29,13 @@
{
try
{
- if (sWhere == null || sWhere.Equals(""))
- {
- ds = oCN.RunProcReturn("select * from h_v_System_UserGroup " + sWhere, "h_v_System_UserGroup");
- }
- else
- {
- string sql1 = "select * from h_v_System_UserGroup where 1 = 1 ";
- string sql = sql1 + sWhere;
- ds = oCN.RunProcReturn(sql, "h_v_System_UserGroup");
- }
- if (ds == null || ds.Tables[0].Rows.Count == 0)
- {
- objJsonResult.code = "0";
- objJsonResult.count = 0;
- objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
- objJsonResult.data = null;
- return objJsonResult;
- }
- else
- {
- objJsonResult.code = "1";
- objJsonResult.count = 1;
- objJsonResult.Message = "Sucess锛�";
- objJsonResult.data = ds.Tables[0];
- return objJsonResult;
- }
+ ds = oCN.RunProcReturn("select * from h_v_System_UserGroup where 1 = 1 " + sWhere, "h_v_System_UserGroup");
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "Sucess锛�";
+ objJsonResult.data = ds.Tables[0];
+ return objJsonResult;
}
catch (Exception e)
{
@@ -65,9 +46,233 @@
return objJsonResult;
}
}
+ #endregion
+
+ #region 瑙掕壊缁戝畾鐢ㄦ埛鏁版嵁
+ [Route("Xt_UserGroup/UserGroupInfoList")]
+ [HttpGet]
+ public object UserGroupInfoList(string sWhere)
+ {
+ try
+ {
+ string sql = "select * from System_UserGroupInfo where 1=1 " + sWhere;
+ ds = oCN.RunProcReturn(sql, "System_UserGroupInfo");
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "Sucess锛�";
+ objJsonResult.data = ds.Tables[0];
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 瑙掕壊鍒楄〃 娣诲姞/淇敼
+ public class Xt_UserGroup
+ {
+ public int HGroupID;
+ public string GroupName { get; set; }
+ public string HLev { get; set; }
+ public string Explain { get; set; }
+ }
+ [Route("Xt_UserGroup/UserGroupInfoEdit")]
+ [HttpPost]
+ public object UserGroupInfoEdit([FromBody] JObject sMainSub)
+ {
+ var _value = sMainSub["sMainSub"].ToString();
+ string msg1 = _value.ToString();
+ oCN.BeginTran();
+ //淇濆瓨涓昏〃
+ objJsonResult = AddBillMain(msg1);
+ if (objJsonResult.code == "0")
+ {
+ oCN.RollBack();
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = objJsonResult.Message;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ oCN.Commit();
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鎴愬姛锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ public json AddBillMain(string msg1)
+ {
+ string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+ string msg2 = sArray[0].ToString();
+ string msg3 = sArray[1].ToString();
+ int OperationType = int.Parse(sArray[2].ToString());//鏁版嵁绫诲瀷 1娣诲姞 3淇敼
+ string user = sArray[3].ToString();
+ try
+ {
+ Xt_UserGroup omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<Xt_UserGroup>(msg2);
+
+ var num = msg3.Split(',');
+
+ if (OperationType == 1)//鏂板
+ {
+ //涓昏〃
+ oCN.RunProc("insert into System_UserGroup (GroupName,HLev,Explain)values" +
+ $"('{omdelMian.GroupName}','{omdelMian.HLev}','{omdelMian.Explain}')");
+
+ //鏂板鍚庢煡璇� 纭繚鏁版嵁娣诲姞鎴愬姛
+ ds = oCN.RunProcReturn("Select * from System_UserGroup where GroupName='" + omdelMian.GroupName + "'", "System_UserGroup");
+ if (ds == null || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鐢ㄦ埛鏂板澶辫触锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ var HGroupID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["GroupID"]);
+ oCN.RunProc("delete from System_UserGroupInfo where GroupId=" + HGroupID.ToString());
+
+ if (num[0] != "-1")
+ {
+ for (int i = 0; i < num.Length; i++)
+ {
+ oCN.RunProc("insert into System_UserGroupInfo (GroupId,UserId) values (" + HGroupID.ToString() + ",'" + num[i] + "')");
+ }
+ }
+
+ }
+ else if (OperationType == 2)//澶嶅埗
+ {
+ string realExplain = omdelMian.Explain.Substring(0, omdelMian.Explain.IndexOf("#澶嶅埗鍘熻鑹睮D锛�")); //鑾峰彇鐣岄潰璁剧疆鐨凟xplain鍊�
+ string sourceBill_GroupID = omdelMian.Explain.Replace(realExplain + "#澶嶅埗鍘熻鑹睮D锛�", ""); //鑾峰彇澶嶅埗鐨勬簮鍗曟嵁鐨処D
+ omdelMian.Explain = realExplain;
+
+ //涓昏〃
+ oCN.RunProc("insert into System_UserGroup (GroupName,HLev,Explain)values" +
+ $"('{omdelMian.GroupName}','{omdelMian.HLev}','{omdelMian.Explain}')");
+
+ //鏂板鍚庢煡璇� 纭繚鏁版嵁娣诲姞鎴愬姛
+ ds = oCN.RunProcReturn("Select * from System_UserGroup where GroupName='" + omdelMian.GroupName + "'", "System_UserGroup");
+ if (ds == null || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鐢ㄦ埛鏂板澶辫触锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ var HGroupID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["GroupID"]);
+ //鏍规嵁澶嶅埗鐨勬簮鍗曟嵁鐨処D锛岃幏鍙栨簮鍗曟嵁鐨処D瀵瑰簲瑙掕壊鐨勬潈闄�
+ ds = oCN.RunProcReturn("Select * from System_UserGroup where GroupID='" + sourceBill_GroupID + "'", "System_UserGroup");
+ if (ds == null || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "琚鍒剁殑瑙掕壊涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ string AuthorityID = ds.Tables[0].Rows[0]["AuthorityID"].ToString();
+ oCN.RunProc("update System_UserGroup set AuthorityID = '" + AuthorityID + "' where GroupID = " + HGroupID);
- //
+
+ //璁剧疆瑙掕壊缁戝畾鐨勭敤鎴�
+ oCN.RunProc("delete from System_UserGroupInfo where GroupId=" + HGroupID.ToString());
+
+ if (num[0] != "-1")
+ {
+ for (int i = 0; i < num.Length; i++)
+ {
+ oCN.RunProc("insert into System_UserGroupInfo (GroupId,UserId) values (" + HGroupID.ToString() + ",'" + num[i] + "')");
+ }
+ }
+
+ }
+ else if (OperationType == 3)
+ {
+ oCN.RunProc("update System_UserGroup set GroupName='" + omdelMian.GroupName + "',HLev='" + omdelMian.HLev + "',Explain='" + omdelMian.Explain + "'"
+ + " where GroupId=" + omdelMian.HGroupID);
+
+ oCN.RunProc("delete from System_UserGroupInfo where GroupId=" + omdelMian.HGroupID);
+ for (int i = 0; i < num.Length; i++)
+ {
+ oCN.RunProc("insert into System_UserGroupInfo (GroupId,UserId) values (" + omdelMian.HGroupID + ",'" + num[i] + "')");
+ }
+ }
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = null;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 瑙掕壊鍒楄〃 鍒犻櫎
+ [Route("Xt_UserGroup/DelXt_UserGroupList")]
+ [HttpGet]
+ public object DelXt_UserGroupList(string HInterID,string User)
+ {
+ try
+ {
+ ds = oCN.RunProcReturn("select * from h_v_System_UserGroup where 1=1 and HGroupID=" + HInterID, "h_v_System_UserGroup");
+
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ oCN.BeginTran();//寮�鍚簨鍔�
+ //鍒犻櫎瑙掕壊琛�
+ oCN.RunProc($"delete from System_UserGroup where GroupID={HInterID}");
+ //鍒犻櫎鍏宠仈鐨勭敤鎴峰叧绯�
+ oCN.RunProc($"delete from System_UserGroupInfo where GroupId={HInterID}");
+
+ oCN.Commit();//缁撴潫浜嬪姟
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "褰撳墠鍗曟嵁涓嶅瓨鍦�,鏃犳硶鍒犻櫎锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ oCN.RollBack();//鍥炴粴浜嬪姟
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+
}
}
\ No newline at end of file
--
Gitblit v1.9.1