yangle
2022-08-19 f4fa0cd3ae3b6f4e67671cdb1fe8ed52259341fb
用户关联
4个文件已修改
1个文件已添加
540 ■■■■■ 已修改文件
WebAPI/Controllers/BLL/Xt_UserController.cs 410 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/BaseSet/Gy_WarehouseController.cs 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/基础资料/基础资料/Gy_WorkStationBillController.cs 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/ListModels.cs 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/WebAPI.csproj 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/BLL/Xt_UserController.cs
@@ -360,5 +360,415 @@
            }
        }
        #endregion
        #region  æ ¹æ®ç”¨æˆ·ç¼–码查找已分配组织列表
        [Route("Xt_User/UserByOrgPlaylist")]
        [HttpGet]
        public object UserByOrgPlaylist(string HUserID)
        {
            try
            {
                ds = oCN.RunProcReturn("select HOrgID HItemID,对应组织代码 HNumber,对应组织名称 HName from h_v_Gy_UserByOrgRelationList where ç”¨æˆ·ç¼–码='" + HUserID + "' ", "h_v_Gy_UserByOrgRelationList");
                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;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region ç”¨æˆ·å…³è”组织保存
        [Route("Xt_User/SaveUserByOrg")]
        [HttpPost]
        public object SaveUserByOrg([FromBody] JObject msg)
        {
            var _value = msg["msg"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString();
            ListModels oListModels = new ListModels();
            try
            {
                List<Models.Xt_ORGANIZATIONS> lsmain = new List<Models.Xt_ORGANIZATIONS>();
                msg2 = msg2.Substring(1, msg2.Length - 2);
                msg2 = msg2.Replace("\\", "");
                msg2 = msg2.Replace("\n", "");  //\n
                lsmain = oListModels.getObjectByJson_Xt_ORGANIZATIONS(msg2);
                oCN.BeginTran();
                //删除已经关联的数据
                oCN.RunProc("Delete From Gy_UserByOrgRelation  where HUserID='" + msg3.ToString() + "'");
                foreach (Models.Xt_ORGANIZATIONS oItem in lsmain)
                {
                    //重新写入关联数据
                    oCN.RunProc("insert into Gy_UserByOrgRelation (HOrgID,HBillType,HUserID) values ('" + oItem.HItemID + "','','" + msg3.ToString() + "')");
                }
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "保存成功!";
                objJsonResult.data = 1;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = 1;
                return objJsonResult;
            }
        }
        #endregion
        #region  æ ¹æ®ç”¨æˆ·ç¼–码查找已分配仓库列表
        [Route("Xt_User/UserStocklistPlaylist")]
        [HttpGet]
        public object UserStocklistPlaylist(string HUserID)
        {
            try
            {
                ds = oCN.RunProcReturn("select HWHID HItemID,仓库代码 HNumber,仓库名称 HName from h_v_Gy_UserStockRelationList where HUserID='" + HUserID + "' ", "h_v_Gy_UserStockRelationList");
                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;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region ç”¨æˆ·å…³è”仓库保存
        [Route("Xt_User/SaveUserStock")]
        [HttpPost]
        public object SaveUserStock([FromBody] JObject msg)
        {
            var _value = msg["msg"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString();
            ListModels oListModels = new ListModels();
            try
            {
                List<Models.Warehouse> lsmain = new List<Models.Warehouse>();
                msg2 = msg2.Substring(1, msg2.Length - 2);
                msg2 = msg2.Replace("\\", "");
                msg2 = msg2.Replace("\n", "");  //\n
                lsmain = oListModels.getObjectByJson_Warehouse(msg2);
                oCN.BeginTran();
                //删除已经关联的数据
                oCN.RunProc("Delete From Gy_UserStockRelation  where HUserID='" + msg3.ToString() + "'");
                foreach (Models.Warehouse oItem in lsmain)
                {
                    //重新写入关联数据
                    oCN.RunProc("insert into Gy_UserStockRelation (HWHID,HUserID) values ('" + oItem.HItemID + "','" + msg3.ToString() + "')");
                }
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "保存成功!";
                objJsonResult.data = 1;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = 1;
                return objJsonResult;
            }
        }
        #endregion
        #region  æ ¹æ®ç”¨æˆ·ç¼–码查找已分配班组列表
        [Route("Xt_User/UserGrouplistPlaylist")]
        [HttpGet]
        public object UserGrouplistPlaylist(string HUserID)
        {
            try
            {
                ds = oCN.RunProcReturn("select HGroupID HItemID,班组代码 HNumber,班组名称 HName from h_v_Gy_UserGroupRelationList where HUserID='" + HUserID + "' ", "h_v_Gy_UserGroupRelationList");
                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;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region ç”¨æˆ·å…³è”班组保存
        [Route("Xt_User/SaveUserGroup")]
        [HttpPost]
        public object SaveUserGroup([FromBody] JObject msg)
        {
            var _value = msg["msg"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString();
            ListModels oListModels = new ListModels();
            try
            {
                List<Models.Gy_Group> lsmain = new List<Models.Gy_Group>();
                msg2 = msg2.Substring(1, msg2.Length - 2);
                msg2 = msg2.Replace("\\", "");
                msg2 = msg2.Replace("\n", "");  //\n
                lsmain = oListModels.getObjectByJson_Gy_Group(msg2);
                oCN.BeginTran();
                //删除已经关联的数据
                oCN.RunProc("Delete From Gy_UserGroupRelation  where HUserID='" + msg3.ToString() + "'");
                foreach (Models.Gy_Group oItem in lsmain)
                {
                    //重新写入关联数据
                    oCN.RunProc("insert into Gy_UserGroupRelation (HGroupID,HUserID) values ('" + oItem.HItemID + "','" + msg3.ToString() + "')");
                }
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "保存成功!";
                objJsonResult.data = 1;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = 1;
                return objJsonResult;
            }
        }
        #endregion
        #region  æ ¹æ®ç”¨æˆ·ç¼–码查找已分配部门列表
        [Route("Xt_User/UserDeptlistPlaylist")]
        [HttpGet]
        public object UserDeptlistPlaylist(string HUserID)
        {
            try
            {
                ds = oCN.RunProcReturn("select HDeptID HItemID,部门代码 HNumber,部门名称 HName from h_v_Gy_UserDeptRelationList where HUserID='" + HUserID + "' ", "h_v_Gy_UserDeptRelationList");
                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;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region ç”¨æˆ·å…³è”部门保存
        [Route("Xt_User/SaveUserDept")]
        [HttpPost]
        public object SaveUserDept([FromBody] JObject msg)
        {
            var _value = msg["msg"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString();
            ListModels oListModels = new ListModels();
            try
            {
                List<Models.Department> lsmain = new List<Models.Department>();
                msg2 = msg2.Substring(1, msg2.Length - 2);
                msg2 = msg2.Replace("\\", "");
                msg2 = msg2.Replace("\n", "");  //\n
                lsmain = oListModels.getObjectByJson_Department(msg2);
                oCN.BeginTran();
                //删除已经关联的数据
                oCN.RunProc("Delete From Gy_UserDeptRelation  where HUserID='" + msg3.ToString() + "'");
                foreach (Models.Department oItem in lsmain)
                {
                    //重新写入关联数据
                    oCN.RunProc("insert into Gy_UserDeptRelation (HDeptID,HUserID) values ('" + oItem.HItemID + "','" + msg3.ToString() + "')");
                }
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "保存成功!";
                objJsonResult.data = 1;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = 1;
                return objJsonResult;
            }
        }
        #endregion
        #region  æ ¹æ®ç”¨æˆ·ç¼–码查找已分配工位列表
        [Route("Xt_User/UserByWorkStationlistPlaylist")]
        [HttpGet]
        public object UserByWorkStationlistPlaylist(string HUserID)
        {
            try
            {
                ds = oCN.RunProcReturn("select HWorkStationID HItemID,工位代码 HNumber,工位名称 HName from h_v_Gy_UserByWorkStationList where HUserID='" + HUserID + "' ", "h_v_Gy_UserByWorkStationList");
                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;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region ç”¨æˆ·å…³è”工位保存
        [Route("Xt_User/SaveUserByWorkStation")]
        [HttpPost]
        public object SaveUserByWorkStation([FromBody] JObject msg)
        {
            var _value = msg["msg"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString();
            ListModels oListModels = new ListModels();
            try
            {
                List<Models.Department> lsmain = new List<Models.Department>();
                msg2 = msg2.Substring(1, msg2.Length - 2);
                msg2 = msg2.Replace("\\", "");
                msg2 = msg2.Replace("\n", "");  //\n
                lsmain = oListModels.getObjectByJson_Department(msg2);
                oCN.BeginTran();
                //删除已经关联的数据
                oCN.RunProc("Delete From Gy_UserByWorkStationRelation  where HUserID='" + msg3.ToString() + "'");
                foreach (Models.Department oItem in lsmain)
                {
                    //重新写入关联数据
                    oCN.RunProc("insert into Gy_UserByWorkStationRelation (HWorkStationID,HUserID) values ('" + oItem.HItemID + "','" + msg3.ToString() + "')");
                }
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "保存成功!";
                objJsonResult.data = 1;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = 1;
                return objJsonResult;
            }
        }
        #endregion
    }
}
WebAPI/Controllers/BaseSet/Gy_WarehouseController.cs
@@ -49,22 +49,12 @@
                    ds = oCN.RunProcReturn(sql, "h_v_IF_WareHouseList");
                }
                //if (ds == null || ds.Tables[0].Rows.Count == 0)
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "false!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                //else
                //{
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "Sucess!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                //}
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
WebAPI/Controllers/»ù´¡×ÊÁÏ/»ù´¡×ÊÁÏ/Gy_WorkStationBillController.cs
New file
@@ -0,0 +1,58 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebAPI.Models;
namespace WebAPI.Controllers.基础资料.基础资料
{
    public class Gy_WorkStationBillController :  ApiController
    {
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        #region å·¥ä½åˆ—表
        [Route("Gy_WorkStationBill/Gy_WorkStationList")]
        [HttpGet]
        public object Gy_WorkStationList(string sWhere, string user)
        {
            try
            {
                //编辑权限
                if (!DBUtility.ClsPub.Security_Log_second("Gy_WorkStation_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                string sql1 = string.Format(@"select * from h_v_Gy_WorkStationList where 1=1  ");
                ds = oCN.RunProcReturn(sql1 + sWhere + " order by å·¥ä½ä»£ç  ", "h_v_Gy_WorkStationList");
                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
    }
}
WebAPI/ListModels.cs
@@ -1782,6 +1782,54 @@
        }
        /// <summary>
        /// ç”¨æˆ·ç»„织关系信息表的json
        /// </summary>
        /// <param name="jsonString"></param>
        /// <returns></returns>
        public List<Models.Xt_ORGANIZATIONS> getObjectByJson_Xt_ORGANIZATIONS(string jsonString)
        {
            jsonString = "[" + jsonString.ToString() + "]";
            List<Models.Xt_ORGANIZATIONS> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.Xt_ORGANIZATIONS>>(jsonString);
            return list;
        }
        /// <summary>
        /// ç”¨æˆ·ä»“库关系信息表的json
        /// </summary>
        /// <param name="jsonString"></param>
        /// <returns></returns>
        public List<Models.Warehouse> getObjectByJson_Warehouse(string jsonString)
        {
            jsonString = "[" + jsonString.ToString() + "]";
            List<Models.Warehouse> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.Warehouse>>(jsonString);
            return list;
        }
        /// <summary>
        /// ç”¨æˆ·ç­ç»„关系信息表的json
        /// </summary>
        /// <param name="jsonString"></param>
        /// <returns></returns>
        public List<Models.Gy_Group> getObjectByJson_Gy_Group(string jsonString)
        {
            jsonString = "[" + jsonString.ToString() + "]";
            List<Models.Gy_Group> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.Gy_Group>>(jsonString);
            return list;
        }
        /// <summary>
        /// ç”¨æˆ·éƒ¨é—¨å…³ç³»ä¿¡æ¯è¡¨çš„json
        /// </summary>
        /// <param name="jsonString"></param>
        /// <returns></returns>
        public List<Models.Department> getObjectByJson_Department(string jsonString)
        {
            jsonString = "[" + jsonString.ToString() + "]";
            List<Models.Department> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.Department>>(jsonString);
            return list;
        }
        /// <summary>
        /// å…¬å‘Šåˆ—表主表的json
        /// </summary>
        /// <param name="jsonString"></param>
WebAPI/WebAPI.csproj
@@ -429,6 +429,7 @@
    <Compile Include="Controllers\仓存管理\验收入库\Kf_StepFoldinBillController.cs" />
    <Compile Include="Controllers\博日自动扫码线\ScanlineAPIController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Gy_StockCheckItemBillController.cs" />
    <Compile Include="Controllers\基础资料\基础资料\Gy_WorkStationBillController.cs" />
    <Compile Include="Controllers\工资管理\Pay_MonthlySalaryReportController.cs" />
    <Compile Include="Controllers\工资管理\Pay_PieceRateWageReportController.cs" />
    <Compile Include="Controllers\工资管理\Gy_ClassTimePrjBillController.cs" />
@@ -835,6 +836,7 @@
    <Folder Include="Views\Gy_EquipType\" />
    <Folder Include="Views\Gy_ICBomBill\" />
    <Folder Include="Views\Gy_RoutingGroup\" />
    <Folder Include="Views\Gy_WorkStation\" />
    <Folder Include="Views\JIT_DayPlanPlatFormBill\" />
    <Folder Include="Views\JIT_DayPlanPlatFormImport\" />
    <Folder Include="Views\JIT_ICMOSortBillList\" />