材料表自动生成

This commit is contained in:
chenjinbu 2025-09-22 09:25:18 +08:00
commit ffc5786ed5
85 changed files with 3199 additions and 1541 deletions

1
.gitignore vendored
View File

@ -1109,3 +1109,4 @@ newFront/c#前端/.vs/
/newFront/c#前端/CAD.Extend/obj/Debug/CAD.Extend.csproj.AssemblyReference.cache /newFront/c#前端/CAD.Extend/obj/Debug/CAD.Extend.csproj.AssemblyReference.cache
/newFront/c#前端/.vs/SWS.CAD/FileContentIndex/f03e1583-e8e0-43b7-9dbb-a1896ce4b92d.vsidx /newFront/c#前端/.vs/SWS.CAD/FileContentIndex/f03e1583-e8e0-43b7-9dbb-a1896ce4b92d.vsidx
/newFront/c#前端/.vs/SWS.CAD/FileContentIndex/f2e37380-e651-406b-9320-af642620eee9.vsidx /newFront/c#前端/.vs/SWS.CAD/FileContentIndex/f2e37380-e651-406b-9320-af642620eee9.vsidx
/SWSDBSchemeUpgradeTool/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache

View File

@ -406,57 +406,7 @@ namespace Learun.Application.Web.AppApi
return Fail(ex.Message); return Fail(ex.Message);
} }
} }
/// <summary>
/// 检入图纸文件
/// </summary>
/// <param name="projectId">项目ID</param>
/// <param name="drawingFileID">图纸文件ID</param>
/// <param name="remark">描述</param>
/// <param name="folderId">文件夹ID</param>
/// <param name="fileMD5">文件MD5</param>
/// <param name="UsersNotified">待通知的用户,逗号分隔</param>
/// <returns></returns>
[HttpPost]
[Obsolete]
public IHttpActionResult CheckInDrawingFile(string projectId, string drawingFileID, string remark, string folderId, string fileMD5, string UsersNotified)
{
//如何避免数据丢失
try
{
var httpContent = Request.Content;
var asyncContent = httpContent.ReadAsStringAsync().Result;
List<ec_enginedata_pixelEntity> entityList = asyncContent.ToList<ec_enginedata_pixelEntity>();
if (entityList == null || entityList.Count == 0)
{
//避免前端因频繁切换图纸造成检入时,一个都没有,而把数据库里的都清空了
XmlConfigurator.Configure();
var log = log4net.LogManager.GetLogger("INFO"); //参数就是config里logger节点的名字
log.Error($"★★★{DateTime.Now.ToString()}★★★Drawing Check In Only 0 Pixel【DrawingId:{drawingFileID}】★★★");
//return Success("检入成功!");
//entityList = new List<ec_enginedata_pixelEntity>();
}
else if (string.IsNullOrEmpty(folderId))
{
log4net.LogManager.GetLogger("ERROR").Error("检入图纸 - " + "无效的空白FolderId");
throw new Exception("检入图纸 - " + "无效的空白FolderId");
}
else
{
pixelBll.SavePixels(entityList, projectId, drawingFileID);
}
//换了下顺序先SaveMuliteEntity再CheckInDrawingFile。这样就算SaveMuliteEntity报错了但是图纸至少不会被检入免得出现之前数据丢失的问题
ec_drawing_fileIBLL.CheckInDrawingFile(drawingFileID, remark, folderId, fileMD5, projectId, UsersNotified);
return Success("检入成功!");
}
catch (Exception ex)
{
return Fail(ex.Message);
}
}
/// <summary>
/// 检入图纸文件(修改消息) /// 检入图纸文件(修改消息)
/// </summary> /// </summary>
/// <param name="projectId">项目ID</param> /// <param name="projectId">项目ID</param>

View File

@ -62,7 +62,7 @@ namespace Learun.Application.Web.AppApi
{ {
List<TreeModelLite> res = new List<TreeModelLite>(); List<TreeModelLite> res = new List<TreeModelLite>();
var ec_enginedata_pixelBLL = new ec_enginedata_pixelBLL(); var ec_enginedata_pixelBLL = new ec_enginedata_pixelBLL();
var data = ec_enginedata_pixelBLL.GetList("{\"ProjectId\":\"" + projectId + "\",\"EngineDataID\":\"" + EngineDataID + "\"}"); var data = ec_enginedata_pixelBLL.GetList("{\"ProjectId\":\"" + projectId + "\",\"EngineDataID\":\"" + EngineDataID + "\"}",projectId);
return Success(data); return Success(data);
} }
@ -184,7 +184,7 @@ namespace Learun.Application.Web.AppApi
Where(x => x.DeleteFlg != 1).ToList(); Where(x => x.DeleteFlg != 1).ToList();
var relTypeTbName = ProjectSugar.TableName<ec_reltypeEntity>(projectId); var relTypeTbName = ProjectSugar.TableName<ec_reltypeEntity>(projectId);
var relType = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(relTypeTbName).ToList().FirstOrDefault(x => x.RelType == ((int)enum_RelType._电缆).ToString()); var relType = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(relTypeTbName).ToList().FirstOrDefault(x => x.RelType == enum_RelType._电缆);
var propBll = new ec_enginedata_propertyBLL(); var propBll = new ec_enginedata_propertyBLL();
var allTagProps = SqlSugarHelper.Db.Queryable<ec_enginedata_propertyEntity>().AS(propTbName).ToList(); var allTagProps = SqlSugarHelper.Db.Queryable<ec_enginedata_propertyEntity>().AS(propTbName).ToList();
@ -265,7 +265,7 @@ namespace Learun.Application.Web.AppApi
Where(x => x.DeleteFlg != 1).ToList(); Where(x => x.DeleteFlg != 1).ToList();
var relTypeTbName = ProjectSugar.TableName<ec_reltypeEntity>(projectId); var relTypeTbName = ProjectSugar.TableName<ec_reltypeEntity>(projectId);
var relType = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(relTypeTbName).ToList().FirstOrDefault(x => x.RelType == ((int)enum_RelType._电缆).ToString()); var relType = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(relTypeTbName).ToList().FirstOrDefault(x => x.RelType == enum_RelType._电缆);
//var propBll = new ec_enginedata_propertyBLL(); //var propBll = new ec_enginedata_propertyBLL();
var allTagProps = SqlSugarHelper.Db.Queryable<ec_enginedata_propertyEntity>().AS(propTBName).ToList(); var allTagProps = SqlSugarHelper.Db.Queryable<ec_enginedata_propertyEntity>().AS(propTBName).ToList();
@ -312,7 +312,7 @@ namespace Learun.Application.Web.AppApi
Where(x => x.DeleteFlg != 1).ToList(); Where(x => x.DeleteFlg != 1).ToList();
var relTypeTbName = ProjectSugar.TableName<ec_reltypeEntity>(projectId); var relTypeTbName = ProjectSugar.TableName<ec_reltypeEntity>(projectId);
var relType = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(relTypeTbName).ToList().FirstOrDefault(x => x.RelType == ((int)enum_RelType._电缆).ToString()); var relType = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(relTypeTbName).ToList().FirstOrDefault(x => x.RelType == enum_RelType._电缆);
var propBll = new ec_enginedata_propertyBLL(); var propBll = new ec_enginedata_propertyBLL();
var CBs = allCBs.Where(x => x.PDBId == Enginedataid).ToList(); var CBs = allCBs.Where(x => x.PDBId == Enginedataid).ToList();

View File

@ -1,16 +1,21 @@
using DocumentFormat.OpenXml.Drawing.Spreadsheet; using DocumentFormat.OpenXml.Drawing.Spreadsheet;
using Learun.Application.Organization; using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.ZZDT_EC; using Learun.Application.TwoDevelopment.ZZDT_EC;
using Learun.Application.TwoDevelopment.ZZDT_EC.Frame;
using Learun.Cache.Base;
using Learun.Cache.Factory;
using Learun.Loger; using Learun.Loger;
using Learun.Util; using Learun.Util;
using Learun.Util.SqlSugar; using Learun.Util.SqlSugar;
using log4net.Config; using log4net.Config;
using Microsoft.Practices.ObjectBuilder2; using Microsoft.Practices.ObjectBuilder2;
using Newtonsoft.Json; using Newtonsoft.Json;
using Org.BouncyCastle.Bcpg.OpenPgp; using Org.BouncyCastle.Bcpg.OpenPgp;
using Pipelines.Sockets.Unofficial.Arenas; using Pipelines.Sockets.Unofficial.Arenas;
using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data.Entity.Infrastructure;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Web.Http; using System.Web.Http;
@ -41,7 +46,49 @@ namespace Learun.Application.Web.AppApi
/// <summary>
/// 找到某一个预分配箱子 附近的某一个箱子
/// <param name="frameLists"/>
/// <param name="allPanel"/>
/// <param name="IOTypeOnCable">Digital,4-20mA,10v,pt100,pulse</param>
/// <param name="PreAssignPanelID"/>
/// </summary>
private ec_PanelEntity FindPanelNearby(List<FrameBll.FrameList> frameLists, List<ec_PanelEntity> allPanel, List<ec_enginedata_propertyEntity> allPanelProps
, string IOTypeOnCable)
{
//当前预分配的箱子的位置
var AssignPanelX = allPanelProps.FirstOrDefault(x => x.PropertyName == GlobalObject.propName_Frame)?.PropertyValue;
AssignPanelX = AssignPanelX.Split(new string[] { GlobalObject.enum_separator }, StringSplitOptions.None)[0];//插件端对于下拉列表 都是 name || nameEN
var AssignPanelXValue = frameLists.FirstOrDefault(X => X.Num == AssignPanelX)?.Value;
if (AssignPanelXValue < 400)//null也没事
{
// 小于400我几乎可以认为此时肋位号用的是m这个单位。因为如果用的是mm400mm的肋位号似乎也太小了。
AssignPanelXValue = 1000 * AssignPanelXValue; // 转成mm
}
var AssignPanelXOff = allPanelProps.FirstOrDefault(x => x.PropertyName == GlobalObject.propName_FrameOff)?.PropertyValue;
var AssignPanelY = allPanelProps.FirstOrDefault(x => x.PropertyName == GlobalObject.propName_YOff)?.PropertyValue;
foreach (var panel in allPanel)
{
//拿到每一个的xy属性
//然后和预分配箱子进行对比
//这也太耗时了把
}
//然后排序一次
//根据电缆上的信号,去找匹配的排序第一位(已经按照距离排序过)的箱子
switch (IOTypeOnCable.ToUpper())
{
case "DIGITAL":
//其他就近箱子的 allowIOTypes里有DI DO
break;
default:
break;
}
return null;
}
/// <summary> /// <summary>
/// IO分配主界面查询查询所有的位置 - 采集箱 - 模块 - 通道 /// IO分配主界面查询查询所有的位置 - 采集箱 - 模块 - 通道
@ -104,7 +151,7 @@ namespace Learun.Application.Web.AppApi
nodeCatalogue.NodeExtData = Loc; nodeCatalogue.NodeExtData = Loc;
treeList.Add(nodeCatalogue); treeList.Add(nodeCatalogue);
var listPanel = Panels.Where(x => x.Panel_Loc_ID == Loc.DataItemDetailID && x.systempanel == specialType..ToString()).ToList(); var listPanel = Panels.Where(x => x.Panel_Loc_ID == Loc.DataItemDetailID && x.systempanel == GlobalEnum.specialType..ToString()).ToList();
if (listPanel != null && listPanel.Count > 0) if (listPanel != null && listPanel.Count > 0)
{ {
foreach (var Panel in listPanel) foreach (var Panel in listPanel)
@ -234,6 +281,158 @@ namespace Learun.Application.Web.AppApi
return Success(res); return Success(res);
} }
}
/// <summary>
/// 自动分配通道(点表信号自动分配)。
///
/// </summary>
/// <param name="projId"></param>
/// <param name="AcceptNearbyPanel"></param>
/// <param name="CableIds">需要分配的电缆cableid,不是enginedataId逗号分开</param>
/// <returns></returns>
[HttpPost]
public IHttpActionResult AutoAssignCable2Channel_step1(string projId, bool AcceptNearbyPanel, [FromBody] List<string> CableIds)
{
#region
var frameBll = new FrameBll();
var allFrames = frameBll.GetFrameList(projId);
var cbll = new ec_CableBLL();
var panelTable = ProjectSugar.TableName<ec_PanelEntity>(projId);
var stripTable = ProjectSugar.TableName<ec_PanelStripEntity>(projId);
var tagTable = ProjectSugar.TableName<ec_enginedataEntity>(projId);
var propTable = ProjectSugar.TableName<ec_enginedata_propertyEntity>(projId);
var typeTable = ProjectSugar.TableName<ec_objecttypeEntity>(projId);
#endregion
#region
if (CableIds == null || CableIds.Count == 0)
{
return Success("OK");
}
var cablesNeedAssigned = cbll.GetCablesPreAssign(projId, CableIds, true);
cablesNeedAssigned = cablesNeedAssigned.Where(x => CableIds.Contains(x.CableID)).ToList();
#endregion
//涉及到哪些箱子
var allPanel = SqlSugarHelper.Db.Queryable<ec_PanelEntity>().AS(panelTable).
InnerJoin<ec_enginedataEntity>((a, b) => a.EngineerDataID == b.EngineDataID).AS<ec_enginedataEntity>(tagTable).
InnerJoin<ec_objecttypeEntity>((a, b, c) => b.ObjectTypeID == c.ObjectTypeID).AS<ec_objecttypeEntity>(typeTable).
Where((a, b, c) => c.specialType == GlobalEnum.specialType.).
ToList();//这里要过滤一下根据object type里的specialType而不是所有的panel
var allPanelProp = SqlSugarHelper.Db.Queryable<ec_enginedata_propertyEntity>().AS(propTable)
.Where(x => allPanel.Select(xx => xx.EngineerDataID).Contains(x.EngineDataID))
.ToList().GroupBy(x => x.EngineDataID).ToDictionary(x => x.Key, x => x.ToList());
var panelsNeed = allPanel.Where(x => cablesNeedAssigned.Select(xx => xx.PanelID).Contains(x.PanelID)).ToList();//用户指定的预分配的箱子
var stripsNeed = SqlSugarHelper.Db.Queryable<ec_PanelStripEntity>().AS(stripTable).
Where(x => panelsNeed.Select(xx => xx.PanelID).Contains(x.PanelID)).
ToList();
#region 1.1()
var cablesNotMatchIO = cablesNeedAssigned.Where(x => x.IOTypesNotMatchedList.Count > 0).ToList(); // GetCablesPreAssign 查询时已经处理过io是否匹配了
if (cablesNotMatchIO != null && cablesNotMatchIO.Count > 0)
{
if (AcceptNearbyPanel)//允许进行
{
//有不匹配的,但是用户允许继续
//在之后的自动分配过程中会自动寻找匹配的采集箱原则上从就近的开始找如果没有匹配的采集箱则提示“未找到具有XX类型的采集箱请新增后再次分配是否取消自动分配进程
bool nearbyFound = false;
foreach (var cable in cablesNotMatchIO)
{
var nearPanel = FindPanelNearby(allFrames, allPanel, allPanelProp[cable.ToPanel.EngineerDataID], cable.PreAssignIOType);
if (nearPanel == null)
{
nearbyFound = false;
return Fail($"在附近未找到具有{cable.PreAssignIOType}类型的采集箱,请新增后再次分配,是否取消自动分配进程?");
}
else
{
nearbyFound = true;
}
}
}
else
{
//不继续自动分配,中断进程,等添加完正确的模块后再继续自动分配
var cableNamesNotMatched = string.Join(",", cablesNotMatchIO.Select(x => x.TagNumber).ToList());
var panelIOMissing = new List<string>();
foreach (ec_CableEntity cableNotMatchIO in cablesNotMatchIO)
{
panelIOMissing.Add(cableNotMatchIO.PanelID + "缺失IO: " + string.Join(",", cableNotMatchIO.IOTypesNotMatchedList));
}
return Fail($"预分配结果中,以下电缆【{cableNamesNotMatched}】的IO类型和其预分配采集箱的IO类型无法匹配。等添加完正确的模块后再继续自动分配。\r\n" +
$"需要添加的正确模块有:{string.Join(",", panelIOMissing)}");
}
}
else
{
//没有不匹配的,可以继续进行
}
//必要的数据存入redis以便后续步骤使用
ICache redisObj = CacheFactory.CaChe();
redisObj.Remove("IOModule_AutoAssign2Ch_" + projId, CacheId.IOModule_AutoAssign2Ch);
redisObj.Write<List<ec_CableEntity>>("IOModule_AutoAssign2Ch_" + projId, cablesNeedAssigned, CacheId.IOModule_AutoAssign2Ch);
return Success("OK");
#endregion
}
/// <summary>
///
/// </summary>
/// <param name="projId"></param>
/// <returns></returns>
public IHttpActionResult AutoAssignCable2Channel_step2(string projId)
{
ICache redisObj = CacheFactory.CaChe();
var cablesNeedAssigned = redisObj.Read<List<ec_CableEntity>>("IOModule_AutoAssign2Ch_" + projId, CacheId.IOModule_AutoAssign2Ch);
//#region 1.2
#region 1.2.2
cablesNeedAssigned = cablesNeedAssigned.OrderBy(x => new { x.PanelID, x.PreAssignIOType, x.System }).ToList();
//var curPanel = new ec_PanelEntity();
//curPanel = panelsNeed.FirstOrDefault(x => x.PanelID == cablesNeedAssigned[0].PanelID);//先定位到第一个电缆所在的箱子
//curPanel.strips = stripsNeed.Where(x => x.PanelID == curPanel.PanelID).ToList();
//var curStrip = new ec_PanelStripEntity();
#endregion
//for (var i = 0; i < cablesNeedAssigned.Count; i++)
//{
// #region 是否有端子排 1.2.1
// if (curPanel.PanelID != cablesNeedAssigned[i].PanelID)
// {
// curPanel = panelsNeed.FirstOrDefault(x => x.PanelID == cablesNeedAssigned[0].PanelID);//切换箱子
// curPanel.strips = stripsNeed.Where(x => x.PanelID == curPanel.PanelID).ToList();
// }
// foreach (var set in cablesNeedAssigned[i].Sets)
// {
// var availableStrips = curPanel.strips.Where(x => x.IO_TYPE.ToUpper() == set.IOType.ToString().ToUpper()).ToList();
// if (availableStrips != null && availableStrips.Count > 0)
// {
// //已经存在端子排
// }
// else
// {
// //没有端子排根据信号数里自动新建端子排通道数里根据端子io模板的默认值获得
// //
// }
// }
// //可能要换一下循环主体评估下是按照cable循环好还是按strip循环好
// #endregion
//}
//#endregion
return Success("自动关联完成");
} }
/// <summary> /// <summary>
/// 把电缆分配到空余的模块的通道上。 /// 把电缆分配到空余的模块的通道上。
@ -256,48 +455,10 @@ namespace Learun.Application.Web.AppApi
[HttpGet] [HttpGet]
public IHttpActionResult GetCablePreAssignPreview(string projId) public IHttpActionResult GetCablePreAssignPreview(string projId)
{ {
var table = ProjectSugar.TableName<ec_CableEntity>(projId); var bll = new ec_CableBLL();
var tagTable = ProjectSugar.TableName<ec_enginedataEntity>(projId); var res = bll.GetCablesPreAssign(projId, null);
var panelTable = ProjectSugar.TableName<ec_PanelEntity>(projId);
var setServ = new ec_CableSetService();
var wireServ = new ec_CableSetWireService();
var preAssignedCables = SqlSugarHelper.Db.Queryable<ec_CableEntity>().AS(table).Where(x => !string.IsNullOrEmpty(x.PanelID)).ToList();
var tags = SqlSugarHelper.Db.Queryable<ec_enginedataEntity>().AS(tagTable).
Where(x => preAssignedCables.Select(xx => xx.EngineerDataID).Contains(x.EngineDataID)).ToList();
var panels = SqlSugarHelper.Db.Queryable<ec_PanelEntity>().AS(panelTable). return Success(res);
Where(x => preAssignedCables.Select(xx => xx.PanelID).Contains(x.PanelID)).ToList();
var panelTags = SqlSugarHelper.Db.Queryable<ec_enginedataEntity>().AS(tagTable).
Where(x => panels.Select(xx => xx.EngineerDataID).Contains(x.EngineDataID)).ToList();
foreach (var cable in preAssignedCables)
{
var sets = setServ.GetList(projId, cable.CableID);
var Wires = wireServ.GetList(projId, cable.CableID, "");
//剩下的感觉都可以是set上的参数
foreach (var set in sets)
{
var wires = Wires.Where(x => x.CableSetID == set.CableSetID);
set.Wires = wires.ToList();
}
cable.Sets = sets;
cable.TagNumber = tags.FirstOrDefault(x => x.EngineDataID == cable.EngineerDataID)?.TagNumber;
var panelObj = panels.FirstOrDefault(x => x.PanelID == cable.PanelID);
if (panelObj != null)
{
panelObj.TagNumber = panelTags.FirstOrDefault(x => x.EngineDataID == panelObj.EngineerDataID)?.TagNumber;
}
cable.ToPanel = panelObj;
}
//分组
preAssignedCables = preAssignedCables.OrderBy(x => x.PreAssignIOType).ToList();
return Success(preAssignedCables);
} }

View File

@ -373,7 +373,7 @@ namespace Learun.Application.Web.AppApi
/// </summary> /// </summary>
/// <param name="projectId">项目ID</param> /// <param name="projectId">项目ID</param>
/// <param name="drawingFileID">图纸文件ID</param> /// <param name="drawingFileID">图纸文件ID</param>
/// <param name="pixelCodes">图元编号集合(用,连接)</param> /// <param name="pixelCodes">图元编号集合(用,连接)。正常就1个</param>
/// <param name="caseID">工况ID</param> /// <param name="caseID">工况ID</param>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
@ -548,11 +548,11 @@ namespace Learun.Application.Web.AppApi
foreach (ec_enginedata_propertyEntity TagProp in tag.EngineDataProperty) foreach (ec_enginedata_propertyEntity TagProp in tag.EngineDataProperty)
{ {
if (TagProp.PropertyName == "起始设备") if (TagProp.PropertyName == GlobalObject.propName_From)
{ {
TagProp.PropertyValue = CableConn.End1Tag; TagProp.PropertyValue = CableConn.End1Tag;
} }
else if (TagProp.PropertyName == "终止设备") else if (TagProp.PropertyName == GlobalObject.propName_To)
{ {
TagProp.PropertyValue = CableConn.End2Tag; TagProp.PropertyValue = CableConn.End2Tag;
} }
@ -591,79 +591,97 @@ namespace Learun.Application.Web.AppApi
var propTbName = ProjectSugar.TableName<ec_enginedata_propertyEntity>(projectId); var propTbName = ProjectSugar.TableName<ec_enginedata_propertyEntity>(projectId);
var allUser = SqlSugarHelper.Db.Queryable<UserEntity>().ToList(); var allUser = SqlSugarHelper.Db.Queryable<UserEntity>().ToList();
var userDict = allUser.ToDictionary(x => x.F_UserId, x => x.F_RealName);
var pixelAll = SqlSugarHelper.Db.Queryable<ec_enginedata_pixelEntity>().AS(pixelTbName).Where(x => x.DrawingFileID == drawingFileID && x.DeleteFlg != 1).ToList(); var pixelAll = SqlSugarHelper.Db.Queryable<ec_enginedata_pixelEntity>().AS(pixelTbName).Where(x => x.DrawingFileID == drawingFileID && x.DeleteFlg != 1).ToList();
var pixelDictByTag = pixelAll.GroupBy(x => x.EngineDataID).ToDictionary(x => x.Key, x => x.ToList());
var pixelObjs = pixelAll.Where(x => pixelCodes.Split(',').ToList().Contains(x.PixelCode)).ToList(); var pixelObjs = pixelAll.Where(x => pixelCodes.Split(',').ToList().Contains(x.PixelCode)).ToList();
var tagIds = pixelObjs.Select(x => x.EngineDataID).Distinct().ToList(); var tagIds = pixelObjs.Select(x => x.EngineDataID).Distinct().ToList();
var tagAll = SqlSugarHelper.Db.Queryable<ec_enginedataEntity>().AS(tagTbName).OrderBy(x => x.TagNumber).ToList(); var tagAll = SqlSugarHelper.Db.Queryable<ec_enginedataEntity>().AS(tagTbName).OrderBy(x => x.TagNumber).ToList();
// 提前分组按ObjectTypeID分组并为每个组预生成字典仅执行一次O(m)时间)
var preGrouped = tagAll
.GroupBy(tag => tag.ObjectTypeID)
.ToDictionary(
group => group.Key, // 键ObjectTypeID
group => group.ToDictionary( // 值该组内的EngineDataID→TagNumber字典
item => item.EngineDataID,
item => item.TagNumber
)
);
var tagObjs = tagAll.Where(x => tagIds.Contains(x.EngineDataID)).ToList(); var tagObjs = tagAll.Where(x => tagIds.Contains(x.EngineDataID)).ToList();
var tagDictByType = tagObjs.GroupBy(x => x.ObjectTypeID).ToDictionary(x => x.Key, x => x.ToList());
var typeIds = tagObjs.Select(x => x.ObjectTypeID).Distinct().ToList(); var typeIds = tagObjs.Select(x => x.ObjectTypeID).Distinct().ToList();
var typeAll = SqlSugarHelper.Db.Queryable<ec_objecttypeEntity>().AS(typeTbName).ToList(); var typeAll = SqlSugarHelper.Db.Queryable<ec_objecttypeEntity>().AS(typeTbName).ToList();
var typeObjs = typeAll.Where(x => typeIds.Contains(x.ObjectTypeID)).ToList(); var typeObjs = typeAll.Where(x => typeIds.Contains(x.ObjectTypeID)).ToList();
var tagPropAll = SqlSugarHelper.Db.Queryable<ec_enginedata_propertyEntity>().AS(propTbName).Where(x => tagIds.Contains(x.EngineDataID)).ToList(); var tagPropAll = SqlSugarHelper.Db.Queryable<ec_enginedata_propertyEntity>().AS(propTbName).Where(x => tagIds.Contains(x.EngineDataID)).ToList();
var tagPropDictByTag = tagPropAll.GroupBy(x => x.EngineDataID).ToDictionary(x => x.Key, x => x.ToList());
//所有类别的属性信息 //所有类别的属性信息
var objectTypeProps2 = objectTypePBll.GetObjectTypePById(string.Join(",", typeIds), projectId, true);//最频繁的那个接口 var objectTypeProps2 = objectTypePBll.GetObjectTypePById(string.Join(",", typeIds), projectId, true);//最频繁的那个接口
var typePropDictByType = objectTypeProps2.GroupBy(x => x.ObjectTypeID).ToDictionary(g => g.Key, g => g.ToList());
try try
{ {
foreach (var objectType in typeObjs) foreach (var objectType in typeObjs)
{ {
//该类型下的属性信息 //该类型下的属性信息
objectType.props = objectTypeProps2.Where(x => x.ObjectTypeID == objectType.ObjectTypeID).ToList(); objectType.props = typePropDictByType[objectType.ObjectTypeID];// objectTypeProps2.Where(x => x.ObjectTypeID == objectType.ObjectTypeID).ToList();
//该类型下的位号基础信息 //该类型下的位号基础信息
objectType.tags = tagObjs.Where(x => x.ObjectTypeID == objectType.ObjectTypeID).ToList(); objectType.tags = tagDictByType[objectType.ObjectTypeID]; // tagObjs.Where(x => x.ObjectTypeID == objectType.ObjectTypeID).ToList();
foreach (var item in objectType.tags)
{
item.CreateUserName = allUser.FirstOrDefault(x => x.F_UserId == item.CreateUserID)?.F_RealName;
}
//每个位号的属性信息 //每个位号的属性信息
foreach (var tag in objectType.tags) foreach (var tag in objectType.tags)
{ {
if (string.IsNullOrEmpty(tag.CreateUserID))
{
tag.CreateUserName = string.Empty;
}
else
{
tag.CreateUserName = userDict[tag.CreateUserID];// allUser.FirstOrDefault(x => x.F_UserId == item.CreateUserID)?.F_RealName;
}
tag.EngineDataID = tag.EngineDataID; tag.EngineDataProperty = tagPropDictByTag[tag.EngineDataID];// tagPropAll.Where(x => x.EngineDataID == tag.EngineDataID).ToList();
tag.EngineDataProperty = tagPropAll.Where(x => x.EngineDataID == tag.EngineDataID).ToList();
tag.ObjectTypeName = objectType.ObjectTypeName; tag.ObjectTypeName = objectType.ObjectTypeName;
if (objectType.ObjectTypeName.EndsWith("电缆")) if (objectType.ObjectTypeName.EndsWith("电缆"))
{ {
//电缆from to //电缆from to
var CableConn = relBll.GetCableConn(tag.EngineDataID, projectId); var CableConn = relBll.GetCableConn(tag.EngineDataID, projectId);//此时就根据rel里的id拿到了新的tagNumber
if (!tag.EngineDataProperty.Any(X => X.PropertyName == "起始设备")) if (!tag.EngineDataProperty.Any(X => X.PropertyName == GlobalObject.propName_From))
{ {
var newProp = new ec_enginedata_propertyEntity() var newProp = new ec_enginedata_propertyEntity()
{ {
EngineDataID = tag.EngineDataID, EngineDataID = tag.EngineDataID,
PropertyName = "起始设备", PropertyName = GlobalObject.propName_From,
//CaseID = string.IsNullOrEmpty(caseID) ? tag.CaseID : caseID, //CaseID = string.IsNullOrEmpty(caseID) ? tag.CaseID : caseID,
}; };
newProp.Create(); newProp.Create();
ec_enginedata_propertyBLL.InsertTagProp(projectId, tag.EngineDataID, newProp); ec_enginedata_propertyBLL.InsertTagProp(projectId, tag.EngineDataID, newProp);//增加 起始设备
tag.EngineDataProperty.Add(newProp); tag.EngineDataProperty.Add(newProp);
} }
if (!tag.EngineDataProperty.Any(X => X.PropertyName == "终止设备")) if (!tag.EngineDataProperty.Any(X => X.PropertyName == GlobalObject.propName_To))
{ {
var newProp = new ec_enginedata_propertyEntity() var newProp = new ec_enginedata_propertyEntity()
{ {
EngineDataID = tag.EngineDataID, EngineDataID = tag.EngineDataID,
PropertyName = "终止设备", PropertyName = GlobalObject.propName_To,
//CaseID = string.IsNullOrEmpty(caseID) ? tag.CaseID : caseID, //CaseID = string.IsNullOrEmpty(caseID) ? tag.CaseID : caseID,
}; };
newProp.Create(); newProp.Create();
ec_enginedata_propertyBLL.InsertTagProp(projectId, tag.EngineDataID, newProp); ec_enginedata_propertyBLL.InsertTagProp(projectId, tag.EngineDataID, newProp);////增加 终止设备
tag.EngineDataProperty.Add(newProp); tag.EngineDataProperty.Add(newProp);
} }
var TagProp = tag.EngineDataProperty.FirstOrDefault(X => X.PropertyName == "起始设备"); var TagProp = tag.EngineDataProperty.FirstOrDefault(X => X.PropertyName == GlobalObject.propName_From);
if (TagProp != null) if (TagProp != null)
{ {
TagProp.PropertyValue = CableConn.End1Tag; TagProp.PropertyValue = CableConn.End1Tag;
} }
TagProp = null; TagProp = null;
TagProp = tag.EngineDataProperty.FirstOrDefault(X => X.PropertyName == "终止设备"); TagProp = tag.EngineDataProperty.FirstOrDefault(X => X.PropertyName == GlobalObject.propName_To);
if (TagProp != null) if (TagProp != null)
{ {
TagProp.PropertyValue = CableConn.End2Tag; TagProp.PropertyValue = CableConn.End2Tag;
@ -671,10 +689,10 @@ namespace Learun.Application.Web.AppApi
} }
//查一下每个位号的图元信息 //查一下每个位号的图元信息
tag.EngineDataPixel = pixelAll.Where(x => x.EngineDataID == tag.EngineDataID).ToList(); tag.EngineDataPixel = pixelDictByTag[tag.EngineDataID];// pixelAll.Where(x => x.EngineDataID == tag.EngineDataID).ToList();
} }
//taglist //taglist
objectType.tagsListDropDown = tagAll.Where(X => X.ObjectTypeID == objectType.ObjectTypeID).ToDictionary(x => x.EngineDataID, x => x.TagNumber); objectType.tagsListDropDown = preGrouped[objectType.ObjectTypeID]; //tagAll.Where(X => X.ObjectTypeID == objectType.ObjectTypeID).ToDictionary(x => x.EngineDataID, x => x.TagNumber);
//该类型下的流水 //该类型下的流水
if (objectType.IsSerialNumber == 1) if (objectType.IsSerialNumber == 1)
@ -775,12 +793,12 @@ namespace Learun.Application.Web.AppApi
tag.EngineDataProperty = engineDataProps.Where(x => x.EngineDataID == tag.EngineDataID).ToList(); tag.EngineDataProperty = engineDataProps.Where(x => x.EngineDataID == tag.EngineDataID).ToList();
//BUG 1483 //BUG 1483
if (!tag.EngineDataProperty.Any(X => X.PropertyName == "起始设备")) if (!tag.EngineDataProperty.Any(X => X.PropertyName == GlobalObject.propName_From))
{ {
var newProp = new ec_enginedata_propertyEntity() var newProp = new ec_enginedata_propertyEntity()
{ {
EngineDataID = tag.EngineDataID, EngineDataID = tag.EngineDataID,
PropertyName = "起始设备", PropertyName = GlobalObject.propName_From,
//CaseID = string.IsNullOrEmpty(caseID) ? tag.CaseID : caseID, //CaseID = string.IsNullOrEmpty(caseID) ? tag.CaseID : caseID,
}; };
newProp.Create(); newProp.Create();
@ -788,12 +806,12 @@ namespace Learun.Application.Web.AppApi
ec_enginedata_propertyIBLL.InsertTagProp(projectId, tag.EngineDataID, newProp); ec_enginedata_propertyIBLL.InsertTagProp(projectId, tag.EngineDataID, newProp);
tag.EngineDataProperty.Add(newProp); tag.EngineDataProperty.Add(newProp);
} }
if (!tag.EngineDataProperty.Any(X => X.PropertyName == "终止设备")) if (!tag.EngineDataProperty.Any(X => X.PropertyName == GlobalObject.propName_To))
{ {
var newProp = new ec_enginedata_propertyEntity() var newProp = new ec_enginedata_propertyEntity()
{ {
EngineDataID = tag.EngineDataID, EngineDataID = tag.EngineDataID,
PropertyName = "终止设备", PropertyName = GlobalObject.propName_To,
//CaseID = string.IsNullOrEmpty(caseID) ? tag.CaseID : caseID, //CaseID = string.IsNullOrEmpty(caseID) ? tag.CaseID : caseID,
}; };
newProp.Create(); newProp.Create();
@ -804,11 +822,11 @@ namespace Learun.Application.Web.AppApi
foreach (ec_enginedata_propertyEntity TagProp in tag.EngineDataProperty) foreach (ec_enginedata_propertyEntity TagProp in tag.EngineDataProperty)
{ {
if (TagProp.PropertyName == "起始设备") if (TagProp.PropertyName == GlobalObject.propName_From)
{ {
TagProp.PropertyValue = CableConn.End1Tag; TagProp.PropertyValue = CableConn.End1Tag;
} }
else if (TagProp.PropertyName == "终止设备") else if (TagProp.PropertyName == GlobalObject.propName_To)
{ {
TagProp.PropertyValue = CableConn.End2Tag; TagProp.PropertyValue = CableConn.End2Tag;
} }
@ -921,7 +939,7 @@ namespace Learun.Application.Web.AppApi
foreach (var DuplicatePixelData in data) foreach (var DuplicatePixelData in data)
{ {
//先根据老的图例找出工程ID //先根据老的图例找出工程ID
var EngineDataIDs = pixelServ.GetList("{\"ProjectId\":\"" + ProjectId + "\",\"PixelCode\":\"" + DuplicatePixelData.oldPixelCode + "\",\"DrawingFileID\":\"" + oldDrawingID + "\"}"). var EngineDataIDs = pixelServ.GetList("{\"ProjectId\":\"" + ProjectId + "\",\"PixelCode\":\"" + DuplicatePixelData.oldPixelCode + "\",\"DrawingFileID\":\"" + oldDrawingID + "\"}", ProjectId).
Where(x => x.EngineDataID != ""). Where(x => x.EngineDataID != "").
Select(x => x.EngineDataID).Distinct(); Select(x => x.EngineDataID).Distinct();
if (EngineDataIDs == null) if (EngineDataIDs == null)

View File

@ -1,4 +1,5 @@
using Learun.Application.TwoDevelopment.ZZDT_EC; using Learun.Application.TwoDevelopment.ZZDT_EC;
using Learun.Application.TwoDevelopment.ZZDT_EC.Frame;
using Learun.Util; using Learun.Util;
using Learun.Util.SqlSugar; using Learun.Util.SqlSugar;
using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.Functions;
@ -54,37 +55,13 @@ namespace Learun.Application.Web.AppApi
return Fail("找不到基点这个对象类型。"); return Fail("找不到基点这个对象类型。");
} }
#region frame #region frame
List<FrameList> frameLists = new List<FrameList>(); var frameBll = new FrameBll();
frameLists.Add(new FrameList() var frameLists = frameBll.GetFrameList(ProjectId);
{ Num = "", Value = 0 }); if (frameLists == null)
var settings = new ec_projectSettingsBLL();
var ec_dataitemBLL = new ec_dataitemBLL();
var FrameListFlg = settings.GetEntity(GlobalObject.projSetting_enumlist_Frame, ProjectId);
if (FrameListFlg != null)
{ {
return Fail("项目数据字典中,没有找到【肋位号】的下拉项中。");// 或者 无法从数据字典中找到对应的那个下拉
var FrameDetail = ec_dataitemBLL.GetDetailList(FrameListFlg.SettingValue, "", ProjectId, false);
if (FrameDetail == null)
{
return Fail("项目数据字典中,没有找到【肋位号】的下拉项中。");// 或者 无法从数据字典中找到对应的那个下拉
}
foreach (var item in FrameDetail)
{
double value;
if (double.TryParse(item.DataItemCode, out value))
{
frameLists.Add(new FrameList() { Num = item.DataItemName, Value = value });
}
}
frameLists = frameLists.OrderBy(t => t.Value).ToList();
}
else
{
return Fail("项目设置中projectSettings表没有找到【肋位号】的设置项。");// 或者 无法从数据字典中找到对应的那个下拉
} }
#endregion #endregion
var pointsOnDwg = SqlSugarHelper.Db.Queryable<ec_enginedata_pixelEntity>().AS(pixelTbName). var pointsOnDwg = SqlSugarHelper.Db.Queryable<ec_enginedata_pixelEntity>().AS(pixelTbName).
@ -148,9 +125,23 @@ namespace Learun.Application.Web.AppApi
} }
//这里要考虑下拉列表 带 ||的问题 //这里要考虑下拉列表 带 ||的问题
var matchedTagIds = propAll.Where(x => x.PropertyName == keyProp List<string> matchedTagIds = new List<string>();
&& (x.PropertyValue == keyValue || x.PropertyValue.StartsWith(keyValue + GlobalObject.enum_separator))). if (keyProp == GlobalObject.propName_System)
Select(X => X.EngineDataID).Distinct().ToList(); {
//#task 9536
// 筛选出所有以 "a||" 或 "b||" 开头的元素
var validSystems = keyValue.Split().ToList();
matchedTagIds = propAll.Where(item =>
validSystems.Any(prefix => item.PropertyValue == prefix) || validSystems.Any(prefix => item.PropertyValue.StartsWith(prefix + GlobalObject.enum_separator))
).Select(X => X.EngineDataID).Distinct().ToList();
}
else
{
matchedTagIds = propAll.Where(x => x.PropertyName == keyProp
&& (x.PropertyValue == keyValue || x.PropertyValue.StartsWith(keyValue + GlobalObject.enum_separator))).
Select(X => X.EngineDataID).Distinct().ToList();
}
//有效范围的设备 //有效范围的设备
var matchedTags = SqlSugarHelper.Db.Queryable<ec_enginedataEntity>().AS(tagTbName). var matchedTags = SqlSugarHelper.Db.Queryable<ec_enginedataEntity>().AS(tagTbName).
@ -167,9 +158,9 @@ namespace Learun.Application.Web.AppApi
#region #region
//甲板 区域都和基点一致的设备 //甲板 区域都和基点一致的设备
var DeckMatchedTagIds = EquipPropAll.Where(x => x.PropertyName == "甲板号" && x.PropertyValue == basePoint.deck).Select(X => X.EngineDataID).ToList(); var DeckMatchedTagIds = EquipPropAll.Where(x => x.PropertyName == "甲板号" && x.PropertyValue == basePoint.deck).Select(X => X.EngineDataID).ToList();
var AreaMatchedTagIds = EquipPropAll.Where(x => x.PropertyName == "区域" && x.PropertyValue == basePoint.area).Select(X => X.EngineDataID).ToList(); //var AreaMatchedTagIds = EquipPropAll.Where(x => x.PropertyName == "区域" && x.PropertyValue == basePoint.area).Select(X => X.EngineDataID).ToList();
//#task 9542
var matchPointTagIds = DeckMatchedTagIds.Intersect(AreaMatchedTagIds).ToList(); var matchPointTagIds = DeckMatchedTagIds;//.Intersect(AreaMatchedTagIds).ToList();
foreach (var matchPointTagId in matchPointTagIds) foreach (var matchPointTagId in matchPointTagIds)
{ {
@ -361,40 +352,21 @@ namespace Learun.Application.Web.AppApi
[HttpGet] [HttpGet]
public IHttpActionResult GetFrameList(string ProjectId) public IHttpActionResult GetFrameList(string ProjectId)
{ {
var ec_dataitemBLL = new ec_dataitemBLL(); var bll = new FrameBll();
var settings = new ec_projectSettingsBLL(); var res = bll.GetFrameList(ProjectId);
if (res == null)
var FrameListFlg = settings.GetEntity(GlobalObject.projSetting_enumlist_Frame, ProjectId);
if (FrameListFlg != null)
{ {
List<FrameList> frameLists = new List<FrameList>(); return Fail("项目设置中projectSettings表没有找到【肋位号】的设置项中对应的那个下拉。");// 或者 无法从数据字典中找到对应的那个下拉
var res = ec_dataitemBLL.GetDetailList(FrameListFlg.SettingValue, "", ProjectId, false);
if (res == null)
{
return Fail("项目设置中projectSettings表没有找到【肋位号】的设置项中对应的那个下拉。");// 或者 无法从数据字典中找到对应的那个下拉
}
foreach (var item in res)
{
double value;
if (double.TryParse(item.DataItemCode, out value))
{
frameLists.Add(new FrameList() { Num = item.DataItemName, Value = value });
}
}
frameLists = frameLists.OrderBy(t => t.Value).ToList();
return Success(frameLists);
} }
else else
{ {
return Fail("项目设置中projectSettings表没有找到【肋位号】的设置项。");// 或者 无法从数据字典中找到对应的那个下拉 return Success(res);
} }
} }
/// <summary> /// <summary>
/// 根据ObjectTypeID查绘制布置图时的图例 /// 根据ObjectTypeID查绘制布置图时的图例
/// </summary> /// </summary>
@ -467,20 +439,6 @@ namespace Learun.Application.Web.AppApi
} }
/// <summary>
/// 肋位号
/// </summary>
public class FrameList
{
/// <summary>
/// 号
/// </summary>
public string Num { get; set; }
/// <summary>
/// 值。单位是m
/// </summary>
public double Value { get; set; }
}
} }

View File

@ -77,7 +77,7 @@ namespace Learun.Application.Web.AppApi
relData.RelEngineData2ID relData.RelEngineData2ID
}; };
} }
ec_relDataBLL.SaveEntitys(ProjectId, relData.RelTypeID, relData.RelEngineData1ID, relData.End2IDs); ec_relDataBLL.SaveEntitys(ProjectId, relData.RelTypeID, relData.RelEngineData1ID, relData.End2IDs,relData.OPCPixel);
} }
@ -214,7 +214,7 @@ namespace Learun.Application.Web.AppApi
//根据句柄和图纸先把工程id查出来先 //根据句柄和图纸先把工程id查出来先
var drawingID = CablePixelID.DrawingID; var drawingID = CablePixelID.DrawingID;
var pixelID = CablePixelID.CablePixelID; var pixelID = CablePixelID.CablePixelID;
var EngineDataIDs = pixelServ.GetList("{\"ProjectId\":\"" + ProjectId + "\",\"PixelCode\":\"" + pixelID + "\",\"DrawingFileID\":\"" + drawingID + "\"}").Distinct(); var EngineDataIDs = pixelServ.GetList("{\"ProjectId\":\"" + ProjectId + "\",\"PixelCode\":\"" + pixelID + "\",\"DrawingFileID\":\"" + drawingID + "\"}", ProjectId).Distinct();
if (EngineDataIDs != null && EngineDataIDs.Count() == 1) if (EngineDataIDs != null && EngineDataIDs.Count() == 1)
{ {
var engineDataPixel = EngineDataIDs.First(); var engineDataPixel = EngineDataIDs.First();
@ -487,7 +487,7 @@ namespace Learun.Application.Web.AppApi
} }
} }
relDataCol = relDataColNotOPC; relDataCol = relDataColNotOPC;
} }
else else
@ -509,9 +509,9 @@ namespace Learun.Application.Web.AppApi
} }
//根据句柄和图纸先把工程id查出来先 //根据句柄和图纸先把工程id查出来先
//获取工程数据图元数据 //获取工程数据图元数据
var EngineDataIDs = pixelServ.GetList("{\"ProjectId\":\"" + ProjectId + "\",\"PixelCode\":\"" + relData.TagPixelID + "\",\"DrawingFileID\":\"" + relData.DrawingID + "\"}"). var EngineDataIDs = pixelServ.GetList("{\"ProjectId\":\"" + ProjectId + "\",\"PixelCode\":\"" + relData.TagPixelID + "\",\"DrawingFileID\":\"" + relData.DrawingID + "\"}", ProjectId).
Select(x => x.EngineDataID).Distinct(); Select(x => x.EngineDataID).Distinct();
var CableIDs = pixelServ.GetList("{\"ProjectId\":\"" + ProjectId + "\",\"PixelCode\":\"" + relData.CablePixelID + "\",\"DrawingFileID\":\"" + relData.DrawingID + "\"}"). var CableIDs = pixelServ.GetList("{\"ProjectId\":\"" + ProjectId + "\",\"PixelCode\":\"" + relData.CablePixelID + "\",\"DrawingFileID\":\"" + relData.DrawingID + "\"}", ProjectId).
Select(x => x.EngineDataID).Distinct(); Select(x => x.EngineDataID).Distinct();
if (EngineDataIDs != null && EngineDataIDs.Count() == 1 && CableIDs != null && CableIDs.Count() == 1) if (EngineDataIDs != null && EngineDataIDs.Count() == 1 && CableIDs != null && CableIDs.Count() == 1)
{ {
@ -536,9 +536,9 @@ namespace Learun.Application.Web.AppApi
{ {
//根据句柄和图纸先把工程id查出来先 //根据句柄和图纸先把工程id查出来先
//获取工程数据图元数据 //获取工程数据图元数据
var EngineDataIDs = pixelServ.GetList("{\"ProjectId\":\"" + ProjectId + "\",\"PixelCode\":\"" + relData.TagPixelID + "\",\"DrawingFileID\":\"" + relData.DrawingID + "\"}"). var EngineDataIDs = pixelServ.GetList("{\"ProjectId\":\"" + ProjectId + "\",\"PixelCode\":\"" + relData.TagPixelID + "\",\"DrawingFileID\":\"" + relData.DrawingID + "\"}", ProjectId).
Select(x => x.EngineDataID).Distinct(); Select(x => x.EngineDataID).Distinct();
var CableIDs = pixelServ.GetList("{\"ProjectId\":\"" + ProjectId + "\",\"PixelCode\":\"" + relData.CablePixelID + "\",\"DrawingFileID\":\"" + relData.DrawingID + "\"}"). var CableIDs = pixelServ.GetList("{\"ProjectId\":\"" + ProjectId + "\",\"PixelCode\":\"" + relData.CablePixelID + "\",\"DrawingFileID\":\"" + relData.DrawingID + "\"}", ProjectId).
Select(x => x.EngineDataID).Distinct(); Select(x => x.EngineDataID).Distinct();
if (EngineDataIDs != null && EngineDataIDs.Count() == 1 && CableIDs != null && CableIDs.Count() == 1) if (EngineDataIDs != null && EngineDataIDs.Count() == 1 && CableIDs != null && CableIDs.Count() == 1)
{ {
@ -547,13 +547,13 @@ namespace Learun.Application.Web.AppApi
if (relData.IsEnd1) if (relData.IsEnd1)//电缆的起始端连接信息设备在end1电缆在end2
{ {
ec_relDataBLL.SaveEntitys(ProjectId, RelTypeID, new List<string> { TagID }, CableID, true); ec_relDataBLL.SaveEntitys(ProjectId, RelTypeID, new List<string> { TagID }, CableID, relData.TagPixelID, true);
} }
else else
{ {
ec_relDataBLL.SaveEntitys(ProjectId, RelTypeID, CableID, new List<string> { TagID }, true); ec_relDataBLL.SaveEntitys(ProjectId, RelTypeID, CableID, new List<string> { TagID }, relData.TagPixelID, true);
} }
} }

View File

@ -55,7 +55,7 @@ namespace Learun.Application.Web.Areas.ZZDT_EC.Controllers
return View(); return View();
} }
/// <summary> /// <summary>
/// 回收站 /// 图纸回收站
/// <summary> /// <summary>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]

View File

@ -40,7 +40,7 @@ namespace Learun.Application.Web.Areas.ZZDT_EC.Controllers
return View(); return View();
} }
/// <summary> /// <summary>
/// 工程数据回收站 /// 工程数据Tag回收站
/// <summary> /// <summary>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]

