public Response GetItemClassMaintainData(string token, [FromBody] SingleField param) { Response response = new Response(); if (string.IsNullOrEmpty(token) || !token.Equals(_token)) { response.code = "404"; response.message = "Invild token"; } else { ItemClassMaintain result = CClassSupplierHelper.GetItemClassMaintainData(param); if ((result.lstItemClass_x == null || result.lstItemClass_x.Count == 0) || (result.lstItemClass_y == null || result.lstItemClass_y.Count == 0)) { response.code = "500"; response.message = "No Data"; } else { response.code = "200"; response.content = result; } } return(response); }
/// <summary> /// 取得ItemClass维护界面的集合 /// </summary> /// <param name="param">公司代码</param> /// <returns></returns> public static ItemClassMaintain GetItemClassMaintainData(SingleField param) { try { ItemClassMaintain result = cClassSupplierFactory.GetItemClassMaintainData(param); if ((result.lstItemClass_x == null || result.lstItemClass_x.Count == 0) || (result.lstItemClass_y == null || result.lstItemClass_y.Count == 0)) { throw new Exception("DAL.MastData.cClassSupplierFactory.GetItemClassMantainData()==null"); } return(result); } catch (Exception ex) { LogHelper.WriteLog(new Log() { message = ex.Message }, "GetItemClassMantainData"); return(null); } }
/// <summary> /// 取得ItemClass维护界面的集合 /// </summary> /// <param name="param">公司代码</param> /// <returns></returns> public ItemClassMaintain GetItemClassMaintainData(SingleField param) { ItemClassMaintain result = new ItemClassMaintain(); string strSql = " SELECT M.ID " + " , M.TYPE " + " , M.COSTCENTERCODE " + " , M.CODE1 " + " , M.NAME1 " + " , M.CODE2 " + " , M.NAME2 " + " , I.SORT " + " FROM TBLDATAMAPPING AS M " + " INNER JOIN TBLITEMCLASS AS I " + " ON M.CODE1 = I.GUID " + " WHERE M.DBCODE = '{0}' " + " AND M.TYPE = 'RMClassMapping' " + " AND M.COSTCENTERCODE IS NULL " + " AND M.DELETEUSER IS NULL "; // Sql文(ItemClass主数据) string strSqlItemClass = " SELECT ID" + " , GUID " + " , CLASSNAME_ZH AS NAME " + " , SORT " + " FROM TBLITEMCLASS " + " WHERE STATUS = 'active' " + " AND TYPE = 'RMClass' " + " ORDER BY SORT "; // 已有的ItemClass Mapping数据 List <tblDataMapping> lstTblDataMapping = SqlServerHelper.GetEntityList <tblDataMapping>(SqlServerHelper.salesorderConn(), string.Format(strSql , param.code)); // X轴数据 List <ItemClass> lstItemClassData = (new ItemFactory()).getItemClass(param.code); // y轴数据 List <ItemClass> lstItemClass_y = SqlServerHelper.GetEntityList <ItemClass>(SqlServerHelper.salesorderConn(), strSqlItemClass); List <ItemClassHierarchy> lstItemClass_x = new List <ItemClassHierarchy>(); ItemClassHierarchy ich = new ItemClassHierarchy(); foreach (ItemClass parent in lstItemClassData) { if (parent.children.Count > 1) { ich = new ItemClassHierarchy(); ich.p_code = parent.value; ich.p_name = parent.label; ich.c_code = "all"; ich.c_name = "全选"; ich.rowSpan = parent.children.Count + 1; lstItemClass_x.Add(ich); } foreach (ItemClass child in parent.children) { ich = new ItemClassHierarchy(); ich.p_code = parent.value; ich.p_name = parent.label; ich.c_code = child.value; ich.c_name = child.label; ich.rowSpan = parent.children.Count == 1 ? 1 : 0; lstItemClass_x.Add(ich); } } result.lstTblDataMapping = lstTblDataMapping; result.lstItemClass_x = lstItemClass_x; result.lstItemClass_y = lstItemClass_y; return(result); }