模型接口

This commit is contained in:
陈向学 2024-06-26 11:40:10 +08:00
parent 27fdc1d59c
commit 9779619812
2 changed files with 48 additions and 3 deletions

View File

@ -147,6 +147,25 @@ namespace Competition.Mysql.BLL
return modelList;
}
public List<object> DataTableToObjectList(DataTable dt)
{
List<object> modelList = new List<object>();
int rowsCount = dt.Rows.Count;
if (rowsCount > 0)
{
object model;
for (int n = 0; n < rowsCount; n++)
{
model = dal.DataRowToModelByObject(dt.Rows[n]);
if (model != null)
{
modelList.Add(model);
}
}
}
return modelList;
}
/// <summary>
/// 获得数据列表
/// </summary>
@ -223,10 +242,10 @@ namespace Competition.Mysql.BLL
/// </summary>
/// <param name="customids"></param>
/// <returns></returns>
public List<Competition.Mysql.Model.v_model_version> GetListByCustom(string[] customids)
public List<object> GetListByCustom(string[] customids)
{
DataSet ds = dal.GetListByCustom(customids);
return DataTableToList(ds.Tables[0]);
return DataTableToObjectList(ds.Tables[0]);
}
#endregion ExtensionMethod
}

View File

@ -295,6 +295,32 @@ namespace Competition.Mysql.DAL
return model;
}
public object DataRowToModelByObject(DataRow row)
{
if (row != null)
{
var tmpModel = new
{
ModelId = row["ModelId"].ToString(),
MONITOR_ID = row["MONITOR_ID"].ToString(),
ModelName = row["ModelName"].ToString(),
VersionNumber = row["VersionNumber"].ToString(),
MapLongitude = row["MapLongitude"].ToString(),
MapLatitude = row["MapLatitude"].ToString(),
TrainingSize = row["TrainingSize"].ToString(),
ModelResources = row["ModelResources"].ToString(),
UpdateTime = DateTime.Parse(row["UpdateTime"].ToString()),
Remark1 = row["Remark1"].ToString(),
Remark2 = row["Remark2"].ToString(),
Remark3 = row["Remark3"].ToString(),
RegistryName = row["RegistryName"].ToString(),
ModelResourcesPath = row["ModelResourcesPath"].ToString(),
CUSTOMS_CODE = row["CUSTOMS_CODE"].ToString()
};
return tmpModel;
}
return null;
}
/// <summary>
/// 获得数据列表
/// </summary>
@ -514,7 +540,7 @@ namespace Competition.Mysql.DAL
{
//三表联查
StringBuilder strSql = new StringBuilder();
strSql.Append("SELECT T1.* FROM v_model_version T1 ");
strSql.Append("SELECT T1.*,T2.CUSTOMS_CODE FROM v_model_version T1 ");
strSql.Append("INNER JOIN ");
strSql.Append("(SELECT S1.* FROM T_BAS_CORPORATION S1 ");
strSql.Append("INNER JOIN ");