View File

@ -32,17 +32,7 @@ namespace Learun.Application.Web.Areas.ZZDT_EC.Controllers
#region #region
/// <summary>
/// 获取列表数据
/// <summary>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public ActionResult GetList(string queryJson)
{
var data = ec_enginedata_pixelIBLL.GetList(queryJson);
return Success(data);
}
/// <summary> /// <summary>
/// 获取工程数据图元表数据 /// 获取工程数据图元表数据
/// <summary> /// <summary>

View File

@ -99,7 +99,7 @@ namespace Learun.Application.Web.Areas.ZZDT_EC.Controllers
public ActionResult SaveForm(string ProjectId, string RelTypeID, string RelEngineData1ID, string strEntity) public ActionResult SaveForm(string ProjectId, string RelTypeID, string RelEngineData1ID, string strEntity)
{ {
List<string> relEngineData2IDs = strEntity.ToList<string>(); List<string> relEngineData2IDs = strEntity.ToList<string>();
ec_enginedata_relIBLL.SaveEntitys(ProjectId, RelTypeID, RelEngineData1ID, relEngineData2IDs); ec_enginedata_relIBLL.SaveEntitys(ProjectId, RelTypeID, RelEngineData1ID, relEngineData2IDs,"");
return Success("保存成功!"); return Success("保存成功!");
} }
#endregion #endregion

View File

@ -28,6 +28,7 @@ using System.Text.RegularExpressions;
using System.Web.Helpers; using System.Web.Helpers;
using System.Web.Mvc; using System.Web.Mvc;
using static Learun.Application.TwoDevelopment.ZZDT_EC.ec_enginedata_pixelService; using static Learun.Application.TwoDevelopment.ZZDT_EC.ec_enginedata_pixelService;
using static Learun.Application.TwoDevelopment.ZZDT_EC.GlobalEnum;
using SystemIO = System.IO; using SystemIO = System.IO;
namespace Learun.Application.Web.Areas.ZZDT_EC.Controllers namespace Learun.Application.Web.Areas.ZZDT_EC.Controllers
@ -764,7 +765,7 @@ namespace Learun.Application.Web.Areas.ZZDT_EC.Controllers
break; break;
} }
var cableFromToRel = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(relTypeTableName).ToList().FirstOrDefault(x => x.RelType == ((int)enum_RelType._电缆).ToString()); var cableFromToRel = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(relTypeTableName).ToList().FirstOrDefault(x => x.RelType == enum_RelType._电缆);
if (cableFromToRel == null) if (cableFromToRel == null)
{ {
throw new Exception($"查不到【{enum_RelType.设备_电缆.ToString()}】这个关联类型。"); throw new Exception($"查不到【{enum_RelType.设备_电缆.ToString()}】这个关联类型。");
@ -1123,7 +1124,7 @@ namespace Learun.Application.Web.Areas.ZZDT_EC.Controllers
//电缆的from to是根据甲板号的order顺序来的高优先级的就属于from //电缆的from to是根据甲板号的order顺序来的高优先级的就属于from
int? FromOrder = -1; int? ToOrder = -1; int? FromOrder = -1; int? ToOrder = -1;
#region From #region From
var cableFromId = relDatas?.FirstOrDefault(x => x?.RelEngineData2ID == cable?.EngineDataID && x?.RelEngDataObjType1?.Contains("OPC")==false)?.RelEngineData1ID; var cableFromId = relDatas?.FirstOrDefault(x => x?.RelEngineData2ID == cable?.EngineDataID && x?.RelEngDataObjType1?.Contains(GlobalObject.objectType_OPC)==false)?.RelEngineData1ID;
if (!string.IsNullOrEmpty(cableFromId)) if (!string.IsNullOrEmpty(cableFromId))
{ {
var cableFromObj = Equips.FirstOrDefault(x => x.EngineDataID == cableFromId); var cableFromObj = Equips.FirstOrDefault(x => x.EngineDataID == cableFromId);
@ -1174,7 +1175,7 @@ namespace Learun.Application.Web.Areas.ZZDT_EC.Controllers
} }
#endregion #endregion
#region To #region To
var cableEndId = relDatas?.FirstOrDefault(x => x?.RelEngineData1ID == cable?.EngineDataID && x?.RelEngDataObjType2?.Contains("OPC")==false)?.RelEngineData2ID; var cableEndId = relDatas?.FirstOrDefault(x => x?.RelEngineData1ID == cable?.EngineDataID && x?.RelEngDataObjType2?.Contains(GlobalObject.objectType_OPC)==false)?.RelEngineData2ID;
if (!string.IsNullOrEmpty(cableEndId)) if (!string.IsNullOrEmpty(cableEndId))
{ {
var cableEndObj = Equips.FirstOrDefault(x => x.EngineDataID == cableEndId); var cableEndObj = Equips.FirstOrDefault(x => x.EngineDataID == cableEndId);
@ -1570,8 +1571,8 @@ namespace Learun.Application.Web.Areas.ZZDT_EC.Controllers
(eep, ee, eo, edf, edc, edp) => eep.EngineDataID == edp.EngineDataID (eep, ee, eo, edf, edc, edp) => eep.EngineDataID == edp.EngineDataID
) )
.LeftJoin(subQuery, (eep, ee, eo, edf, edc, edp,dde)=> edp. == dde.DataItemName) .LeftJoin(subQuery, (eep, ee, eo, edf, edc, edp,dde)=> edp. == dde.DataItemName)
.WhereIF(selectModel == 0, (eep, ee, eo, edf, edc, edp, dde) => !eo.FullPathCN.EndsWith("电缆") && !eo.FullPathCN.EndsWith("图框") && !eo.FullPathCN.EndsWith(GlobalObject.objectType_Base) && !eo.FullPathCN.EndsWith("OPC") && eep.DeleteFlg == 0) .WhereIF(selectModel == 0, (eep, ee, eo, edf, edc, edp, dde) => !eo.FullPathCN.EndsWith("电缆") && !eo.FullPathCN.EndsWith("图框") && !eo.FullPathCN.EndsWith(GlobalObject.objectType_Base) && !eo.FullPathCN.EndsWith(GlobalObject.objectType_OPC) && eep.DeleteFlg == 0)
.WhereIF(selectModel == 1, (eep, ee, eo, edf, edc, edp, dde) => !eo.FullPathCN.EndsWith("电缆") && !eo.FullPathCN.EndsWith("图框") && !eo.FullPathCN.EndsWith(GlobalObject.objectType_Base) && !eo.FullPathCN.EndsWith("OPC") && dwgIdCos.Contains(eep.DrawingFileID) && eep.DeleteFlg == 0) .WhereIF(selectModel == 1, (eep, ee, eo, edf, edc, edp, dde) => !eo.FullPathCN.EndsWith("电缆") && !eo.FullPathCN.EndsWith("图框") && !eo.FullPathCN.EndsWith(GlobalObject.objectType_Base) && !eo.FullPathCN.EndsWith(GlobalObject.objectType_OPC) && dwgIdCos.Contains(eep.DrawingFileID) && eep.DeleteFlg == 0)
.GroupBy((eep, ee, eo, edf, edc, edp, dde) => new .GroupBy((eep, ee, eo, edf, edc, edp, dde) => new
{ {
edc.DrawingCatalogueNO, edc.DrawingCatalogueNO,

View File

@ -1,5 +1,7 @@
using Learun.Application.Scheduler; using Learun.Application.Scheduler;
using Learun.Application.Web.Common; using Learun.Application.Web.Common;
using Learun.Cache.Base;
using Learun.Cache.Factory;
using System; using System;
using System.Timers; using System.Timers;
using System.Web; using System.Web;
@ -30,12 +32,17 @@ namespace Learun.Application.Web
GlobalConfiguration.Configure(WebApiConfig.Register); GlobalConfiguration.Configure(WebApiConfig.Register);
RouteConfig.RegisterRoutes(RouteTable.Routes); RouteConfig.RegisterRoutes(RouteTable.Routes);
////一天执行一次备份 ////一天执行一次备份
Timer timer = new Timer(86400000); Timer timer = new Timer(86400000);
//timer.Elapsed += Timer_Elapsed; //timer.Elapsed += Timer_Elapsed;
//timer.Start(); //timer.Start();
#region redis清理
ICache redisObj = CacheFactory.CaChe();
redisObj.RemoveAll();
#endregion
} }
private void Timer_Elapsed(object sender, ElapsedEventArgs e) private void Timer_Elapsed(object sender, ElapsedEventArgs e)

View File

@ -18,7 +18,7 @@
<WebStackScaffolding_IsReferencingScriptLibrariesSelected>True</WebStackScaffolding_IsReferencingScriptLibrariesSelected> <WebStackScaffolding_IsReferencingScriptLibrariesSelected>True</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
<WebStackScaffolding_LayoutPageFile /> <WebStackScaffolding_LayoutPageFile />
<WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected> <WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
<ProjectView>ShowAllFiles</ProjectView> <ProjectView>ProjectFiles</ProjectView>
</PropertyGroup> </PropertyGroup>
<ProjectExtensions> <ProjectExtensions>
<VisualStudio> <VisualStudio>

View File

@ -1,5 +1,5 @@
ALTER TABLE ec_project ADD `IO_predicted_issue` VARCHAR(50) NULL; ALTER TABLE ec_project ADD `IO_predicted_issue` VARCHAR(50) NULL;
ALTER TABLE ec_project ADD `IO_predicted_issue` VARCHAR(50) NULL; ALTER TABLE ec_project ADD `IO_predicted_construct` VARCHAR(50) NULL;
ALTER TABLE ec_project ADD `IO_predicted_issue` VARCHAR(50) NULL; ALTER TABLE ec_project ADD `IO_real_issue` VARCHAR(50) NULL;
ALTER TABLE ec_project ADD `IO_predicted_issue` VARCHAR(50) NULL; ALTER TABLE ec_project ADD `IO_real_construct` VARCHAR(50) NULL;

View File

@ -274,6 +274,7 @@
<Compile Include="ZZDT_EC\ec_operate_log\ec_operate_logIBLL.cs" /> <Compile Include="ZZDT_EC\ec_operate_log\ec_operate_logIBLL.cs" />
<Compile Include="ZZDT_EC\ec_operate_log\ec_operate_logBLL.cs" /> <Compile Include="ZZDT_EC\ec_operate_log\ec_operate_logBLL.cs" />
<Compile Include="ZZDT_EC\ec_Wire_Group\signalGroup.cs" /> <Compile Include="ZZDT_EC\ec_Wire_Group\signalGroup.cs" />
<Compile Include="ZZDT_EC\Frame\FrameBll.cs" />
<Compile Include="ZZDT_EC\GlobalEnum.cs" /> <Compile Include="ZZDT_EC\GlobalEnum.cs" />
<Compile Include="ZZDT_EC\GlobalObject.cs" /> <Compile Include="ZZDT_EC\GlobalObject.cs" />
<Compile Include="ZZDT_EC\ec_template_catalogue\ec_template_catalogueEntity.cs" /> <Compile Include="ZZDT_EC\ec_template_catalogue\ec_template_catalogueEntity.cs" />

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView> <ProjectView>ProjectFiles</ProjectView>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -0,0 +1,64 @@
using DocumentFormat.OpenXml.Bibliography;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Learun.Application.TwoDevelopment.ZZDT_EC.Frame
{
public class FrameBll
{
/// <summary>
/// 肋位号
/// </summary>
public class FrameList
{
/// <summary>
/// 号
/// </summary>
public string Num { get; set; }
/// <summary>
/// 值。单位是m
/// </summary>
public double Value { get; set; }
}
public List<FrameList> GetFrameList(string ProjectId)
{
var ec_dataitemBLL = new ec_dataitemBLL();
var settings = new ec_projectSettingsBLL();
var FrameListFlg = settings.GetEntity(GlobalObject.projSetting_enumlist_Frame, ProjectId);
if (FrameListFlg != null)
{
List<FrameList> frameLists = new List<FrameList>();
var res = ec_dataitemBLL.GetDetailList(FrameListFlg.SettingValue, "", ProjectId, false);
if (res == null)
{
return null;// 或者 无法从数据字典中找到对应的那个下拉
}
foreach (var item in res)
{
double value;
if (double.TryParse(item.DataItemCode, out value))
{
frameLists.Add(new FrameList() { Num = item.DataItemName, Value = value });
}
}
frameLists = frameLists.OrderBy(t => t.Value).ToList();
return frameLists;
}
else
{
return null;// 或者 无法从数据字典中找到对应的那个下拉
}
}
}
}

View File

@ -8,12 +8,95 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
{ {
public class GlobalEnum public class GlobalEnum
{ {
#region io模块模板有关
public enum inOrOut
{
= 0,
= 1
}
/// <summary>
/// 电缆预分配时会选择的信号类型。通讯和非通讯digital等几个
/// </summary>
public enum signalType
{
/// <summary>
/// 数字量
/// </summary>
Digital = 1,
/// <summary>
/// 模拟量 4-20mA等
/// </summary>
Analog = 2,
/// <summary>
///
/// </summary>
TenVolt = 3,
/// <summary>
///
/// </summary>
PT100 = 4,
PULSE
}
/// <summary>
/// 端子排上的IO类型
/// </summary>
public enum IOType
{
DI = 0,
DO,
AI,
AO,
PT100,
PULSE,
TenVolt,
LAN,
/// <summary>
/// 485 422
/// </summary>
RS485,
}
#endregion
/// <summary>
/// 对象类型上特殊的一些分类。对应<see cref="ec_objecttypeEntity.specialType"/>
/// </summary>
public enum specialType
{
= 0,
= 1,
= 2,
= 3,
}
/// <summary>
/// 用于<see cref="ec_enginedataEntity.DataStatus"/>
/// </summary>
public enum TagDataStatus public enum TagDataStatus
{ {
= 00001, = 00001,
= 00002, = 00002,
= 00003, = 00003,
= 00004 = 00004
} }
/// <summary>
/// 用于 信号组别的状态<see cref="signalGroup.status"/>
/// </summary>
public enum signalGroupStatusEnum
{
/// <summary>
/// 待删除
/// </summary>
= 01,
/// <summary>
/// 新增的
/// </summary>
= 02,
/// <summary>
/// 已关联
/// </summary>
= 03
}
} }
} }

View File

@ -1,8 +1,10 @@
using DocumentFormat.OpenXml.Drawing.Spreadsheet; using DocumentFormat.OpenXml.Drawing.Spreadsheet;
using Learun.Util; using Learun.Util;
using Learun.Util.SqlSugar; using Learun.Util.SqlSugar;
using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
@ -121,7 +123,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
var panelStripTableName = ProjectSugar.TableName<ec_PanelStripEntity>(ProjID); var panelStripTableName = ProjectSugar.TableName<ec_PanelStripEntity>(ProjID);
var allRelTypeDef = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(relTypeTableName).ToList(); var allRelTypeDef = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(relTypeTableName).ToList();
//var x2 = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(relTypeTableName).ToList().FirstOrDefault(x => x.RelType == ((int)enum_RelType.设备_电缆).ToString()); //var x2 = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(relTypeTableName).ToList().FirstOrDefault(x => x.RelType == ((int)enum_RelType.设备_电缆).ToString());
var cableFromToRel = allRelTypeDef.FirstOrDefault(x => x.RelType == ((int)enum_RelType._电缆).ToString()); var cableFromToRel = allRelTypeDef.FirstOrDefault(x => x.RelType == enum_RelType._电缆);
if (cableFromToRel == null) if (cableFromToRel == null)
{ {
throw new Exception($"查不到【{enum_RelType.设备_电缆.ToString()}】这个关联类型。"); throw new Exception($"查不到【{enum_RelType.设备_电缆.ToString()}】这个关联类型。");
@ -166,12 +168,14 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
} }
} }
} }
/// <summary> /// <summary>
/// 预览所有有信号预分配的电缆信息 /// 预分配情况下的电缆set wire数据
/// </summary> /// </summary>
/// <param name="ProjID"></param> /// <param name="ProjID"></param>
/// <param name="EngineerDataID"></param>
/// <returns></returns> /// <returns></returns>
public ec_CableEntity CablePreAssignPreview(string ProjID) public ec_CableEntity GetCablePreAssign(string ProjID, string EngineerDataID)
{ {
var engineerDataServ = new ec_enginedataService(); var engineerDataServ = new ec_enginedataService();
var panelServ = new ec_PanelService(); var panelServ = new ec_PanelService();
@ -187,14 +191,12 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
return null; return null;
} }
var res = ec_CableService.GetList("{ProjectId:\"" + ProjID + "\"}").FirstOrDefault(); //电缆 var res = ec_CableService.GetList("{ProjectId:\"" + ProjID + "\",EngineerDataID:\"" + EngineerDataID + "\"}").FirstOrDefault(); //电缆
if (res != null) if (res != null)
{ {
var sets = ec_CableSetService.GetList(ProjID, res.CableID); var sets = ec_CableSetService.GetList(ProjID, res.CableID);
var Wires = ec_CableSetWireService.GetList(ProjID, res.CableID, ""); var Wires = ec_CableSetWireService.GetList(ProjID, res.CableID, "");
Console.WriteLine(res.CableClass);//是否通讯信号
Console.WriteLine(res.PreAssignIOType);//通讯类型
//剩下的感觉都可以是set上的参数 //剩下的感觉都可以是set上的参数
foreach (var set in sets) foreach (var set in sets)
@ -219,53 +221,161 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
#region #region
#endregion #endregion
} }
public ec_CableEntity GetCablePreAssign(string ProjID, string EngineerDataID) /// <summary>
/// 所有的
/// </summary>
/// <param name="projId"></param>
/// <param name="range">按需指定某几个id</param>
/// <param name="needProp">是否需要带出电缆上的工程属性</param>
/// <returns></returns>
public List<ec_CableEntity> GetCablesPreAssign(string projId, List<string> range, bool needProp = false)
{ {
var engineerDataServ = new ec_enginedataService(); var table = ProjectSugar.TableName<ec_CableEntity>(projId);
var panelServ = new ec_PanelService(); var tagTable = ProjectSugar.TableName<ec_enginedataEntity>(projId);
var panelStripBll = new ec_PanelStripBLL(); var panelTable = ProjectSugar.TableName<ec_PanelEntity>(projId);
var panelStripServ = new ec_PanelStripService(); var propTable = ProjectSugar.TableName<ec_enginedata_propertyEntity>(projId);
var termServ = new ec_PanelStripTermBLL(); var relTable = ProjectSugar.TableName<ec_enginedata_relEntity>(projId);
var channelServ = new ec_PanelChannelService(); var relTypeTable = ProjectSugar.TableName<ec_reltypeEntity>(projId);
var setServ = new ec_CableSetService();
var wireServ = new ec_CableSetWireService();
//先查出所有已经预分配的电缆
var preAssignedCables = SqlSugarHelper.Db.Queryable<ec_CableEntity>().AS(table).
WhereIF(range != null && range.Count() > 0, x => range.Contains(x.CableID)).
Where(x => !string.IsNullOrEmpty(x.PanelID)).ToList();
var tags = SqlSugarHelper.Db.Queryable<ec_enginedataEntity>().AS(tagTable).
Where(x => preAssignedCables.Select(xx => xx.EngineerDataID).Contains(x.EngineDataID)).ToList().
ToDictionary(x => x.EngineDataID);
//var allpropOnFrom = new List<ec_enginedata_propertyEntity>();
var ProjectEntity = new ec_projectEntity(); var panels = SqlSugarHelper.Db.Queryable<ec_PanelEntity>().AS(panelTable).
ProjectEntity = new ec_projectBLL().GetEntity(ProjID); Where(x => preAssignedCables.Select(xx => xx.PanelID).Contains(x.PanelID)).ToList();
if (ProjectEntity == null) var panelDict = panels.ToDictionary(x => x.PanelID);
var panelTags = SqlSugarHelper.Db.Queryable<ec_enginedataEntity>().AS(tagTable).
Where(x => panels.Select(xx => xx.EngineerDataID).Contains(x.EngineDataID)).ToList().ToDictionary(x => x.EngineDataID);
var FromRels = new Dictionary<string, string>();//key是cablevalue是from设备的id
var allpropOnFrom = new List<ec_enginedata_propertyEntity>();
if (needProp)
{ {
return null; var relTypeObj = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(relTypeTable).ToList().
FirstOrDefault(x => x.RelType == enum_RelType._电缆);
FromRels = SqlSugarHelper.Db.Queryable<ec_enginedata_relEntity>().AS(relTable).
Where(x => x.RelTypeID == relTypeObj.RelTypeID && preAssignedCables.Select(c => c.EngineerDataID).Contains(x.RelEngineData2ID)).
Distinct().
ToList().ToDictionary(x => x.RelEngineData2ID, x => x.RelEngineData1ID);
//设备上的属性
//电缆在2因为1.2.2里用于取的是from端的设备(设备在1电缆在2)
allpropOnFrom = SqlSugarHelper.Db.Queryable<ec_enginedata_propertyEntity>().AS(propTable).
Where(x => FromRels.Values.Contains(x.EngineDataID)).ToList();
} }
var allPropOnFromDict = allpropOnFrom.GroupBy(x => x.EngineDataID).ToDictionary(x => x.Key,
var res = ec_CableService.GetList("{ProjectId:\"" + ProjID + "\",EngineerDataID:\"" + EngineerDataID + "\"}").FirstOrDefault(); //电缆 groupValue => groupValue.ToDictionary(
if (res != null) item => item.PropertyName, // 内层字典的键:比如 PropertyID
item => item)); // 内层字典的值:整个对象或其某个属性);
foreach (var cable in preAssignedCables)
{ {
var sets = ec_CableSetService.GetList(ProjID, res.CableID); var sets = setServ.GetList(projId, cable.CableID);
var Wires = ec_CableSetWireService.GetList(ProjID, res.CableID, ""); var Wires = wireServ.GetList(projId, cable.CableID, "");
Console.WriteLine(res.CableClass);//是否通讯信号
Console.WriteLine(res.PreAssignIOType);//通讯类型
cable.TagNumber = tags[cable.EngineerDataID]?.TagNumber;
var panelObj = panelDict[cable.PanelID];
if (panelObj == null)
{
continue;//分配就已经不合理了
}
else if (panelObj != null)
{
panelObj.TagNumber = panelTags[panelObj.EngineerDataID]?.TagNumber;
//1.2.2 系统属性从电缆的from端上的设备中取设备的系统
var panelId = FromRels[cable.EngineerDataID];
var panelProps = allPropOnFromDict[panelId];
cable.System = panelProps[GlobalObject.propName_System]?.PropertyValue;
}
cable.ToPanel = panelObj;//暂用一下topanel属性相当于电缆预分配的采集箱背后的Panel对象。
var IOsOnPanel = panelObj.allowedIOTypes.Split(',').ToList();
//剩下的感觉都可以是set上的参数 //剩下的感觉都可以是set上的参数
foreach (var set in sets) foreach (var set in sets)
{ {
#region io匹配程度
if (set.PreAssignInOrOut == GlobalEnum.inOrOut..ToString() && cable.PreAssignIOType.ToLower() == "digital")
{
set.IOType = GlobalEnum.IOType.DI;
}
else if (set.PreAssignInOrOut == GlobalEnum.inOrOut..ToString() && cable.PreAssignIOType.ToLower() == "digital")
{
set.IOType = GlobalEnum.IOType.DO;
}
else if (set.PreAssignInOrOut == GlobalEnum.inOrOut..ToString() && cable.PreAssignIOType == "4~20mA")
{
set.IOType = GlobalEnum.IOType.AI;
}
else if (set.PreAssignInOrOut == GlobalEnum.inOrOut..ToString() && cable.PreAssignIOType == "4~20mA")
{
set.IOType = GlobalEnum.IOType.AO;
}
else if (cable.PreAssignIOType == "10v")
{
set.IOType = GlobalEnum.IOType.TenVolt;
}
else if (cable.PreAssignIOType == GlobalEnum.signalType.PT100.ToString())
{
set.IOType = GlobalEnum.IOType.PT100;
}
else if (cable.PreAssignIOType.ToUpper() == GlobalEnum.signalType.PULSE.ToString())
{
set.IOType = GlobalEnum.IOType.PULSE;
}
else if (cable.PreAssignIOType == GlobalEnum.signalType.PT100.ToString())
{
set.IOType = GlobalEnum.IOType.PT100;
}
//下面是通讯的
else
{
}
if (IOsOnPanel.Contains(set.IOType.ToString()))
{
set.IOTypeMatch = true;
}
else
{
set.IOTypeMatch = false;
cable.IOTypesNotMatchedList.Add(set.IOType.ToString());//从电缆上就能知道哪些io是匹配补上的
}
#endregion
var wires = Wires.Where(x => x.CableSetID == set.CableSetID); var wires = Wires.Where(x => x.CableSetID == set.CableSetID);
set.Wires = wires.ToList(); set.Wires = wires.ToList();
} }
res.Sets = sets; cable.Sets = sets;
//除了端子号 //if (cable.Sets.Any(x => !x.IOTypeMatch))
//{
return res; // cable.IOTypeMatch = true;
} //}
else //else
{ //{
//还没有电缆规格的实体,自然肯定也没有预配置 // cable.IOTypeMatch = false;
return null;//由客户端根据当前电缆规格来渲染布局然后保存时进行新建set wire和其他的预分配的内容 //}
} }
#region //分组
#endregion preAssignedCables = preAssignedCables.OrderBy(x => x.PreAssignIOType).ToList();
#region
#endregion return preAssignedCables;
} }
#endregion #endregion

View File

