Task #6599 增加了查询返回时的||处理

This commit is contained in:
xingheng 2025-09-02 09:59:25 +08:00
parent 459becb1a9
commit 819427a115
3 changed files with 32 additions and 186 deletions

View File

@ -12,7 +12,7 @@ using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Web.Http;
using System.Web.Http.Description;
using System.Web.Http.Description;
using System.Web.Services.Description;
namespace Learun.Application.Web.AppApi
@ -471,17 +471,31 @@ namespace Learun.Application.Web.AppApi
var list = allLists.FirstOrDefault(x => x.DataItemCode == prop.EnumData);
if (list != null)
{
var details = allDetails.Where(x => x.DataItemID == list.DataItemID).ToList();
prop.EnumDataCode = "";
foreach (var detail in details)
//是否需要换行
if (list.ShowEN == 1)
{
if (string.IsNullOrEmpty(detail.DataItemNameEN))
foreach (var detail in details)
{
prop.EnumDataCode += detail.DataItemName + ",";
if (string.IsNullOrEmpty(detail.DataItemNameEN))
{
prop.EnumDataCode += detail.DataItemName + ",";
}
else
{
prop.EnumDataCode += detail.DataItemName + GlobalObject.enum_separator + detail.DataItemNameEN + ",";//右侧属性列表,同时带出属性的中文和英文
}
}
else
}
else
{
foreach (var detail in details)
{
prop.EnumDataCode += detail.DataItemName + GlobalObject.enum_separator + detail.DataItemNameEN + ",";//右侧属性列表,同时带出属性的中文和英文
prop.EnumDataCode += detail.DataItemName + ","; //右侧属性列表,只带出属性的中文
}
}
}
@ -607,7 +621,7 @@ namespace Learun.Application.Web.AppApi
//每个位号的属性信息
foreach (var tag in objectType.tags)
{
tag.EngineDataID = tag.EngineDataID;
tag.EngineDataProperty = tagPropAll.Where(x => x.EngineDataID == tag.EngineDataID).ToList();
tag.ObjectTypeName = objectType.ObjectTypeName;
@ -686,178 +700,7 @@ namespace Learun.Application.Web.AppApi
}
#endregion
#region old
//查询所有的位号基础信息
stopWatch.Start();
var engineData = ec_enginedataIBLL.GetList("{\"ProjectId\":\"" + projectId + "\",\"DrawingFileID\":\"" + drawingFileID + "\",\"PixelCodes\":\"" + pixelCodes + "\"}").ToList();
stopWatch.Stop();
this.Logger.Info(DateTime.Now.ToString() + ", " + controllerName + "-" + actionName + "图纸ID" + drawingFileID + ",新版查询所有的位号基础信息运行时长:" + stopWatch.ElapsedMilliseconds.ToString(CultureInfo.InvariantCulture) + "\r\n");
//得到所有的类别(不重复的)
stopWatch.Start();
var objectTypes = engineData.Select(x => x.ObjectTypeID).Distinct().ToList();
string objectTypeIDs = "";
objectTypeIDs = string.Join(",", objectTypes);
var resultCol = new List<ec_objecttypeEntity>();
resultCol = ec_objecttypeBLL.GetList("{\"ProjectId\":\"" + projectId + "\",\"ObjectTypeIDs\":\"" + objectTypeIDs + "\"}",
null, true).ToList();
if (objectTypeIDs != "")
{
//objectTypeIDs = objectTypeIDs.Substring(0, objectTypeIDs.Length - 1);
}
else
{
return Ok(resultCol);
}
stopWatch.Stop();
this.Logger.Info(DateTime.Now.ToString() + ", " + controllerName + "-" + actionName + " 新版得到所有的类别(不重复的)运行时长:" + stopWatch.ElapsedMilliseconds.ToString(CultureInfo.InvariantCulture) + "\r\n");
stopWatch.Start();
//所有类别的属性信息
//stopWatch.Start();
var objectTypeProps = objectTypePBll.GetObjectTypePById(objectTypeIDs, projectId, true);//最频繁的那个接口
//stopWatch.Stop();
//this.Logger.Info(DateTime.Now.ToString() + ", " + controllerName + "-" + actionName + " 新版所有类别的属性信息运行时长:" + stopWatch.ElapsedMilliseconds.ToString(CultureInfo.InvariantCulture) + "\r\n");
//GetProjectCodeList
stopWatch.Stop();
this.Logger.Info(DateTime.Now.ToString() + ", " + controllerName + "-" + actionName + " 新版得到所有类别的属性信息:" + stopWatch.ElapsedMilliseconds.ToString(CultureInfo.InvariantCulture) + "\r\n");
//GetEngineDataListByTags
stopWatch.Start();
var listEngineDataID = engineData.Select(x => x.EngineDataID).Distinct().ToList();
//一次查询全部属性信息
var engineDataProps = ec_enginedata_propertyBLL.GetEnginePropByList(projectId, listEngineDataID, caseID);//最频繁的那个接口
//一次查询全部的位号信息
var allTags = ec_enginedataIBLL.GetList("{\"ProjectId\":\"" + projectId + "\",\"ObjectTypeIDs\":\"" + objectTypeIDs + "\"}").OrderBy(X => X.TagNumber).ToList();
stopWatch.Stop();
this.Logger.Info(DateTime.Now.ToString() + ", " + controllerName + "-" + actionName + " 新版一次查询全部属性信息运行时长:" + stopWatch.ElapsedMilliseconds.ToString(CultureInfo.InvariantCulture) + "\r\n");
stopWatch.Start();
//一次查询图上的所有句柄
var allPixels = ec_enginedata_pixelIBLL.GetDrawingEnginePixel("{\"ProjectId\":\"" + projectId + "\",\"DrawingFileID\":\"" + drawingFileID + "\"}").ToList();
//clear
//stopWatch.Stop();
//ec_enginedata_pixelIBLL.Clear(drawingFileID, projectId);
//this.Logger.Info(DateTime.Now.ToString() + ", " + controllerName + "-" + actionName + " 新版clear无效的图元信息:" + stopWatch.ElapsedMilliseconds.ToString(CultureInfo.InvariantCulture) + "\r\n");
//stopWatch.Start();
//var detailTbName = ProjectSugar.TableName<ec_dataitemdetailEntity>(projectId);
var DATAITEMBLL = new ec_dataitemBLL();
var allDetails = DATAITEMBLL.GetDetailList("", "", projectId);// SqlSugarHelper.Db.Queryable<ec_dataitemdetailEntity>().AS(detailTbName).ToList();
//var listTbName = ProjectSugar.TableName<ec_dataitemEntity>(projectId);
var allLists = DATAITEMBLL.GetList("{ProjectId:\"" + projectId + "\"}"); //SqlSugarHelper.Db.Queryable<ec_dataitemEntity>().AS(listTbName).ToList();
foreach (var objectType in resultCol)
{
//该类型下的属性信息
objectType.props = objectTypeProps.Where(x => x.ObjectTypeID == objectType.ObjectTypeID).ToList();
#region 5356
foreach (var prop in objectType.props.Where(x => !string.IsNullOrEmpty(x.EnumData)))
{
//下拉的属性
var list = allLists.FirstOrDefault(x => x.DataItemCode == prop.EnumData);
if (list != null)
{
var details = allDetails.Where(x => x.DataItemID == list.DataItemID).ToList();
prop.EnumDataCode = "";
foreach (var detail in details)
{
if (string.IsNullOrEmpty(detail.DataItemNameEN))
{
prop.EnumDataCode += detail.DataItemName + ",";
}
else
{
prop.EnumDataCode += detail.DataItemName + GlobalObject.enum_separator + detail.DataItemNameEN + ",";//右侧属性列表,同时带出属性的中文和英文
}
}
}
}
#endregion
//该类型下的位号基础信息
objectType.tags = engineData.Where(x => x.ObjectTypeID == objectType.ObjectTypeID).ToList();
foreach (var tag in objectType.tags)
{
//电缆from to
var CableConn = relBll.GetCableConn(tag.EngineDataID, projectId);
//每个位号的属性信息
tag.EngineDataID = tag.EngineDataID;
tag.EngineDataProperty = engineDataProps.Where(x => x.EngineDataID == tag.EngineDataID).ToList();
//BUG 1483
if (objectType.ObjectTypeName.EndsWith("电缆"))
{
if (!tag.EngineDataProperty.Any(X => X.PropertyName == "起始设备"))
{
var newProp = new ec_enginedata_propertyEntity()
{
EngineDataID = tag.EngineDataID,
PropertyName = "起始设备",
//CaseID = string.IsNullOrEmpty(caseID) ? tag.CaseID : caseID,
};
newProp.Create();
ec_enginedata_propertyBLL.InsertTagProp(projectId, tag.EngineDataID, newProp);
tag.EngineDataProperty.Add(newProp);
}
if (!tag.EngineDataProperty.Any(X => X.PropertyName == "终止设备"))
{
var newProp = new ec_enginedata_propertyEntity()
{
EngineDataID = tag.EngineDataID,
PropertyName = "终止设备",
//CaseID = string.IsNullOrEmpty(caseID) ? tag.CaseID : caseID,
};
newProp.Create();
ec_enginedata_propertyBLL.InsertTagProp(projectId, tag.EngineDataID, newProp);
tag.EngineDataProperty.Add(newProp);
}
}
foreach (ec_enginedata_propertyEntity TagProp in tag.EngineDataProperty)
{
if (TagProp.PropertyName == "起始设备")
{
TagProp.PropertyValue = CableConn.End1Tag;
}
else if (TagProp.PropertyName == "终止设备")
{
TagProp.PropertyValue = CableConn.End2Tag;
}
}
//查一下每个位号的图元信息
tag.EngineDataPixel = allPixels.Where(x => x.EngineDataID == tag.EngineDataID).ToList();
}
objectType.tagsListDropDown = allTags.ToDictionary(x => x.EngineDataID, x => x.TagNumber);
//该类型下的流水
if (objectType.IsSerialNumber == 1)
{
int SerialNumber = 1;
if (engineData != null && allTags.Count > 0)
{
SerialNumber = engineData.Max(x => x.SerialNumber).ToInt() + 1;
}
objectType.TagAutoBySerialNumber = objectType.ObjectTypeNameEN + SerialNumber;
}
}
stopWatch.Stop();
this.Logger.Info(DateTime.Now.ToString() + ", " + controllerName + "-" + actionName + " 新版GetEngineDataListByTags运行时长:" + stopWatch.ElapsedMilliseconds.ToString(CultureInfo.InvariantCulture) + "\r\n");
return Ok(resultCol);
//this.Logger.Info(DateTime.Now.ToString() + ", " + controllerName + "-" + actionName + " 新版返回resultCol结果:" + JsonConvert.SerializeObject(resultCol) + "\r\n");
#endregion
#endregion
}
@ -1159,7 +1002,7 @@ namespace Learun.Application.Web.AppApi
{
var objectTypeProps = objectTypePBll.GetObjectTypePById(en1.ObjectTypeID, projectId, true);
foreach (var props in objectTypeProps)
{
{
var curProp = en1.EngineDataProperty.Find(x => x.PropertyName == props.PropertyName);
if (string.IsNullOrEmpty(curProp?.PropertyValue))
{

View File

@ -137,7 +137,8 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
var t2 = allProp.FirstOrDefault(x => x.PropertyID == objectTypeProp.PropertyID);
if (t2 == null) { continue; }
var t3 = allGroup.FirstOrDefault(x => x.PropertyGID == t2.PropertyGID);
if (t3 == null) { continue; };
if (t3 == null) { continue; }
;
objectTypeProp.PropertyName = t2.PropertyName;
objectTypeProp.PropertyNameEN = t2.PropertyNameEN;
objectTypeProp.PropertyType = t2.PropertyType;
@ -169,13 +170,15 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
foreach (var detail in allDetails.Where(x => x.DataItemID == Dic.DataItemID))
{
if (string.IsNullOrEmpty(detail.DataItemNameEN))
if (!string.IsNullOrEmpty(detail.DataItemNameEN) && Dic.ShowEN == 1)
{
objectTypeProp.EnumDataCode += detail.DataItemName + ",";
objectTypeProp.EnumDataCode += detail.DataItemName + GlobalObject.enum_separator + detail.DataItemNameEN + ",";//右侧属性列表,同时带出属性的中文和英文
}
else
{
objectTypeProp.EnumDataCode += detail.DataItemName + GlobalObject.enum_separator + detail.DataItemNameEN + ",";//右侧属性列表,同时带出属性的中文和英文
objectTypeProp.EnumDataCode += detail.DataItemName + ",";
}
}
}
@ -209,7 +212,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
}
if (!string.IsNullOrEmpty(objectTypeID))
{
{
var tObjectType = ProjectSugar.TableName<ec_objecttypeEntity>(ProjectId);
var tobjTypeAll = SqlSugarHelper.Db.Queryable<ec_objecttypeEntity>().AS(tObjectType).ToList();

View File

@ -146,7 +146,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
[SugarColumn(IsIgnore = true)]
public string EnumData { get; set; }
/// <summary>
/// 枚举数据字典名称
/// 枚举的列表,以逗号分隔
/// </summary>
/// <returns></returns>
[SugarColumn(IsIgnore = true)]