chenhaozhe
2026-02-28 0ea85f05fb9248216de064fee4ccd592640fb76b
WebAPI/Controllers/WebAPIController.cs
@@ -1150,7 +1150,52 @@
            }
        }
        /// <summary>
        /// 获取仓库列表  --添加模具仓库条件  用于只查询模具仓库
        /// </summary>
        /// <returns></returns>
        [Route("Web/GetWarehouseList_Json_MJ")]
        [HttpGet]
        public object GetWarehouseList_Json_MJ(string Warehouse, Int64 HOrgID)
        {
            sWhere = " Where HStopFlag=0  and HEndFlag=1 and HWarehouseType='模具仓库' and HUSEORGID =" + HOrgID + "";
            //sWhere = " Where HStopFlag=0  and HEndFlag=1  and HUSEORGID = " + DBUtility.ClsPub.HORGANIZATIONSID.ToString();
            if (Warehouse != "")
            {
                sWhere = sWhere + " and ( HNumber like '%" + Warehouse + "%' or HName like '%" + Warehouse + "%'  or HUSEORGID like '%" + Warehouse + "%' ) ";
            }
            try
            {
                WebS.WebService1 oWeb = new WebS.WebService1();
                ds = oWeb.GetWarehouseList(sWhere, ref DBUtility.ClsPub.sErrInfo);
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo;
                    objjson.data = null;
                    return objjson;
                }
                else
                {
                    objjson.code = "0";
                    objjson.count = 1;
                    objjson.Message = "获取成功!";
                    objjson.data = ds.Tables[0];
                    return objjson;
                }
            }
            catch (Exception ex)
            {
                objjson.code = "0";
                objjson.count = 0;
                objjson.Message = "获取失败" + ex.ToString();
                objjson.data = null;
                return objjson;
            }
        }
        /// <summary>
        /// 获取仓位列表
@@ -1466,14 +1511,71 @@
            }
        }
        #region 获取职员列表 (添加车间筛选)
        [Route("Web/GetEmployeeList_Json")]
        [HttpGet]
        public object GetEmployeeList_Json3(string Employee, Int64 HGroupID, Int64 HDeptID = -1)
        {
            // 给部门(车间)ID设置默认值,当没有传入值或者值为0的时候,走旧有的函数,否则走新的逻辑
            if(HDeptID == -1 || HDeptID == 0)
            {
                return GetEmployeeList_Json2(Employee, HGroupID);
            }else
            {
                sWhere = $" Where HStopFlag=0  and HEndFlag=1  and HDeptID=${HDeptID}";
                if(Employee != "")
                {
                    sWhere += " and ( HNumber like '%" + Employee + "%' or HName like '%" + Employee + "%' )";
                }
                if(HGroupID != 0)
                {
                    sWhere += " and HGroupID=" + HGroupID.ToString();
                }
                try
                {
                    string sql = $"Select * from h_v_IF_Emp {sWhere} Order by HNumber";
                    ds = oCN.RunProcReturn(sql, "h_v_IF_Emp");
                    if (ds == null || ds.Tables[0].Rows.Count <= 0)
                    {
                        objjson.code = "0";
                        objjson.count = 0;
                        objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo;
                        objjson.data = null;
                        return objjson;
                    }
                    else
                    {
                        objjson.code = "0";
                        objjson.count = 1;
                        objjson.Message = "获取成功!";
                        objjson.data = ds.Tables[0];
                        return objjson;
                    }
                }
                catch (Exception ex)
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "获取失败" + ex.ToString();
                    objjson.data = null;
                    return objjson;
                }
            }
        }
        #endregion
        /// <summary>
        /// 获取职员列表
        /// </summary>
        /// <returns></returns>
        [Route("Web/GetEmployeeList_Json")]
        [HttpGet]
        public object GetEmployeeList_Json(string Employee, Int64 HGroupID)
        // [Route("Web/GetEmployeeList_Json")]
        // [HttpGet]
        public object GetEmployeeList_Json2(string Employee, Int64 HGroupID)
        {
            sWhere = " Where HStopFlag=0  and HEndFlag=1";
            //sWhere = " Where HStopFlag=0  and HEndFlag=1  and HUSEORGID = " + DBUtility.ClsPub.HORGANIZATIONSID.ToString();
@@ -1492,11 +1594,11 @@
            {
                if (Employee != "")
                {
                    sWhere = " Where HStopFlag=0 and HWHID=" + HGroupID.ToString() + " and ( HNumber like '%" + Employee + "%' or HName like '%" + Employee + "%' ) ";
                    sWhere = " Where HStopFlag=0 and HGroupID=" + HGroupID.ToString() + " and ( HNumber like '%" + Employee + "%' or HName like '%" + Employee + "%' ) ";
                }
                else
                {
                    sWhere = " Where HStopFlag=0 and HWHID=" + HGroupID.ToString();
                    sWhere = " Where HStopFlag=0 and HGroupID=" + HGroupID.ToString();
                }
            }
            try
@@ -1531,6 +1633,7 @@
            }
        }
        /// <summary>
        /// 获取班次列表
@@ -20070,7 +20173,7 @@
                List<object> columnNameList = new List<object>();
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                string sql = "Select * from h_v_Gy_GetSampleSchemeListView where 1 = 1 " + sWhere + "Order by hmainid ";
                string sql = "Select * from h_v_Gy_GetSampleSchemeListView where 1 = 1 and HUSEORGID = "+OrganizationID + sWhere + "Order by hmainid ";
                ds = oCN.RunProcReturn(sql, "h_v_Gy_GetSampleSchemeListView");
                //添加列名
@@ -23175,5 +23278,86 @@
            }
        }
        #endregion
        #region 用于连接的健康度检验,只要能访问通这个接口,则表明连接可用
        [Route("Health")]
        [HttpGet]
        public IHttpActionResult CheckHealth()
        {
            // 返回 200 状态码 确认健康状态
            return Ok();
        }
        #endregion
        #region 登录用户与设备ClientID 的关系 写入数据库
        [Route("Web/SetGy_UserClientIdConnection")]
        [HttpPost]
        public object SetGy_UserClientIdConnection([FromBody] JObject msg)
        {
            DataSet ds;
            oCN.BeginTran();
            try
            {
                ds = oCN.RunProcReturn($@"exec h_p_SetGy_UserClientIdRelation
                @HUserbm=N'{msg["HUserbm"].ToString()}',
               @HUserName=N'{msg["HUserName"].ToString()}',
               @HClientID=N'{msg["HClientID"].ToString()}',
                @HOnline={msg["HOnline"].ToString()}
                ", "h_p_SetGy_UserClientIdRelation");
                if(ds.Tables[0].Rows[0]["HStatus"].ToString() == "1")
                {
                    oCN.Commit();
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存设备信息成功!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存设备信息失败!" + ds.Tables[0].Rows[0]["msg"];
                    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
        #region APP 根据模块获取该模块下需要显示消息标识的子模块
        [Route("Web/getMessageIdentified")]
        [HttpGet]
        public object getMessageIdentified(string user, string moduleName)
        {
            DataSet oDs = oCN.RunProcReturn($"exec h_p_getMessageIdentifier_APP '{user}', '{moduleName}'", "h_p_getMessageIdentifier_APP");
            if(oDs == null || oDs.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 = "获取消息标识成功!";
                objJsonResult.data = oDs.Tables[0];
                return objJsonResult;
            }
        }
        #endregion
    }
}