@ -6,7 +6,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
{ {
/// <summary> /// <summary>
/// 版 本 PIT-ADMS V7.0.3 敏捷开发框架 /// 版 本 PIT-ADMS V7.0.3 敏捷开发框架
/// Copyright (c) 2013-2018 Hexagon PPM /// Copyright (c) 2013-2018 Hexagon PPM
@ -42,13 +42,14 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
public string CableClass { get; set; } = ""; public string CableClass { get; set; } = "";
/// <summary> /// <summary>
/// 即里面走的信号的信号类型?<see cref="ec_Wire_GroupEntity.IO_Type"/> /// 即里面走的信号的信号类型?<see cref="GlobalEnum.signalType"/>。然后加上<see cref="ec_CableSetEntity.PreAssignInOrOut"/>,才是<see cref="GlobalEnum.IOType"/>
/// RS485 RS422 TCP/IP MQTT(如果是通讯母线,通讯类型是什么。) /// RS485 RS422 TCP/IP MQTT(如果是通讯母线,通讯类型是什么。)
/// Digital 4-20mA Pulse Pt100(如果是非母线IO类型是什么。) /// Digital 4-20mA Pulse Pt100(如果是非母线IO类型是什么。)
/// </summary> /// </summary>
public string PreAssignIOType { get; set; } = ""; public string PreAssignIOType { get; set; } = "";
/// <summary> /// <summary>
/// 电缆预分配时必须指定它应该在哪个IO柜子 /// 电缆预分配时必须指定它应该在哪个IO柜子。所以这个不为空,就说明是预分配的电缆。
/// </summary> /// </summary>
public string PanelID { get; set; } public string PanelID { get; set; }
/// <summary> /// <summary>
@ -101,6 +102,10 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
#region #region
/// <summary> /// <summary>
/// <see cref="PreAssignIOType"/> 是否和 <see cref="ec_PanelEntity.allowedIOTypes"/> 里的匹配。
/// </summary>
public HashSet<string> IOTypesNotMatchedList = new HashSet<string>();
/// <summary>
/// ///
/// </summary> /// </summary>
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
@ -129,16 +134,20 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
/// </summary> /// </summary>
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
public string TagNumber { set; get; } public string TagNumber { set; get; }
/// <summary>
/// 电缆所在的From端设备的所在的system
/// </summary>
[SugarColumn(IsIgnore = true)]
public string System { set; get; }
/// <summary> /// <summary>
/// From连接处的工程位号信息 /// From连接处的工程位号信息
/// </summary> /// </summary>
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
public ec_PanelEntity FromPanel { set; get; } public ec_PanelEntity FromPanel { set; get; }
/// <summary> /// <summary>
/// From连接处的工程位号信息( /// From连接处的工程位号信息。同时也表达下预分配电缆panelid对应的柜子信息。
/// </summary> /// </summary>
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
public ec_PanelEntity ToPanel { set; get; } public ec_PanelEntity ToPanel { set; get; }

View File

@ -129,6 +129,16 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
#region #region
/// <summary> /// <summary>
/// 根据<see cref="PreAssignInOrOut"/> 和 <see cref="ec_CableEntity.PreAssignIOType"/> 算出来的比如4-20mA + 输入得到AI
/// </summary>
[SugarColumn(IsIgnore = true)]
public GlobalEnum.IOType IOType { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(IsIgnore = true)]
public bool IOTypeMatch { get; set; }
/// <summary>
/// ///
/// </summary> /// </summary>
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]

View File

@ -586,7 +586,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
List<ec_Archive_Rel> ArchiveRels = new List<ec_Archive_Rel>(); List<ec_Archive_Rel> ArchiveRels = new List<ec_Archive_Rel>();
var tbRelType = ProjectSugar.TableName<ec_reltypeEntity>(targetProjId); var tbRelType = ProjectSugar.TableName<ec_reltypeEntity>(targetProjId);
var RelTypeCableFromTo = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(tbRelType).ToList().FirstOrDefault(x => x.RelType == ((int)enum_RelType._电缆).ToString()); var RelTypeCableFromTo = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(tbRelType).ToList().FirstOrDefault(x => x.RelType == enum_RelType._电缆);
//图上的pixel内容 //图上的pixel内容
@ -824,7 +824,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
var sourceTermAll = Db.Queryable<ec_PanelStripTermEntity>().AS($"ec_Panel_Strip_Term_{sourceProject.ProjectIndex}").ToList(); var sourceTermAll = Db.Queryable<ec_PanelStripTermEntity>().AS($"ec_Panel_Strip_Term_{sourceProject.ProjectIndex}").ToList();
var sourceChAll = Db.Queryable<ec_PanelChannelEntity>().AS($"ec_Panel_Channel_{sourceProject.ProjectIndex}").ToList(); var sourceChAll = Db.Queryable<ec_PanelChannelEntity>().AS($"ec_Panel_Channel_{sourceProject.ProjectIndex}").ToList();
var sourceCBAll = Db.Queryable<ec_CircuitBreakerEntity>().AS($"ec_CircuitBreaker_{sourceProject.ProjectIndex}").ToList(); var sourceCBAll = Db.Queryable<ec_CircuitBreakerEntity>().AS($"ec_CircuitBreaker_{sourceProject.ProjectIndex}").ToList();
var sourceConnRelType = Db.Queryable<ec_reltypeEntity>().AS($"ec_reltype_{sourceProject.ProjectIndex}").ToList().FirstOrDefault(x => x.RelType == ((int)enum_RelType._电缆).ToString()); var sourceConnRelType = Db.Queryable<ec_reltypeEntity>().AS($"ec_reltype_{sourceProject.ProjectIndex}").ToList().FirstOrDefault(x => x.RelType == enum_RelType._电缆);
if (sourceConnRelType == null) if (sourceConnRelType == null)
{ {
return "原始项目中,找不到 设备-电缆 的连接关系RelType定义。"; return "原始项目中,找不到 设备-电缆 的连接关系RelType定义。";
@ -859,7 +859,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
var targetTypeAll = objectTypeBll.GetList("{ProjectId:\"" + ProjectId + "\"}").ToList(); var targetTypeAll = objectTypeBll.GetList("{ProjectId:\"" + ProjectId + "\"}").ToList();
var TargetDrawingFile = drawingBll.GetList("{ProjectId:\"" + ProjectId + "\"}").ToList(); var TargetDrawingFile = drawingBll.GetList("{ProjectId:\"" + ProjectId + "\"}").ToList();
var targetTags = ec_enginedataService.GetListSingleTable(ProjectId, null); var targetTags = ec_enginedataService.GetListSingleTable(ProjectId, null);
var targetConnRelType = Db.Queryable<ec_reltypeEntity>().AS($"ec_reltype_{targetProject.ProjectIndex}").ToList().FirstOrDefault(x => x.RelType == ((int)enum_RelType._电缆).ToString()); var targetConnRelType = Db.Queryable<ec_reltypeEntity>().AS($"ec_reltype_{targetProject.ProjectIndex}").ToList().FirstOrDefault(x => x.RelType == enum_RelType._电缆);
if (targetConnRelType == null) if (targetConnRelType == null)
{ {
return "当前项目中,找不到 设备-电缆 的连接关系RelType定义。"; return "当前项目中,找不到 设备-电缆 的连接关系RelType定义。";
@ -986,7 +986,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
#region #region
var resourcePixelList = ec_enginedata_pixelService.GetList("{ProjectId:\"" + item.ProjectId + "\",DrawingFileID:\"" + item.DrawingFileID + "\"}").ToList(); var resourcePixelList = ec_enginedata_pixelService.GetList("{ProjectId:\"" + item.ProjectId + "\",DrawingFileID:\"" + item.DrawingFileID + "\"}",ProjectId).ToList();
if (resourcePixelList != null && resourcePixelList.Count() > 0)//不包含deleteflg的 if (resourcePixelList != null && resourcePixelList.Count() > 0)//不包含deleteflg的
{ {
//获取拷贝图纸所有的工程数据ID //获取拷贝图纸所有的工程数据ID

View File

@ -2,6 +2,7 @@
using DocumentFormat.OpenXml.ExtendedProperties; using DocumentFormat.OpenXml.ExtendedProperties;
using DocumentFormat.OpenXml.Office2010.Excel; using DocumentFormat.OpenXml.Office2010.Excel;
using DocumentFormat.OpenXml.Office2013.Drawing.Chart; using DocumentFormat.OpenXml.Office2013.Drawing.Chart;
using DocumentFormat.OpenXml.Office2021.DocumentTasks;
using DocumentFormat.OpenXml.Spreadsheet; using DocumentFormat.OpenXml.Spreadsheet;
@ -87,7 +88,8 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
var drawingInfo = Db.Queryable<ec_drawing_fileEntity>().AS(drawingfileTableName) var drawingInfo = Db.Queryable<ec_drawing_fileEntity>().AS(drawingfileTableName)
.LeftJoin<ec_dataitemdetailEntity>((edf, edid) => edf.DrawingSystem == edid.DataItemDetailID).AS<ec_dataitemdetailEntity>(dataitemdetailTableName) .LeftJoin<ec_dataitemdetailEntity>((edf, edid) => edf.DrawingSystem == edid.DataItemDetailID).AS<ec_dataitemdetailEntity>(dataitemdetailTableName)
.Where((edf, edid) => edf.DrawingFileID == drawingId) .Where((edf, edid) => edf.DrawingFileID == drawingId)
.Select((edf, edid) => new { .Select((edf, edid) => new
{
edid.DataItemName, edid.DataItemName,
edf.DrawingFileName, edf.DrawingFileName,
edid.UpDataItemDetailID edid.UpDataItemDetailID
@ -126,10 +128,10 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
allTag = FilterEngineDataBySystemTopName(propertiesOfEnginedata, allTag, topDataItemDetailName, dataitemdetailTableName); allTag = FilterEngineDataBySystemTopName(propertiesOfEnginedata, allTag, topDataItemDetailName, dataitemdetailTableName);
} }
var allType = Db.Queryable<ec_objecttypeEntity>().AS(typeT). var allType = Db.Queryable<ec_objecttypeEntity>().AS(typeT).
Where(x => allTag.Select(y => y.ObjectTypeID).Contains(x.ObjectTypeID) Where(x => allTag.Select(y => y.ObjectTypeID).Contains(x.ObjectTypeID)
&& !x.FullPathCN.EndsWith("图框") && !x.FullPathCN.EndsWith("图框")
&& !x.FullPathCN.EndsWith(GlobalObject.objectType_Base) && !x.FullPathCN.EndsWith(GlobalObject.objectType_Base)
&& !x.FullPathCN.EndsWith("OPC")).Distinct().ToList(); && !x.FullPathCN.EndsWith(GlobalObject.objectType_OPC)).Distinct().ToList();
var allPropDef = Db.Queryable<ec_propertyEntity>().AS(propT).ToList(); var allPropDef = Db.Queryable<ec_propertyEntity>().AS(propT).ToList();
//var allObjectTypeP = Db.Queryable<ec_objecttypepEntity>().AS(objectTypeP_T).ToList(); //var allObjectTypeP = Db.Queryable<ec_objecttypepEntity>().AS(objectTypeP_T).ToList();
var allObjectTypeP = new ec_objecttypepBLL().GetObjectTypePById("", projectId, true).ToList(); var allObjectTypeP = new ec_objecttypepBLL().GetObjectTypePById("", projectId, true).ToList();
@ -226,8 +228,8 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
groupedProps[cableId] = props; groupedProps[cableId] = props;
} }
bool hasStart = props.Any(x => x.PropertyName == "起始设备"); bool hasStart = props.Any(x => x.PropertyName == GlobalObject.propName_From);
bool hasEnd = props.Any(x => x.PropertyName == "终止设备"); bool hasEnd = props.Any(x => x.PropertyName == GlobalObject.propName_To);
var cableTypeName = cableTypeMap.TryGetValue(cableId, out var typeName) ? typeName : "电缆"; var cableTypeName = cableTypeMap.TryGetValue(cableId, out var typeName) ? typeName : "电缆";
if (!hasStart) if (!hasStart)
@ -236,12 +238,12 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
{ {
EngineDataID = cableId, EngineDataID = cableId,
ObjectTypeName = cableTypeName, ObjectTypeName = cableTypeName,
PropertyName = "起始设备", PropertyName = GlobalObject.propName_From,
PropertyValue = "" PropertyValue = ""
}; };
props.Add(newStartProp); props.Add(newStartProp);
allTagProps.Add(newStartProp); // ✅ 加入总集合 allTagProps.Add(newStartProp); // ✅ 加入总集合
tagPropDict[(cableId, "起始设备")] = newStartProp; // ✅ 加入/覆盖字典 tagPropDict[(cableId, GlobalObject.propName_From)] = newStartProp; // ✅ 加入/覆盖字典
} }
if (!hasEnd) if (!hasEnd)
@ -250,18 +252,18 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
{ {
EngineDataID = cableId, EngineDataID = cableId,
ObjectTypeName = cableTypeName, ObjectTypeName = cableTypeName,
PropertyName = "终止设备", PropertyName = GlobalObject.propName_To,
PropertyValue = "" PropertyValue = ""
}; };
props.Add(newEndProp); props.Add(newEndProp);
allTagProps.Add(newEndProp); // ✅ 加入总集合 allTagProps.Add(newEndProp); // ✅ 加入总集合
tagPropDict[(cableId, "终止设备")] = newEndProp; // ✅ 加入/覆盖字典 tagPropDict[(cableId, GlobalObject.propName_To)] = newEndProp; // ✅ 加入/覆盖字典
} }
} }
// 整合所有补全后的属性 // 整合所有补全后的属性
var cableProperties = groupedProps.Values.SelectMany(g => g) var cableProperties = groupedProps.Values.SelectMany(g => g)
.Where(x => x.PropertyName == "起始设备" || x.PropertyName == "终止设备") .Where(x => x.PropertyName == GlobalObject.propName_From || x.PropertyName == GlobalObject.propName_To)
.ToList(); .ToList();
// 一次性获取所有连接信息 // 一次性获取所有连接信息
@ -271,18 +273,18 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
{ {
if (cableRelDict.TryGetValue(changeprofromto.EngineDataID, out var conn)) if (cableRelDict.TryGetValue(changeprofromto.EngineDataID, out var conn))
{ {
if (changeprofromto.PropertyName == "起始设备") if (changeprofromto.PropertyName == GlobalObject.propName_From)
{ {
changeprofromto.PropertyValue = conn.End1Tag; changeprofromto.PropertyValue = conn.End1Tag;
} }
else if (changeprofromto.PropertyName == "终止设备") else if (changeprofromto.PropertyName == GlobalObject.propName_To)
{ {
changeprofromto.PropertyValue = conn.End2Tag; changeprofromto.PropertyValue = conn.End2Tag;
} }
} }
} }
foreach (var type in allType) foreach (var type in allType)
{ {
string sheetName = $"{seq}_{type.ObjectTypeName}"; string sheetName = $"{seq}_{type.ObjectTypeName}";
@ -320,7 +322,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
// 4. 处理 `RequireIfRequired` 依赖项 // 4. 处理 `RequireIfRequired` 依赖项
foreach (var item in requireIfRequiredProps) foreach (var item in requireIfRequiredProps)
{ {
if (requiredProps.ContainsKey(item.trigger_property_id) && (item.IsRequired == -1 || item.IsRequired == null || item.IsRequired==0))//isrequired==0是因为历史遗留数据正常情况是没有0的 if (requiredProps.ContainsKey(item.trigger_property_id) && (item.IsRequired == -1 || item.IsRequired == null || item.IsRequired == 0))//isrequired==0是因为历史遗留数据正常情况是没有0的
{ {
//在必填的里面累加不必填的内容,但是需要处理依赖项的 //在必填的里面累加不必填的内容,但是需要处理依赖项的
allLinkedPropSet.Add(item); allLinkedPropSet.Add(item);
@ -366,21 +368,21 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
{ {
curSheet.Cells[curRow, 1].Value = tag.TagNumber; curSheet.Cells[curRow, 1].Value = tag.TagNumber;
//var tagPropDict = allTagProps //var tagPropDict = allTagProps
//.GroupBy(x => (x.EngineDataID, x.PropertyName)) //.GroupBy(x => (x.EngineDataID, x.PropertyName))
//.ToDictionary(g => g.Key, g => g.First()); //.ToDictionary(g => g.Key, g => g.First());
var tagProp = tagPropDict.TryGetValue((tag.EngineDataID, propDef.PropertyName), out var propVal) ? propVal : null; var tagProp = tagPropDict.TryGetValue((tag.EngineDataID, propDef.PropertyName), out var propVal) ? propVal : null;
//var tagProp = allTagProps.FirstOrDefault(x => x.EngineDataID == tag.EngineDataID && x.PropertyName == propDef.PropertyName); //var tagProp = allTagProps.FirstOrDefault(x => x.EngineDataID == tag.EngineDataID && x.PropertyName == propDef.PropertyName);
if (tagProp == null) if (tagProp == null)
{ {
if (!string.IsNullOrEmpty(propDef.DefaultValue) && propDef.DefaultValue != "0") if (!string.IsNullOrEmpty(propDef.DefaultValue) && propDef.DefaultValue != "0")
{ {
curSheet.Cells[curRow, propCol].Value = propDef.DefaultValue; curSheet.Cells[curRow, propCol].Value = propDef.DefaultValue;
} }
else else
{ {
CheckDependency(prop, allTagProps, tag, triggerProName, triggerOperator, triggerValue, curSheet, curRow, propCol, allLinkedPropId); CheckDependency(prop, allTagProps, tag, triggerProName, triggerOperator, triggerValue, curSheet, curRow, propCol, allLinkedPropId);
} }
} }
else if (string.IsNullOrEmpty(tagProp.PropertyValue) || tagProp.PropertyValue == "0") else if (string.IsNullOrEmpty(tagProp.PropertyValue) || tagProp.PropertyValue == "0")
{ {
@ -536,7 +538,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
curSheet.Cells[1, 1, totalRows, totalColumns].Style.Locked = false; curSheet.Cells[1, 1, totalRows, totalColumns].Style.Locked = false;
curSheet.Cells[1, 1, 1, totalColumns].Style.Locked = true; // 锁定第一行 curSheet.Cells[1, 1, 1, totalColumns].Style.Locked = true; // 锁定第一行
curSheet.Cells[1, 1, totalRows, 1].Style.Locked = true; // 锁定第一列 curSheet.Cells[1, 1, totalRows, 1].Style.Locked = true; // 锁定第一列
curSheet.Protection.IsProtected = true; curSheet.Protection.IsProtected = true;
curSheet.Protection.AllowFormatColumns = true; // 允许调整列宽 curSheet.Protection.AllowFormatColumns = true; // 允许调整列宽
} }
@ -596,7 +598,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
{ {
var isRequired = tagDepObjtypep.IsRequired;//上级的必填阶段值 var isRequired = tagDepObjtypep.IsRequired;//上级的必填阶段值
//只有当前属性的必填阶段大于等于上级关联的必填阶段时才会去判断自身是不是要必填,不然都没有检查下去的必要 //只有当前属性的必填阶段大于等于上级关联的必填阶段时才会去判断自身是不是要必填,不然都没有检查下去的必要
if(prop.IsRequired >= isRequired) if (prop.IsRequired >= isRequired)
{ {
//取某个位号的工程数据属性 //取某个位号的工程数据属性
var tagDepProp = allTagProps.FirstOrDefault(x => x.EngineDataID == tag.EngineDataID && x.PropertyName == triggerProName); var tagDepProp = allTagProps.FirstOrDefault(x => x.EngineDataID == tag.EngineDataID && x.PropertyName == triggerProName);
@ -612,7 +614,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
} }
} }
} }
} }
} }
else if (prop.dependency_type.Equals(dependency_type.RequireIfRequired)) else if (prop.dependency_type.Equals(dependency_type.RequireIfRequired))
@ -633,7 +635,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
else else
{ {
//不依赖特定条件,且没有默认值,变色 //不依赖特定条件,且没有默认值,变色
SetCellColor(curSheet, curRow, propCol, prop.IsRequired, dependency_type.RequireNone,""); SetCellColor(curSheet, curRow, propCol, prop.IsRequired, dependency_type.RequireNone, "");
} }
} }
/// <summary> /// <summary>
@ -643,7 +645,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
/// <param name="row">行</param> /// <param name="row">行</param>
/// <param name="col">列</param> /// <param name="col">列</param>
/// <param name="isRequired">图纸阶段</param> /// <param name="isRequired">图纸阶段</param>
private void SetCellColor(ExcelWorksheet curSheet, int row, int col, int? isRequired, dependency_type deType, string strTriggerProName="", Dictionary<string, int> fillStyleCache = null) private void SetCellColor(ExcelWorksheet curSheet, int row, int col, int? isRequired, dependency_type deType, string strTriggerProName = "", Dictionary<string, int> fillStyleCache = null)
{ {
curSheet.Cells[row, col].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; curSheet.Cells[row, col].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
@ -808,7 +810,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
.Where((ed, edp, eo) => .Where((ed, edp, eo) =>
!SqlFunc.Contains(eo.ObjectTypeName, "%电缆") && !SqlFunc.Contains(eo.ObjectTypeName, "%电缆") &&
!SqlFunc.Contains(eo.ObjectTypeName, "%图框") && !SqlFunc.Contains(eo.ObjectTypeName, "%图框") &&
!SqlFunc.Contains(eo.ObjectTypeName, "%"+ GlobalObject.objectType_Base) && !SqlFunc.Contains(eo.ObjectTypeName, "%" + GlobalObject.objectType_Base) &&
!SqlFunc.Contains(eo.ObjectTypeName, "%OPC") && !SqlFunc.Contains(eo.ObjectTypeName, "%OPC") &&
validEngineDataIds.Contains(ed.EngineDataID) validEngineDataIds.Contains(ed.EngineDataID)
) )
@ -1165,7 +1167,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
#endregion #endregion
#region #region
public async Task LockTag(string projId, string enginedataId, string action) public async System.Threading.Tasks.Task LockTag(string projId, string enginedataId, string action)
{ {
var data = LoginUserInfo.Get(); var data = LoginUserInfo.Get();
@ -1505,6 +1507,8 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
var objectTypeTableName = TableName<ec_objecttypeEntity>(ProjectEntity.ProjectIndex.ToString()); var objectTypeTableName = TableName<ec_objecttypeEntity>(ProjectEntity.ProjectIndex.ToString());
var objectTypepTableName = TableName<ec_objecttypepEntity>(ProjectEntity.ProjectIndex.ToString()); var objectTypepTableName = TableName<ec_objecttypepEntity>(ProjectEntity.ProjectIndex.ToString());
var unitTableName = TableName<ec_measuring_unitEntity>(ProjectEntity.ProjectIndex.ToString()); var unitTableName = TableName<ec_measuring_unitEntity>(ProjectEntity.ProjectIndex.ToString());
var relTableName = TableName<ec_reltypeEntity>(ProjectEntity.ProjectIndex.ToString());
var reldataTableName = TableName<ec_enginedata_relEntity>(ProjectEntity.ProjectIndex.ToString());
var lookupBll = new ec_REFLOOKUPTABLEBLL(); var lookupBll = new ec_REFLOOKUPTABLEBLL();
@ -1558,6 +1562,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
var typeTbName = ProjectSugar.TableName<ec_objecttypeEntity>(projectId); var typeTbName = ProjectSugar.TableName<ec_objecttypeEntity>(projectId);
var dwgTbName = ProjectSugar.TableName<ec_drawing_fileEntity>(projectId); var dwgTbName = ProjectSugar.TableName<ec_drawing_fileEntity>(projectId);
var pixelTbName = ProjectSugar.TableName<ec_enginedata_pixelEntity>(projectId); var pixelTbName = ProjectSugar.TableName<ec_enginedata_pixelEntity>(projectId);
var dataitemdetailTableName = TableName<ec_dataitemdetailEntity>(projectId);
var allType = SqlSugarHelper.Db.Queryable<ec_objecttypeEntity>().AS(typeTbName).ToList(); var allType = SqlSugarHelper.Db.Queryable<ec_objecttypeEntity>().AS(typeTbName).ToList();
var systems = new ec_dataitemBLL().GetDetailList(GlobalObject.enumlist_System, "", projectId); var systems = new ec_dataitemBLL().GetDetailList(GlobalObject.enumlist_System, "", projectId);
@ -1569,14 +1574,24 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
{ {
var cableSystemObj = entity.EngineDataProperty.FirstOrDefault(x => x.PropertyName == GlobalObject.propName_System); var cableSystemObj = entity.EngineDataProperty.FirstOrDefault(x => x.PropertyName == GlobalObject.propName_System);
var cableSystem = cableSystemObj == null ? "" : systems.FirstOrDefault(x => x.DataItemName == cableSystemObj.PropertyValue)?.DataItemDetailID; string systemNameAfterDealWith = string.Empty;
if (cableSystem != null) var cableSystem =string.Empty;
var topDataItemDetailIDofDwg = string.Empty;
var topDataItemDetailIDofEng = string.Empty;
if (cableSystemObj != null)
{ {
if (dwgObj.DrawingSystem == cableSystem && !string.IsNullOrEmpty(dwgObj.DrawingSystem)) int index = cableSystemObj.PropertyValue.IndexOf("||");
systemNameAfterDealWith = index >= 0 ? cableSystemObj.PropertyValue.Substring(0, index) : cableSystemObj.PropertyValue;
cableSystem = systems.FirstOrDefault(x => x.DataItemName == systemNameAfterDealWith)?.DataItemDetailID;
//获取图纸系统的最上级ID
topDataItemDetailIDofDwg = GetTopParentDataItemDetailByID(dataitemdetailTableName, dwgObj.DrawingSystem);
//获取位号系统的最上级ID
topDataItemDetailIDofEng= GetTopParentDataItemDetailByID(dataitemdetailTableName, cableSystem);
if (topDataItemDetailIDofDwg == topDataItemDetailIDofEng && !string.IsNullOrEmpty(dwgObj.DrawingSystem))
{ {
//可以修改 //可以修改
} }
else if (string.IsNullOrEmpty(cableSystem)) else if (string.IsNullOrEmpty(topDataItemDetailIDofEng))
{ {
//不可以 //不可以
allowPropertyModify = false; allowPropertyModify = false;
@ -1602,6 +1617,12 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
} }
} }
//var cableSystem = cableSystemObj == null ? "" : systems.FirstOrDefault(x => x.DataItemName == cableSystemObj.PropertyValue)?.DataItemDetailID;
//if (cableSystem != null)
//{
//}
} }
else else
{ {
@ -1715,10 +1736,10 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
//db.UpdateByNoMap(curEnginedata, $"ec_enginedata_{ProjectEntity.ProjectIndex}", "EngineDataID"); //db.UpdateByNoMap(curEnginedata, $"ec_enginedata_{ProjectEntity.ProjectIndex}", "EngineDataID");
Db.Updateable(curEnginedata).AS($"ec_enginedata_{ProjectEntity.ProjectIndex}").ExecuteCommand(); Db.Updateable(curEnginedata).AS($"ec_enginedata_{ProjectEntity.ProjectIndex}").ExecuteCommand();
} }
engineDataID = curEnginedata.EngineDataID;//更新位号时 engineDataID = curEnginedata.EngineDataID;//更新位号时
#endregion #endregion
} }
else else
@ -1774,37 +1795,8 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
validTagProps.Add(engineDataProp); validTagProps.Add(engineDataProp);
} }
Db.Insertable(validTagProps).AS($"ec_enginedata_property_{ProjectEntity.ProjectIndex}").ExecuteCommand(); Db.Insertable(validTagProps).AS($"ec_enginedata_property_{ProjectEntity.ProjectIndex}").ExecuteCommand();
#endregion #endregion
#region case
//foreach (var caseEntity in cases.Where(x => x.CaseID != caseID))
//{
// //把objectTypep里的一套和默认值带过来即可
// var enginedataProps = new List<ec_enginedata_propertyEntity>();
// Db.Queryable<ec_propertyEntity>().AS(propertyTableName)
// .InnerJoin<ec_objecttypepEntity>((a, b) => a.PropertyID == b.PropertyID)//&& !string.IsNullOrEmpty(a.DefaultValue)
// .AS<ec_objecttypepEntity>(objectTypepTableName)
// .InnerJoin<ec_objecttypeEntity>((a, b, c) => b.ObjectTypeID == c.ObjectTypeID && c.ObjectTypeID == entity.ObjectTypeID)
// .AS<ec_objecttypeEntity>(objectTypeTableName)
// .LeftJoin<ec_measuring_unitEntity>((a, b, c, d) => a.DefaultUnit == d.MeasuringUnitID)
// .AS<ec_measuring_unitEntity>(unitTableName)
// .Select((a, b, c, d) => new { a, d })
// .ToList().ForEach(x =>
// {
// var enginedataProp = new ec_enginedata_propertyEntity()
// {
// EngineDataID = engineDataID,
// PropertyName = x.a.PropertyName,
// PropertyValue = x.a.DefaultValue,
// MeasuringUnit = x.d.MeasuringUnitName,
// CaseID = caseEntity.CaseID,
// };
// enginedataProp.Create();
// enginedataProps.Add(enginedataProp);
// });
// Db.Insertable(enginedataProps).AS($"ec_enginedata_property_{ProjectEntity.ProjectIndex}").ExecuteCommand(); //231007
//}
#endregion
#region ec panel的记录 #region ec panel的记录
var objectType = new ec_objecttypeBLL().GetEntity(addEnginedata.ObjectTypeID, projectId); var objectType = new ec_objecttypeBLL().GetEntity(addEnginedata.ObjectTypeID, projectId);
if (objectType != null && !objectType.ObjectTypeName.EndsWith("电缆") && objectType.IsOOTB != 1) if (objectType != null && !objectType.ObjectTypeName.EndsWith("电缆") && objectType.IsOOTB != 1)
@ -1830,6 +1822,46 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
First(x => x.DrawingFileID == pixel.DrawingFileID && x.PixelCode == pixel.PixelCode); First(x => x.DrawingFileID == pixel.DrawingFileID && x.PixelCode == pixel.PixelCode);
if (existPixel != null) if (existPixel != null)
{ {
#region TASK #9476
//是否这个句柄换过位号换过的话更新为当前位号同时要更新相关电缆的from/to
var oldTagId = existPixel.EngineDataID;
var newTagId = engineDataID;
if (oldTagId != newTagId)
{
//句柄换位号主体了
//原本句柄相关的rel
var relObj = Db.Queryable<ec_reltypeEntity>().AS(relTableName).First(x => x.RelType == enum_RelType._电缆);
if (relObj != null)
{
var existCableConns = Db.Queryable<ec_enginedata_relEntity>().AS(reldataTableName).
Where(x => x.RelTypeID == relObj.RelTypeID && x.OPCPixel == pixel.PixelCode && (x.RelEngineData1ID == oldTagId || x.RelEngineData2ID == oldTagId)).ToList();
//这里有问题。
//比如设备B在多个图上多有句柄P1 P2 P3且这些句柄都关联了多个电缆C1 C2 C3那么在rel表里就有3个B的记录
//这时如果进行提交,句柄P1的主体变为了设备BBB那么B的所有句柄P1 P2 P3都变为BBB了没有单独分离出来 C1 C2 C3中的某一个
//解决在进行saveconnection把设备的句柄存入
if (existCableConns != null)
{
//更新rel表
foreach (var existConn in existCableConns)
{
if (existConn.RelEngineData1ID == oldTagId)
{
existConn.RelEngineData1ID = newTagId;
}
else if (existConn.RelEngineData2ID == oldTagId)
{
existConn.RelEngineData2ID = newTagId;
}
}
//更新电缆属性里的 起始设备 和 终止设备
//不需要 查询时会自动处理
Db.Updateable(existCableConns).AS($"ec_enginedata_rel_{ProjectEntity.ProjectIndex}").ExecuteCommand();
}
}
}
#endregion
existPixel.Modify(existPixel.EngineDataPixelID); existPixel.Modify(existPixel.EngineDataPixelID);
existPixel.DeleteFlg = 0; existPixel.DeleteFlg = 0;
existPixel.EngineDataID = engineDataID; existPixel.EngineDataID = engineDataID;
@ -1858,102 +1890,10 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
#region
//更新电缆规格
//var cableTableName = ProjectSugar.TableName<ec_CableEntity>(projectId);
//var enginedataTableName = ProjectSugar.TableName<ec_enginedataEntity>(projectId);
//var enginedataPropertyTableName = ProjectSugar.TableName<ec_enginedata_propertyEntity>(projectId);
//var cableFormat = SqlSugarHelper.Db.Queryable<ec_CableEntity>().AS<ec_CableEntity>(cableTableName)
// .InnerJoin<ec_enginedata_propertyEntity>((a, b) => a.EngineerDataID == b.EngineDataID).AS<ec_enginedata_propertyEntity>(enginedataPropertyTableName)
// .InnerJoin<ec_enginedataEntity>((a, b, c) => b.EngineDataID == c.EngineDataID).AS<ec_enginedataEntity>(enginedataTableName)
// .Where((a, b, c) => b.PropertyName == GlobalObject.propName_CableSpec && b.CaseID == caseID && c.TagNumber == entity.TagNumber)
// .Select((a, b, c) => new { a, b })
// .First();
//if (cableFormat != null)
//{
// var cableID = cableFormat.a.CableID;
// var start = cableFormat.b.PropertyValue.Split('*', 'x', 'X', '✖');
// if (start.Length >= 2)
// {
// int setCount;
// int wireCount;
// var b1 = int.TryParse(start[0], out setCount);
// var b2 = int.TryParse(start[1], out wireCount);
// if (b1 && b2)
// {
// var cableSetTableName = ProjectSugar.TableName<ec_CableSetEntity>(projectId);
// var cableSetWireTableName = ProjectSugar.TableName<ec_CableSetWireEntity>(projectId);
// var sets = SqlSugarHelper.Db.Queryable<ec_CableSetEntity>().AS(cableSetTableName).Where(x => x.CableID == cableID).ToList();
// var wires = SqlSugarHelper.Db.Queryable<ec_CableSetWireEntity>().AS(cableSetWireTableName).Where(x => sets.Select(Y => Y.CableSetID).Contains(x.CableSetID)).ToList();
// var setMax = Math.Max(setCount, sets.Count);
// var insSets = new List<ec_CableSetEntity>();
// var insWires = new List<ec_CableSetWireEntity>();
// var delSets = new List<ec_CableSetEntity>();
// var delWires = new List<ec_CableSetWireEntity>();
// for (int i = 0; i < setMax; i++)
// {
// var set = new ec_CableSetEntity();
// if (i <= setCount - 1 && i <= sets.Count - 1)
// {
// set = sets[i];
// }
// if (i > setCount - 1)
// {
// var delSet = sets[i];
// delSets.Add(delSet);
// delWires.AddRange(wires.Where(x => x.CableSetID == delSet.CableSetID).ToList());
// }
// if (i > sets.Count - 1)
// {
// set = new ec_CableSetEntity()
// {
// CableID = cableID,
// CableSetSeq = i + 1,
// CableSetName = $"Set{i + 1}",
// };
// set.Create();
// insSets.Add(set);
// }
// if (!string.IsNullOrEmpty(set.CableSetID))
// {
// var setWires = wires.Where(x => x.CableSetID == set.CableSetID).ToList();
// var wireMax = Math.Max(wireCount, setWires.Count);
// for (int j = 0; j < wireMax; j++)
// {
// if (j > wireCount - 1)
// {
// var delWire = setWires[j];
// delWires.Add(delWire);
// }
// if (j > setWires.Count - 1)
// {
// var wire = new ec_CableSetWireEntity()
// {
// //CableID = cableID,
// CableSetID = set.CableSetID,
// SetLevel = j,
// Wire_Tag = $"W{j + 1}"
// };
// wire.Create();
// insWires.Add(wire);
// }
// }
// }
// }
// SqlSugarHelper.Db.Insertable(insSets).AS(cableSetTableName).ExecuteCommand();
// SqlSugarHelper.Db.Insertable(insWires).AS(cableSetWireTableName).ExecuteCommand();
// SqlSugarHelper.Db.Deleteable(delWires).AS(cableSetWireTableName).ExecuteCommand();
// SqlSugarHelper.Db.Deleteable(delSets).AS(cableSetTableName).ExecuteCommand();
// }
// }
//}
#endregion
Db.CommitTran(); Db.CommitTran();
} }
catch (Exception ex) catch (Exception ex)
{ {
log4net.LogManager.GetLogger("ERROR").Error(ex.StackTrace + " || " + ex.Message); log4net.LogManager.GetLogger("ERROR").Error(ex.StackTrace + " || " + ex.Message);
Db.RollbackTran(); Db.RollbackTran();
if (ex is ExceptionEx) if (ex is ExceptionEx)
@ -2489,6 +2429,38 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
return current.DataItemName; return current.DataItemName;
} }
/// <summary>
/// 找到最上级的DataItemDetailID
/// </summary>
/// <param name="DtatTableName">表名</param>
/// <param name="strDataItemName">当前的DataItemName</param>
/// <returns>最上层的Name</returns>
public string GetTopParentDataItemDetailByID(string DtatTableName, string strDataItemDetailID)
{
// 先找到初始节点
var current = Db.Queryable<ec_dataitemdetailEntity>().AS(DtatTableName).Where(x => x.DataItemDetailID == strDataItemDetailID).First();
// 如果找不到,直接返回 null
if (current == null)
return null;
// 循环向上查找
while (current.UpDataItemDetailID != "0")
{
// upDataItemDetailID是上级节点的DataItemDetailID
var parent = Db.Queryable<ec_dataitemdetailEntity>().AS(DtatTableName).Where(x => x.DataItemDetailID == current.UpDataItemDetailID).First();
// 如果找不到就返回 null防止死循环
if (parent == null)
return null;
current = parent;
}
// 返回最上层的 DataItemDetailID也就是 0对应的ID
return current.DataItemDetailID;
}
/// <summary> /// <summary>
/// 过滤掉与图纸系统最上层不一致的 EngineDataID /// 过滤掉与图纸系统最上层不一致的 EngineDataID
/// </summary> /// </summary>
@ -2648,7 +2620,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
// 筛选出“真实设备”这里排除OPC、通讯器等中转对象 // 筛选出“真实设备”这里排除OPC、通讯器等中转对象
var deviceTags = endpointInfo var deviceTags = endpointInfo
.Where(x => !x.objectType.Contains("OPC")) .Where(x => !x.objectType.Contains(GlobalObject.objectType_OPC))
.Select(x => x.tagNumber) .Select(x => x.tagNumber)
.Distinct() .Distinct()
.Take(2) // 只取前两个设备 .Take(2) // 只取前两个设备
@ -2660,5 +2632,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
return result; return result;
} }
} }
} }

View File

@ -136,6 +136,12 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
UserInfo userInfo = LoginUserInfo.Get(); UserInfo userInfo = LoginUserInfo.Get();
this.CreateUserID = userInfo.userId; this.CreateUserID = userInfo.userId;
} }
public void Modify()
{
this.UpdateTime = Time.MySqlTime;
UserInfo userInfo = LoginUserInfo.Get();
this.UpdateUserID = userInfo.userId;
}
/// <summary> /// <summary>
/// 编辑调用 /// 编辑调用
/// </summary> /// </summary>

View File

