WebAPI/Controllers/SBGL/Gy_EquipFileMainController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
WebAPI/Controllers/SBGL/Gy_EquipFileMainController.cs
@@ -649,5 +649,85 @@ } } #endregion #region 设备档案列表 树状图 设备分类查询 public class TreeModel { public string id { get; set; } public string title { get; set; } public List<TreeModel> children = new List<TreeModel>(); } [Route("Gy_EquipFileMain/TreeGetList")] [HttpGet] public object TreeGetList(string sWhere, string user) { try { ds = oCN.RunProcReturn("select HItemID,HNumber,HName from Gy_EquipFileType", "Gy_EquipFileType"); List<TreeModel> treeModels = new List<TreeModel>(); TreeModel first = new TreeModel(); first.id = "0"; first.title = "设备分类设置"; treeModels.Add(first); foreach (DataRow row in ds.Tables[0].Rows) { var strLen = row["hitemid"].ToString().Split('.'); if (strLen.Length == 1) { TreeModel tree = new TreeModel(); tree.id = row["HItemID"].ToString(); tree.title = row["HName"].ToString(); treeModels[0].children.Add(tree); } } digui(ds.Tables[0], treeModels[0].children, 2); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = Newtonsoft.Json.JsonConvert.SerializeObject(treeModels); return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } /// <summary> /// 递归函数 /// </summary> public void digui(DataTable dt, List<TreeModel> tree, int num) { for (int m = 0; m < tree.Count; m++) { tree[m].children = new List<TreeModel>(); for (int i = 0; i < dt.Rows.Count; i++)//第一次循环,得到所有根节点的子集 { var strLen = dt.Rows[i]["HNumber"].ToString().Split('.'); if (strLen.Length == num && dt.Rows[i]["HNumber"].ToString().Contains(tree[m].id + ".")) { TreeModel tbjson = new TreeModel(); tbjson.id = dt.Rows[i]["HItemID"].ToString(); tbjson.title = dt.Rows[i]["HName"].ToString(); tree[m].children.Add(tbjson); } } var strLens = tree[m].id.Split('.'); for (int i = 0; i < tree[m].children.Count; i++) { digui(dt, tree[m].children, strLens.Length + 2);//再次用子集去循环,拿出子集的子集 } } } #endregion } } WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs
@@ -472,5 +472,100 @@ } #endregion #region 设备分类禁用、反禁用 /// <summary> /// /// </summary> /// <param name="HInterID">单据ID</param> /// <param name="IsStop">禁用(0),反禁用(1)</param> /// <param name="CurUserName">审核人</param> /// <returns></returns> [Route("Gy_EquipTypeBill/StopGy_EquipTypeBill")] [HttpGet] public object StopGy_EquipTypeBill(int HInterID, int IsStop, string CurUserName) { try { //审核权限 if (!DBUtility.ClsPub.Security_Log_second("Gy_MaterType_Stop", 1, false, CurUserName)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "禁用失败!无权限!"; objJsonResult.data = null; return objJsonResult; } var ds = oCN.RunProcReturn("select * from Gy_EquipFileType where HItemID=" + HInterID, "Gy_EquipFileType"); if (ds.Tables[0].Rows.Count > 0) { if (IsStop == 0) //禁用判断 { if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已禁用!不能再次禁用!"; objJsonResult.data = null; return objJsonResult; } } if (IsStop == 1) //反禁用判断 { if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未禁用!不需要反禁用!"; objJsonResult.data = null; return objJsonResult; } } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据不存在!"; objJsonResult.data = null; return objJsonResult; } oCN.BeginTran(); if (IsStop == 0) //禁用判断 { oCN.RunProc("update Gy_EquipFileType set HStopEmp='" + CurUserName + "',HStopTime=getdate(),HStopflag=1 where HItemID=" + HInterID); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "禁用成功"; objJsonResult.data = null; } if (IsStop == 1) //反禁用判断 { oCN.RunProc("update Gy_EquipFileType set HStopEmp='',HStopTime=null,HStopflag=0 where HItemID=" + HInterID); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "反禁用成功"; objJsonResult.data = null; } oCN.Commit(); return objJsonResult; } catch (Exception e) { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "禁用失败或者反禁用失败!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion } }