优化检入检查循环

This commit is contained in:
supercjj2023 2025-09-12 15:48:00 +08:00
parent 8e44650cfb
commit 72d236d8ea

View File

@ -484,32 +484,52 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
} }
} }
} }
// 构建一个字典key = (EngineDataID, PropertyID)value = PropertyValue
var propDict = AllPropsOfEng
.GroupBy(x => (x.EngineDataID, x.PropertyID))
.ToDictionary(g => g.Key, g => g.First().PropertyValue);
//检查必填属性 //检查必填属性
foreach (var checkproperty in NeedCheckProperties) foreach (var checkproperty in NeedCheckProperties)
{ {
//如果ec_enginedata_propety里面没有必填属性要求的这个属性就代表没有保存认为是没有填值为空 var key = (checkproperty.EngineDataID, checkproperty.PropertyID);
if (AllPropsOfEng.Where(x => x.EngineDataID == checkproperty.EngineDataID).Select(x => x.PropertyID).Contains(checkproperty.PropertyID)) if (propDict.TryGetValue(key, out var propertyValue))
{ {
var PropertyValue = AllPropsOfEng if (string.IsNullOrEmpty(propertyValue) || propertyValue == "0")
.FirstOrDefault(x => {
x.EngineDataID == checkproperty.EngineDataID && errText = $"图面有对象【{checkproperty.TagNumber}】在即时更新阶段的必填属性【{checkproperty.PropertyName}】值为空,不能检入,请执行“属性检查”功能对图纸进行属性检查。";
x.PropertyID == checkproperty.PropertyID) return res = false;
?.PropertyValue; }
//foreach (var property in AllPropsOfEng)
//{
//如果ec_enginedata_propety里面的EngineDataID等于需要检查对象的EngineDataID且属性ID也能对上且属性值为空或者NULL则认为没有填写
if (string.IsNullOrEmpty(PropertyValue) || PropertyValue == "0")
{
errText = $"图面有对象【{checkproperty.TagNumber}】在即时更新阶段的必填属性【{checkproperty.PropertyName}】值为空,不能检入,请执行“属性检查”功能对图纸进行属性检查。";
return res = false;
}
//}
} }
else else
{ {
errText = $"图面有对象【{checkproperty.TagNumber}】在即时更新阶段的必填属性【{checkproperty.PropertyName}】不存在,认为空,需要填写,不能检入,请执行“属性检查”功能对图纸进行属性检查。"; errText = $"图面有对象【{checkproperty.TagNumber}】在即时更新阶段的必填属性【{checkproperty.PropertyName}】不存在,认为空,需要填写,不能检入,请执行“属性检查”功能对图纸进行属性检查。";
return res = false; return res = false;
} }
//如果ec_enginedata_propety里面没有必填属性要求的这个属性就代表没有保存认为是没有填值为空
//if (AllPropsOfEng.Where(x => x.EngineDataID == checkproperty.EngineDataID).Select(x => x.PropertyID).Contains(checkproperty.PropertyID))
//{
// var PropertyValue = AllPropsOfEng
// .FirstOrDefault(x =>
// x.EngineDataID == checkproperty.EngineDataID &&
// x.PropertyID == checkproperty.PropertyID)
// ?.PropertyValue;
// //foreach (var property in AllPropsOfEng)
// //{
// //如果ec_enginedata_propety里面的EngineDataID等于需要检查对象的EngineDataID且属性ID也能对上且属性值为空或者NULL则认为没有填写
// if (string.IsNullOrEmpty(PropertyValue) || PropertyValue == "0")
// {
// errText = $"图面有对象【{checkproperty.TagNumber}】在即时更新阶段的必填属性【{checkproperty.PropertyName}】值为空,不能检入,请执行“属性检查”功能对图纸进行属性检查。";
// return res = false;
// }
// //}
//}
//else
//{
// errText = $"图面有对象【{checkproperty.TagNumber}】在即时更新阶段的必填属性【{checkproperty.PropertyName}】不存在,认为空,需要填写,不能检入,请执行“属性检查”功能对图纸进行属性检查。";
// return res = false;
//}
} }
//需要去看依赖项的数据了这里的条件为无需必填或者即时更新版必填又或者Isrequired=null,都要去检查又由于会去这个List里面找上级关联对象所以也不能针对dependency_type去做过滤不然可能就找不到上级对象了 //需要去看依赖项的数据了这里的条件为无需必填或者即时更新版必填又或者Isrequired=null,都要去检查又由于会去这个List里面找上级关联对象所以也不能针对dependency_type去做过滤不然可能就找不到上级对象了