@ -8,6 +8,7 @@ using System.Data;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;
using static Learun.Application.TwoDevelopment.ZZDT_EC.GlobalEnum;
using DbType = System.Data.DbType; using DbType = System.Data.DbType;
namespace Learun.Application.TwoDevelopment.ZZDT_EC namespace Learun.Application.TwoDevelopment.ZZDT_EC
@ -63,11 +64,11 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
WHERE t1.DataStatus != '00001' "); WHERE t1.DataStatus != '00001' ");
if (queryParam["ProjectId"].IsEmpty()) if (queryParam["ProjectId"].IsEmpty())
{ {
strSql.Append(" AND (select count(1) from ec_enginedata_pixel st2 where st2.EngineDataID = t1.EngineDataID) = 0 "); return new List<ec_enginedataEntity>();
} }
else else
{ {
strSql.Append($" AND (select count(1) from ec_enginedata_pixel_{ProjectEntity.ProjectIndex} st2 where st2.EngineDataID = t1.EngineDataID) = 0 "); //strSql.Append($" AND (select count(1) from ec_enginedata_pixel_{ProjectEntity.ProjectIndex} st2 where st2.EngineDataID = t1.EngineDataID) = 0 ");
} }
// 虚拟参数 // 虚拟参数
@ -89,7 +90,22 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
strSql.Append(" AND t1.DataStatus = @DataStatus "); strSql.Append(" AND t1.DataStatus = @DataStatus ");
} }
//return this.BaseRepository().FindList<ec_enginedataEntity>(strSql.ToString(), dp, pagination); //return this.BaseRepository().FindList<ec_enginedataEntity>(strSql.ToString(), dp, pagination);
return SqlSugarHelper.Db.SqlQueryable<ec_enginedataEntity>(strSql.ToString()).AddParameters(dp).ToPageList(pagination.page, pagination.rows); var sql = strSql.ToString();
var res = SqlSugarHelper.Db.SqlQueryable<ec_enginedataEntity>(sql).AddParameters(dp).ToPageList(pagination.page, pagination.rows);
var allTagIds = res.Select(x => x.EngineDataID).Distinct().ToList();
var pixelTbName = ProjectSugar.TableName<ec_enginedata_pixelEntity>(ProjectEntity.ProjectId);
var allPixels = SqlSugarHelper.Db.Queryable<ec_enginedata_pixelEntity>().AS(pixelTbName)
.Where(x => allTagIds.Contains(x.EngineDataID) && x.DeleteFlg !=1)
.ToList();
var allTagIdsHavingPixel = allPixels.Select(x => x.EngineDataID).Distinct().ToList();
var TagNotHavingPixel = allTagIds.Except(allTagIdsHavingPixel).ToList();
var res2 = res.Where(x => TagNotHavingPixel.Contains(x.EngineDataID)).ToList();
return res2;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -215,7 +231,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
} }
} }
} }
#endregion #endregion
@ -269,7 +285,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
SqlSugarHelper.Db.Deleteable(chs).AS($"ec_panel_channel_{ProjectEntity.ProjectIndex}").ExecuteCommand(); SqlSugarHelper.Db.Deleteable(chs).AS($"ec_panel_channel_{ProjectEntity.ProjectIndex}").ExecuteCommand();
//SqlSugarHelper.Db.Ado.ExecuteCommand($@" DELETE FROM ec_panel_channel_{ProjectEntity.ProjectIndex} WHERE PanelID = '{panel.PanelID}'"); //SqlSugarHelper.Db.Ado.ExecuteCommand($@" DELETE FROM ec_panel_channel_{ProjectEntity.ProjectIndex} WHERE PanelID = '{panel.PanelID}'");
var wts = SqlSugarHelper.Db.Queryable<ec_WireTerminalEntity>().AS($"ec_wire_terminal_{ProjectEntity.ProjectIndex}"). var wts = SqlSugarHelper.Db.Queryable<ec_WireTerminalEntity>().AS($"ec_wire_terminal_{ProjectEntity.ProjectIndex}").
Where(x => terms.Select(y=>y.TermID).Contains(x.TermID)).ToList(); Where(x => terms.Select(y => y.TermID).Contains(x.TermID)).ToList();
SqlSugarHelper.Db.Deleteable(wts).AS($"ec_wire_terminal_{ProjectEntity.ProjectIndex}").ExecuteCommand(); SqlSugarHelper.Db.Deleteable(wts).AS($"ec_wire_terminal_{ProjectEntity.ProjectIndex}").ExecuteCommand();
//SqlSugarHelper.Db.Ado.ExecuteCommand($@" DELETE FROM ec_wire_terminal_{ProjectEntity.ProjectIndex} WHERE PanelID = '{panel.PanelID}'"); //SqlSugarHelper.Db.Ado.ExecuteCommand($@" DELETE FROM ec_wire_terminal_{ProjectEntity.ProjectIndex} WHERE PanelID = '{panel.PanelID}'");
} }
@ -723,7 +739,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
} }
} }
/// <summary> /// <summary>
/// 更新工程数据属性默认值 /// 更新工程数据属性默认值
/// </summary> /// </summary>

View File

@ -199,11 +199,11 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
/// 获取列表数据 /// 获取列表数据
/// <summary> /// <summary>
/// <returns></returns> /// <returns></returns>
public IEnumerable<ec_enginedata_pixelEntity> GetList(string queryJson) public IEnumerable<ec_enginedata_pixelEntity> GetList(string queryJson,string projId)
{ {
try try
{ {
return ec_enginedata_pixelService.GetList(queryJson); return ec_enginedata_pixelService.GetList(queryJson,projId);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -400,7 +400,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
.LeftJoin<ec_enginedataEntity>((edp, ede) => edp.EngineDataID == ede.EngineDataID).AS<ec_enginedataEntity>(enginedataTableName) .LeftJoin<ec_enginedataEntity>((edp, ede) => edp.EngineDataID == ede.EngineDataID).AS<ec_enginedataEntity>(enginedataTableName)
.LeftJoin<ec_objecttypeEntity>((edp, ede, eot) => ede.ObjectTypeID == eot.ObjectTypeID).AS<ec_objecttypeEntity>(objectTypeTableName) .LeftJoin<ec_objecttypeEntity>((edp, ede, eot) => ede.ObjectTypeID == eot.ObjectTypeID).AS<ec_objecttypeEntity>(objectTypeTableName)
.Where((edp, ede, eot) => edp.DeleteFlg == 0 && edp.DrawingFileID == drawingFileID && pixelEntities.Select(y => y.PixelCode).Contains(edp.PixelCode) .Where((edp, ede, eot) => edp.DeleteFlg == 0 && edp.DrawingFileID == drawingFileID && pixelEntities.Select(y => y.PixelCode).Contains(edp.PixelCode)
&& !eot.FullPathCN.EndsWith("图框") && !eot.FullPathCN.EndsWith(GlobalObject.objectType_Base) && !eot.FullPathCN.EndsWith("OPC")) && !eot.FullPathCN.EndsWith("图框") && !eot.FullPathCN.EndsWith(GlobalObject.objectType_Base) && !eot.FullPathCN.EndsWith(GlobalObject.objectType_OPC))
.Select((edp, ede, eot) => edp.EngineDataID) .Select((edp, ede, eot) => edp.EngineDataID)
.Distinct() .Distinct()
.ToList(); .ToList();
@ -460,7 +460,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
// 获取所有需要处理的属性(只包含电缆对象,起始设备和终止设备) // 获取所有需要处理的属性(只包含电缆对象,起始设备和终止设备)
var cableProperties = AllPropsOfEng var cableProperties = AllPropsOfEng
.Where(x => x.ObjectTypeName.Contains("电缆") && .Where(x => x.ObjectTypeName.Contains("电缆") &&
(x.PropertyName == "起始设备" || x.PropertyName == "终止设备")) (x.PropertyName == GlobalObject.propName_From || x.PropertyName == GlobalObject.propName_To))
.ToList(); .ToList();
// 提取所有 CableID // 提取所有 CableID
@ -474,36 +474,34 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
{ {
if (cableRelDict.TryGetValue(changeprofromto.EngineDataID, out var conn)) if (cableRelDict.TryGetValue(changeprofromto.EngineDataID, out var conn))
{ {
if (changeprofromto.PropertyName == "起始设备") if (changeprofromto.PropertyName == GlobalObject.propName_From)
{ {
changeprofromto.PropertyValue = conn.End1Tag; changeprofromto.PropertyValue = conn.End1Tag;
} }
else if (changeprofromto.PropertyName == "终止设备") else if (changeprofromto.PropertyName == GlobalObject.propName_To)
{ {
changeprofromto.PropertyValue = conn.End2Tag; changeprofromto.PropertyValue = conn.End2Tag;
} }
} }
} }
// 构建一个字典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
.FirstOrDefault(x =>
x.EngineDataID == checkproperty.EngineDataID &&
x.PropertyID == checkproperty.PropertyID)
?.PropertyValue;
//foreach (var property in AllPropsOfEng)
//{
//如果ec_enginedata_propety里面的EngineDataID等于需要检查对象的EngineDataID且属性ID也能对上且属性值为空或者NULL则认为没有填写 //如果ec_enginedata_propety里面的EngineDataID等于需要检查对象的EngineDataID且属性ID也能对上且属性值为空或者NULL则认为没有填写
if (string.IsNullOrEmpty(PropertyValue) || PropertyValue == "0") if (string.IsNullOrEmpty(propertyValue) || propertyValue == "0")
{ {
errText = $"图面有对象【{checkproperty.TagNumber}】在即时更新阶段的必填属性【{checkproperty.PropertyName}】值为空,不能检入,请执行“属性检查”功能对图纸进行属性检查。"; errText = $"图面有对象【{checkproperty.TagNumber}】在即时更新阶段的必填属性【{checkproperty.PropertyName}】值为空,不能检入,请执行“属性检查”功能对图纸进行属性检查。";
return res = false; return res = false;
} }
//}
} }
else else
{ {
@ -525,7 +523,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
TagNumber = ee.TagNumber, TagNumber = ee.TagNumber,
ObjectTypeID = ee.ObjectTypeID, ObjectTypeID = ee.ObjectTypeID,
PropertyID = ote.PropertyID, PropertyID = ote.PropertyID,
PropertyName=epe.PropertyName, PropertyName = epe.PropertyName,
PropertyGID = epe.PropertyGID, PropertyGID = epe.PropertyGID,
IsRequired = ote.IsRequired, IsRequired = ote.IsRequired,
dependency_type = SqlFunc.IIF(SqlFunc.IsNullOrEmpty(ote.dependency_type), dependency_type.RequireNone, ote.dependency_type), dependency_type = SqlFunc.IIF(SqlFunc.IsNullOrEmpty(ote.dependency_type), dependency_type.RequireNone, ote.dependency_type),
@ -535,131 +533,140 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
ValueInGroup = false ValueInGroup = false
}) })
.ToList(); .ToList();
// ====== [1] 提前建索引避免循环里反复Where ======
// AllPropsOfEng 索引: (EngineDataID, PropertyID) -> 属性对象
var allPropsDict = AllPropsOfEng
.GroupBy(x => (x.EngineDataID, x.PropertyID))
.ToDictionary(g => g.Key, g => g.First());
// quaryNeedCheckPropertiesDependency 索引: (EngineDataID, PropertyID) -> Dependency对象
var depDict = quaryNeedCheckPropertiesDependency
.GroupBy(x => (x.EngineDataID, x.PropertyID))
.ToDictionary(g => g.Key, g => g.First());
// 索引: (PropertyID, ObjectTypeID) -> Dependency对象 (用于 RequireIf)
var depByPropObjDict = quaryNeedCheckPropertiesDependency
.GroupBy(x => (x.PropertyID, x.ObjectTypeID))
.ToDictionary(g => g.Key, g => g.First());
// 索引: (PropertyGID, EngineDataID) -> List<Dependency> (用于 RequireMutually)
var depByGroupDict = quaryNeedCheckPropertiesDependency
.GroupBy(x => (x.PropertyGID, x.EngineDataID))
.ToDictionary(g => g.Key, g => g.ToList());
foreach (var checkproperty in quaryNeedCheckPropertiesDependency) foreach (var checkproperty in quaryNeedCheckPropertiesDependency)
{ {
//先看前置属性必填的情况 // ----------------- RequireIfRequired -----------------
if (checkproperty.dependency_type == dependency_type.RequireIfRequired if (checkproperty.dependency_type == dependency_type.RequireIfRequired
&& !string.IsNullOrEmpty(checkproperty.trigger_property_id)) && !string.IsNullOrEmpty(checkproperty.trigger_property_id))
{ {
//获得关联对象是否必填 if (depDict.TryGetValue((checkproperty.EngineDataID, checkproperty.trigger_property_id), out var depObj)
var depObjIsNotRequired = quaryNeedCheckPropertiesDependency && depObj.IsRequired == 1 && checkproperty.IsRequired == 1)
.Where(x => x.EngineDataID == checkproperty.EngineDataID
&& x.PropertyID == checkproperty.trigger_property_id)
.Select(x => x.IsRequired)
.FirstOrDefault();
//如果关联对象是必填的那么就需要检查属性本身的值是不是空或者0
if (depObjIsNotRequired == 1 && checkproperty.IsRequired == 1)//前置属性即时更新版必填的话自己的即时更新版也必填不然本身自己也显示不到EXCEL里面
{ {
var PropertyValue = AllPropsOfEng if (allPropsDict.TryGetValue((checkproperty.EngineDataID, checkproperty.PropertyID), out var prop))
.FirstOrDefault(x => {
x.EngineDataID == checkproperty.EngineDataID && var value = prop.PropertyValue;
x.PropertyID == checkproperty.PropertyID) if (string.IsNullOrEmpty(value) || value == "0")
?.PropertyValue;
//foreach (var property in AllPropsOfEng.Where(x=>x.EngineDataID.Equals(checkproperty.EngineDataID)))
//{
//判断当前属性的值是不是为空、为NULL还是为0如果是的话报错
if (string.IsNullOrEmpty(PropertyValue) || PropertyValue == "0")
{ {
errText = $"图面有对象【{checkproperty.TagNumber}】,其前置属性设置了必填,所以属性【{checkproperty.PropertyName}】本身也必须填值,不然不能检入,请执行“属性检查”功能对图纸进行属性检查。"; errText = $"图面有对象【{checkproperty.TagNumber}】,其前置属性设置了必填,所以属性【{checkproperty.PropertyName}】本身也必须填值,不然不能检入,请执行“属性检查”功能对图纸进行属性检查。";
return res = false; return res = false;
} }
//} }
} }
} }
//前置属性符合某种条件时 // ----------------- RequireIf -----------------
if (checkproperty.dependency_type == dependency_type.RequireIf if (checkproperty.dependency_type == dependency_type.RequireIf
&& !string.IsNullOrEmpty(checkproperty.trigger_property_id) && !string.IsNullOrEmpty(checkproperty.trigger_property_id)
&& !string.IsNullOrEmpty(checkproperty.trigger_operator) && !string.IsNullOrEmpty(checkproperty.trigger_operator)
&& !string.IsNullOrEmpty(checkproperty.trigger_value)) && !string.IsNullOrEmpty(checkproperty.trigger_value))
{ {
var triggerOperator = checkproperty.trigger_operator;
var triggerValue = checkproperty.trigger_value;
var triggerPropertyId = checkproperty.trigger_property_id; var triggerPropertyId = checkproperty.trigger_property_id;
//先从该对象的属性列表里面找前置条件的那个属性如果没有找到证明前置属性为NULL就是空那么也就不用继续考虑本身是不是为空了
if (AllPropsOfEng.Where(x => x.EngineDataID == checkproperty.EngineDataID).Select(x => x.PropertyID).Contains(triggerPropertyId)) // 如果前置属性在 AllProps 里面找不到,就直接跳过
if (allPropsDict.ContainsKey((checkproperty.EngineDataID, triggerPropertyId)))
{ {
//找到上级的Isrequired值 if (depByPropObjDict.TryGetValue((triggerPropertyId, checkproperty.ObjectTypeID), out var upObj)
var upObjectIsRequired = quaryNeedCheckPropertiesDependency.Where(x => x.PropertyID.Equals(triggerPropertyId) && x.ObjectTypeID.Equals(checkproperty.ObjectTypeID)).Select(x => x.IsRequired).FirstOrDefault(); && upObj.IsRequired == 1 && checkproperty.IsRequired == 1)
//当前属性的IsRequired和上级的IsRequired都是即时更新版必填时才可以去做检入时检查
if (upObjectIsRequired == 1 && checkproperty.IsRequired == 1)
{ {
var PropertyValue = AllPropsOfEng // 当前属性值
.FirstOrDefault(x => string propertyValue = allPropsDict.TryGetValue((checkproperty.EngineDataID, checkproperty.PropertyID), out var prop)
x.EngineDataID == checkproperty.EngineDataID && ? prop.PropertyValue : null;
x.PropertyID == checkproperty.PropertyID)
?.PropertyValue; if (string.IsNullOrEmpty(propertyValue) || propertyValue == "0")
//进入循环了,证明能找到前置属性 {
//foreach (var property in AllPropsOfEng) // 找上级属性值
//{ if (!allPropsDict.TryGetValue((checkproperty.EngineDataID, triggerPropertyId), out var upProp))
//先判断当前属性值是不是空或者0不是的话也就不用去进一步判断了如果是空或者0则去看她的前置属性
if (string.IsNullOrEmpty(PropertyValue) || PropertyValue == "0")
{ {
//取当前属性的上级联动属性值 errText = $"图面对象【{checkproperty.TagNumber}】,其属性【{checkproperty.PropertyName}】的前置属性【{triggerPropertyId}】找不到。请管理员确认。";
var upPropertyValue = AllPropsOfEng?.Where(x => return res = false;
x?.EngineDataID != null
&& x.PropertyID != null
&& x.EngineDataID.Equals(checkproperty?.EngineDataID)
&& x.PropertyID.Equals(triggerPropertyId)).FirstOrDefault();
if (upPropertyValue == null)
{
errText = $"图面对象【{checkproperty.TagNumber}】,其属性【{checkproperty.PropertyName}】的前置属性【{triggerPropertyId}】找不到。请管理员确认。";
return res = false;
}
//如果上级属性值符合条件那么同时根据上面的判断当前属性值不是空就是0那么需要报错
if ((triggerOperator == "=" && upPropertyValue.PropertyValue.ToUpper().Equals(triggerValue.ToUpper())) ||
(triggerOperator == ">" && double.Parse(upPropertyValue.PropertyValue) > double.Parse(triggerValue)) ||
(triggerOperator == "<" && double.Parse(upPropertyValue.PropertyValue) < double.Parse(triggerValue)) ||
(triggerOperator == "!=" && !upPropertyValue.PropertyValue.ToUpper().Equals(triggerValue.ToUpper())))
{
errText = $"图面有对象【{checkproperty.TagNumber}】,其前置属性【{upPropertyValue.PropertyName}】符合{triggerOperator}条件,所以属性本身【{checkproperty.PropertyName}】必须填值,不然不能检入,请执行“属性检查”功能对图纸进行属性检查。";
return res = false;
}
} }
//}
// 判断触发条件
bool conditionMet = false;
var triggerValue = checkproperty.trigger_value;
var triggerOperator = checkproperty.trigger_operator;
switch (triggerOperator)
{
case "=":
conditionMet = upProp.PropertyValue?.Equals(triggerValue, StringComparison.OrdinalIgnoreCase) == true;
break;
case "!=":
conditionMet = !upProp.PropertyValue?.Equals(triggerValue, StringComparison.OrdinalIgnoreCase) == true;
break;
case ">":
if (double.TryParse(upProp.PropertyValue, out var upVal) &&
double.TryParse(triggerValue, out var trgVal))
conditionMet = upVal > trgVal;
break;
case "<":
if (double.TryParse(upProp.PropertyValue, out var upVal2) &&
double.TryParse(triggerValue, out var trgVal2))
conditionMet = upVal2 < trgVal2;
break;
}
if (conditionMet)
{
errText = $"图面有对象【{checkproperty.TagNumber}】,其前置属性【{upProp.PropertyName}】符合{triggerOperator}条件,所以属性本身【{checkproperty.PropertyName}】必须填值,不然不能检入,请执行“属性检查”功能对图纸进行属性检查。";
return res = false;
}
}
} }
} }
} }
//最后看组内互斥,检入的话只检查即时更新版的 // ----------------- RequireMutually -----------------
if (checkproperty.dependency_type == dependency_type.RequireMutually if (checkproperty.dependency_type == dependency_type.RequireMutually
&& checkproperty.ValueInGroup == false && checkproperty.ValueInGroup == false
&& checkproperty.IsRequired==1) && checkproperty.IsRequired == 1)
{ {
var PgID = string.Empty; if (allPropsDict.TryGetValue((checkproperty.EngineDataID, checkproperty.PropertyID), out var prop))
//如果ec_enginedata_propety里面没有必填属性要求的这个属性就代表没有保存认为是没有填值为空
if (AllPropsOfEng.Where(x => x.EngineDataID == checkproperty.EngineDataID).Select(x => x.PropertyID).Contains(checkproperty.PropertyID))
{ {
var PropertyValue = AllPropsOfEng var value = prop.PropertyValue;
.FirstOrDefault(x => if (!string.IsNullOrEmpty(value) && value != "0")
x.EngineDataID == checkproperty.EngineDataID &&
x.PropertyID == checkproperty.PropertyID)
?.PropertyValue;
//foreach (var property in AllPropsOfEng)
//{
//如果ec_enginedata_propety里面的EngineDataID等于需要检查对象的EngineDataID且属性ID也能对上也属于同一group且属性值为空或者NULL则认为没有填写
if (!string.IsNullOrEmpty(PropertyValue) && PropertyValue != "0")
{
PgID = checkproperty.PropertyGID;//获得有属性值的属性组ID
//break;
}
//}
if (!string.IsNullOrEmpty(PgID))
{ {
foreach (var propertyvalue in quaryNeedCheckPropertiesDependency // 有属性值 → 找到组
.Where(x => x.PropertyGID == PgID var groupKey = (checkproperty.PropertyGID, checkproperty.EngineDataID);
&& x.EngineDataID == checkproperty.EngineDataID if (depByGroupDict.TryGetValue(groupKey, out var groupList))
&& x.dependency_type == dependency_type.RequireMutually))
{ {
//把这个对象上只要属于这个检查组的ValueInGroup都打上标记代表检查组里面至少有一个属性是有值的 foreach (var dep in groupList)
propertyvalue.ValueInGroup = true; {
dep.ValueInGroup = true;
}
} }
} }
} }
} }
} }
var lstValueGroup = quaryNeedCheckPropertiesDependency.Where(x => x.dependency_type == dependency_type.RequireMutually && x.IsRequired== 1).Select(x => new { x.ValueInGroup, x.EngineDataID }).Distinct().ToList(); // ====== [3] 组内互斥最后检查 ======
var lstValueGroup = quaryNeedCheckPropertiesDependency
.Where(x => x.dependency_type == dependency_type.RequireMutually && x.IsRequired == 1)
.Select(x => new { x.ValueInGroup, x.EngineDataID })
.Distinct()
.ToList();
foreach (var item in lstValueGroup) foreach (var item in lstValueGroup)
{ {
if (item.ValueInGroup == false) if (item.ValueInGroup == false)
@ -753,7 +760,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
.LeftJoin<ec_enginedataEntity>((edp, ede) => edp.EngineDataID == ede.EngineDataID).AS<ec_enginedataEntity>(enginedataTableName) .LeftJoin<ec_enginedataEntity>((edp, ede) => edp.EngineDataID == ede.EngineDataID).AS<ec_enginedataEntity>(enginedataTableName)
.LeftJoin<ec_objecttypeEntity>((edp, ede, eot) => ede.ObjectTypeID == eot.ObjectTypeID).AS<ec_objecttypeEntity>(objectTypeTableName) .LeftJoin<ec_objecttypeEntity>((edp, ede, eot) => ede.ObjectTypeID == eot.ObjectTypeID).AS<ec_objecttypeEntity>(objectTypeTableName)
.Where((edp, ede, eot) => edp.DeleteFlg == 0 && edp.DrawingFileID == drawingFileID .Where((edp, ede, eot) => edp.DeleteFlg == 0 && edp.DrawingFileID == drawingFileID
&& !eot.FullPathCN.EndsWith("图框") && !eot.FullPathCN.EndsWith(GlobalObject.objectType_Base) && !eot.FullPathCN.EndsWith("OPC")) && !eot.FullPathCN.EndsWith("图框") && !eot.FullPathCN.EndsWith(GlobalObject.objectType_Base) && !eot.FullPathCN.EndsWith(GlobalObject.objectType_OPC))
.Select((edp, ede, eot) => edp.EngineDataID) .Select((edp, ede, eot) => edp.EngineDataID)
.Distinct() .Distinct()
.ToList(); .ToList();
@ -812,7 +819,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
// 获取所有需要处理的属性(只包含电缆对象,起始设备和终止设备) // 获取所有需要处理的属性(只包含电缆对象,起始设备和终止设备)
var cableProperties = quaryPropertiesOfEng var cableProperties = quaryPropertiesOfEng
.Where(x => x.ObjectTypeName.Contains("电缆") && .Where(x => x.ObjectTypeName.Contains("电缆") &&
(x.PropertyName == "起始设备" || x.PropertyName == "终止设备")) (x.PropertyName == GlobalObject.propName_From || x.PropertyName == GlobalObject.propName_To))
.ToList(); .ToList();
// 提取所有 CableID // 提取所有 CableID
@ -826,16 +833,17 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
{ {
if (cableRelDict.TryGetValue(changeprofromto.EngineDataID, out var conn)) if (cableRelDict.TryGetValue(changeprofromto.EngineDataID, out var conn))
{ {
if (changeprofromto.PropertyName == "起始设备") if (changeprofromto.PropertyName == GlobalObject.propName_From)
{ {
changeprofromto.PropertyValue = conn.End1Tag; changeprofromto.PropertyValue = conn.End1Tag;
} }
else if (changeprofromto.PropertyName == "终止设备") else if (changeprofromto.PropertyName == GlobalObject.propName_To)
{ {
changeprofromto.PropertyValue = conn.End2Tag; changeprofromto.PropertyValue = conn.End2Tag;
} }
} }
} }
//没有依赖对象但要必填的循环 //没有依赖对象但要必填的循环
foreach (var checkproperty in quaryNeedCheckProperties) foreach (var checkproperty in quaryNeedCheckProperties)
{ {
@ -849,12 +857,12 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
?.PropertyValue; ?.PropertyValue;
//foreach (var property in quaryPropertiesOfEng) //foreach (var property in quaryPropertiesOfEng)
//{ //{
//如果ec_enginedata_propety里面的EngineDataID等于需要检查对象的EngineDataID且属性ID也能对上且属性值为空或者NULL则认为没有填写 //如果ec_enginedata_propety里面的EngineDataID等于需要检查对象的EngineDataID且属性ID也能对上且属性值为空或者NULL则认为没有填写
if (string.IsNullOrEmpty(PropertyValue) || PropertyValue == "0") if (string.IsNullOrEmpty(PropertyValue) || PropertyValue == "0")
{ {
errText = "图面有对象在" + reversion + "阶段或者之前阶段的必填属性值为空,不能发布,请执行“属性检查”功能对图纸进行属性检查。"; errText = "图面有对象在" + reversion + "阶段或者之前阶段的必填属性值为空,不能发布,请执行“属性检查”功能对图纸进行属性检查。";
return res = false; return res = false;
} }
//} //}
} }
else else
@ -909,12 +917,12 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
?.PropertyValue; ?.PropertyValue;
//foreach (var property in quaryPropertiesOfEng) //foreach (var property in quaryPropertiesOfEng)
//{ //{
//判断当前属性的值是不是为空、为NULL还是为0如果是的话报错 //判断当前属性的值是不是为空、为NULL还是为0如果是的话报错
if (string.IsNullOrEmpty(PropertyValue) || PropertyValue == "0") if (string.IsNullOrEmpty(PropertyValue) || PropertyValue == "0")
{ {
errText = "图面有对象她的前置属性在" + reversion + "阶段或者再之前阶段设置了必填,所以她必须填值,不然不能发布,请执行“属性检查”功能对图纸进行属性检查。"; errText = "图面有对象她的前置属性在" + reversion + "阶段或者再之前阶段设置了必填,所以她必须填值,不然不能发布,请执行“属性检查”功能对图纸进行属性检查。";
return res = false; return res = false;
} }
//} //}
} }
} }
@ -945,26 +953,26 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
//进入循环了,证明能找到前置属性 //进入循环了,证明能找到前置属性
//foreach (var property in quaryPropertiesOfEng) //foreach (var property in quaryPropertiesOfEng)
//{ //{
//先判断当前属性值是不是空或者0不是的话也就不用去进一步判断了如果是空或者0则去看她的前置属性 //先判断当前属性值是不是空或者0不是的话也就不用去进一步判断了如果是空或者0则去看她的前置属性
if (string.IsNullOrEmpty(PropertyValue) || PropertyValue == "0") if (string.IsNullOrEmpty(PropertyValue) || PropertyValue == "0")
{
//取当前属性的上级联动属性值
var upPropertyValue = quaryPropertiesOfEng?.Where(x =>
x?.EngineDataID != null
&& x.PropertyID != null
&& x.EngineDataID.Equals(checkproperty?.EngineDataID)
&& x.PropertyID.Equals(triggerPropertyId))
.Select(x => x.PropertyValue).FirstOrDefault();
//如果上级属性值符合条件那么同时根据上面的判断当前属性值不是空就是0那么需要报错
if ((triggerOperator == "=" && upPropertyValue.ToUpper().Equals(triggerValue.ToUpper())) ||
(triggerOperator == ">" && double.Parse(upPropertyValue) > double.Parse(triggerValue)) ||
(triggerOperator == "<" && double.Parse(upPropertyValue) < double.Parse(triggerValue)) ||
(triggerOperator == "!=" && !upPropertyValue.ToUpper().Equals(triggerValue.ToUpper())))
{ {
//取当前属性的上级联动属性值 errText = "图面有对象她的前置属性符合某种条件,所以她必须填值,不然不能在" + reversion + "阶段发布,请执行“属性检查”功能对图纸进行属性检查。";
var upPropertyValue = quaryPropertiesOfEng?.Where(x => return res = false;
x?.EngineDataID != null
&& x.PropertyID != null
&& x.EngineDataID.Equals(checkproperty?.EngineDataID)
&& x.PropertyID.Equals(triggerPropertyId))
.Select(x => x.PropertyValue).FirstOrDefault();
//如果上级属性值符合条件那么同时根据上面的判断当前属性值不是空就是0那么需要报错
if ((triggerOperator == "=" && upPropertyValue.ToUpper().Equals(triggerValue.ToUpper())) ||
(triggerOperator == ">" && double.Parse(upPropertyValue) > double.Parse(triggerValue)) ||
(triggerOperator == "<" && double.Parse(upPropertyValue) < double.Parse(triggerValue)) ||
(triggerOperator == "!=" && !upPropertyValue.ToUpper().Equals(triggerValue.ToUpper())))
{
errText = "图面有对象她的前置属性符合某种条件,所以她必须填值,不然不能在" + reversion + "阶段发布,请执行“属性检查”功能对图纸进行属性检查。";
return res = false;
}
} }
}
//} //}
} }
} }
@ -985,12 +993,12 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
?.PropertyValue; ?.PropertyValue;
//foreach (var property in quaryPropertiesOfEng) //foreach (var property in quaryPropertiesOfEng)
//{ //{
//如果ec_enginedata_propety里面的EngineDataID等于需要检查对象的EngineDataID且属性ID也能对上也属于同一group且属性值为空或者NULL则认为没有填写 //如果ec_enginedata_propety里面的EngineDataID等于需要检查对象的EngineDataID且属性ID也能对上也属于同一group且属性值为空或者NULL则认为没有填写
if (!string.IsNullOrEmpty(PropertyValue) && PropertyValue != "0") if (!string.IsNullOrEmpty(PropertyValue) && PropertyValue != "0")
{ {
PgID = checkproperty.PropertyGID;//获得有属性值的属性组ID PgID = checkproperty.PropertyGID;//获得有属性值的属性组ID
//break; //break;
} }
//} //}
if (!string.IsNullOrEmpty(PgID)) if (!string.IsNullOrEmpty(PgID))
{ {
@ -1007,7 +1015,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
} }
} }
var lstValueGroup = quaryNeedCheckPropertiesDependency.Where(x => x.dependency_type == dependency_type.RequireMutually && x.IsRequired<=period).Select(x => x.ValueInGroup).Distinct().ToList(); var lstValueGroup = quaryNeedCheckPropertiesDependency.Where(x => x.dependency_type == dependency_type.RequireMutually && x.IsRequired <= period).Select(x => x.ValueInGroup).Distinct().ToList();
foreach (var item in lstValueGroup) foreach (var item in lstValueGroup)
{ {
if (item == false) if (item == false)
@ -1032,7 +1040,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
/// <param name="DtatTableName">表名</param> /// <param name="DtatTableName">表名</param>
/// <param name="strDataItemName">当前的DataItemName</param> /// <param name="strDataItemName">当前的DataItemName</param>
/// <returns>最上层的Name</returns> /// <returns>最上层的Name</returns>
public string GetTopParentDataItemDetail(string DtatTableName, string strDataItemName) private string GetTopParentDataItemDetail(string DtatTableName, string strDataItemName)
{ {
// 先找到初始节点 // 先找到初始节点
var current = SqlSugarHelper.Db.Queryable<ec_dataitemdetailEntity>().AS(DtatTableName).Where(x => x.DataItemName == strDataItemName).First(); var current = SqlSugarHelper.Db.Queryable<ec_dataitemdetailEntity>().AS(DtatTableName).Where(x => x.DataItemName == strDataItemName).First();
@ -1150,7 +1158,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
/// <param name="cableIds">电缆IDLIST</param> /// <param name="cableIds">电缆IDLIST</param>
/// <param name="projectId">项目编号</param> /// <param name="projectId">项目编号</param>
/// <returns>电缆连接信息</returns> /// <returns>电缆连接信息</returns>
public List<CableConnRes> GetCableConnListBatch(List<string> cableIds, string projectId) private List<CableConnRes> GetCableConnListBatch(List<string> cableIds, string projectId)
{ {
ec_enginedata_relBLL relbll = new ec_enginedata_relBLL(); ec_enginedata_relBLL relbll = new ec_enginedata_relBLL();
var allRel = relbll.GetList($"{{ProjectId:\"{projectId}\", RelType:\"{(int)enum_RelType.设备_电缆}\"}}") var allRel = relbll.GetList($"{{ProjectId:\"{projectId}\", RelType:\"{(int)enum_RelType.设备_电缆}\"}}")
@ -1212,7 +1220,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
// 筛选出“真实设备”这里排除OPC、通讯器等中转对象 // 筛选出“真实设备”这里排除OPC、通讯器等中转对象
var deviceTags = endpointInfo var deviceTags = endpointInfo
.Where(x => !x.objectType?.Contains("OPC")??false) .Where(x => !x.objectType?.Contains(GlobalObject.objectType_OPC) ?? false)
.Select(x => x.tagNumber) .Select(x => x.tagNumber)
.Where(tag => !string.IsNullOrWhiteSpace(tag)) .Where(tag => !string.IsNullOrWhiteSpace(tag))
.Distinct() .Distinct()

View File

@ -19,7 +19,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
/// 获取列表数据 /// 获取列表数据
/// <summary> /// <summary>
/// <returns></returns> /// <returns></returns>
IEnumerable<ec_enginedata_pixelEntity> GetList(string queryJson); IEnumerable<ec_enginedata_pixelEntity> GetList(string queryJson,string projId);
/// <summary> /// <summary>
/// 获取工程数据图元表数据 /// 获取工程数据图元表数据
/// <summary> /// <summary>

View File

@ -78,7 +78,7 @@ left JOIN ec_enginedata_{ProjectEntity.ProjectIndex} t3 ON t3.EngineDataID = t1.
/// <summary> /// <summary>
/// <param name="NeedDeleted">是否需要查询出被删的</param> /// <param name="NeedDeleted">是否需要查询出被删的</param>
/// <returns></returns> /// <returns></returns>
public IEnumerable<ec_enginedata_pixelEntity> GetList(string queryJson, bool NeedDeleted = false) public IEnumerable<ec_enginedata_pixelEntity> GetList(string queryJson, string projId, bool NeedDeleted = false)
{ {
try try
{ {
@ -93,7 +93,7 @@ left JOIN ec_enginedata_{ProjectEntity.ProjectIndex} t3 ON t3.EngineDataID = t1.
else else
{ {
//var ProjectEntity = this.BaseRepository().FindEntity<ec_projectEntity>(queryParam["ProjectId"].ToString()); //var ProjectEntity = this.BaseRepository().FindEntity<ec_projectEntity>(queryParam["ProjectId"].ToString());
var ProjectEntity = new ec_projectBLL().GetEntity(queryParam["ProjectId"].ToString()); var ProjectEntity = new ec_projectBLL().GetEntity(projId);
strSql.Append($@" FROM ec_enginedata_pixel_{ProjectEntity.ProjectIndex} t1 strSql.Append($@" FROM ec_enginedata_pixel_{ProjectEntity.ProjectIndex} t1
JOIN ec_drawing_file_{ProjectEntity.ProjectIndex} t2 ON t2.DrawingFileID = t1.DrawingFileID JOIN ec_drawing_file_{ProjectEntity.ProjectIndex} t2 ON t2.DrawingFileID = t1.DrawingFileID
JOIN ec_enginedata_{ProjectEntity.ProjectIndex} t3 ON t3.EngineDataID = t1.EngineDataID JOIN ec_enginedata_{ProjectEntity.ProjectIndex} t3 ON t3.EngineDataID = t1.EngineDataID
@ -553,8 +553,12 @@ left JOIN ec_enginedata_{ProjectEntity.ProjectIndex} t3 ON t3.EngineDataID = t1.
SqlSugarHelper.Db.BeginTran(); SqlSugarHelper.Db.BeginTran();
try try
{ {
if (string.IsNullOrWhiteSpace(ProjectId))
{
return;
}
//获取某个图纸上的图元数据 //获取某个图纸上的图元数据
var existPixels = this.GetList("{\"ProjectId\":\"" + ProjectId + "\",\"DrawingFileID\":\"" + drawingFileID + "\"}", true).ToList(); var existPixels = this.GetList("{\"ProjectId\":\"" + ProjectId + "\",\"DrawingFileID\":\"" + drawingFileID + "\"}", ProjectId, true).ToList();
ec_projectEntity ProjectEntity = new ec_projectEntity(); ec_projectEntity ProjectEntity = new ec_projectEntity();
if (!string.IsNullOrWhiteSpace(ProjectId)) if (!string.IsNullOrWhiteSpace(ProjectId))
{ {
@ -583,32 +587,42 @@ left JOIN ec_enginedata_{ProjectEntity.ProjectIndex} t3 ON t3.EngineDataID = t1.
//存在 //存在
it.DeleteFlg = 0; it.DeleteFlg = 0;
} }
} }
_enginedataPixelRepository.AsUpdateable(existPixels).AS($"ec_enginedata_pixel_{ProjectEntity.ProjectIndex}").ExecuteCommand(); _enginedataPixelRepository.AsUpdateable(existPixels).AS($"ec_enginedata_pixel_{ProjectEntity.ProjectIndex}").ExecuteCommand();//batch commit
if (string.IsNullOrWhiteSpace(ProjectId))
//db.ExecuteBySql($@"UPDATE ec_enginedata_{ ProjectEntity.ProjectIndex} T1
// SET DataStatus = '00001'
// WHERE (SELECT COUNT(*) FROM ec_enginedata_pixel_{ ProjectEntity.ProjectIndex} WHERE EngineDataID = T1.EngineDataID ) <= 0");
//db.ExecuteBySql($@"UPDATE ec_enginedata_{ProjectEntity.ProjectIndex} T1
// SET DataStatus = '00002'
// WHERE (SELECT COUNT(*) FROM ec_enginedata_pixel_{ProjectEntity.ProjectIndex} WHERE EngineDataID = T1.EngineDataID ) > 0 AND DataStatus != '00003'");
var tagTbName = TableName<ec_enginedataEntity>(ProjectId);
var tags = SqlSugarHelper.Db.Queryable<ec_enginedataEntity>().AS(tagTbName).
Where(t => existPixels.Select(x => x.EngineDataID).Distinct().Contains(t.EngineDataID) && t.DataStatus != "00003").ToList();
foreach (var tag in tags)
{ {
tag.DataStatus = "00002";tag.Modify();
} }
else
{
//db.ExecuteBySql($@"UPDATE ec_enginedata_{ ProjectEntity.ProjectIndex} T1
// SET DataStatus = '00001'
// WHERE (SELECT COUNT(*) FROM ec_enginedata_pixel_{ ProjectEntity.ProjectIndex} WHERE EngineDataID = T1.EngineDataID ) <= 0");
//db.ExecuteBySql($@"UPDATE ec_enginedata_{ProjectEntity.ProjectIndex} T1
// SET DataStatus = '00002'
// WHERE (SELECT COUNT(*) FROM ec_enginedata_pixel_{ProjectEntity.ProjectIndex} WHERE EngineDataID = T1.EngineDataID ) > 0 AND DataStatus != '00003'");
foreach (var EngineDataID in existPixels.Select(x => x.EngineDataID).Distinct()) SqlSugarHelper.Db.Updateable(tags).AS(tagTbName).UpdateColumns(x => x.DataStatus).ExecuteCommand();
{ //foreach (var EngineDataID in existPixels.Select(x => x.EngineDataID).Distinct())
if (EngineDataID != null) //{
{ // if (EngineDataID != null)
SqlSugarHelper.Db.Ado.ExecuteCommand($@"UPDATE ec_enginedata_{ProjectEntity.ProjectIndex} T1 // {
SET DataStatus = '00002' // SqlSugarHelper.Db.Ado.ExecuteCommand($@"UPDATE ec_enginedata_{ProjectEntity.ProjectIndex} T1
WHERE DataStatus != '00003' and EngineDataID='{EngineDataID}'"); // SET DataStatus = '00002'
} // WHERE DataStatus != '00003' and EngineDataID='{EngineDataID}'");
// }
}; //}
} //;
SqlSugarHelper.Db.CommitTran(); SqlSugarHelper.Db.CommitTran();
} }

View File

@ -13,7 +13,7 @@ using System.Data;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using static Learun.Application.TwoDevelopment.ZZDT_EC.ProjectSugar; using static Learun.Application.TwoDevelopment.ZZDT_EC.ProjectSugar;
using static Learun.Util.SqlSugar.SqlSugarHelper; using static Learun.Util.SqlSugar.SqlSugarHelper;
@ -79,7 +79,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
Where(x => x.DeleteFlg != 1).ToList(); Where(x => x.DeleteFlg != 1).ToList();
var relTypeTbName = ProjectSugar.TableName<ec_reltypeEntity>(projId); var relTypeTbName = ProjectSugar.TableName<ec_reltypeEntity>(projId);
var relType = Db.Queryable<ec_reltypeEntity>().AS(relTypeTbName).ToList().FirstOrDefault(x => x.RelType == ((int)enum_RelType._电缆).ToString()); var relType = Db.Queryable<ec_reltypeEntity>().AS(relTypeTbName).ToList().FirstOrDefault(x => x.RelType == enum_RelType._电缆);
var propBll = new ec_enginedata_propertyBLL(); var propBll = new ec_enginedata_propertyBLL();
@ -176,7 +176,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
Where(x => x.DeleteFlg != 1).ToList(); Where(x => x.DeleteFlg != 1).ToList();
var relTypeTbName = ProjectSugar.TableName<ec_reltypeEntity>(projId); var relTypeTbName = ProjectSugar.TableName<ec_reltypeEntity>(projId);
var relType = Db.Queryable<ec_reltypeEntity>().AS(relTypeTbName).ToList().FirstOrDefault(x => x.RelType == ((int)enum_RelType._电缆).ToString()); var relType = Db.Queryable<ec_reltypeEntity>().AS(relTypeTbName).ToList().FirstOrDefault(x => x.RelType == enum_RelType._电缆);
var allTagProps = SqlSugarHelper.Db.Queryable<ec_enginedata_propertyEntity>().AS(propTbName).ToList(); var allTagProps = SqlSugarHelper.Db.Queryable<ec_enginedata_propertyEntity>().AS(propTbName).ToList();
@ -1348,7 +1348,7 @@ Select((a, b, c) => new
//根据句柄和图纸先把工程id查出来先 //根据句柄和图纸先把工程id查出来先
var drawingID = CablePixelID.DrawingID; var drawingID = CablePixelID.DrawingID;
var pixelID = CablePixelID.CablePixelID; var pixelID = CablePixelID.CablePixelID;
var EngineDataIDs = pixelServ.GetList("{\"ProjectId\":\"" + ProjectId + "\",\"PixelCode\":\"" + pixelID + "\",\"DrawingFileID\":\"" + drawingID + "\"}"). var EngineDataIDs = pixelServ.GetList("{\"ProjectId\":\"" + ProjectId + "\",\"PixelCode\":\"" + pixelID + "\",\"DrawingFileID\":\"" + drawingID + "\"}", ProjectId).
Select(x => x.EngineDataID).Distinct(); Select(x => x.EngineDataID).Distinct();
if (EngineDataIDs != null && EngineDataIDs.Count() == 1) if (EngineDataIDs != null && EngineDataIDs.Count() == 1)
{ {
@ -1395,7 +1395,19 @@ Select((a, b, c) => new
var End2 = new ec_enginedata_relEntity(); var End2 = new ec_enginedata_relEntity();
//查单一记录 //查单一记录
var existRel = this.GetList("{ProjectId:\"" + ProjectId + "\",RelType:\"" + (int)enum_RelType._电缆 + "\",RelEngineDataID:\"" + CableID + "\"}").ToList(); var existRel = this.GetList("{ProjectId:\"" + ProjectId + "\",RelType:\"" + (int)enum_RelType._电缆 + "\",RelEngineDataID:\"" + CableID + "\"}").ToList();
if (existRel.Any(x => !string.IsNullOrEmpty(x.OPCPixel))) //需要换判断了,现在所有东西都有存这个
var tagIds = existRel.Select(x => x.RelEngineData1ID).ToList();
tagIds.AddRange(existRel.Select(x => x.RelEngineData2ID).ToList());
tagIds = tagIds.Where(X => X != CableID).Distinct().ToList();
var tbName = ProjectSugar.TableName<ec_enginedataEntity>(ProjectId);
var typeTbName = ProjectSugar.TableName<ec_objecttypeEntity>(ProjectId);
var tags = SqlSugarHelper.Db.Queryable<ec_enginedataEntity>().AS(tbName).
InnerJoin<ec_objecttypeEntity>((t, t2) => t.ObjectTypeID == t2.ObjectTypeID).AS<ec_objecttypeEntity>(typeTbName).
Where(t => tagIds.Contains(t.EngineDataID)).
Select((t, t2) => new { t.EngineDataID, t.TagNumber, t2.ObjectTypeName }).ToList();
if (tags.Any(x => x.ObjectTypeName == GlobalObject.objectType_OPC))
{ {
//OPC //OPC
var tb = ProjectSugar.TableName<ec_enginedata_pixelEntity>(ProjectId); var tb = ProjectSugar.TableName<ec_enginedata_pixelEntity>(ProjectId);
@ -1420,6 +1432,7 @@ Select((a, b, c) => new
} }
else else
{ {
//正常情况
existRel = existRel.Where(X => X.RelEngineData1ID != opcId.EngineDataID && X.RelEngineData2ID != opcId.EngineDataID).ToList();//排除opc的留下电缆的 existRel = existRel.Where(X => X.RelEngineData1ID != opcId.EngineDataID && X.RelEngineData2ID != opcId.EngineDataID).ToList();//排除opc的留下电缆的
} }
} }
@ -1444,11 +1457,11 @@ Select((a, b, c) => new
} }
public class ec_enginedataEntity_2: ec_enginedataEntity public class ec_enginedataEntity_2 : ec_enginedataEntity
{ {
} }
public class ec_objecttypeEntity_2: ec_objecttypeEntity public class ec_objecttypeEntity_2 : ec_objecttypeEntity
{ {
} }
@ -1470,6 +1483,11 @@ Select((a, b, c) => new
var RelEngineData2ID = queryParam["RelEngineData2ID"]?.ToString(); var RelEngineData2ID = queryParam["RelEngineData2ID"]?.ToString();
var RelTypeName = queryParam["RelTypeName"]?.ToString(); var RelTypeName = queryParam["RelTypeName"]?.ToString();
var RelType = queryParam["RelType"]?.ToString(); var RelType = queryParam["RelType"]?.ToString();
enum_RelType RelEnum = default;
if (!string.IsNullOrEmpty(RelType) && Enum.TryParse<enum_RelType>(RelType, out RelEnum))
{
}
var TagNumber = queryParam["TagNumber"]?.ToString(); var TagNumber = queryParam["TagNumber"]?.ToString();
var tableName = TableName<ec_enginedata_relEntity>(ProjectId); var tableName = TableName<ec_enginedata_relEntity>(ProjectId);
@ -1490,8 +1508,8 @@ Select((a, b, c) => new
.WhereIF(!string.IsNullOrEmpty(RelEngineData1ID), a => a.RelEngineData1ID == RelEngineData1ID) .WhereIF(!string.IsNullOrEmpty(RelEngineData1ID), a => a.RelEngineData1ID == RelEngineData1ID)
.WhereIF(!string.IsNullOrEmpty(RelEngineData2ID), a => a.RelEngineData2ID == RelEngineData2ID) .WhereIF(!string.IsNullOrEmpty(RelEngineData2ID), a => a.RelEngineData2ID == RelEngineData2ID)
.WhereIF(!string.IsNullOrEmpty(RelTypeName), (a, b) => b.RelTypeName == RelTypeName) .WhereIF(!string.IsNullOrEmpty(RelTypeName), (a, b) => b.RelTypeName == RelTypeName)
.WhereIF(!string.IsNullOrEmpty(RelType), (a, b) => b.RelType == RelType) .WhereIF(!string.IsNullOrEmpty(RelType), (a, b) => b.RelType == RelEnum)
.Select((a, b, t1,t2,o1,o2) => new ec_enginedata_relEntity .Select((a, b, t1, t2, o1, o2) => new ec_enginedata_relEntity
{ {
EngineDataRelID = a.EngineDataRelID, EngineDataRelID = a.EngineDataRelID,
RelTypeID = a.RelTypeID, RelTypeID = a.RelTypeID,
@ -1529,7 +1547,7 @@ Select((a, b, c) => new
// dataIds.Add(x.RelEngineData1ID); // dataIds.Add(x.RelEngineData1ID);
// dataIds.Add(x.RelEngineData2ID); // dataIds.Add(x.RelEngineData2ID);
//}); //});
//dataIds.AddRange(list?.Select(x => x.RelEngineData1ID).Distinct()); //dataIds.AddRange(list?.Select(x => x.RelEngineData1ID).Distinct());
//dataIds.AddRange(list?.Select(x => x.RelEngineData2ID).Distinct()); //dataIds.AddRange(list?.Select(x => x.RelEngineData2ID).Distinct());
//dataIds = dataIds.Distinct().ToList(); //dataIds = dataIds.Distinct().ToList();
@ -1633,7 +1651,7 @@ Select((a, b, c) => new
/// <param name="NeedRemove">是否移除已有的true的话基本就是确保一对一的这种rel关系</param> /// <param name="NeedRemove">是否移除已有的true的话基本就是确保一对一的这种rel关系</param>
/// <summary> /// <summary>
/// <returns></returns> /// <returns></returns>
public void SaveEntitys(string ProjectId, string RelTypeID, string RelEngineData1ID, List<string> relEngineData2IDs, bool NeedRemove = false) public void SaveEntitys(string ProjectId, string RelTypeID, string RelEngineData1ID, List<string> relEngineData2IDs, string tagPixelId, bool NeedRemove = false)
{ {
try try
{ {
@ -1653,7 +1671,8 @@ Select((a, b, c) => new
model.Create(); model.Create();
model.RelTypeID = RelTypeID; model.RelTypeID = RelTypeID;
model.RelEngineData1ID = RelEngineData1ID; model.RelEngineData1ID = RelEngineData1ID;
model.RelEngineData2ID = item; model.RelEngineData2ID = item;
model.OPCPixel = tagPixelId;//普通情况
engineDataRelAdd.Add(model); engineDataRelAdd.Add(model);
continue; continue;
} }
@ -1672,6 +1691,7 @@ Select((a, b, c) => new
model.RelTypeID = RelTypeID; model.RelTypeID = RelTypeID;
model.RelEngineData1ID = RelEngineData1ID; model.RelEngineData1ID = RelEngineData1ID;
model.RelEngineData2ID = item; model.RelEngineData2ID = item;
model.OPCPixel = tagPixelId;//普通情况
engineDataRelAdd.Add(model); engineDataRelAdd.Add(model);
continue; continue;
} }
@ -1688,7 +1708,7 @@ Select((a, b, c) => new
} }
//engineDataRelDel = engineDataRel.Except(engineDataRelExcept).ToList(); //engineDataRelDel = engineDataRel.Except(engineDataRelExcept).ToList();
List<string> delEngineDataRelIDs = new List<string>(); //engineDataRelDel.Select(x => x.EngineDataRelID).ToList(); List<string> delEngineDataRelIDs = new List<string>(); //engineDataRelDel.Select(x => x.EngineDataRelID).ToList();
ec_enginedata_relService.SaveEntity(ProjectId, engineDataRelAdd, delEngineDataRelIDs); ec_enginedata_relService.SaveEntity(ProjectId, engineDataRelAdd, delEngineDataRelIDs); //电缆在end1进行最后的保存
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -1711,7 +1731,7 @@ Select((a, b, c) => new
/// <param name="RelEngineData1IDs"></param> /// <param name="RelEngineData1IDs"></param>
/// <param name="relEngineData2ID">电缆ID大概率</param> /// <param name="relEngineData2ID">电缆ID大概率</param>
/// <param name="NeedRemove"></param> /// <param name="NeedRemove"></param>
public void SaveEntitys(string ProjectId, string RelTypeID, List<string> RelEngineData1IDs, string relEngineData2ID, bool NeedRemove = false) public void SaveEntitys(string ProjectId, string RelTypeID, List<string> RelEngineData1IDs, string relEngineData2ID, string tagPixelId, bool NeedRemove = false)
{ {
try try
{ {
@ -1726,7 +1746,6 @@ Select((a, b, c) => new
foreach (var item in RelEngineData1IDs) foreach (var item in RelEngineData1IDs)
{ {
//判断下是否为OPC
if (NeedRemove) if (NeedRemove)
{ {
@ -1737,6 +1756,7 @@ Select((a, b, c) => new
model.RelTypeID = RelTypeID; model.RelTypeID = RelTypeID;
model.RelEngineData1ID = item; model.RelEngineData1ID = item;
model.RelEngineData2ID = relEngineData2ID; model.RelEngineData2ID = relEngineData2ID;
model.OPCPixel = tagPixelId;//普通情况
engineDataRelAdd.Add(model); engineDataRelAdd.Add(model);
continue; continue;
@ -1759,6 +1779,7 @@ Select((a, b, c) => new
model.RelTypeID = RelTypeID; model.RelTypeID = RelTypeID;
model.RelEngineData1ID = item; model.RelEngineData1ID = item;
model.RelEngineData2ID = relEngineData2ID; model.RelEngineData2ID = relEngineData2ID;
model.OPCPixel = tagPixelId;//普通情况
engineDataRelAdd.Add(model); engineDataRelAdd.Add(model);
continue; continue;
} }
@ -1775,7 +1796,7 @@ Select((a, b, c) => new
} }
//engineDataRelDel = engineDataRel.Except(engineDataRelExcept).ToList(); //engineDataRelDel = engineDataRel.Except(engineDataRelExcept).ToList();
List<string> delEngineDataRelIDs = new List<string>(); //engineDataRelDel.Select(x => x.EngineDataRelID).ToList(); List<string> delEngineDataRelIDs = new List<string>(); //engineDataRelDel.Select(x => x.EngineDataRelID).ToList();
ec_enginedata_relService.SaveEntity(ProjectId, engineDataRelAdd, delEngineDataRelIDs); ec_enginedata_relService.SaveEntity(ProjectId, engineDataRelAdd, delEngineDataRelIDs);//电缆在end2进行最后的保存
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -35,10 +35,10 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
/// <param name="keyValue">主键</param> /// <param name="keyValue">主键</param>
/// <summary> /// <summary>
/// <returns></returns> /// <returns></returns>
void SaveEntitys(string ProjectId, string RelTypeID, string RelEngineData1ID, List<string> relEngineData2IDs, bool NeedRemove = false); void SaveEntitys(string ProjectId, string RelTypeID, string RelEngineData1ID, List<string> relEngineData2IDs, string tagPixeId, bool NeedRemove = false);
void SaveEntitys(string ProjectId, string RelTypeID, List<string> RelEngineData1IDs, string relEngineData2ID, string tagPixeId, bool NeedRemove = false);
void SaveEntitys(string ProjectId, string RelTypeID, List<string> RelEngineData1IDs, string relEngineData2ID, bool NeedRemove = false);
#endregion #endregion

View File

@ -201,7 +201,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
var relTb = ProjectSugar.TableName<ec_reltypeEntity>(ProjId); var relTb = ProjectSugar.TableName<ec_reltypeEntity>(ProjId);
var relDataTb = ProjectSugar.TableName<ec_enginedata_relEntity>(ProjId); var relDataTb = ProjectSugar.TableName<ec_enginedata_relEntity>(ProjId);
var relTypes = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(relTb).ToList(); var relTypes = SqlSugarHelper.Db.Queryable<ec_reltypeEntity>().AS(relTb).ToList();
var relType = relTypes.FirstOrDefault(x => x.RelType == ((int)enum_RelType._电缆).ToString()); var relType = relTypes.FirstOrDefault(x => x.RelType == enum_RelType._电缆);
if (relType != null) if (relType != null)
{ {
foreach (var cableId in cableIds) foreach (var cableId in cableIds)

View File

@ -198,7 +198,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
//DELETE //DELETE
var tagsExisted = ec_EnginedataService.GetListBySQL("", ProjectId).Where(TAG => DateTime.Compare((DateTime)TAG.CreateTime, (DateTime)Drawing.CheckOutTime) < 0).OrderBy(x => x.ObjectTypeName); var tagsExisted = ec_EnginedataService.GetListBySQL("", ProjectId).Where(TAG => DateTime.Compare((DateTime)TAG.CreateTime, (DateTime)Drawing.CheckOutTime) < 0).OrderBy(x => x.ObjectTypeName);
//图纸上所有的pixel记录 //图纸上所有的pixel记录
var pixelsExisted = new ec_enginedata_pixelService().GetList("{\"ProjectId\":\"" + ProjectId + "\",\"DrawingFileID\":\"" + DrawingID + "\"}").ToList(); var pixelsExisted = new ec_enginedata_pixelService().GetList("{\"ProjectId\":\"" + ProjectId + "\",\"DrawingFileID\":\"" + DrawingID + "\"}",ProjectId).ToList();
// 创建时间 早于 检出时间 // 创建时间 早于 检出时间
foreach (var TAG in tagsExisted) foreach (var TAG in tagsExisted)

View File

@ -10,6 +10,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Web.Caching; using System.Web.Caching;
using System.Windows.Input; using System.Windows.Input;
using static Learun.Application.TwoDevelopment.ZZDT_EC.GlobalEnum;
using static Learun.Application.TwoDevelopment.ZZDT_EC.ProjectSugar; using static Learun.Application.TwoDevelopment.ZZDT_EC.ProjectSugar;
using static Learun.Util.SqlSugar.SqlSugarHelper; using static Learun.Util.SqlSugar.SqlSugarHelper;
@ -86,7 +87,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
if (dataType.Equals("2"))//2时才额外需要 if (dataType.Equals("2"))//2时才额外需要
{ {
listPixel = ec_enginedata_pixelBLL.GetList(queryJson).ToList(); listPixel = ec_enginedata_pixelBLL.GetList(queryJson,projectId).ToList();
listPixel = listPixel.Where(x => x.DeleteFlg != 1).ToList(); listPixel = listPixel.Where(x => x.DeleteFlg != 1).ToList();
} }
if (!string.IsNullOrEmpty(KeyWord)) if (!string.IsNullOrEmpty(KeyWord))

View File

@ -2,6 +2,7 @@
using SqlSugar; using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using static Learun.Application.TwoDevelopment.ZZDT_EC.GlobalEnum;
namespace Learun.Application.TwoDevelopment.ZZDT_EC namespace Learun.Application.TwoDevelopment.ZZDT_EC
{ {
/// <summary> /// <summary>
@ -181,12 +182,6 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
#endregion #endregion
} }
public enum specialType
{
= 0,
= 1,
= 2,
= 3,
}
} }

View File

@ -116,29 +116,54 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
if (!string.IsNullOrEmpty(objectTypeID)) if (!string.IsNullOrEmpty(objectTypeID))
{ {
RES = RES.Where(X => objectTypeID.Split(',').ToList().Contains(X.ObjectTypeID)).ToList(); RES = RES.Where(X => objectTypeID.Split(',').Contains(X.ObjectTypeID)).ToList();
} }
var propBll = new ec_propertyBLL(); var propBll = new ec_propertyBLL();
var allProp = propBll.GetListRedis(ProjectId); var allProp = propBll.GetListRedis(ProjectId);
// 提前构建Dictionary键为PropertyID值为对应的AllProp对象
var allPropDict = allProp.ToDictionary(x => x.PropertyID);
var propGroupBll = new ec_propertygBLL(); var propGroupBll = new ec_propertygBLL();
var allGroup = propGroupBll.GetList("{ProjectId:\"" + ProjectId + "\"}"); var allGroup = propGroupBll.GetList("{ProjectId:\"" + ProjectId + "\"}");
var allGroupDict = allGroup.ToDictionary(x => x.PropertyGID);
var unitTypeBll = new ec_measuring_unittypeBLL(); var unitTypeBll = new ec_measuring_unittypeBLL();
var allUnitType = unitTypeBll.GetList("{ProjectId:\"" + ProjectId + "\"}"); var allUnitType = unitTypeBll.GetList("{ProjectId:\"" + ProjectId + "\"}");
var allUnitTypeDict = allUnitType.ToDictionary(x => x.MeasuringUnitTypeID);
var unitBll = new ec_measuring_unitBLL(); var unitBll = new ec_measuring_unitBLL();
var allUnit = unitBll.GetListRedis(ProjectId); var allUnit = unitBll.GetListRedis(ProjectId);
var allUnitDict = allUnit.ToDictionary(x => x.MeasuringUnitID);
var detailBll = new ec_dataitemBLL(); var detailBll = new ec_dataitemBLL();
var allDics = detailBll.GetList("{ProjectId:\"" + ProjectId + "\"}"); var allDics = detailBll.GetList("{ProjectId:\"" + ProjectId + "\"}");
var allDetails = detailBll.GetDetailList("", "", ProjectId); var allDetails = detailBll.GetDetailList("", "", ProjectId);
var detailsDictGrouped = allDetails.GroupBy(x => x.DataItemID).ToDictionary(g => g.Key, g => g.ToList());//按照DataItemID分组
//strSql.Append($" FROM ec_objecttypep_{ProjectEntity.ProjectIndex} t1 "); //strSql.Append($" FROM ec_objecttypep_{ProjectEntity.ProjectIndex} t1 ");
if (isLoadExtraData) if (isLoadExtraData)
{ {
foreach (var objectTypeProp in RES) foreach (var objectTypeProp in RES)
{ {
var t2 = allProp.FirstOrDefault(x => x.PropertyID == objectTypeProp.PropertyID); // 用TryGetValue快速查询O(1)时间)
if (t2 == null) { continue; } if (allPropDict.TryGetValue(objectTypeProp.PropertyID, out var t2))
var t3 = allGroup.FirstOrDefault(x => x.PropertyGID == t2.PropertyGID); {
if (t3 == null) { continue; } // 找到匹配项处理t2
; }
else
{
// 未找到匹配项的处理逻辑
continue;
}
//var t2 = allProp.FirstOrDefault(x => x.PropertyID == objectTypeProp.PropertyID);
//if (t2 == null) { continue; }
if (allGroupDict.TryGetValue(t2.PropertyGID, out var t3))
{
// 找到匹配项处理t2
}
else
{
// 未找到匹配项的处理逻辑
continue;
}
//var t3 = allGroup.FirstOrDefault(x => x.PropertyGID == t2.PropertyGID);
//if (t3 == null) { continue; }
//;
objectTypeProp.PropertyName = t2.PropertyName; objectTypeProp.PropertyName = t2.PropertyName;
objectTypeProp.PropertyNameEN = t2.PropertyNameEN; objectTypeProp.PropertyNameEN = t2.PropertyNameEN;
objectTypeProp.PropertyType = t2.PropertyType; objectTypeProp.PropertyType = t2.PropertyType;
@ -158,17 +183,26 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
objectTypeProp.PropertyGroupName = t3.PropertyGroupName; objectTypeProp.PropertyGroupName = t3.PropertyGroupName;
objectTypeProp.PropertyGID = t3.PropertyGID; objectTypeProp.PropertyGID = t3.PropertyGID;
if (allUnitTypeDict.TryGetValue(t2.MeasuringUnitTypeID, out var t4))
{
// 找到匹配项处理t2
objectTypeProp.MeasuringUnitTypeName = t4.MeasuringUnitTypeName;
objectTypeProp.MeasuringUnitTypeName = allUnitType.FirstOrDefault(x => x.MeasuringUnitTypeID == t2.MeasuringUnitTypeID)?.MeasuringUnitTypeName; }
objectTypeProp.DefaultUnitName = allUnit.FirstOrDefault(x => x.MeasuringUnitID == t2.DefaultUnit)?.MeasuringUnitName; if (allUnitDict.TryGetValue(t2.DefaultUnit, out var t5))
{
objectTypeProp.DefaultUnitName = t5.MeasuringUnitName;
}
if (!string.IsNullOrEmpty(t2.EnumData)) if (!string.IsNullOrEmpty(t2.EnumData))
{ {
var Dic = allDics.FirstOrDefault(X => t2.EnumData == X.DataItemName || t2.EnumData == X.DataItemCode);
var Dic = allDics.FirstOrDefault(X => t2.EnumData == X.DataItemName || t2.EnumData == X.DataItemCode);//不是按照id来找
if (Dic != null) if (Dic != null)
{ {
foreach (var detail in allDetails.Where(x => x.DataItemID == Dic.DataItemID)) foreach (ec_dataitemdetailEntity detail in detailsDictGrouped[Dic.DataItemID])// allDetails.Where(x => x.DataItemID == Dic.DataItemID))
{ {
if (!string.IsNullOrEmpty(detail.DataItemNameEN) && Dic.ShowEN == 1) if (!string.IsNullOrEmpty(detail.DataItemNameEN) && Dic.ShowEN == 1)
{ {
@ -215,16 +249,19 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
{ {
var tObjectType = ProjectSugar.TableName<ec_objecttypeEntity>(ProjectId); var tObjectType = ProjectSugar.TableName<ec_objecttypeEntity>(ProjectId);
var tobjTypeAll = SqlSugarHelper.Db.Queryable<ec_objecttypeEntity>().AS(tObjectType).ToList(); var tobjTypeAll = SqlSugarHelper.Db.Queryable<ec_objecttypeEntity>().AS(tObjectType).ToList();
var tobjTypeDict = tobjTypeAll.ToDictionary(x => x.ObjectTypeID);
foreach (var item in objectTypeID.Split(',')) foreach (var item in objectTypeID.Split(','))
{ {
var pObjectType = RES.Where(x => x.ObjectTypeID == item).ToList(); var pObjectType = RES.Where(x => x.ObjectTypeID == item).ToList();//每种类型下的属性
var tobjType = tobjTypeAll.First(x => x.ObjectTypeID == item); var tobjType = tobjTypeDict[item];//每种类型的名字
// 提前提取所有PropertyName到HashSet仅需一次遍历
var propertyNames = new HashSet<string>(pObjectType.Select(x => x.PropertyName));//每种类型下的属性的名字
if (tobjType.ObjectTypeName.EndsWith("电缆")) if (tobjType.ObjectTypeName.EndsWith("电缆"))
{ {
if (!pObjectType.Any(X => X.PropertyName == GlobalObject.propName_parallelCableCombineName)) if (!propertyNames.Any(X => X == GlobalObject.propName_parallelCableCombineName))
{ {
ec_objecttypepEntity UDF_01 = new ec_objecttypepEntity(); ec_objecttypepEntity UDF_01 = new ec_objecttypepEntity();
UDF_01.ObjectTypePID = Guid.NewGuid().ToString(); UDF_01.ObjectTypePID = Guid.NewGuid().ToString();
@ -236,7 +273,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
RES.Add(UDF_01); RES.Add(UDF_01);
} }
if (!pObjectType.Any(X => X.PropertyName == GlobalObject.propName_parallelCableList)) if (!propertyNames.Any(X => X == GlobalObject.propName_parallelCableList))
{ {
ec_objecttypepEntity UDF_02 = new ec_objecttypepEntity(); ec_objecttypepEntity UDF_02 = new ec_objecttypepEntity();
UDF_02.ObjectTypePID = Guid.NewGuid().ToString(); UDF_02.ObjectTypePID = Guid.NewGuid().ToString();

View File

@ -170,7 +170,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
Where((a, b) => allPanelIds.Contains(b.PanelID)). Where((a, b) => allPanelIds.Contains(b.PanelID)).
Distinct().ToList(); Distinct().ToList();
var relId = Db.Queryable<ec_reltypeEntity>().AS(relTypeTb).ToList().First(x => x.RelType == ((int)enum_RelType._电缆).ToString()); var relId = Db.Queryable<ec_reltypeEntity>().AS(relTypeTb).ToList().First(x => x.RelType == enum_RelType._电缆);
var existRels = Db.Queryable<ec_enginedata_relEntity>().AS(relTb).Where(x => x.RelTypeID == relId.RelTypeID).ToList(); var existRels = Db.Queryable<ec_enginedata_relEntity>().AS(relTb).Where(x => x.RelTypeID == relId.RelTypeID).ToList();
@ -319,7 +319,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
var allEngineData = Db.Queryable<ec_enginedataEntity>().AS(tagTb).ToList(); var allEngineData = Db.Queryable<ec_enginedataEntity>().AS(tagTb).ToList();
var allPanels = Db.Queryable<ec_PanelEntity>().AS(panelTb).ToList(); var allPanels = Db.Queryable<ec_PanelEntity>().AS(panelTb).ToList();
var relId = Db.Queryable<ec_reltypeEntity>().AS(relTypeTb).ToList().First(x => x.RelType == ((int)enum_RelType._电缆).ToString()); var relId = Db.Queryable<ec_reltypeEntity>().AS(relTypeTb).ToList().First(x => x.RelType == enum_RelType._电缆);
var newWTCommits = new List<ec_WireTerminalEntity>(); var newWTCommits = new List<ec_WireTerminalEntity>();
var SignalCommits = new List<ec_Wire_GroupEntity>(); var SignalCommits = new List<ec_Wire_GroupEntity>();

View File

@ -217,7 +217,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
//创建工程数据图元表 //创建工程数据图元表
baseDAL.Create<ec_enginedata_pixelEntity>(sqlitePath); baseDAL.Create<ec_enginedata_pixelEntity>(sqlitePath);
//添加工程数据图元表数据 //添加工程数据图元表数据
baseDAL.Add(new ec_enginedata_pixelService().GetList(queryJson).ToList(), sqlitePath); baseDAL.Add(new ec_enginedata_pixelService().GetList(queryJson,ProjectId).ToList(), sqlitePath);
continue; continue;
} }
if (table == "ec_enginedata") if (table == "ec_enginedata")

View File

@ -33,11 +33,14 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
var ProjectId = queryParam["ProjectId"]?.ToString(); var ProjectId = queryParam["ProjectId"]?.ToString();
var RelTypeName = queryParam["RelTypeName"]?.ToString(); var RelTypeName = queryParam["RelTypeName"]?.ToString();
var RelType = queryParam["RelType"]?.ToString(); var RelType = queryParam["RelType"]?.ToString();
enum_RelType RelEnum = default;
if (!string.IsNullOrEmpty(RelType) && Enum.TryParse(RelType, out RelEnum))
{
}
var tableName = TableName<ec_reltypeEntity>(ProjectId); var tableName = TableName<ec_reltypeEntity>(ProjectId);
var query = Db.Queryable<ec_reltypeEntity>().AS(tableName) var query = Db.Queryable<ec_reltypeEntity>().AS(tableName)
.WhereIF(!string.IsNullOrEmpty(RelTypeName), x => x.RelTypeName.Contains(RelTypeName)) .WhereIF(!string.IsNullOrEmpty(RelTypeName), x => x.RelTypeName.Contains(RelTypeName))
.WhereIF(!string.IsNullOrEmpty(RelType), x => x.RelType == RelType) .WhereIF(!string.IsNullOrEmpty(RelType), x => x.RelType == RelEnum)
.OrderByDescending(x => x.CreateTime); .OrderByDescending(x => x.CreateTime);
List<ec_reltypeEntity> list; List<ec_reltypeEntity> list;
if (pagination == null) if (pagination == null)

View File

@ -46,7 +46,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
/// 关联类型缩写 /// 关联类型缩写
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public string RelType { get; set; } = ""; public enum_RelType RelType { get; set; }
/// <summary> /// <summary>
/// 创建人 /// 创建人
/// </summary> /// </summary>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>

View File

@ -138,6 +138,7 @@
#endregion #endregion
#region 8 #region 8
public static int IOModule_AutoAssign2Ch { get { return 8; } }
#endregion #endregion
#region 9 #region 9

View File

@ -33,8 +33,7 @@ namespace Learun.Cache.Redis
if (expireTime == null) if (expireTime == null)
{ {
expireTime = TimeSpan.FromHours(1); // 如果参数为null设置为1小时 expireTime = TimeSpan.FromHours(1); // 如果参数为null设置为1小时
} }
// 先从Redis缓存中获取数据 // 先从Redis缓存中获取数据
var cachedData = redisCache.StringGet<T>(cacheKey); var cachedData = redisCache.StringGet<T>(cacheKey);
if (cachedData != null) if (cachedData != null)

View File

@ -591,7 +591,7 @@ WHERE
} }
catch (Exception ex) catch (Exception ex)
{ {
LogInfo(baseDirectory + logFileName, tableName + " 项目表更新出现问题," + ex.Message); LogInfo(baseDirectory + logFileName, tableName +"_" + proj.ProjectIndex + " 项目表更新出现问题," + ex.Message);
} }
} }
} }

View File

@ -1,70 +0,0 @@
#pragma checksum "..\..\App.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "C59FD92DD7F882290C4D1E00897269832FF33C044AE5C3AC38691771009953DB"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using SWSDBSchemeUpgradeTool;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
namespace SWSDBSchemeUpgradeTool {
/// <summary>
/// App
/// </summary>
public partial class App : System.Windows.Application {
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent() {
#line 6 "..\..\App.xaml"
this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative);
#line default
#line hidden
}
/// <summary>
/// Application Entry Point.
/// </summary>
[System.STAThreadAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public static void Main() {
SWSDBSchemeUpgradeTool.App app = new SWSDBSchemeUpgradeTool.App();
app.InitializeComponent();
app.Run();
}
}
}

View File

@ -1,70 +0,0 @@
#pragma checksum "..\..\App.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "C59FD92DD7F882290C4D1E00897269832FF33C044AE5C3AC38691771009953DB"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using SWSDBSchemeUpgradeTool;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
namespace SWSDBSchemeUpgradeTool {
/// <summary>
/// App
/// </summary>
public partial class App : System.Windows.Application {
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent() {
#line 6 "..\..\App.xaml"
this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative);
#line default
#line hidden
}
/// <summary>
/// Application Entry Point.
/// </summary>
[System.STAThreadAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public static void Main() {
SWSDBSchemeUpgradeTool.App app = new SWSDBSchemeUpgradeTool.App();
app.InitializeComponent();
app.Run();
}
}
}

View File

@ -1,146 +0,0 @@
#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "A0C489F14831BC98743B3A71A943EBA949B115892D4776AC738A96131DA29AA4"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using SWSDBSchemeUpgradeTool;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
namespace SWSDBSchemeUpgradeTool {
/// <summary>
/// MainWindow
/// </summary>
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
#line 12 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Grid ContentGrid;
#line default
#line hidden
#line 64 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.ProgressBar ProgressBar;
#line default
#line hidden
#line 70 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Label StatusText;
#line default
#line hidden
#line 75 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock StatusText2;
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/SWSDBSchemeUpgradeTool;component/mainwindow.xaml", System.UriKind.Relative);
#line 1 "..\..\MainWindow.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.ContentGrid = ((System.Windows.Controls.Grid)(target));
return;
case 2:
this.ProgressBar = ((System.Windows.Controls.ProgressBar)(target));
return;
case 3:
this.StatusText = ((System.Windows.Controls.Label)(target));
return;
case 4:
this.StatusText2 = ((System.Windows.Controls.TextBlock)(target));
return;
case 5:
#line 86 "..\..\MainWindow.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);
#line default
#line hidden
return;
case 6:
#line 91 "..\..\MainWindow.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click_1);
#line default
#line hidden
return;
case 7:
#line 97 "..\..\MainWindow.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click_2);
#line default
#line hidden
return;
}
this._contentLoaded = true;
}
}
}

View File

@ -1,146 +0,0 @@
#pragma checksum "..\..\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "A0C489F14831BC98743B3A71A943EBA949B115892D4776AC738A96131DA29AA4"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using SWSDBSchemeUpgradeTool;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
namespace SWSDBSchemeUpgradeTool {
/// <summary>
/// MainWindow
/// </summary>
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
#line 12 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Grid ContentGrid;
#line default
#line hidden
#line 64 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.ProgressBar ProgressBar;
#line default
#line hidden
#line 70 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Label StatusText;
#line default
#line hidden
#line 75 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock StatusText2;
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/SWSDBSchemeUpgradeTool;component/mainwindow.xaml", System.UriKind.Relative);
#line 1 "..\..\MainWindow.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.ContentGrid = ((System.Windows.Controls.Grid)(target));
return;
case 2:
this.ProgressBar = ((System.Windows.Controls.ProgressBar)(target));
return;
case 3:
this.StatusText = ((System.Windows.Controls.Label)(target));
return;
case 4:
this.StatusText2 = ((System.Windows.Controls.TextBlock)(target));
return;
case 5:
#line 86 "..\..\MainWindow.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);
#line default
#line hidden
return;
case 6:
#line 91 "..\..\MainWindow.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click_1);
#line default
#line hidden
return;
case 7:
#line 97 "..\..\MainWindow.xaml"
((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click_2);
#line default
#line hidden
return;
}
this._contentLoaded = true;
}
}
}

View File

@ -1,89 +0,0 @@
#pragma checksum "..\..\SQLPreview.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "68D1F76124B5320845E5CAEA226A6F687D21C37205B359F167F55D30D3DE8FA5"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using SWSDBSchemeUpgradeTool;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
namespace SWSDBSchemeUpgradeTool {
/// <summary>
/// SQLPreview
/// </summary>
public partial class SQLPreview : System.Windows.Window, System.Windows.Markup.IComponentConnector {
#line 12 "..\..\SQLPreview.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Grid xxx;
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/SWSDBSchemeUpgradeTool;component/sqlpreview.xaml", System.UriKind.Relative);
#line 1 "..\..\SQLPreview.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.xxx = ((System.Windows.Controls.Grid)(target));
return;
}
this._contentLoaded = true;
}
}
}

View File

@ -1,89 +0,0 @@
#pragma checksum "..\..\SQLPreview.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "68D1F76124B5320845E5CAEA226A6F687D21C37205B359F167F55D30D3DE8FA5"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using SWSDBSchemeUpgradeTool;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
namespace SWSDBSchemeUpgradeTool {
/// <summary>
/// SQLPreview
/// </summary>
public partial class SQLPreview : System.Windows.Window, System.Windows.Markup.IComponentConnector {
#line 12 "..\..\SQLPreview.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Grid xxx;
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/SWSDBSchemeUpgradeTool;component/sqlpreview.xaml", System.UriKind.Relative);
#line 1 "..\..\SQLPreview.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.xxx = ((System.Windows.Controls.Grid)(target));
return;
}
this._contentLoaded = true;
}
}
}

View File

@ -58,6 +58,7 @@ namespace DI_Electrical
GlobalObject._prismContainer.RegisterDialog<DialogSignalPropertyhisAndLogs, DialogSignalPropertyhisAndLogsViewModel>(); GlobalObject._prismContainer.RegisterDialog<DialogSignalPropertyhisAndLogs, DialogSignalPropertyhisAndLogsViewModel>();
GlobalObject._prismContainer.RegisterDialog<DialogSignalSelect, DialogSignalSelectViewModel>(); GlobalObject._prismContainer.RegisterDialog<DialogSignalSelect, DialogSignalSelectViewModel>();
GlobalObject._prismContainer.RegisterDialog<DialogAllOutputSignal, DialogAllOutputSignalViewModel>(); GlobalObject._prismContainer.RegisterDialog<DialogAllOutputSignal, DialogAllOutputSignalViewModel>();
GlobalObject._prismContainer.RegisterDialog<DialogAssociatedSignal, DialogAssociatedSignalViewModel>();
GlobalObject._prismContainer.RegisterDialog<DialogInput, DialogInputViewModel>(); GlobalObject._prismContainer.RegisterDialog<DialogInput, DialogInputViewModel>();
GlobalObject._prismContainer.Register<IDialogService, DialogService>(); GlobalObject._prismContainer.Register<IDialogService, DialogService>();

View File

@ -24,6 +24,7 @@ using Panel = Bricscad.Windows.Panel;
using GlobalObject = SWS.Commons.GlobalObject; using GlobalObject = SWS.Commons.GlobalObject;
using SWS.Model; using SWS.Model;
using SWS.Service; using SWS.Service;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
[assembly: CommandClass(typeof(Commands))] [assembly: CommandClass(typeof(Commands))]
@ -540,6 +541,8 @@ namespace SWS.CAD
//选择的元素返回的属性信息 //选择的元素返回的属性信息
var ResTagInfosByPixels = new Model.ec_objecttype(); var ResTagInfosByPixels = new Model.ec_objecttype();
var listPropertys = new List<propertyModel>(); var listPropertys = new List<propertyModel>();
var _objectTypeService = GlobalObject.container.Resolve<ObjectTypeService>();
var _iOModuleService = GlobalObject.container.Resolve<IOModuleService>();
// 持续选择直到获取有效电缆 // 持续选择直到获取有效电缆
bool isValidCable = false; bool isValidCable = false;
@ -564,7 +567,7 @@ namespace SWS.CAD
{ {
// 获取句柄Handle 是字符串类型) // 获取句柄Handle 是字符串类型)
var handId = (cable.Handle.ToString()); var handId = (cable.Handle.ToString());
var _objectTypeService = GlobalObject.container.Resolve<ObjectTypeService>(); _objectTypeService = GlobalObject.container.Resolve<ObjectTypeService>();
var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId); var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId);
if (res != null) if (res != null)
{ {
@ -600,8 +603,20 @@ namespace SWS.CAD
//Thread.Sleep(2000); //Thread.Sleep(2000);
if (isValidCable) if (isValidCable)
{ {
var _iOModuleService = GlobalObject.container.Resolve<IOModuleService>(); var ResTagNumberById = await _objectTypeService.GetTagNumberById(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
var ObjectTypePListBy = await _objectTypeService.GetObjectTypePListByIds(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
string CableSpecification = ObjectTypePListBy.Where(q => q.PropertyName.Equals("电缆规格")).Select(s => s.EnumDataCode).FirstOrDefault();
CableSpecification = CableSpecification.Substring(0, CableSpecification.Length - 1);
var LatestSerialNumber = await _objectTypeService.GetLatestSerialNumber(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
//获取位号的电缆属性,判断是否设置电缆规格
var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber)).FirstOrDefault();
if (string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
//if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
{
System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return;
}
var ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID); var ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
//如果配置不存在 //如果配置不存在
if (ResCableEngID == null) if (ResCableEngID == null)
@ -636,6 +651,7 @@ namespace SWS.CAD
ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID; ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
ec_Cable.Sets = new List<ec_CableSet>(); ec_Cable.Sets = new List<ec_CableSet>();
int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0; int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
int n = 0;
for (int i = 0; i < CableSetCount; i++) for (int i = 0; i < CableSetCount; i++)
{ {
ec_CableSet ec_CableSet = new ec_CableSet(); ec_CableSet ec_CableSet = new ec_CableSet();
@ -645,6 +661,7 @@ namespace SWS.CAD
int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0; int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
for (int j = 0; j < WireCount; j++) for (int j = 0; j < WireCount; j++)
{ {
n++;
ec_CableSetWire ec_CableSetWire = new ec_CableSetWire(); ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)]; ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
ec_CableSetWire.SetLevel = j + 1; ec_CableSetWire.SetLevel = j + 1;
@ -653,6 +670,20 @@ namespace SWS.CAD
switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault()) switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
{ {
case "按电缆编号": case "按电缆编号":
if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
{
Tag = n.ToString();
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
{
Tag = Tag + (char)('A' + (n - 1));
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{
Tag = (i + 1) + "-" + n.ToString();
}
break;
case "按电缆对编号":
if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
{ {
Tag = (j + 1).ToString(); Tag = (j + 1).ToString();
@ -663,12 +694,9 @@ namespace SWS.CAD
} }
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{ {
Tag = (i + 1).ToString(); Tag = (i + 1) + "-" + (j + 1).ToString();
} }
break; break;
case "按电缆对编号":
a = ResTagInfosByPixels.tags.FirstOrDefault().TagNumber;
break;
} }
ec_CableSetWire.Wire_Tag = a + Tag; ec_CableSetWire.Wire_Tag = a + Tag;
ec_CableSet.Wires.Add(ec_CableSetWire); ec_CableSet.Wires.Add(ec_CableSetWire);
@ -705,6 +733,7 @@ namespace SWS.CAD
ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID; ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
ec_Cable.Sets = new List<ec_CableSet>(); ec_Cable.Sets = new List<ec_CableSet>();
int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0; int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
int n = 0;
for (int i = 0; i < CableSetCount; i++) for (int i = 0; i < CableSetCount; i++)
{ {
ec_CableSet ec_CableSet = new ec_CableSet(); ec_CableSet ec_CableSet = new ec_CableSet();
@ -714,6 +743,7 @@ namespace SWS.CAD
int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0; int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
for (int j = 0; j < WireCount; j++) for (int j = 0; j < WireCount; j++)
{ {
n++;
ec_CableSetWire ec_CableSetWire = new ec_CableSetWire(); ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)]; ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
ec_CableSetWire.SetLevel = j + 1; ec_CableSetWire.SetLevel = j + 1;
@ -722,6 +752,20 @@ namespace SWS.CAD
switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault()) switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
{ {
case "按电缆编号": case "按电缆编号":
if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
{
Tag = n.ToString();
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
{
Tag = Tag + (char)('A' + (n - 1));
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{
Tag = (i + 1) + "-" + n.ToString();
}
break;
case "按电缆对编号":
if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
{ {
Tag = (j + 1).ToString(); Tag = (j + 1).ToString();
@ -732,12 +776,9 @@ namespace SWS.CAD
} }
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{ {
Tag = (i + 1).ToString(); Tag = (i + 1) + "-" + (j + 1).ToString();
} }
break; break;
case "按电缆对编号":
a = ResTagInfosByPixels.tags.FirstOrDefault().TagNumber;
break;
} }
ec_CableSetWire.Wire_Tag = a + Tag; ec_CableSetWire.Wire_Tag = a + Tag;
ec_CableSet.Wires.Add(ec_CableSetWire); ec_CableSet.Wires.Add(ec_CableSetWire);
@ -849,20 +890,305 @@ namespace SWS.CAD
btnCableSinal.ToolTip = "信号预分配"; btnCableSinal.ToolTip = "信号预分配";
btnCableSinal.Text = "信号预分配"; btnCableSinal.Text = "信号预分配";
btnCableSinal.ButtonStyle = RibbonButtonStyle.SmallWithText; btnCableSinal.ButtonStyle = RibbonButtonStyle.SmallWithText;
btnCableSinal.CommandHandler = new DelegateCommand(x => btnCableSinal.CommandHandler = new DelegateCommand(async x =>
{ {
//打开窗体 if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
var para = new Prism.Services.Dialogs.DialogParameters();
var _dialogService = GlobalObject._prismContainer.Resolve<IDialogService>();
_dialogService.ShowDialog(nameof(DialogSignalPredistribution), para, (RES) =>
{ {
if (RES.Result == ButtonResult.Yes) MessageBox.Show("请先登录系统并选择项目!");
return;
}
//在SWS系统内打开且不是只读的图纸才可
var dwgName = General.GetDwgName();
var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
if (dwgFile == null)
{ return; }
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
//选择的元素返回的属性信息
var ResTagInfosByPixels = new Model.ec_objecttype();
var listPropertys = new List<propertyModel>();
var _objectTypeService = GlobalObject.container.Resolve<ObjectTypeService>();
var _iOModuleService = GlobalObject.container.Resolve<IOModuleService>();
// 持续选择直到获取有效电缆
bool isValidCable = false;
try
{
#region
// 创建选择选项(禁用回车确认)
PromptEntityOptions options = new PromptEntityOptions("\n请单击选择电缆: ");
options.AllowNone = false; // 禁止空选
// 执行选择(直接单击生效)
PromptEntityResult resultEntity = ed.GetEntity(options);
//WindowVisibility = System.Windows.Visibility.Hidden;
while (resultEntity.Status == PromptStatus.OK)
{ {
using (Transaction tr = db.TransactionManager.StartTransaction())
{
// 获取选中的电缆实体
Entity cable = tr.GetObject(resultEntity.ObjectId, OpenMode.ForRead) as Entity;
//if (cable != null&&cable.XData != null)
if (cable != null)
{
// 获取句柄Handle 是字符串类型)
var handId = (cable.Handle.ToString());
var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId);
if (res != null)
{
if (res.Count == 1)
{
var item = res[0];
var objTypeName = item.ObjectTypeName;
if (objTypeName.Contains("电缆"))
{
ResTagInfosByPixels = item;
isValidCable = true; // 校验通过
ed.WriteMessage($"\n已选择电缆:{ResTagInfosByPixels.tags.FirstOrDefault().TagNumber}");
}
}
}
}
tr.Commit();
}
if (isValidCable)
{
break;
}
else
{
ed.WriteMessage($"\n已选择电缆:");
resultEntity = ed.GetEntity(options);
}
} }
else if (RES.Result == ButtonResult.No) #endregion
{ }
});
//Thread.Sleep(2000);
if (isValidCable)
{
var ResTagNumberById = await _objectTypeService.GetTagNumberById(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
var ObjectTypePListBy = await _objectTypeService.GetObjectTypePListByIds(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
string CableSpecification = ObjectTypePListBy.Where(q => q.PropertyName.Equals("电缆规格")).Select(s => s.EnumDataCode).FirstOrDefault();
CableSpecification = CableSpecification.Substring(0, CableSpecification.Length - 1);
var LatestSerialNumber = await _objectTypeService.GetLatestSerialNumber(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
//获取位号的电缆属性,判断是否设置电缆规格
var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber)).FirstOrDefault();
if(string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
//if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
{
System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return;
}
var ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
//如果配置不存在
if (ResCableEngID == null)
{
listPropertys = new List<propertyModel>();
System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show($"是否为通讯母线?", "KunHengCAD", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Question);
if (result == System.Windows.MessageBoxResult.OK)
{
listPropertys = new List<propertyModel>();
Dictionary<string, string> pulldownlist;
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "1", ControlTypeName = PROPERTYType.TextBox, });
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
pulldownlist = new Dictionary<string, string>();
pulldownlist.Add("数字", "数字");
pulldownlist.Add("字母", "字母");
pulldownlist.Add("电缆对序号", "电缆对序号");
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
pulldownlist = new Dictionary<string, string>();
pulldownlist.Add("按电缆编号", "按电缆编号");
pulldownlist.Add("按电缆对编号", "按电缆对编号");
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
//显示属性弹窗
var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
if (ReslistPro == null || ReslistPro.Count() == 0) return;
ec_Cable ec_Cable = new ec_Cable();
ec_Cable.CableClass = "homerun";//母线
ec_Cable.Cable_Format = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault();
ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
ec_Cable.Sets = new List<ec_CableSet>();
int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
int n = 0;
for (int i = 0; i < CableSetCount; i++)
{
ec_CableSet ec_CableSet = new ec_CableSet();
ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
ec_CableSet.CableSetSeq = i + 1;
ec_CableSet.Wires = new List<ec_CableSetWire>();
int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
for (int j = 0; j < WireCount; j++)
{
n++;
ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
ec_CableSetWire.SetLevel = j + 1;
string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
string Tag = "";//线号名的中间部分
switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
{
case "按电缆编号":
if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
{
Tag = n.ToString();
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
{
Tag = Tag + (char)('A' + (n - 1));
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{
Tag = (i + 1) + "-" + n.ToString();
}
break;
case "按电缆对编号":
if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
{
Tag = (j + 1).ToString();
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
{
Tag = Tag + (char)('A' + j);
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{
Tag = (i + 1) + "-" + (j + 1).ToString();
}
break;
}
ec_CableSetWire.Wire_Tag = a + Tag;
ec_CableSet.Wires.Add(ec_CableSetWire);
}
ec_Cable.Sets.Add(ec_CableSet);
}
var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
}
else
{
listPropertys = new List<propertyModel>();
Dictionary<string, string> pulldownlist;
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "10", ControlTypeName = PROPERTYType.TextBox, });
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
pulldownlist = new Dictionary<string, string>();
pulldownlist.Add("数字", "数字");
pulldownlist.Add("字母", "字母");
pulldownlist.Add("电缆对序号", "电缆对序号");
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
pulldownlist = new Dictionary<string, string>();
pulldownlist.Add("按电缆编号", "按电缆编号");
pulldownlist.Add("按电缆对编号", "按电缆对编号");
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
//显示属性弹窗
var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
if (ReslistPro == null || ReslistPro.Count() == 0) return;
ec_Cable ec_Cable = new ec_Cable();
ec_Cable.CableClass = "conventional";//常规电缆
ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
ec_Cable.Sets = new List<ec_CableSet>();
int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
int n = 0;
for (int i = 0; i < CableSetCount; i++)
{
ec_CableSet ec_CableSet = new ec_CableSet();
ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
ec_CableSet.CableSetSeq = i + 1;
ec_CableSet.Wires = new List<ec_CableSetWire>();
int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
for (int j = 0; j < WireCount; j++)
{
n++;
ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
ec_CableSetWire.SetLevel = j + 1;
string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
string Tag = "";//线号名的中间部分
switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
{
case "按电缆编号"://所有的电缆对中的电芯一起编号
if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
{
Tag = n.ToString();
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
{
Tag = Tag + (char)('A' + (n-1));
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{
Tag = (i+1)+"-"+ n.ToString();
}
break;
case "按电缆对编号"://一个电缆对中线号按顺序编号另一个电缆对中线号重新从1开始编号
if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
{
Tag = (j + 1).ToString();
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
{
Tag = Tag + (char)('A' + j);
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{
Tag = (i+1) + "-" + (j+1).ToString();
}
break;
}
ec_CableSetWire.Wire_Tag = a + Tag;
ec_CableSet.Wires.Add(ec_CableSetWire);
}
ec_Cable.Sets.Add(ec_CableSet);
}
var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
}
}
if (ResCableEngID != null)
{
IntPtr cadHandle = Bricscad.ApplicationServices.Application.MainWindow.Handle;
//打开窗体
var para = new Prism.Services.Dialogs.DialogParameters();
//para.Add(GlobalObject.dialogPar.para1.ToString(), "6e2919e4-28cd-4fb6-9035-10b2ff0e30fb");
para.Add(GlobalObject.dialogPar.info.ToString(), cadHandle);
para.Add(GlobalObject.dialogPar.para1.ToString(), ResCableEngID);
para.Add(GlobalObject.dialogPar.para2.ToString(), ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
var _dialogService = GlobalObject._prismContainer.Resolve<IDialogService>();
_dialogService.ShowDialog(nameof(DialogSignalPredistribution), para, (RES) =>
{
if (RES.Result == ButtonResult.Yes)
{
}
else if (RES.Result == ButtonResult.No)
{ }
});
}
}
}
catch (System.Exception ex)
{
ed.WriteMessage($"\n错误: {ex.Message}");
}
}); });
btnCableSinal.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CableSinal.png"); btnCableSinal.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CableSinal.png");
btnCableSinal.Id = "信号预分配"; btnCableSinal.Id = "信号预分配";

View File

@ -0,0 +1,9 @@
using Newtonsoft.Json.Linq;
using Prism.Events;
namespace SWS.CAD.Event
{
public class ScrollToItemEvent: PubSubEvent<object>
{
}
}

View File

@ -156,7 +156,7 @@ namespace SWS.CAD
if (_dwgSystem == null) if (_dwgSystem == null)
{ {
var serv = GlobalObje.container.Resolve<DataItemService>(); var serv = GlobalObject.container.Resolve<DataItemService>();
var res = Task.Run(() => serv.GetDetails(DBConst.Be_DrawingSystem.ToString())); var res = Task.Run(() => serv.GetDetails(DBConst.Be_DrawingSystem.ToString()));
var res2 = res.Result; var res2 = res.Result;
var res3 = DataItemDetailsToTree(res2); var res3 = DataItemDetailsToTree(res2);
@ -244,11 +244,11 @@ namespace SWS.CAD
para1, para1,
para2 para2
} }
public static IUnityContainer container; //public static IUnityContainer container;
public static IContainerExtension _prismContainer; //public static IContainerExtension _prismContainer;
public static HttpClient client; //public static HttpClient client;
public static loginRes userInfo; //public static loginRes userInfo;
public static List<User> Users; //public static List<User> Users;
public static bool isConfigIniCreateBySys = true; public static bool isConfigIniCreateBySys = true;
//public static string drawingFileId; //public static string drawingFileId;
@ -322,27 +322,27 @@ namespace SWS.CAD
} }
#endregion #endregion
#region ID获取用户名称 //#region 根据ID获取用户名称
/// <summary> ///// <summary>
/// 根据ID获取用户名称 ///// 根据ID获取用户名称
/// </summary> ///// </summary>
/// <param name="id"></param> ///// <param name="id"></param>
/// <returns></returns> ///// <returns></returns>
public static string GetUserNameById(string id) //public static string GetUserNameById(string id)
{ //{
if (string.IsNullOrEmpty(id)) // if (string.IsNullOrEmpty(id))
{ return ""; } // { return ""; }
var user = Users.FirstOrDefault(a => a.F_UserId == id || a.F_Account == id); // var user = Users.FirstOrDefault(a => a.F_UserId == id || a.F_Account == id);
if (user != null) // if (user != null)
{ return user.F_RealName; } // { return user.F_RealName; }
else // else
{ // {
return ""; // return "";
//user = GlobalObject.Users.FirstOrDefault(a => a.F_Account == id); // //user = GlobalObject.Users.FirstOrDefault(a => a.F_Account == id);
//return user != null ? user.F_RealName : ""; // //return user != null ? user.F_RealName : "";
} // }
} //}
#endregion //#endregion
#region #region

View File

@ -167,6 +167,7 @@
<Compile Include="Event\propertyChangeEvent.cs" /> <Compile Include="Event\propertyChangeEvent.cs" />
<Compile Include="Event\IORelationEvent.cs" /> <Compile Include="Event\IORelationEvent.cs" />
<Compile Include="Event\tagChangeEvent.cs" /> <Compile Include="Event\tagChangeEvent.cs" />
<Compile Include="Event\ScrollToItemEvent.cs" />
<Compile Include="Event\treeNodeChangeEvent.cs" /> <Compile Include="Event\treeNodeChangeEvent.cs" />
<Compile Include="Event\SelectProjectEvent.cs" /> <Compile Include="Event\SelectProjectEvent.cs" />
<Compile Include="Helper\Converter\ComboBoxFilterConverter.cs" /> <Compile Include="Helper\Converter\ComboBoxFilterConverter.cs" />

View File

@ -55,6 +55,7 @@ namespace SWS.CAD
GlobalObject._prismContainer.RegisterDialog<DialogPublishRecord, DialogPublishRecordViewModel>(); GlobalObject._prismContainer.RegisterDialog<DialogPublishRecord, DialogPublishRecordViewModel>();
GlobalObject._prismContainer.RegisterDialog<SWS.WPF.Views.DialogSignalManagement,SWS.WPF.ViewModels.DialogSignalManagementViewModel>(); GlobalObject._prismContainer.RegisterDialog<SWS.WPF.Views.DialogSignalManagement,SWS.WPF.ViewModels.DialogSignalManagementViewModel>();
GlobalObject._prismContainer.RegisterDialog<DialogAllOutputSignal, DialogAllOutputSignalViewModel>(); GlobalObject._prismContainer.RegisterDialog<DialogAllOutputSignal, DialogAllOutputSignalViewModel>();
GlobalObject._prismContainer.RegisterDialog<DialogAssociatedSignal, DialogAssociatedSignalViewModel>();
GlobalObject._prismContainer.RegisterDialog<DialogOperateRecord, DialogOperateRecordViewModel>(); GlobalObject._prismContainer.RegisterDialog<DialogOperateRecord, DialogOperateRecordViewModel>();
GlobalObject._prismContainer.RegisterDialog<DialogPropertyHistory, DialogPropertyHistoryViewModel>(); GlobalObject._prismContainer.RegisterDialog<DialogPropertyHistory, DialogPropertyHistoryViewModel>();
GlobalObject._prismContainer.RegisterDialog<DialogSignalNotice, DialogSignalNoticeViewModel>(); GlobalObject._prismContainer.RegisterDialog<DialogSignalNotice, DialogSignalNoticeViewModel>();

View File

@ -10,6 +10,7 @@ using System.Windows.Threading;
using Bricscad.ApplicationServices; using Bricscad.ApplicationServices;
using Bricscad.EditorInput; using Bricscad.EditorInput;
using OfficeOpenXml; using OfficeOpenXml;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
using Prism.Events; using Prism.Events;
using Prism.Ioc; using Prism.Ioc;
using Prism.Services.Dialogs; using Prism.Services.Dialogs;
@ -56,6 +57,8 @@ namespace SWS.CAD.ViewModels
RaisePropertyChanged(nameof(SelectedTreeNode)); RaisePropertyChanged(nameof(SelectedTreeNode));
UpdateChannelInfos(); UpdateChannelInfos();
var path = FindNodePath(PanelTreels, _SelectedTreeNode);
_eventAggregator.GetEvent<ScrollToItemEvent>().Publish(path);
} }
} }
@ -279,7 +282,7 @@ namespace SWS.CAD.ViewModels
{ {
ChannelInfo c = new ChannelInfo(); ChannelInfo c = new ChannelInfo();
//电缆位号,电缆对,电缆线号,极性 //电缆位号,电缆对,电缆线号,极性
foreach (var Term in child.Terms) foreach (var Term in child.Terms.OrderBy(p => p.Term_Seq).ToList())
{ {
index++; index++;
c.Index.Add(index.ToString()); c.Index.Add(index.ToString());
@ -302,7 +305,8 @@ namespace SWS.CAD.ViewModels
c.Polaritys.Add(new ec_WireTerminal()); c.Polaritys.Add(new ec_WireTerminal());
} }
} }
c.Terms.AddRange(child.Terms); //端子号
c.Terms.AddRange(child.Terms.OrderBy(p => p.Term_Seq).ToList());
//关联信号 //关联信号
c.Signal = child.Signal; c.Signal = child.Signal;
if (child.Signal != null) if (child.Signal != null)
@ -333,14 +337,14 @@ namespace SWS.CAD.ViewModels
} }
catch (Exception ex) catch (Exception ex)
{ {
System.Windows.MessageBox.Show(ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error); System.Windows.MessageBox.Show(ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
} }
finally finally
{ {
IsBusy = false; IsBusy = false;
} }
} }
#endregion #endregion
@ -523,6 +527,44 @@ namespace SWS.CAD.ViewModels
} }
#endregion #endregion
#region
public List<string> FindNodePath(ObservableCollection<TreeModel> nodes, TreeModel targetNode)
{
List<string> path = new List<string>();
FindNodePathRecursive(nodes, targetNode, path);
return path;
}
private bool FindNodePathRecursive(IEnumerable<TreeModel> nodes, TreeModel targetNode, List<string> currentPath)
{
foreach (var node in nodes)
{
currentPath.Add(node.Text);
if (node == targetNode) return true; // 找到目标节点返回True并结束搜索
if (node.ChildNodes.Count > 0 && FindNodePathRecursive(node.ChildNodes, targetNode, currentPath))
return true; // 在子节点中继续搜索并找到目标节点返回True并结束搜索
currentPath.RemoveAt(currentPath.Count - 1); // 回溯,尝试下一个兄弟节点或父节点的其他兄弟节点
}
return false; // 没有找到目标节点返回False
}
#endregion
#region id查找项
private TreeModel FindTreeModelById(IEnumerable<TreeModel> TreeModels, string id)
{
foreach (var Tree in TreeModels)
{
if (Tree.ID == id)
return Tree;
var foundInChildren = FindTreeModelById(Tree.ChildNodes, id);
if (foundInChildren != null)
return foundInChildren;
}
return null;
}
#endregion
#region #region
public ICommand MouseRightCmd => new DelegateCommand(MouseRight_Click); public ICommand MouseRightCmd => new DelegateCommand(MouseRight_Click);
@ -685,13 +727,14 @@ namespace SWS.CAD.ViewModels
DataItemName = listPro.Where(p => p.DisplayText.Equals("位置名称")).Select(p => p.PropertyValue).FirstOrDefault(), DataItemName = listPro.Where(p => p.DisplayText.Equals("位置名称")).Select(p => p.PropertyValue).FirstOrDefault(),
OrderID = int.Parse(listPro.Where(p => p.DisplayText.Equals("排序号")).Select(p => p.PropertyValue).FirstOrDefault()), OrderID = int.Parse(listPro.Where(p => p.DisplayText.Equals("排序号")).Select(p => p.PropertyValue).FirstOrDefault()),
}; };
var httpres = await _dataItemService.SaveDetailForm(ent); var httpres = await _dataItemService.SaveDetailForm(ent) as learunHttpRes<ec_dataitemdetail>;
if (httpres != null) if (httpres.code != 200)
{ {
System.Windows.MessageBox.Show(httpres.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; System.Windows.MessageBox.Show(httpres.info.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return;
} }
PanelTreels.Clear(); PanelTreels.Clear();
PanelTreels.AddRange(await _iOModuleService.GetPanelTree()); PanelTreels.AddRange(await _iOModuleService.GetPanelTree());
SelectedTreeNode = FindNodeByNodeId(PanelTreels, httpres.data.DataItemID);
} }
else if (RES.Result == ButtonResult.No) else if (RES.Result == ButtonResult.No)
{ } { }
@ -881,13 +924,15 @@ namespace SWS.CAD.ViewModels
} }
#endregion #endregion
var httpres = await _iOModuleService.CreatePanelStripByProfile(e); var httpres = await _iOModuleService.CreatePanelStripByProfile(e) as learunHttpRes<ec_PanelStrip>;
if (httpres != null) if (httpres.code != 200)
{ {
System.Windows.MessageBox.Show(httpres.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; System.Windows.MessageBox.Show(httpres.info.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return;
} }
PanelTreels.Clear(); PanelTreels.Clear();
PanelTreels.AddRange(await _iOModuleService.GetPanelTree()); PanelTreels.AddRange(await _iOModuleService.GetPanelTree());
SelectedTreeNode = FindTreeModelById(PanelTreels, httpres.data.StripID);
} }
else if (RES.Result == ButtonResult.No) else if (RES.Result == ButtonResult.No)
{ } { }
@ -940,13 +985,14 @@ namespace SWS.CAD.ViewModels
DataItemName = listPro.Where(p => p.DisplayText.Equals("位置名称")).Select(p => p.PropertyValue).FirstOrDefault(), DataItemName = listPro.Where(p => p.DisplayText.Equals("位置名称")).Select(p => p.PropertyValue).FirstOrDefault(),
OrderID = int.Parse(listPro.Where(p => p.DisplayText.Equals("排序号")).Select(p => p.PropertyValue).FirstOrDefault()), OrderID = int.Parse(listPro.Where(p => p.DisplayText.Equals("排序号")).Select(p => p.PropertyValue).FirstOrDefault()),
}; };
var httpres = await _dataItemService.SaveDetailForm(ent); var httpres = await _dataItemService.SaveDetailForm(ent) as learunHttpRes<ec_dataitemdetail>;
if (httpres != null) if (httpres.code != 200)
{ {
System.Windows.MessageBox.Show(httpres.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; System.Windows.MessageBox.Show(httpres.info.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return;
} }
PanelTreels.Clear(); PanelTreels.Clear();
PanelTreels.AddRange(await _iOModuleService.GetPanelTree()); PanelTreels.AddRange(await _iOModuleService.GetPanelTree());
SelectedTreeNode = FindNodeByNodeId(PanelTreels, httpres.info);
} }
else if (RES.Result == ButtonResult.No) else if (RES.Result == ButtonResult.No)
{ } { }
@ -974,6 +1020,7 @@ namespace SWS.CAD.ViewModels
{ {
if (RES.Result == ButtonResult.Yes) if (RES.Result == ButtonResult.Yes)
{ {
var tempID = SelectedTreeNode.ID;
var listPro = RES.Parameters.GetValue<ObservableCollection<propertyModel>>(GlobalObject.dialogPar.para1.ToString()); var listPro = RES.Parameters.GetValue<ObservableCollection<propertyModel>>(GlobalObject.dialogPar.para1.ToString());
ec_PanelStrip ent = new ec_PanelStrip() ec_PanelStrip ent = new ec_PanelStrip()
@ -985,12 +1032,13 @@ namespace SWS.CAD.ViewModels
StripID = StripIDValue, StripID = StripIDValue,
}; };
var httpres = await _iOModuleService.SavePanelStrip(ent); var httpres = await _iOModuleService.SavePanelStrip(ent);
if (httpres != null) if (httpres!= null)
{ {
System.Windows.MessageBox.Show(httpres.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; System.Windows.MessageBox.Show(httpres.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return;
} }
PanelTreels.Clear(); PanelTreels.Clear();
PanelTreels.AddRange(await _iOModuleService.GetPanelTree()); PanelTreels.AddRange(await _iOModuleService.GetPanelTree());
SelectedTreeNode = FindNodeByNodeId(PanelTreels, tempID);
} }
else if (RES.Result == ButtonResult.No) else if (RES.Result == ButtonResult.No)
{ } { }
@ -1017,7 +1065,15 @@ namespace SWS.CAD.ViewModels
MessageBoxResult result = System.Windows.MessageBox.Show($"确定删除[{SelectedTreeNode.Text}]节点以及子节点吗", "KunHengCAD", MessageBoxButton.OKCancel, MessageBoxImage.Question); MessageBoxResult result = System.Windows.MessageBox.Show($"确定删除[{SelectedTreeNode.Text}]节点以及子节点吗", "KunHengCAD", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (result == MessageBoxResult.OK) if (result == MessageBoxResult.OK)
{ {
var tempParentId = SelectedTreeNode.parentId;
var httpres = await _iOModuleService.DeletePanelStrip(SelectedTreeNode.ID); var httpres = await _iOModuleService.DeletePanelStrip(SelectedTreeNode.ID);
if (httpres!=null)
{
System.Windows.MessageBox.Show(httpres.ToString(), "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return;
}
PanelTreels.Clear();
PanelTreels.AddRange(await _iOModuleService.GetPanelTree());
SelectedTreeNode = FindTreeModelById(PanelTreels, tempParentId);
} }
} }
return; return;
@ -1069,7 +1125,8 @@ namespace SWS.CAD.ViewModels
//获取位号的电缆属性,判断是否设置电缆规格 //获取位号的电缆属性,判断是否设置电缆规格
var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(selectTagNumberOB.TagNumber); var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(selectTagNumberOB.TagNumber);
var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(selectTagNumberOB.TagNumber)).FirstOrDefault(); var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(selectTagNumberOB.TagNumber)).FirstOrDefault();
if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault())) if (string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
//if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
{ {
System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return;
@ -1108,6 +1165,7 @@ namespace SWS.CAD.ViewModels
ec_Cable.EngineerDataID = selectTagNumberOB.EngineDataID; ec_Cable.EngineerDataID = selectTagNumberOB.EngineDataID;
ec_Cable.Sets = new List<ec_CableSet>(); ec_Cable.Sets = new List<ec_CableSet>();
int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0; int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
int n = 0;
for (int i = 0; i < CableSetCount; i++) for (int i = 0; i < CableSetCount; i++)
{ {
ec_CableSet ec_CableSet = new ec_CableSet(); ec_CableSet ec_CableSet = new ec_CableSet();
@ -1117,6 +1175,7 @@ namespace SWS.CAD.ViewModels
int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0; int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
for (int j = 0; j < WireCount; j++) for (int j = 0; j < WireCount; j++)
{ {
n++;
ec_CableSetWire ec_CableSetWire = new ec_CableSetWire(); ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)]; ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
ec_CableSetWire.SetLevel = j + 1; ec_CableSetWire.SetLevel = j + 1;
@ -1125,6 +1184,20 @@ namespace SWS.CAD.ViewModels
switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault()) switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
{ {
case "按电缆编号": case "按电缆编号":
if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
{
Tag = n.ToString();
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
{
Tag = Tag + (char)('A' + (n - 1));
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{
Tag = (i + 1) + "-" + n.ToString();
}
break;
case "按电缆对编号":
if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
{ {
Tag = (j + 1).ToString(); Tag = (j + 1).ToString();
@ -1135,12 +1208,9 @@ namespace SWS.CAD.ViewModels
} }
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{ {
Tag = (i + 1).ToString(); Tag = (i + 1) + "-" + (j + 1).ToString();
} }
break; break;
case "按电缆对编号":
a = selectTagNumberOB.TagNumber;
break;
} }
ec_CableSetWire.Wire_Tag = a + Tag; ec_CableSetWire.Wire_Tag = a + Tag;
ec_CableSet.Wires.Add(ec_CableSetWire); ec_CableSet.Wires.Add(ec_CableSetWire);
@ -1177,6 +1247,7 @@ namespace SWS.CAD.ViewModels
ec_Cable.EngineerDataID = selectTagNumberOB.EngineDataID; ec_Cable.EngineerDataID = selectTagNumberOB.EngineDataID;
ec_Cable.Sets = new List<ec_CableSet>(); ec_Cable.Sets = new List<ec_CableSet>();
int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0; int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
int n = 0;
for (int i = 0; i < CableSetCount; i++) for (int i = 0; i < CableSetCount; i++)
{ {
ec_CableSet ec_CableSet = new ec_CableSet(); ec_CableSet ec_CableSet = new ec_CableSet();
@ -1186,6 +1257,7 @@ namespace SWS.CAD.ViewModels
int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0; int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
for (int j = 0; j < WireCount; j++) for (int j = 0; j < WireCount; j++)
{ {
n++;
ec_CableSetWire ec_CableSetWire = new ec_CableSetWire(); ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)]; ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
ec_CableSetWire.SetLevel = j + 1; ec_CableSetWire.SetLevel = j + 1;
@ -1194,6 +1266,20 @@ namespace SWS.CAD.ViewModels
switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault()) switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
{ {
case "按电缆编号": case "按电缆编号":
if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
{
Tag = n.ToString();
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
{
Tag = Tag + (char)('A' + (n - 1));
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{
Tag = (i + 1) + "-" + n.ToString();
}
break;
case "按电缆对编号":
if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
{ {
Tag = (j + 1).ToString(); Tag = (j + 1).ToString();
@ -1204,12 +1290,9 @@ namespace SWS.CAD.ViewModels
} }
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{ {
Tag = (i + 1).ToString(); Tag = (i + 1) + "-" + (j + 1).ToString();
} }
break; break;
case "按电缆对编号":
a = selectTagNumberOB.TagNumber;
break;
} }
ec_CableSetWire.Wire_Tag = a + Tag; ec_CableSetWire.Wire_Tag = a + Tag;
ec_CableSet.Wires.Add(ec_CableSetWire); ec_CableSet.Wires.Add(ec_CableSetWire);
@ -1502,11 +1585,12 @@ namespace SWS.CAD.ViewModels
//获取位号的电缆属性,判断是否设置电缆规格 //获取位号的电缆属性,判断是否设置电缆规格
var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(resTagNumberListByPixels.TagNumber); var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(resTagNumberListByPixels.TagNumber);
var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(resTagNumberListByPixels.TagNumber)).FirstOrDefault(); var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(resTagNumberListByPixels.TagNumber)).FirstOrDefault();
if (string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
//if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault())) //if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
//{ {
// System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return;
//} }
//获取电缆的配置,没有则创建新配置 //获取电缆的配置,没有则创建新配置
var CableBy = await _iOModuleService.GetCableByEngID(resTagNumberListByPixels?.EngineDataID); var CableBy = await _iOModuleService.GetCableByEngID(resTagNumberListByPixels?.EngineDataID);
if (CableBy == null) if (CableBy == null)
@ -1540,6 +1624,7 @@ namespace SWS.CAD.ViewModels
ec_Cable.EngineerDataID = resTagNumberListByPixels.EngineDataID; ec_Cable.EngineerDataID = resTagNumberListByPixels.EngineDataID;
ec_Cable.Sets = new List<ec_CableSet>(); ec_Cable.Sets = new List<ec_CableSet>();
int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0; int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
int n = 0;
for (int i = 0; i < CableSetCount; i++) for (int i = 0; i < CableSetCount; i++)
{ {
ec_CableSet ec_CableSet = new ec_CableSet(); ec_CableSet ec_CableSet = new ec_CableSet();
@ -1549,6 +1634,7 @@ namespace SWS.CAD.ViewModels
int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0; int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
for (int j = 0; j < WireCount; j++) for (int j = 0; j < WireCount; j++)
{ {
n++;
ec_CableSetWire ec_CableSetWire = new ec_CableSetWire(); ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)]; ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
ec_CableSetWire.SetLevel = j + 1; ec_CableSetWire.SetLevel = j + 1;
@ -1557,6 +1643,20 @@ namespace SWS.CAD.ViewModels
switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault()) switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
{ {
case "按电缆编号": case "按电缆编号":
if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
{
Tag = n.ToString();
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
{
Tag = Tag + (char)('A' + (n - 1));
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{
Tag = (i + 1) + "-" + n.ToString();
}
break;
case "按电缆对编号":
if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
{ {
Tag = (j + 1).ToString(); Tag = (j + 1).ToString();
@ -1567,12 +1667,9 @@ namespace SWS.CAD.ViewModels
} }
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{ {
Tag = (i + 1).ToString(); Tag = (i + 1) + "-" + (j + 1).ToString();
} }
break; break;
case "按电缆对编号":
a = resTagNumberListByPixels.TagNumber;
break;
} }
ec_CableSetWire.Wire_Tag = a + Tag; ec_CableSetWire.Wire_Tag = a + Tag;
ec_CableSet.Wires.Add(ec_CableSetWire); ec_CableSet.Wires.Add(ec_CableSetWire);
@ -1609,6 +1706,7 @@ namespace SWS.CAD.ViewModels
ec_Cable.EngineerDataID = resTagNumberListByPixels.EngineDataID; ec_Cable.EngineerDataID = resTagNumberListByPixels.EngineDataID;
ec_Cable.Sets = new List<ec_CableSet>(); ec_Cable.Sets = new List<ec_CableSet>();
int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0; int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
int n = 0;
for (int i = 0; i < CableSetCount; i++) for (int i = 0; i < CableSetCount; i++)
{ {
ec_CableSet ec_CableSet = new ec_CableSet(); ec_CableSet ec_CableSet = new ec_CableSet();
@ -1618,6 +1716,7 @@ namespace SWS.CAD.ViewModels
int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0; int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
for (int j = 0; j < WireCount; j++) for (int j = 0; j < WireCount; j++)
{ {
n++;
ec_CableSetWire ec_CableSetWire = new ec_CableSetWire(); ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)]; ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
ec_CableSetWire.SetLevel = j + 1; ec_CableSetWire.SetLevel = j + 1;
@ -1626,6 +1725,20 @@ namespace SWS.CAD.ViewModels
switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault()) switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
{ {
case "按电缆编号": case "按电缆编号":
if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
{
Tag = n.ToString();
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
{
Tag = Tag + (char)('A' + (n - 1));
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{
Tag = (i + 1) + "-" + n.ToString();
}
break;
case "按电缆对编号":
if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字")) if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
{ {
Tag = (j + 1).ToString(); Tag = (j + 1).ToString();
@ -1636,12 +1749,9 @@ namespace SWS.CAD.ViewModels
} }
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号")) else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{ {
Tag = (i + 1).ToString(); Tag = (i + 1) + "-" + (j + 1).ToString();
} }
break; break;
case "按电缆对编号":
a = resTagNumberListByPixels.TagNumber;
break;
} }
ec_CableSetWire.Wire_Tag = a + Tag; ec_CableSetWire.Wire_Tag = a + Tag;
ec_CableSet.Wires.Add(ec_CableSetWire); ec_CableSet.Wires.Add(ec_CableSetWire);
@ -2055,7 +2165,7 @@ namespace SWS.CAD.ViewModels
if (result == MessageBoxResult.OK) if (result == MessageBoxResult.OK)
{ {
var httpres = await _iOModuleService.DeletePanelChannel(SelectedChannelInfo.ChannelID); var httpres = await _iOModuleService.DeletePanelChannel(SelectedChannelInfo.ChannelID);
if (httpres!=null) if (httpres != null)
{ {
System.Windows.MessageBox.Show(httpres, "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return; System.Windows.MessageBox.Show(httpres, "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); return;
@ -2531,8 +2641,8 @@ namespace SWS.CAD.ViewModels
ent.Signals = new List<SWS.Model.ec_Wire_Group>(); ent.Signals = new List<SWS.Model.ec_Wire_Group>();
ent.Signals.Add(SelectedChannelInfo.Signal); ent.Signals.Add(SelectedChannelInfo.Signal);
//解除信号 //解除信号
var data = await _wireGroupService.SaveSignals(ent); var data = await _wireGroupService.SaveSignals(ent) as learunHttpRes<List<ec_Wire_Group>>;
if (data != null) if (data.code ==200)
{ {
ChannelInfos.Clear(); ChannelInfos.Clear();
UpdateChannelInfos(); UpdateChannelInfos();

View File

@ -1,29 +1,208 @@
 
using Prism.Events;
using Prism.Ioc; using Prism.Ioc;
using Prism.Services.Dialogs; using Prism.Services.Dialogs;
using SWS.CAD.Event;
using SWS.CAD.ViewModels.myViewModelBase; using SWS.CAD.ViewModels.myViewModelBase;
using SWS.CAD.Views; using SWS.CAD.Views;
using SWS.CAD.Views.CustomControl; using SWS.CAD.Views.CustomControl;
using SWS.Commons; using SWS.Commons;
using SWS.Model;
using SWS.Service;
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input; using System.Windows.Input;
using Telerik.Windows.Controls;
using Unity; using Unity;
using DelegateCommand = Prism.Commands.DelegateCommand;
namespace SWS.CAD.ViewModels namespace SWS.CAD.ViewModels
{ {
public class DialogSignalPredistributionViewModel : DialogBase, IDialogAware public class DialogSignalPredistributionViewModel : DialogBase, IDialogAware
{ {
private string objectTypeId; #region
private ObservableCollection<Model.TreeModel> _PanelTreels = new ObservableCollection<Model.TreeModel>();
/// <summary> /// <summary>
/// 新建位号 /// 页面左侧树形结构数据
/// </summary> /// </summary>
public ICommand Command_NewTagNumber { get; set; } public ObservableCollection<Model.TreeModel> PanelTreels
{
get { return _PanelTreels; }
set { _PanelTreels = value; RaisePropertyChanged(nameof(PanelTreels)); }
}
private Model.TreeModel _SelectedTreeNode;
/// <summary>
/// 当前选中的树形节点
/// </summary>
public Model.TreeModel SelectedTreeNode
{
get { return _SelectedTreeNode; }
set
{
_SelectedTreeNode = value;
RaisePropertyChanged(nameof(SelectedTreeNode));
var path= FindNodePath(PanelTreels, _SelectedTreeNode);
_eventAggregator.GetEvent<ScrollToItemEvent>().Publish(path);
}
}
private ObservableCollection<SignalPredistributionInfo> _SignalPredistributionInfos = new ObservableCollection<SignalPredistributionInfo>();
/// <summary>
/// 表格数据
/// </summary>
public ObservableCollection<SignalPredistributionInfo> SignalPredistributionInfos
{
get { return _SignalPredistributionInfos; }
set
{
_SignalPredistributionInfos = value;
RaisePropertyChanged(nameof(SignalPredistributionInfos));
}
}
private string _SelectedOption1;
/// <summary>
/// 是否通讯母线
/// </summary>
public string SelectedOption1
{
get { return _SelectedOption1; }
set
{
_SelectedOption1 = value;
RaisePropertyChanged(nameof(SelectedOption1));
}
}
private string _SelectedOption2;
/// <summary>
/// 选择的信号类型
/// </summary>
public string SelectedOption2
{
get { return _SelectedOption2; }
set
{
_SelectedOption2 = value;
SignalColumnName = value;
RaisePropertyChanged(nameof(SelectedOption2));
}
}
private string _SignalColumnName;
/// <summary>
/// 信号类型列的列名
/// </summary>
public string SignalColumnName
{
get { return _SignalColumnName; }
set
{
_SignalColumnName = value;
RaisePropertyChanged(nameof(SignalColumnName));
if (value.Equals("Digital"))
{
SignalTypeColumn = new ObservableCollection<string>() { "无公共端接线(断开报警NC)", "无公共端接线(闭合报警NO)", "带公共端接线(断开报警NC)", "带公共端接线(闭合报警NO)" };
}
else if (value.Equals("4-20mA"))
{
SignalTypeColumn = new ObservableCollection<string>() { "无源", "有源" };
}
else if (value.Equals("-10V-10V"))
{
SignalTypeColumn = new ObservableCollection<string>() { "无源", "有源" };
}
else if (value.Equals("PT100"))
{
SignalTypeColumn = new ObservableCollection<string>() { "量程100", "量程150", "量程200", "量程600" };
}
else if (value.Equals("Pulse"))
{
SignalTypeColumn = new ObservableCollection<string>() { "脉冲信号" };
}
}
}
private List<string> _CommunicationFormats = new List<string>() { "RS485", "RS482", "TCP/IP", "MQTT" };
/// <summary>
/// 通讯格式集合
/// </summary>
public List<string> CommunicationFormats
{
get { return _CommunicationFormats; }
set
{
_CommunicationFormats = value;
RaisePropertyChanged(nameof(CommunicationFormats));
}
}
private string _CommunicationFormat = "RS485";
/// <summary>
/// 通讯格式
/// </summary>
public string CommunicationFormat
{
get { return _CommunicationFormat; }
set
{
_CommunicationFormat = value;
RaisePropertyChanged(nameof(CommunicationFormat));
}
}
private ObservableCollection<string> _SignalTypeColumn;
/// <summary>
/// 信号类型列的下拉列表
/// </summary>
public ObservableCollection<string> SignalTypeColumn
{
get { return _SignalTypeColumn; }
set
{
_SignalTypeColumn = value;
RaisePropertyChanged(nameof(SignalTypeColumn));
if (SignalPredistributionInfos != null)
{
foreach (var item in SignalPredistributionInfos)
{
item.SignalType = _SignalTypeColumn.FirstOrDefault();
}
}
}
}
private List<string> _InorOuts = new List<string>() { "输出", "输入" };
/// <summary>
/// 输入/输出列的下拉列表
/// </summary>
public List<string> InorOuts
{
get { return _InorOuts; }
set
{
_InorOuts = value;
RaisePropertyChanged(nameof(InorOuts));
}
}
#endregion
IOModuleService _iOModuleService;
IEventAggregator _eventAggregator;
public DialogSignalPredistributionViewModel() public DialogSignalPredistributionViewModel()
{ {
title = "电缆信号预分配"; _iOModuleService = GlobalObject.container.Resolve<IOModuleService>();
_eventAggregator = GlobalObject.container.Resolve<IEventAggregator>();
} }
public string Title => ""; public string Title => "";
@ -38,16 +217,157 @@ namespace SWS.CAD.ViewModels
{ {
} }
private ec_Cable CableBy;
public void OnDialogOpened(IDialogParameters parameters) public async void OnDialogOpened(IDialogParameters parameters)
{ {
//listTags = parameters.GetValue<ObservableCollection<KeyValueModel>>(GlobalObject.dialogPar.info.ToString()); title = $"电缆信号({parameters.GetValue<string>(GlobalObject.dialogPar.para2.ToString())})预分配";
objectTypeId = parameters.GetValue<string>(GlobalObject.dialogPar.id.ToString()); //树形结构数据
PanelTreels.AddRange(await _iOModuleService.GetPanelTree());
//电缆信息
CableBy = parameters.GetValue<ec_Cable>(GlobalObject.dialogPar.para1.ToString());
//是否母线
if (CableBy.CableClass.Equals("homerun"))
{
SelectedOption1 = "是";
}
else if (CableBy.CableClass.Equals("conventional") || CableBy.CableClass.Equals(""))
{
SelectedOption1 = "否";
}
//设置默认信号类型
if (string.IsNullOrEmpty(CableBy.PreAssignIOType))
{
SelectedOption2 = "Digital";
}
else
{
SelectedOption2 = CableBy.PreAssignIOType;
}
//设置表格数据
int index = 0;
foreach (var Set in CableBy.Sets)
{
SignalPredistributionInfo predistributionInfo = new SignalPredistributionInfo();
predistributionInfo.CablePair = Set.CableSetName;
foreach (var Wire in Set.Wires)
{
index++;
predistributionInfo.Index.Add(index.ToString());
predistributionInfo.CableWires.Add(Wire);
predistributionInfo.Polaritys.Add(Wire);
}
if (string.IsNullOrEmpty(Set.PreAssignIOTypeDetail))
{
predistributionInfo.SignalType = SignalTypeColumn.FirstOrDefault();
}
else
{
predistributionInfo.SignalType = Set.PreAssignIOTypeDetail;
}
predistributionInfo.ChineseDescription = Set.PreAssignGroup_Desc;
predistributionInfo.EnglishDescription = Set.PreAssignGroup_Desc_EN;
if (string.IsNullOrEmpty(Set.PreAssignInOrOut))
{
predistributionInfo.InorOut = InorOuts.FirstOrDefault();
}
else
{
predistributionInfo.InorOut = Set.PreAssignInOrOut;
}
predistributionInfo.SensorCode = Set.PreAssignSensorCode;
SignalPredistributionInfos.Add(predistributionInfo);
}
//是否预关联,有则选中节点
foreach (var Panel in PanelTreels)
{
if (!string.IsNullOrEmpty(Panel.ID))
{
if (Panel.ID.Equals(CableBy.PanelID))
{
SelectedTreeNode = Panel;
break;
}
}
foreach (var Child in Panel.ChildNodes)
{
if (!string.IsNullOrEmpty(Child.ID))
{
if (Child.ID.Equals(CableBy.PanelID))
{
SelectedTreeNode = Child;
break;
}
}
}
}
} }
public override void ExecuteOKCommandAsync(object para) public override async void ExecuteOKCommandAsync(object para)
{ {
//创建SaveCable接口实例
ec_Cable newCable = new ec_Cable();
if (SelectedOption1.Equals("是"))
{
newCable.CableClass = "homerun";
newCable.PreAssignIOType = CommunicationFormat;
}
else
{
newCable.CableClass = "conventional";
newCable.PreAssignIOType = SelectedOption2;
}
newCable.CableID = CableBy.CableID;
newCable.EngineerDataID = CableBy.EngineerDataID;
if (SelectedTreeNode != null)
{
newCable.PanelID = SelectedTreeNode.ID;
}
else
{
MessageBox.Show("请选择系统柜!", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
newCable.UpdateUserID = GlobalObject.userInfo.userId;
newCable.Sets = new List<ec_CableSet>();
foreach (var CableBySet in CableBy.Sets)
{
ec_CableSet newCableSet = new ec_CableSet();
newCableSet.CableSetID = CableBySet.CableSetID;
newCableSet.CableSetName = CableBySet.CableSetName;
newCableSet.CableSetSeq = CableBySet.CableSetSeq;
newCableSet.IsConned = CableBySet.IsConned;
newCableSet.PreAssignGroup_Desc = SignalPredistributionInfos.FirstOrDefault(s => s.CablePair.Equals(CableBySet.CableSetName)).ChineseDescription;
newCableSet.PreAssignGroup_Desc_EN = SignalPredistributionInfos.FirstOrDefault(s => s.CablePair.Equals(CableBySet.CableSetName)).EnglishDescription;
newCableSet.PreAssignIOTypeDetail = SignalPredistributionInfos.FirstOrDefault(s => s.CablePair.Equals(CableBySet.CableSetName)).SignalType;
newCableSet.PreAssignInOrOut = SignalPredistributionInfos.FirstOrDefault(s => s.CablePair.Equals(CableBySet.CableSetName)).InorOut;
newCableSet.PreAssignSensorCode = SignalPredistributionInfos.FirstOrDefault(s => s.CablePair.Equals(CableBySet.CableSetName)).SensorCode;
newCableSet.Wires = new List<ec_CableSetWire>();
foreach (var wire in CableBySet.Wires)
{
ec_CableSetWire newWire = new ec_CableSetWire();
newWire.Polarity = wire.Polarity;
newWire.SetLevel = 0;
newWire.WireID = wire.WireID;
newWire.Wire_Tag = wire.Wire_Tag;
newWire.Wire_Color_ID = wire.Wire_Color_ID;
newWire.PreAssignChannelTermNo = SignalPredistributionInfos.FirstOrDefault(s => s.CablePair.Equals(CableBySet.CableSetName)).CableWires.FirstOrDefault(c => c.Wire_Tag.Equals(wire.Wire_Tag)).PreAssignChannelTermNo;
newCableSet.Wires.Add(newWire);
}
newCable.Sets.Add(newCableSet);
}
var httpres = await _iOModuleService.SaveCable(newCable);
IDialogParameters res = new Prism.Services.Dialogs.DialogParameters(); IDialogParameters res = new Prism.Services.Dialogs.DialogParameters();
//res.Add(GlobalObject.dialogPar.info.ToString(), TagNumber); //res.Add(GlobalObject.dialogPar.info.ToString(), TagNumber);
RequestClose.Invoke(new DialogResult(ButtonResult.Yes, res)); RequestClose.Invoke(new DialogResult(ButtonResult.Yes, res));
@ -65,8 +385,199 @@ namespace SWS.CAD.ViewModels
} }
this.Dispose(); this.Dispose();
} }
#region
public ICommand ButtonCmd => new DelegateCommand(Button_Click);
/// <summary>
/// 页面左侧按钮
/// </summary>
/// <param name="parameter"></param>
public virtual async void Button_Click(object parameter)
{
#region
if (parameter.ToString().Equals("清除配置"))
{
MessageBoxResult result = MessageBox.Show($"确定删除“{ CableBy.TagNumber}”电缆配置?", "KunHengCAD", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (result == MessageBoxResult.OK)
{
var httpres = await _iOModuleService.DeleteCableProfile(CableBy.CableID);
if (httpres == null)
{
RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
this.Dispose();
}
}
return;
}
#endregion
#region
if (parameter.ToString().Equals("指定中英文"))
{
//SelectedTreeNode = PanelTreels[2].ChildNodes.LastOrDefault();
return;
}
#endregion
}
#region
public List<string> FindNodePath(ObservableCollection<TreeModel> nodes, TreeModel targetNode)
{
List<string> path = new List<string>();
FindNodePathRecursive(nodes, targetNode, path);
return path;
}
private bool FindNodePathRecursive(IEnumerable<TreeModel> nodes, TreeModel targetNode, List<string> currentPath)
{
foreach (var node in nodes)
{
currentPath.Add(node.Text);
if (node == targetNode) return true; // 找到目标节点返回True并结束搜索
if (node.ChildNodes.Count > 0 && FindNodePathRecursive(node.ChildNodes, targetNode, currentPath))
return true; // 在子节点中继续搜索并找到目标节点返回True并结束搜索
currentPath.RemoveAt(currentPath.Count - 1); // 回溯,尝试下一个兄弟节点或父节点的其他兄弟节点
}
return false; // 没有找到目标节点返回False
}
#endregion
#endregion
} }
public class SignalPredistributionInfo : DialogBase
{
#region
private ObservableCollection<string> _Index = new ObservableCollection<string>();
/// <summary>
/// 序号集合
/// </summary>
public ObservableCollection<string> Index
{
get { return _Index; }
set { _Index = value; }
}
private string _CablePair;
/// <summary>
/// 电缆对
/// </summary>
public string CablePair
{
get { return _CablePair; }
set { _CablePair = value; }
}
private ObservableCollection<ec_CableSetWire> _CableWires = new ObservableCollection<ec_CableSetWire>();
/// <summary>
/// 电缆线号
/// </summary>
public ObservableCollection<ec_CableSetWire> CableWires
{
get { return _CableWires; }
set { _CableWires = value; }
}
private ObservableCollection<ec_CableSetWire> _Polaritys = new ObservableCollection<ec_CableSetWire>();
/// <summary>
/// 极性
/// </summary>
public ObservableCollection<ec_CableSetWire> Polaritys
{
get { return _Polaritys; }
set
{
_Polaritys = value;
RaisePropertyChanged(nameof(Polaritys));
}
}
private string _SignalType;
/// <summary>
/// 信号类型
/// </summary>
public string SignalType
{
get { return _SignalType; }
set
{
_SignalType = value;
RaisePropertyChanged(nameof(SignalType));
}
}
private string _ChineseDescription;
/// <summary>
/// 中文描述
/// </summary>
public string ChineseDescription
{
get { return _ChineseDescription; }
set
{
_ChineseDescription = value;
RaisePropertyChanged(nameof(ChineseDescription));
}
}
private string _EnglishDescription;
/// <summary>
/// 英文描述
/// </summary>
public string EnglishDescription
{
get { return _EnglishDescription; }
set
{
_EnglishDescription = value;
RaisePropertyChanged(nameof(EnglishDescription));
}
}
private string _InorOut;
/// <summary>
/// 输入/输出
/// </summary>
public string InorOut
{
get { return _InorOut; }
set
{
_InorOut = value;
RaisePropertyChanged(nameof(InorOut));
}
}
private string _SensorCode;
/// <summary>
/// 传感器编号
/// </summary>
public string SensorCode
{
get { return _SensorCode; }
set
{
_SensorCode = value;
RaisePropertyChanged(nameof(SensorCode));
}
}
private ObservableCollection<ec_PanelStripTerm> _Terms = new ObservableCollection<ec_PanelStripTerm>();
/// <summary>
/// 端子号集合
/// </summary>
public ObservableCollection<ec_PanelStripTerm> Terms
{
get { return _Terms; }
set { _Terms = value; }
}
#endregion
}
} }

View File

@ -248,7 +248,6 @@
</ItemsControl> </ItemsControl>
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="CellEditTemplate1"> <DataTemplate x:Key="CellEditTemplate1">
<!-- 使用ItemsControl垂直显示多个值 -->
<ItemsControl ItemsSource="{Binding Index}"> <ItemsControl ItemsSource="{Binding Index}">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
@ -265,7 +264,6 @@
<!-- 使用ItemsControl垂直显示多个值 --> <!-- 使用ItemsControl垂直显示多个值 -->
<DataTemplate x:Key="CellTemplate2"> <DataTemplate x:Key="CellTemplate2">
<!-- 使用ItemsControl垂直显示多个值 -->
<ItemsControl ItemsSource="{Binding Terms}"> <ItemsControl ItemsSource="{Binding Terms}">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
@ -283,7 +281,6 @@
</ItemsControl> </ItemsControl>
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="CellEditTemplate2"> <DataTemplate x:Key="CellEditTemplate2">
<!-- 使用ItemsControl垂直显示多个值 -->
<ItemsControl ItemsSource="{Binding Terms}"> <ItemsControl ItemsSource="{Binding Terms}">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
@ -503,6 +500,7 @@
Margin="5" telerik:StyleManager.Theme="Office_Blue" AllowDrop="True" Margin="5" telerik:StyleManager.Theme="Office_Blue" AllowDrop="True"
AutoScrollToSelectedItem="True" AutoScrollToSelectedItem="True"
IsVirtualizing="True" IsVirtualizing="True"
telerik:TextSearch.TextPath="Text"
> >
<telerik:RadTreeView.ItemTemplate> <telerik:RadTreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding ChildNodes}"> <HierarchicalDataTemplate ItemsSource="{Binding ChildNodes}">

View File

@ -1,12 +1,17 @@
 
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using Prism.Events;
using SWS.CAD.Event;
using SWS.CAD.ViewModels; using SWS.CAD.ViewModels;
using SWS.Commons;
using Telerik.Windows.Controls; using Telerik.Windows.Controls;
using Unity;
namespace SWS.CAD.Views.Dialog namespace SWS.CAD.Views.Dialog
{ {
@ -15,10 +20,14 @@ namespace SWS.CAD.Views.Dialog
/// </summary> /// </summary>
public partial class DialogIODistribution : UserControl public partial class DialogIODistribution : UserControl
{ {
IEventAggregator _eventAggregator;
public DialogIODistribution() public DialogIODistribution()
{ {
InitializeComponent(); InitializeComponent();
DataContext = new DialogIODistributionViewModel(); DataContext = new DialogIODistributionViewModel();
_eventAggregator = GlobalObject.container.Resolve<IEventAggregator>();
_eventAggregator.GetEvent<ScrollToItemEvent>().Subscribe(ScrollToSelectedItem, ThreadOption.UIThread, true);
} }
private void RadTreeView_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) private void RadTreeView_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
@ -83,5 +92,13 @@ namespace SWS.CAD.Views.Dialog
return source as T; return source as T;
} }
// 滚动到选中项
private void ScrollToSelectedItem(object path)
{
var pathls = path as List<string>;
var ph = string.Join("\\", pathls);
treeView1.BringPathIntoView(ph);
}
} }
} }

View File

@ -6,8 +6,9 @@
xmlns:prism="http://prismlibrary.com/" xmlns:prism="http://prismlibrary.com/"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:local="clr-namespace:SWS.CAD.Views.Dialog" xmlns:local="clr-namespace:SWS.CAD.Views.Dialog"
xmlns:cvt="clr-namespace:SWS.Commons.Helper.Converter;assembly=SWS.Commons"
xmlns:CustomControl="clr-namespace:SWS.CustomControl;assembly=SWS.CustomControl" xmlns:CustomControl="clr-namespace:SWS.CustomControl;assembly=SWS.CustomControl"
Width="1000" Height="800" Width="1000" Height="790"
mc:Ignorable="d" > mc:Ignorable="d" >
<prism:Dialog.WindowStyle> <prism:Dialog.WindowStyle>
<Style TargetType="Window"> <Style TargetType="Window">
@ -27,11 +28,246 @@
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/SWS.WPF;component/Style/CustomStyles.xaml" /> <ResourceDictionary Source="pack://application:,,,/SWS.WPF;component/Style/CustomStyles.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<!-- 转换器 -->
<cvt:RadioButtonValueConverter x:Key="RadioButtonValueCvt" />
<!-- GroupBox显示隐藏 -->
<Style x:Key="SecondGroupStyle1" TargetType="GroupBox">
<Style.Triggers>
<DataTrigger Binding="{Binding IsChecked, ElementName=RadioButton1}" Value="True">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsChecked, ElementName=RadioButton1}" Value="False">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="SecondGroupStyle2" TargetType="GroupBox">
<Style.Triggers>
<DataTrigger Binding="{Binding IsChecked, ElementName=RadioButton1}" Value="True">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsChecked, ElementName=RadioButton1}" Value="False">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
<!-- 树结构展开按钮样式 -->
<Style x:Key="ExpanderStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="IsEnabled" Value="True" />
<Setter Property="IsTabStop" Value="True" />
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid>
<Grid x:Name="ButtonOver" Opacity="0" Margin="0,4,0,0"
HorizontalAlignment="Right" VerticalAlignment="Top"
Width="16" Height="16">
<Rectangle Stroke="#FF027BA6" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" Width="Auto" Height="Auto"
RadiusX="3" RadiusY="3">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF00BCFF" Offset="0" />
<GradientStop Color="#FF027BA6" Offset="1" />
<GradientStop Color="#FF00A5E0" Offset="0.5" />
<GradientStop Color="#FF005674" Offset="0.501" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle x:Name="CollapsedVisualOver"
HorizontalAlignment="Left" VerticalAlignment="Top"
Width="2" Height="8" RadiusX="0" RadiusY="0"
Fill="#FFFFFFFF" Margin="7,4,0,0" />
<Rectangle RadiusX="0" RadiusY="0" Fill="#FFFFFFFF"
HorizontalAlignment="Left" VerticalAlignment="Top"
Width="8" Height="2" Margin="4,7,0,0" />
</Grid>
<Grid x:Name="Button" Margin="0,6,5.5,0" HorizontalAlignment="Right"
VerticalAlignment="Top" Width="10" Height="10">
<Rectangle Stroke="#ffc7defc" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" Width="Auto" Height="Auto"
RadiusX="1" RadiusY="1" Fill="#ffc7defc">
</Rectangle>
<Rectangle x:Name="CollapsedVisual" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="2" Height="6" RadiusX="0"
RadiusY="0" Fill="#FF3C6AA3" Margin="4,2,0,0" />
<Rectangle RadiusX="0" RadiusY="0" Fill="#FF3C6AA3"
HorizontalAlignment="Left" Margin="2,3.5,0,0"
VerticalAlignment="Top" Width="6" Height="2" />
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="CollapsedVisualOver" Storyboard.TargetProperty="(UIElement.Opacity)" To="0"/>
<DoubleAnimation Storyboard.TargetName="CollapsedVisual" Storyboard.TargetProperty="(UIElement.Opacity)" To="0"/>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="CollapsedVisualOver" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/>
<DoubleAnimation Storyboard.TargetName="CollapsedVisual" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/>
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 树结构节点默认展开样式设置 -->
<Style x:Key="ExpandedTreeViewItemStyle" TargetType="telerik:RadTreeViewItem">
<Setter Property="IsExpanded" Value="True"/>
</Style>
<!-- GridViewCell样式 -->
<Style x:Key="CellTyle1" TargetType="telerik:GridViewCell" >
<Setter Property="Background" Value="#F8F9F1" />
</Style>
<!-- 使用ItemsControl垂直显示多个值 -->
<DataTemplate x:Key="CellTemplate1">
<ItemsControl ItemsSource="{Binding Index}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#cccccc" BorderThickness="0,0,0,1" Padding="0">
<TextBlock Text="{Binding}" TextAlignment="Center" Padding="4,2" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
<DataTemplate x:Key="CellEditTemplate1">
<ItemsControl ItemsSource="{Binding Index}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding}" TextAlignment="Center" Padding="4,2" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
<!-- 使用ItemsControl垂直显示多个值 -->
<DataTemplate x:Key="CellTemplate2">
<ItemsControl ItemsSource="{Binding CableWires}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#cccccc" BorderThickness="0,0,0,1" Padding="0"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<TextBlock Text="{Binding PreAssignChannelTermNo}" TextAlignment="Center" Padding="4,2" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
<DataTemplate x:Key="CellEditTemplate2">
<ItemsControl ItemsSource="{Binding CableWires}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding PreAssignChannelTermNo}" TextAlignment="Center" Padding="4,2" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
<!-- 使用ItemsControl垂直显示多个值 -->
<DataTemplate x:Key="CellTemplate3">
<ItemsControl ItemsSource="{Binding CableWires}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#cccccc" BorderThickness="0,0,0,1" Padding="0">
<TextBlock Text="{Binding Wire_Tag}" TextAlignment="Center" Padding="4,2" Width="auto"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
<DataTemplate x:Key="CellEditTemplate3">
<ItemsControl ItemsSource="{Binding CableWires}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding Wire_Tag}" TextAlignment="Center" Padding="4,2" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
<!-- 使用ItemsControl垂直显示多个值 -->
<DataTemplate x:Key="CellTemplate4">
<ItemsControl ItemsSource="{Binding Polaritys}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#cccccc" BorderThickness="0,0,0,1" Padding="0">
<TextBlock Text="{Binding Polarity}" TextAlignment="Center" Padding="4,2" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
<DataTemplate x:Key="CellEditTemplate4">
<ItemsControl ItemsSource="{Binding Polaritys}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding Polarity}" TextAlignment="Center" Padding="4,2" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
<telerik:RadBusyIndicator BusyContent="{Binding BusyContent}" IsBusy="{Binding IsBusy}"> <telerik:RadBusyIndicator BusyContent="{Binding BusyContent}" IsBusy="{Binding IsBusy}">
<StackPanel Background="#f0f0f0"> <StackPanel Background="#f0f0f0">
<CustomControl:customWindowTitleBar x:Name="titleBar" /> <CustomControl:customWindowTitleBar x:Name="titleBar" />
<StackPanel Grid.Row="1" Orientation="Horizontal"> <StackPanel Grid.Row="1" Orientation="Horizontal">
<GroupBox Margin="5,10,5,5" <GroupBox Margin="5,10,5,5"
@ -39,78 +275,197 @@
Header="通讯信号"> Header="通讯信号">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="是否通讯母线" Margin="5"/> <TextBlock Text="是否通讯母线" Margin="5"/>
<RadioButton Content="是" GroupName="OptionGroup1" Margin="5"/> <RadioButton x:Name="RadioButton1"
<RadioButton x:Name="RadioButton1" Content="否" GroupName="OptionGroup1" Margin="5"/> Content="是"
<TextBlock Text="通讯格式" Margin="5"/> GroupName="OptionGroup1"
<ComboBox /> Margin="5"
IsChecked="{Binding SelectedOption1 ,Converter={StaticResource RadioButtonValueCvt},ConverterParameter=是}"/>
<RadioButton x:Name="RadioButton2"
Content="否"
GroupName="OptionGroup1"
Margin="5"
IsChecked="{Binding SelectedOption1 ,Converter={StaticResource RadioButtonValueCvt},ConverterParameter=否}"/>
</StackPanel> </StackPanel>
</GroupBox> </GroupBox>
<GroupBox Margin="5,0,5,5" <GroupBox Margin="5,0,5,5"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
Header="信号类型"> Header="信号类型"
Style="{StaticResource SecondGroupStyle1}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<RadioButton IsEnabled="{Binding IsChecked,ElementName=RadioButton1}" Content="Digital" GroupName="OptionGroup2" Margin="5"/> <RadioButton IsChecked="{Binding SelectedOption2 ,Converter={StaticResource RadioButtonValueCvt},ConverterParameter=Digital}"
<RadioButton IsEnabled="{Binding IsChecked,ElementName=RadioButton1}" Content="4-20mA" GroupName="OptionGroup2" Margin="5"/> Content="Digital" GroupName="OptionGroup2" Margin="5"/>
<RadioButton IsEnabled="{Binding IsChecked,ElementName=RadioButton1}" Content="-10V-10V" GroupName="OptionGroup2" Margin="5"/> <RadioButton IsChecked="{Binding SelectedOption2 ,Converter={StaticResource RadioButtonValueCvt},ConverterParameter=4-20mA}"
<RadioButton IsEnabled="{Binding IsChecked,ElementName=RadioButton1}" Content="PT100" GroupName="OptionGroup2" Margin="5"/> Content="4-20mA" GroupName="OptionGroup2" Margin="5"/>
<RadioButton IsEnabled="{Binding IsChecked,ElementName=RadioButton1}" Content="Pulse" GroupName="OptionGroup2" Margin="5"/> <RadioButton IsChecked="{Binding SelectedOption2 ,Converter={StaticResource RadioButtonValueCvt},ConverterParameter=-10V-10V}"
Content="-10V-10V" GroupName="OptionGroup2" Margin="5"/>
<RadioButton IsChecked="{Binding SelectedOption2 ,Converter={StaticResource RadioButtonValueCvt},ConverterParameter=PT100}"
Content="PT100" GroupName="OptionGroup2" Margin="5"/>
<RadioButton IsChecked="{Binding SelectedOption2 ,Converter={StaticResource RadioButtonValueCvt},ConverterParameter=Pulse}"
Content="Pulse" GroupName="OptionGroup2" Margin="5"/>
</StackPanel>
</GroupBox>
<GroupBox Margin="5,0,5,5"
VerticalAlignment="Bottom"
Header="通讯格式"
Style="{StaticResource SecondGroupStyle2}">
<StackPanel Orientation="Horizontal">
<RadioButton IsChecked="{Binding CommunicationFormat ,Converter={StaticResource RadioButtonValueCvt},ConverterParameter=RS485}"
Content="RS485" GroupName="OptionGroup3" Margin="5"/>
<RadioButton IsChecked="{Binding CommunicationFormat ,Converter={StaticResource RadioButtonValueCvt},ConverterParameter=RS482}"
Content="RS482" GroupName="OptionGroup3" Margin="5"/>
<RadioButton IsChecked="{Binding CommunicationFormat ,Converter={StaticResource RadioButtonValueCvt},ConverterParameter=TCP/IP}"
Content="TCP/IP" GroupName="OptionGroup3" Margin="5"/>
<RadioButton IsChecked="{Binding CommunicationFormat ,Converter={StaticResource RadioButtonValueCvt},ConverterParameter=MQTT}"
Content="MQTT" GroupName="OptionGroup3" Margin="5"/>
</StackPanel> </StackPanel>
</GroupBox> </GroupBox>
</StackPanel> </StackPanel>
<GroupBox Margin="5,0,5,5" <StackPanel Orientation="Horizontal" Grid.Row="2">
Grid.Row="2" <!-- 左侧树形结构 -->
VerticalAlignment="Bottom" <GroupBox Margin="5,0,5,0"
Header="电缆配置信息"> Height="auto"
<Grid> Header="选择该电缆预分配系统柜">
<Grid.ColumnDefinitions> <telerik:RadTreeView x:Name="treeView1"
<ColumnDefinition Width="auto" /> Height="620"
<ColumnDefinition Width="*" /> Width="200"
</Grid.ColumnDefinitions> Background="White"
<StackPanel> IsLineEnabled="True"
<Border BorderThickness="0 0 0 1" Margin="10,0,0,0"> ItemContainerStyle="{StaticResource ExpandedTreeViewItemStyle}"
<TextBlock Text="选择系统柜" Foreground="Black" /> ExpanderStyle="{StaticResource ExpanderStyle}"
</Border> ItemsSource="{Binding PanelTreels}"
SelectedItem="{Binding SelectedTreeNode,Mode=TwoWay}"
<!-- 左侧树形结构 --> telerik:StyleManager.Theme="Office_Blue"
<Border> AllowDrop="True"
<telerik:RadTreeView x:Name="treeView1" AutoScrollToSelectedItem="True"
Height="660" IsVirtualizing="True"
Background="White" telerik:TextSearch.TextPath="Text"
IsLineEnabled="True" >
ItemsSource="{Binding PanelTreels}" <telerik:RadTreeView.ItemTemplate>
SelectedItem="{Binding SelectedTreeNode,Mode=TwoWay}" <HierarchicalDataTemplate ItemsSource="{Binding ChildNodes}">
Margin="5" <TextBlock Text="{Binding Text}">
telerik:StyleManager.Theme="Office_Blue" </TextBlock>
AllowDrop="True" <HierarchicalDataTemplate.ItemTemplate>
AutoScrollToSelectedItem="True"
IsVirtualizing="True"
>
<telerik:RadTreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding ChildNodes}"> <HierarchicalDataTemplate ItemsSource="{Binding ChildNodes}">
<TextBlock Text="{Binding Text}"> <TextBlock Text="{Binding Text}"/>
</TextBlock>
<HierarchicalDataTemplate.ItemTemplate> <HierarchicalDataTemplate.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding ChildNodes}"> <HierarchicalDataTemplate ItemsSource="{Binding PanelTreels}">
<TextBlock Text="{Binding Text}"/> <StackPanel Orientation="Horizontal">
<HierarchicalDataTemplate.ItemTemplate> <TextBlock Text="{Binding Text}"/>
<HierarchicalDataTemplate ItemsSource="{Binding PanelTreels}"> <TextBlock Text=" (" />
<StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding NodeExtData.ChannelsSpared}" FontWeight="Bold" />
<TextBlock Text="{Binding Text}"/> <TextBlock Text=")" />
<TextBlock Text=" (" /> </StackPanel>
<TextBlock Text="{Binding NodeExtData.ChannelsSpared}" FontWeight="Bold" />
<TextBlock Text=")" />
</StackPanel>
</HierarchicalDataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
</HierarchicalDataTemplate> </HierarchicalDataTemplate>
</HierarchicalDataTemplate.ItemTemplate> </HierarchicalDataTemplate.ItemTemplate>
</HierarchicalDataTemplate> </HierarchicalDataTemplate>
</telerik:RadTreeView.ItemTemplate> </HierarchicalDataTemplate.ItemTemplate>
</telerik:RadTreeView> </HierarchicalDataTemplate>
</Border> </telerik:RadTreeView.ItemTemplate>
</StackPanel> </telerik:RadTreeView>
</Grid> </GroupBox>
</GroupBox> <GroupBox Margin="5,0,5,0"
Width="770"
Header="电缆配置信息">
<!-- 数据表格 -->
<Grid>
<telerik:RadGridView x:Name="RadGridView1" SelectionMode="Single" Width="auto" Height="630"
AutoGenerateColumns="False" IsFilteringAllowed="False" Background="#a0a0a0"
IsReadOnly="False" RowIndicatorVisibility="Collapsed"
ShowGroupPanel="False" telerik:StyleManager.Theme="Office_Blue"
ItemsSource="{Binding SignalPredistributionInfos}" SelectedItem="{Binding SelectedChannelInfo, Mode=TwoWay}">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="序号" CellTemplate="{StaticResource CellTemplate1}" CellStyle="{StaticResource CellTyle1}" IsReadOnly="True"/>
<telerik:GridViewDataColumn Header="电缆对" DataMemberBinding="{Binding CablePair}"/>
<telerik:GridViewDataColumn Header="电缆线芯" CellTemplate="{StaticResource CellTemplate3}" CellEditTemplate="{StaticResource CellEditTemplate3}"/>
<telerik:GridViewDataColumn Header="极性" CellTemplate="{StaticResource CellTemplate4}" CellEditTemplate="{StaticResource CellEditTemplate4}"/>
<telerik:GridViewComboBoxColumn Header="{Binding SignalColumnName,Mode=TwoWay}"
IsVisible="{Binding IsChecked,ElementName=RadioButton2}"
ItemsSource="{Binding DataContext.SignalTypeColumn, RelativeSource={RelativeSource AncestorType={x:Type telerik:RadGridView}}}"
DataMemberBinding="{Binding SignalType}"
Width="120">
<telerik:GridViewComboBoxColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding SignalType}"
TextTrimming="CharacterEllipsis"
ToolTip="{Binding SignalType}"/>
</DataTemplate>
</telerik:GridViewComboBoxColumn.CellTemplate>
</telerik:GridViewComboBoxColumn>
<telerik:GridViewDataColumn Header="中文描述" DataMemberBinding="{Binding ChineseDescription}" Width="120">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding ChineseDescription}"
TextTrimming="CharacterEllipsis"
ToolTip="{Binding ChineseDescription}"/>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="英文描述" DataMemberBinding="{Binding EnglishDescription}" Width="120">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding EnglishDescription}"
TextTrimming="CharacterEllipsis"
ToolTip="{Binding EnglishDescription}"/>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
<telerik:GridViewComboBoxColumn Header="输入/输出"
ItemsSource="{Binding DataContext.InorOuts, RelativeSource={RelativeSource AncestorType={x:Type telerik:RadGridView}}}"
DataMemberBinding="{Binding InorOut}"
Width="60">
</telerik:GridViewComboBoxColumn>
<telerik:GridViewDataColumn Header="传感器编号" DataMemberBinding="{Binding EnglishDescription}" Width="auto">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding SensorCode}"
TextTrimming="CharacterEllipsis"
ToolTip="{Binding SensorCode}"/>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="端子号" Width="*" CellTemplate="{StaticResource CellTemplate2}" CellEditTemplate="{StaticResource CellEditTemplate2}"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
</GroupBox>
</StackPanel>
<Grid>
<StackPanel Margin="5" Orientation="Horizontal" HorizontalAlignment="Left">
<telerik:RadButton Margin="0,0,20,0"
Width="100"
HorizontalAlignment="Right"
Style="{StaticResource sysBtn4}"
Command="{Binding ButtonCmd}"
CommandParameter="清除配置"
Content="清除配置" />
<telerik:RadButton Margin="0,0,0,0"
Width="100"
HorizontalAlignment="Right"
Style="{StaticResource sysBtn2}"
Command="{Binding ButtonCmd}"
CommandParameter="指定中英文"
Content="指定中英文" />
</StackPanel>
<StackPanel Margin="5" Orientation="Horizontal" HorizontalAlignment="Right">
<telerik:RadButton Margin="0,0,20,0"
Width="100"
HorizontalAlignment="Right"
Style="{StaticResource sysBtn}"
Command="{Binding OKCommand}"
CommandParameter="确定"
Content="确定" />
<telerik:RadButton Margin="0,0,0,0"
Width="100"
HorizontalAlignment="Right"
Style="{StaticResource sysBtn2}"
Command="{Binding CloseCommand}"
CommandParameter="取消"
Content="取消" />
</StackPanel>
</Grid>
</StackPanel> </StackPanel>
</telerik:RadBusyIndicator> </telerik:RadBusyIndicator>
</UserControl> </UserControl>

View File

@ -12,6 +12,13 @@ using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
using System.Windows.Threading;
using Prism.Events;
using SWS.CAD.Event;
using SWS.Commons;
using SWS.Model;
using Telerik.Windows.Controls;
using Unity;
namespace SWS.CAD.Views.Dialog namespace SWS.CAD.Views.Dialog
{ {
@ -20,9 +27,23 @@ namespace SWS.CAD.Views.Dialog
/// </summary> /// </summary>
public partial class DialogSignalPredistribution : UserControl public partial class DialogSignalPredistribution : UserControl
{ {
IEventAggregator _eventAggregator;
public DialogSignalPredistribution() public DialogSignalPredistribution()
{ {
InitializeComponent(); InitializeComponent();
_eventAggregator = GlobalObject.container.Resolve<IEventAggregator>();
_eventAggregator.GetEvent<ScrollToItemEvent>().Subscribe(ScrollToSelectedItem, ThreadOption.UIThread, true);
}
// 滚动到选中项
private void ScrollToSelectedItem(object path)
{
var pathls = path as List<string>;
var ph = string.Join("\\", pathls);
treeView1.BringPathIntoView(ph);
} }
} }
} }

View File

@ -85,6 +85,7 @@ namespace SWS.Commons
public static List<TreeModel> designTree = new List<TreeModel>(); public static List<TreeModel> designTree = new List<TreeModel>();
#endregion #endregion
public enum DBConst public enum DBConst
{ {
/// <summary> /// <summary>

View File

@ -0,0 +1,36 @@
using System;
using System.Globalization;
using System.Windows.Data;
using SWS.Model;
namespace SWS.Commons.Helper.Converter
{
public class RadioButtonValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string isChecked)
{
if (isChecked.Equals(parameter.ToString()))
{
return true;
}
else
{
return false;
}
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool isChecked)
{
return parameter.ToString();
}
return parameter.ToString();
}
}
}

View File

@ -106,6 +106,7 @@
<Compile Include="GlobalObject.cs" /> <Compile Include="GlobalObject.cs" />
<Compile Include="Helper\Converter\CollectionToStringConverter.cs" /> <Compile Include="Helper\Converter\CollectionToStringConverter.cs" />
<Compile Include="Helper\Converter\TimeSpanToColourValueConverter.cs" /> <Compile Include="Helper\Converter\TimeSpanToColourValueConverter.cs" />
<Compile Include="Helper\Converter\RadioButtonValueConverter.cs" />
<Compile Include="Helper\Converter\TimeSpanValueConverter.cs" /> <Compile Include="Helper\Converter\TimeSpanValueConverter.cs" />
<Compile Include="Helper\Converter\RadGridViewRowToBoolConverter.cs" /> <Compile Include="Helper\Converter\RadGridViewRowToBoolConverter.cs" />
<Compile Include="Helper\Converter\ColumnValueConverter.cs" /> <Compile Include="Helper\Converter\ColumnValueConverter.cs" />

View File

@ -65,6 +65,7 @@ namespace SWS.Electrical
GlobalObject._prismContainer.RegisterDialog<DialogSignalPropertyhisAndLogs, DialogSignalPropertyhisAndLogsViewModel>(); GlobalObject._prismContainer.RegisterDialog<DialogSignalPropertyhisAndLogs, DialogSignalPropertyhisAndLogsViewModel>();
GlobalObject._prismContainer.RegisterDialog<DialogSignalSelect, DialogSignalSelectViewModel>(); GlobalObject._prismContainer.RegisterDialog<DialogSignalSelect, DialogSignalSelectViewModel>();
GlobalObject._prismContainer.RegisterDialog<DialogAllOutputSignal, DialogAllOutputSignalViewModel>(); GlobalObject._prismContainer.RegisterDialog<DialogAllOutputSignal, DialogAllOutputSignalViewModel>();
GlobalObject._prismContainer.RegisterDialog<DialogAssociatedSignal, DialogAssociatedSignalViewModel>();
GlobalObject._prismContainer.RegisterDialog<DialogAutoArrangeLayout, DialogAutoArrangeLayoutViewModel>(); GlobalObject._prismContainer.RegisterDialog<DialogAutoArrangeLayout, DialogAutoArrangeLayoutViewModel>();
GlobalObject._prismContainer.RegisterDialog<DialogGenerateBOM, DialogGenerateBOMViewModel>(); GlobalObject._prismContainer.RegisterDialog<DialogGenerateBOM, DialogGenerateBOMViewModel>();

View File

@ -51,7 +51,9 @@ namespace SWS.Service
//directory = data["Profile"]["strLocalWorkDir"]; //directory = data["Profile"]["strLocalWorkDir"];
address = IniHelper.ReadValueFromIniFile("Profile", "strIPAddress"); address = IniHelper.ReadValueFromIniFile("Profile", "strIPAddress");
port = int.Parse(IniHelper.ReadValueFromIniFile("Profile", "nPort")); string portString = IniHelper.ReadValueFromIniFile("Profile", "nPort");
int.TryParse(portString?.Trim(), out port);
//port = int.Parse(IniHelper.ReadValueFromIniFile("Profile", "nPort"));
directory = IniHelper.ReadValueFromIniFile("Profile", "strLocalWorkDir"); directory = IniHelper.ReadValueFromIniFile("Profile", "strLocalWorkDir");
} }

View File

@ -50,16 +50,16 @@ namespace SWS.Service
public async Task<object> SaveDetailForm(ec_dataitemdetail entity) public async Task<object> SaveDetailForm(ec_dataitemdetail entity)
{ {
var res = await this.PostBodyAsync<ec_dataitemdetail, ec_dataitemdetail>($"DataItemApi/SaveDetailForm?ProjectId={GlobalObject.curProject?.ProjectId}", entity); var res = await this.PostBodyAsync<ec_dataitemdetail, ec_dataitemdetail>($"DataItemApi/SaveDetailForm?ProjectId={GlobalObject.curProject?.ProjectId}", entity);
if (res.code == 200) //if (res.code == 200)
{ //{
//return res.info; // //return res.info;
return null; // return null;
} //}
else //else
{ //{
return res.info; // 返回错误信息 // return res.info; // 返回错误信息
} //}
return res;
} }
} }
} }

View File

@ -139,16 +139,16 @@ namespace SWS.Service
public async Task<object> CreatePanelStripByProfile(ec_PanelStrip entity) public async Task<object> CreatePanelStripByProfile(ec_PanelStrip entity)
{ {
var res = await this.PostBodyAsync<ec_PanelStrip, ec_PanelStrip>($"IOModuleApi/CreatePanelStripByProfile?projId={GlobalObject.curProject?.ProjectId}", entity); var res = await this.PostBodyAsync<ec_PanelStrip, ec_PanelStrip>($"IOModuleApi/CreatePanelStripByProfile?projId={GlobalObject.curProject?.ProjectId}", entity);
if (res.code == 200) //if (res.code == 200)
{ //{
//return res.info; // //return res.info;
return null; // return null;
} //}
else //else
{ //{
return res.info; // 返回错误信息 // return res.info; // 返回错误信息
} //}
return res;
} }
public async Task<string> DeletePanel(string PanelID) public async Task<string> DeletePanel(string PanelID)

View File

@ -126,6 +126,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ViewModels\DialogInputViewModel.cs" /> <Compile Include="ViewModels\DialogInputViewModel.cs" />
<Compile Include="ViewModels\DialogSignalManagementVM\DialogAssociatedSignalViewModel.cs" />
<Compile Include="ViewModels\DialogSignalManagementVM\DialogSignalManagementViewModel.cs" /> <Compile Include="ViewModels\DialogSignalManagementVM\DialogSignalManagementViewModel.cs" />
<Compile Include="ViewModels\DialogSignalManagementVM\DialogAllOutputSignalViewModel.cs" /> <Compile Include="ViewModels\DialogSignalManagementVM\DialogAllOutputSignalViewModel.cs" />
<Compile Include="ViewModels\DialogSignalManagementVM\DialogSignalNoticeViewModel.cs" /> <Compile Include="ViewModels\DialogSignalManagementVM\DialogSignalNoticeViewModel.cs" />
@ -137,6 +138,9 @@
<Compile Include="Views\CustomDialogWindow.xaml.cs"> <Compile Include="Views\CustomDialogWindow.xaml.cs">
<DependentUpon>CustomDialogWindow.xaml</DependentUpon> <DependentUpon>CustomDialogWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\DialogSignalManagements\DialogAssociatedSignal.xaml.cs">
<DependentUpon>DialogAssociatedSignal.xaml</DependentUpon>
</Compile>
<Compile Include="Views\DialogSignalManagements\DialogAllOutputSignal.xaml.cs"> <Compile Include="Views\DialogSignalManagements\DialogAllOutputSignal.xaml.cs">
<DependentUpon>DialogAllOutputSignal.xaml</DependentUpon> <DependentUpon>DialogAllOutputSignal.xaml</DependentUpon>
</Compile> </Compile>
@ -200,6 +204,10 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="Views\DialogSignalManagements\DialogAssociatedSignal.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\DialogSignalManagements\DialogAllOutputSignal.xaml"> <Page Include="Views\DialogSignalManagements\DialogAllOutputSignal.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>

View File

@ -0,0 +1,267 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Input;
using Prism.Services.Dialogs;
using Prism.Ioc;
using SWS.Commons;
using SWS.Model;
using SWS.Service;
using SWS.WPF.Views;
using Telerik.Windows.Controls;
using Unity;
using DialogParameters = Prism.Services.Dialogs.DialogParameters;
using System.Windows;
namespace SWS.WPF.ViewModels
{
public class DialogAssociatedSignalViewModel : DialogBase, IDialogAware
{
#region
private ObservableCollection<SignalManagementInfo> _MySignals = new ObservableCollection<SignalManagementInfo>();
/// <summary>
/// 表格数据源
/// </summary>
public ObservableCollection<SignalManagementInfo> MySignals
{
get { return _MySignals; }
set { _MySignals = value; RaisePropertyChanged(nameof(MySignals)); }
}
private SignalManagementInfo _SelectedSignal;
/// <summary>
/// 选中行
/// </summary>
public SignalManagementInfo SelectedSignal
{
get { return _SelectedSignal; }
set { _SelectedSignal = value; RaisePropertyChanged(nameof(SelectedSignal)); }
}
private string _Info;
/// <summary>
/// 列表上方文字
/// </summary>
public string Info
{
get { return _Info; }
set { _Info = value; RaisePropertyChanged(nameof(Info)); }
}
private Visibility _IsVisibility = Visibility.Collapsed;
/// <summary>
/// 控制取消关联按钮是否可见
/// </summary>
public Visibility IsVisibility
{
get { return _IsVisibility; }
set
{
_IsVisibility = value;
RaisePropertyChanged(nameof(IsVisibility));
}
}
/// <summary>
/// 信号接口服务
/// </summary>
WireGroupService _wireGroupService;
public DialogSignalNotice SignalNoticeView { get; set; }
#endregion
public DialogAssociatedSignalViewModel()
{
_wireGroupService = GlobalObject.container.Resolve<WireGroupService>();
}
public string Title => "";
public event Action<IDialogResult> RequestClose;
public bool CanCloseDialog()
{
return true;
}
public void OnDialogClosed()
{
}
public async void OnDialogOpened(IDialogParameters parameters)
{
title = parameters.GetValue<string>(GlobalObject.dialogPar.title.ToString());
Info = parameters.GetValue<string>(GlobalObject.dialogPar.info.ToString());
var signals = parameters.GetValue<ObservableCollection<SignalManagementInfo>>(GlobalObject.dialogPar.para1.ToString());
foreach (var item in signals)
{
if (title.Equals("信号选择框"))
{
if (item.type.Equals("信号"))
{
MySignals.Add(item);
}
}
else if (title.Equals("信号关联列表"))
{
MySignals.Add(item);
IsVisibility = Visibility.Visible;
}
}
}
public override void ExecuteOKCommandAsync(object para)
{
IDialogParameters par = new DialogParameters();
if (title.Equals("信号选择框"))
{
if (SelectedSignal == null)
{
MessageBox.Show("请选择一个信号!");
return;
}
}
else if (title.Equals("信号关联列表"))
{
//如何是取消关联,则把取消的列表传回去
par.Add(GlobalObject.dialogPar.para2.ToString(), CancelAssociationls);
}
par.Add(GlobalObject.dialogPar.para1.ToString(), SelectedSignal);
DialogResult result = new DialogResult(ButtonResult.Yes, par);
RequestClose.Invoke(result);
}
public override void ExecuteCloseCommand(object parameter)
{
if (parameter as string == "ClickNo")
{
DialogResult result = new DialogResult(ButtonResult.No);
RequestClose.Invoke(result);
}
else
{
DialogResult result = new DialogResult(ButtonResult.Cancel);
RequestClose.Invoke(result);
}
this.Dispose();
}
//全局的取消关联列表
List<SignalManagementInfo> CancelAssociationls = new List<SignalManagementInfo>();
public ICommand CancelAssociationCmd => new DelegateCommand(CancelAssociation_Click);
/// <summary>
/// 取消关联按钮的点击事件
/// </summary>
/// <param name="parameter"></param>
public virtual void CancelAssociation_Click(object parameter)
{
CancelAssociationls.Add(SelectedSignal);
MySignals.Remove(SelectedSignal);
}
}
public class AssociatedSignalInfo : ViewModelBase
{
#region
private string _Group_Name;
/// <summary>
/// CH.NO
/// </summary>
public string Group_Name
{
get { return _Group_Name; }
set { _Group_Name = value; RaisePropertyChanged(nameof(Group_Name)); }
}
private string _Group_Desc_EN;
/// <summary>
/// 英文描述
/// </summary>
public string Group_Desc_EN
{
get { return _Group_Desc_EN; }
set { _Group_Desc_EN = value; RaisePropertyChanged(nameof(Group_Desc_EN)); }
}
private string _Group_Desc;
/// <summary>
/// 中文描述
/// </summary>
public string Group_Desc
{
get { return _Group_Desc; }
set { _Group_Desc = value; RaisePropertyChanged(nameof(Group_Desc)); }
}
private string _IO_Type;
/// <summary>
/// 信号类型
/// </summary>
public string IO_Type
{
get { return _IO_Type; }
set { _IO_Type = value; RaisePropertyChanged(nameof(IO_Type)); }
}
private string _Alarm_LL;
public string Alarm_LL
{
get { return _Alarm_LL; }
set { _Alarm_LL = value; RaisePropertyChanged(nameof(Alarm_LL)); }
}
private string _Alarm_L;
public string Alarm_L
{
get { return _Alarm_L; }
set { _Alarm_L = value; RaisePropertyChanged(nameof(Alarm_L)); }
}
private string _Alarm_H;
public string Alarm_H
{
get { return _Alarm_H; }
set { _Alarm_H = value; RaisePropertyChanged(nameof(Alarm_H)); }
}
private string _Alarm_HH;
public string Alarm_HH
{
get { return _Alarm_HH; }
set { _Alarm_HH = value; RaisePropertyChanged(nameof(Alarm_HH)); }
}
private string _SENSOR_CODE;
/// <summary>
/// 传感器编号
/// </summary>
public string SENSOR_CODE
{
get { return _SENSOR_CODE; }
set { _SENSOR_CODE = value; RaisePropertyChanged(nameof(SENSOR_CODE)); }
}
#endregion
public AssociatedSignalInfo(ec_Wire_Group ec_Wire_Group)
{
}
}
}

View File

@ -347,11 +347,11 @@ namespace SWS.WPF.ViewModels
} }
} }
private DateTime _ReviewTime; private DateTime? _ReviewTime;
/// <summary> /// <summary>
/// 送审时间 /// 送审时间
/// </summary> /// </summary>
public DateTime ReviewTime public DateTime? ReviewTime
{ {
get { return _ReviewTime; } get { return _ReviewTime; }
set { _ReviewTime = value; set { _ReviewTime = value;
@ -359,11 +359,11 @@ namespace SWS.WPF.ViewModels
} }
} }
private DateTime _ConstructionTime; private DateTime? _ConstructionTime;
/// <summary> /// <summary>
/// 施工时间 /// 施工时间
/// </summary> /// </summary>
public DateTime ConstructionTime public DateTime? ConstructionTime
{ {
get { return _ConstructionTime; } get { return _ConstructionTime; }
set { _ConstructionTime = value; set { _ConstructionTime = value;
@ -371,6 +371,33 @@ namespace SWS.WPF.ViewModels
} }
} }
private Visibility _IsReviewTimeVisibility = Visibility.Visible;
/// <summary>
/// 控制送审时间是否可见
/// </summary>
public Visibility IsReviewTimeVisibility
{
get { return _IsReviewTimeVisibility; }
set
{
_IsReviewTimeVisibility = value;
RaisePropertyChanged(nameof(IsReviewTimeVisibility));
}
}
private Visibility _IsConstructionTimeVisibility = Visibility.Visible;
/// <summary>
/// 控制施工时间是否可见
/// </summary>
public Visibility IsConstructionTimeVisibility
{
get { return _IsConstructionTimeVisibility; }
set
{
_IsConstructionTimeVisibility = value;
RaisePropertyChanged(nameof(IsConstructionTimeVisibility));
}
}
private readonly DispatcherTimer _timer = new DispatcherTimer(); private readonly DispatcherTimer _timer = new DispatcherTimer();
@ -423,6 +450,10 @@ namespace SWS.WPF.ViewModels
//DateTime startTime = DateTime.Now; //DateTime startTime = DateTime.Now;
//设置信号源 //设置信号源
signals = await _wireGroupService.GetSignals(GlobalObject.curProject.ProjectId, false); signals = await _wireGroupService.GetSignals(GlobalObject.curProject.ProjectId, false);
if (signals == null)
{
signals = new List<ec_Wire_Group>();
}
//TimeSpan duration = DateTime.Now - startTime; //TimeSpan duration = DateTime.Now - startTime;
//System.Windows.MessageBox.Show($"Time taken: {duration.Seconds} milliseconds"); //System.Windows.MessageBox.Show($"Time taken: {duration.Seconds} milliseconds");
count = signals.Count().ToString(); count = signals.Count().ToString();
@ -448,28 +479,29 @@ namespace SWS.WPF.ViewModels
IsAssociated = parameters.GetValue<ec_Wire_Group>(GlobalObject.dialogPar.info.ToString()); IsAssociated = parameters.GetValue<ec_Wire_Group>(GlobalObject.dialogPar.info.ToString());
//获取送审时间和施工时间 //获取送审时间和施工时间
ReviewTime = (DateTime)GlobalObject.curProject.IO_predicted_issue; ReviewTime = GlobalObject.curProject.IO_predicted_issue;
ConstructionTime = (DateTime)GlobalObject.curProject.IO_predicted_construct; ConstructionTime = GlobalObject.curProject.IO_predicted_issue;
if (ReviewTime == null) IsReviewTimeVisibility = Visibility.Collapsed;
if (ConstructionTime == null) IsConstructionTimeVisibility = Visibility.Collapsed;
// 获取当前时间 // 获取当前时间
DateTime currentTime = DateTime.Now; DateTime currentTime = DateTime.Now;
// 初始化倒计时时间 // 初始化倒计时时间
ReviewCountdown.TimeRemaining = (TimeSpan)(ReviewTime - currentTime); ReviewCountdown.TimeRemaining = ReviewTime==null? TimeSpan.Zero:(TimeSpan)(ReviewTime - currentTime);
ReviewCountdown.IsActive = true; ReviewCountdown.IsActive = ReviewTime == null ?false: true;
if (ReviewCountdown.TimeRemaining<= TimeSpan.Zero) if (ReviewCountdown.TimeRemaining<= TimeSpan.Zero)
{ {
if ((DateTime)GlobalObject.curProject.IO_real_issue == null) if (GlobalObject.curProject.IO_real_issue == null && GlobalObject.curProject.IO_predicted_issue!=null)
{ {
System.Windows.MessageBox.Show($"送审时间已过期: {ReviewCountdown.TimeRemaining:%d}天 {ReviewCountdown.TimeRemaining:hh\\:mm\\:ss}", "错误", MessageBoxButton.OK, MessageBoxImage.Error); System.Windows.MessageBox.Show($"送审时间已过期: {ReviewCountdown.TimeRemaining:%d}天 {ReviewCountdown.TimeRemaining:hh\\:mm\\:ss}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
} }
} }
ConstructionCountdown.TimeRemaining = (TimeSpan)(ConstructionTime - currentTime); ConstructionCountdown.TimeRemaining = ConstructionTime==null? TimeSpan.Zero:(TimeSpan)(ConstructionTime - currentTime);
ConstructionCountdown.IsActive = true; ConstructionCountdown.IsActive = ConstructionTime == null ? false: true;
if (ConstructionCountdown.TimeRemaining <= TimeSpan.Zero) if (ConstructionCountdown.TimeRemaining <= TimeSpan.Zero)
{ {
if ((DateTime)GlobalObject.curProject.IO_real_construct == null) if (GlobalObject.curProject.IO_real_construct == null&& GlobalObject.curProject.IO_predicted_issue!=null)
{ {
System.Windows.MessageBox.Show($"施工时间已过期: {ConstructionCountdown.TimeRemaining:%d}天 {ConstructionCountdown.TimeRemaining:hh\\:mm\\:ss}", "错误", MessageBoxButton.OK, MessageBoxImage.Error); System.Windows.MessageBox.Show($"施工时间已过期: {ConstructionCountdown.TimeRemaining:%d}天 {ConstructionCountdown.TimeRemaining:hh\\:mm\\:ss}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
@ -1346,25 +1378,25 @@ namespace SWS.WPF.ViewModels
para.Add(GlobalObject.dialogPar.title.ToString(), "信号选择框"); para.Add(GlobalObject.dialogPar.title.ToString(), "信号选择框");
para.Add(GlobalObject.dialogPar.info.ToString(), "请选择要关联的信号:"); para.Add(GlobalObject.dialogPar.info.ToString(), "请选择要关联的信号:");
para.Add(GlobalObject.dialogPar.para1.ToString(), smInfols); para.Add(GlobalObject.dialogPar.para1.ToString(), smInfols);
_dialogService.ShowDialog(nameof(DialogSignalSelect), para, (RES) => _dialogService.ShowDialog(nameof(DialogAssociatedSignal), para, (RES) =>
{ {
if (RES.Result == ButtonResult.Yes) if (RES.Result == ButtonResult.Yes)
{ {
var signal = RES.Parameters.GetValue<Signal>(GlobalObject.dialogPar.para1.ToString()); var signal = RES.Parameters.GetValue<SignalManagementInfo>(GlobalObject.dialogPar.para1.ToString());
if (!string.IsNullOrEmpty(SelectedSmInfo.LinkedID)) if (!string.IsNullOrEmpty(SelectedSmInfo.LinkedID))
{ {
var LinkedIDs = SelectedSmInfo.LinkedID.Split(',').ToList(); var LinkedIDs = SelectedSmInfo.LinkedID.Split(',').ToList();
LinkedIDs.RemoveAll(item => string.IsNullOrEmpty(item)); LinkedIDs.RemoveAll(item => string.IsNullOrEmpty(item));
if (!LinkedIDs.Contains(signal.SignalId)) if (!LinkedIDs.Contains(signal.Wire_Group_ID))
{ {
LinkedIDs.Add(signal.SignalId); LinkedIDs.Add(signal.Wire_Group_ID);
} }
SelectedSmInfo.LinkedID = string.Join(",", LinkedIDs); SelectedSmInfo.LinkedID = string.Join(",", LinkedIDs);
} }
else else
{ {
SelectedSmInfo.LinkedID = signal.SignalId; SelectedSmInfo.LinkedID = signal.Wire_Group_ID;
} }
SelectedSmInfo.IsModified = true; SelectedSmInfo.IsModified = true;
System.Windows.MessageBox.Show("关联成功", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); System.Windows.MessageBox.Show("关联成功", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning);
@ -1397,15 +1429,15 @@ namespace SWS.WPF.ViewModels
para.Add(GlobalObject.dialogPar.title.ToString(), "信号关联列表"); para.Add(GlobalObject.dialogPar.title.ToString(), "信号关联列表");
para.Add(GlobalObject.dialogPar.info.ToString(), "下面是信号关联列表"); para.Add(GlobalObject.dialogPar.info.ToString(), "下面是信号关联列表");
para.Add(GlobalObject.dialogPar.para1.ToString(), sminfols); para.Add(GlobalObject.dialogPar.para1.ToString(), sminfols);
_dialogService.ShowDialog(nameof(DialogSignalSelect), para, (RES) => _dialogService.ShowDialog(nameof(DialogAssociatedSignal), para, (RES) =>
{ {
if (RES.Result == ButtonResult.Yes) if (RES.Result == ButtonResult.Yes)
{ {
var signals = RES.Parameters.GetValue<List<Signal>>(GlobalObject.dialogPar.para2.ToString()); var signals = RES.Parameters.GetValue<List<SignalManagementInfo>>(GlobalObject.dialogPar.para2.ToString());
signals.ForEach(s => signals.ForEach(s =>
{ {
var signalid = s.SignalId; var signalid = s.Wire_Group_ID;
if (LinkedIDs.Contains(signalid)) if (LinkedIDs.Contains(signalid))
{ {
LinkedIDs.Remove(signalid); LinkedIDs.Remove(signalid);

View File

@ -0,0 +1,106 @@
<UserControl x:Class="SWS.WPF.Views.DialogAssociatedSignal"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SWS.WPF.Views"
xmlns:prism="http://prismlibrary.com/"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:cvt="clr-namespace:SWS.Commons.Helper.Converter;assembly=SWS.Commons"
xmlns:CustomControl="clr-namespace:SWS.CustomControl;assembly=SWS.CustomControl"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<prism:Dialog.WindowStyle>
<Style TargetType="Window">
<!--最大化-->
<Setter Property="Width" Value="1000" />
<Setter Property="Height" Value="800" />
<Setter Property="SizeToContent" Value="WidthAndHeight" />
<Setter Property="WindowState" Value="Normal" />
<Setter Property="WindowStyle" Value="None" />
<Setter Property="ResizeMode" Value="NoResize" />
</Style>
</prism:Dialog.WindowStyle>
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/SWS.WPF;component/Style/CustomStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<telerik:RadBusyIndicator BusyContent="{Binding BusyContent}" IsBusy="{Binding IsBusy}">
<StackPanel>
<CustomControl:customWindowTitleBar x:Name="titleBar" />
<TextBlock Margin="10,0" Text="{Binding Info}" />
<telerik:RadGridView x:Name="RadGridView1" SelectionMode="Single" Width="500" Height="530"
AutoGenerateColumns="False" IsFilteringAllowed="False" Background="#a0a0a0"
IsReadOnly="True" RowIndicatorVisibility="Collapsed"
ShowGroupPanel="False" telerik:StyleManager.Theme="Office_Blue"
ItemsSource="{Binding MySignals}" SelectedItem="{Binding SelectedSignal, Mode=TwoWay}">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Group_Name}"
Header="CH.NO"
IsFilterable="False"/>
<telerik:GridViewDataColumn Width="120"
DataMemberBinding="{Binding Group_Desc_EN}"
Header="英文描述"
IsFilterable="False" />
<telerik:GridViewDataColumn Width="120"
DataMemberBinding="{Binding Group_Desc}"
Header="中文描述"
IsFilterable="False" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding IO_Type}"
Header="信号类型"
IsFilterable="False" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Alarm_LL}"
Header="L.L"
IsFilterable="False" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Alarm_L}"
Header="L"
IsFilterable="False" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Alarm_H}"
Header="H"
IsFilterable="False" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Alarm_HH}"
Header="H.H"
IsFilterable="False" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding SENSOR_CODE}"
Header="CODE"
IsFilterable="False"
Width="*"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
<Border Grid.Row="2"
Height="30"
Background="{StaticResource ColorPrimary}">
<DockPanel >
<StackPanel DockPanel.Dock="Left">
<telerik:RadButton Margin="5"
HorizontalAlignment="Left"
Command="{Binding CancelAssociationCmd}"
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}"
Content="取消关联"
Visibility="{Binding IsVisibility}"
Style="{StaticResource sysBtn4}" />
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<telerik:RadButton Margin="5"
Command="{Binding OKCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}"
Content="确定"
Style="{StaticResource sysBtn}" />
<telerik:RadButton Margin="5"
Command="{Binding CloseCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}"
Content="取消"
Style="{StaticResource sysBtn2}" />
</StackPanel>
</DockPanel>
</Border>
</StackPanel>
</telerik:RadBusyIndicator>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace SWS.WPF.Views
{
/// <summary>
/// DialogAssociatedSignal.xaml 的交互逻辑
/// </summary>
public partial class DialogAssociatedSignal : UserControl
{
public DialogAssociatedSignal()
{
InitializeComponent();
}
}
}

View File

@ -220,49 +220,41 @@
Foreground="White" Foreground="White"
Style="{StaticResource sysLabel}" Style="{StaticResource sysLabel}"
Text="{Binding pojectName}" /> Text="{Binding pojectName}" />
<!-- 送审时间倒计时 --> <!--送审时间倒计时-->
<Border <Border Background="{Binding ReviewCountdown.TimeRemaining,Converter={StaticResource TimeSpanToColourCvt}}" CornerRadius="6"
Margin="50,1,0,1" Visibility="{Binding IsReviewTimeVisibility}"
Padding="1" Margin="50,1,0,1" Padding="1">
Background="{Binding ReviewCountdown.TimeRemaining, Converter={StaticResource TimeSpanToColourCvt}}" <StackPanel Orientation="Horizontal" VerticalAlignment="Center" >
CornerRadius="6"> <TextBlock Text="送审时间"
<StackPanel VerticalAlignment="Center" Orientation="Horizontal"> FontSize="14" Foreground="White"
<TextBlock Margin="1,0,5,0"/>
Margin="1,0,5,0" <TextBlock x:Name="txtReviewCountdown"
FontSize="14" FontSize="14" FontWeight="Bold"
Foreground="White" Foreground="White"
Text="送审时间" /> TextAlignment="Center"
<TextBlock Text="{Binding ReviewTime,
x:Name="txtReviewCountdown" StringFormat='yyyy-MM-dd',
Margin="0,0,2,0" Mode=TwoWay}"
FontSize="14" Margin="0,0,2,0"/>
FontWeight="Bold"
Foreground="White"
Text="{Binding ReviewTime, StringFormat='yyyy-MM-dd', Mode=TwoWay}"
TextAlignment="Center" />
</StackPanel> </StackPanel>
</Border> </Border>
<!-- 施工时间倒计时 --> <!--施工时间倒计时-->
<Border <Border Background="{Binding ConstructionCountdown.TimeRemaining,Converter={StaticResource TimeSpanToColourCvt}}" CornerRadius="6"
Margin="25,1,0,1" Visibility="{Binding IsConstructionTimeVisibility}"
Padding="1" Margin="25,1,0,1" Padding="1">
Background="{Binding ConstructionCountdown.TimeRemaining, Converter={StaticResource TimeSpanToColourCvt}}" <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
CornerRadius="6"> <TextBlock Text="施工时间"
<StackPanel VerticalAlignment="Center" Orientation="Horizontal"> FontSize="14" Foreground="White"
<TextBlock Margin="1,0,5,0"/>
Margin="1,0,5,0" <TextBlock x:Name="txtConstructionCountdown"
FontSize="14" FontSize="14" FontWeight="Bold"
Foreground="White" Foreground="White"
Text="施工时间" /> Text="{Binding ConstructionTime,
<TextBlock StringFormat='yyyy-MM-dd',
x:Name="txtConstructionCountdown" UpdateSourceTrigger=PropertyChanged}"
Margin="0,0,2,0" TextAlignment="Center"
FontSize="14" Margin="0,0,2,0"/>
FontWeight="Bold"
Foreground="White"
Text="{Binding ConstructionTime, StringFormat='yyyy-MM-dd', UpdateSourceTrigger=PropertyChanged}"
TextAlignment="Center" />
</StackPanel> </StackPanel>
</Border> </Border>
</StackPanel> </StackPanel>

View File

@ -1,4 +1,4 @@
#pragma checksum "..\..\..\..\Views\DialogSignalManagements\DialogSignalManagement.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "F05F8EFCE0FDA8526127C3C8FC25192B1D13876C84EA73B5F724F982994B8768" #pragma checksum "..\..\..\..\Views\DialogSignalManagements\DialogSignalManagement.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "D4B655A725F9DA5CEF801330CC2E000E8A952FC6E92D22159739897F8A32A6A6"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// 此代码由工具生成。 // 此代码由工具生成。
@ -86,7 +86,7 @@ namespace SWS.WPF.Views {
#line hidden #line hidden
#line 236 "..\..\..\..\Views\DialogSignalManagements\DialogSignalManagement.xaml" #line 233 "..\..\..\..\Views\DialogSignalManagements\DialogSignalManagement.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock txtReviewCountdown; internal System.Windows.Controls.TextBlock txtReviewCountdown;
@ -94,7 +94,7 @@ namespace SWS.WPF.Views {
#line hidden #line hidden
#line 259 "..\..\..\..\Views\DialogSignalManagements\DialogSignalManagement.xaml" #line 252 "..\..\..\..\Views\DialogSignalManagements\DialogSignalManagement.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock txtConstructionCountdown; internal System.Windows.Controls.TextBlock txtConstructionCountdown;
@ -102,7 +102,7 @@ namespace SWS.WPF.Views {
#line hidden #line hidden
#line 314 "..\..\..\..\Views\DialogSignalManagements\DialogSignalManagement.xaml" #line 308 "..\..\..\..\Views\DialogSignalManagements\DialogSignalManagement.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal SWS.CustomControl.IconButton PopupButton; internal SWS.CustomControl.IconButton PopupButton;
@ -110,7 +110,7 @@ namespace SWS.WPF.Views {
#line hidden #line hidden
#line 325 "..\..\..\..\Views\DialogSignalManagements\DialogSignalManagement.xaml" #line 318 "..\..\..\..\Views\DialogSignalManagements\DialogSignalManagement.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Primitives.Popup CustomPopup; internal System.Windows.Controls.Primitives.Popup CustomPopup;
@ -118,7 +118,7 @@ namespace SWS.WPF.Views {
#line hidden #line hidden
#line 376 "..\..\..\..\Views\DialogSignalManagements\DialogSignalManagement.xaml" #line 367 "..\..\..\..\Views\DialogSignalManagements\DialogSignalManagement.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal SWS.CustomControl.IconButton myButton; internal SWS.CustomControl.IconButton myButton;
@ -126,7 +126,7 @@ namespace SWS.WPF.Views {
#line hidden #line hidden
#line 409 "..\..\..\..\Views\DialogSignalManagements\DialogSignalManagement.xaml" #line 400 "..\..\..\..\Views\DialogSignalManagements\DialogSignalManagement.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal Telerik.Windows.Controls.RadTreeListView RadGridView1; internal Telerik.Windows.Controls.RadTreeListView RadGridView1;