Compare commits
2 Commits
3a2d551fc8
...
6351a1dab3
Author | SHA1 | Date | |
---|---|---|---|
6351a1dab3 | |||
c2f35e0495 |
198
Learun.Application.Web/AppApi/PlotBOMApiController.cs
Normal file
198
Learun.Application.Web/AppApi/PlotBOMApiController.cs
Normal file
@ -0,0 +1,198 @@
|
||||
using Learun.Application.TwoDevelopment.ZZDT_EC;
|
||||
using Learun.Util;
|
||||
using Learun.Util.SqlSugar;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using NPOI.SS.Formula.PTG;
|
||||
using NPOI.Util.Collections;
|
||||
using Pipelines.Sockets.Unofficial.Arenas;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Learun.Application.Web.AppApi
|
||||
{
|
||||
/// <summary>
|
||||
/// 绘制材料表相关的(By YuXH)
|
||||
/// </summary>
|
||||
[HandlerApiLogin(FilterMode.Ignore)]
|
||||
public class PlotBOMApiController : WebApiControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取材料表绘制所需的分组信息、symbol信息
|
||||
/// </summary>
|
||||
/// <param name="ProjectId"></param>
|
||||
/// <param name="drawingId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IHttpActionResult GetBOMGroupInfo(string ProjectId = "c151f5d4-cbe1-4522-945c-501b1ad990d5", string drawingId = "277d883d-e271-45e4-990b-926585321fa8")
|
||||
{
|
||||
var res = new List<BOMGroupInfo>();
|
||||
|
||||
var typeTbName = ProjectSugar.TableName<ec_objecttypeEntity>(ProjectId);
|
||||
var pixelTbName = ProjectSugar.TableName<ec_enginedata_pixelEntity>(ProjectId);
|
||||
var tagTbName = ProjectSugar.TableName<ec_enginedataEntity>(ProjectId);
|
||||
var propTbName = ProjectSugar.TableName<ec_enginedata_propertyEntity>(ProjectId);
|
||||
|
||||
|
||||
|
||||
var allTag = SqlSugarHelper.Db.Queryable<ec_enginedataEntity>().AS(tagTbName)
|
||||
.InnerJoin<ec_enginedata_pixelEntity>((t, p) => t.EngineDataID == p.EngineDataID && p.DrawingFileID == drawingId)
|
||||
.AS<ec_enginedata_pixelEntity>(pixelTbName)
|
||||
.GroupBy(t => t.ObjectTypeID)
|
||||
.ToList();
|
||||
|
||||
var allProp = SqlSugarHelper.Db.Queryable<ec_enginedata_propertyEntity>().AS(propTbName)
|
||||
.Where(x => allTag.Select(t => t.EngineDataID).Contains(x.EngineDataID))
|
||||
.ToList();
|
||||
|
||||
//1.先按类型分组
|
||||
//2.去除tagnumber下的右侧数字
|
||||
|
||||
|
||||
//3.再按几个属性分组
|
||||
//设备型号 和 厂商
|
||||
|
||||
|
||||
var TagsInBOM = new List<TagInBOM>();
|
||||
foreach (ec_enginedataEntity tag in allTag)
|
||||
{
|
||||
var matchedTypes = new List<string>();
|
||||
|
||||
//???特定类型的,还需要额外根据”中文名称“来分组,比如照明设备类型下的所有设备
|
||||
if (matchedTypes.Contains(tag.ObjectTypeID))
|
||||
{
|
||||
//如照明下的。比如10个照明的灯,4个中文名称是“顶灯”,6个中文名称是“壁灯”
|
||||
TagsInBOM.Add(new TagInBOM()
|
||||
{
|
||||
objectTypeId = tag.ObjectTypeID,
|
||||
TagNumber = TrimTagNubmer(tag.TagNumber),// 如 A-B1,A-B2,
|
||||
vendor = allProp.FirstOrDefault(x => x.EngineDataID == tag.EngineDataID && x.PropertyName == "厂商")?.PropertyValue ?? "",
|
||||
model = allProp.FirstOrDefault(x => x.EngineDataID == tag.EngineDataID && x.PropertyName == "设备型号")?.PropertyValue ?? "",
|
||||
Name = allProp.FirstOrDefault(x => x.EngineDataID == tag.EngineDataID && x.PropertyName == GlobalObject.propName_NameCN)?.PropertyValue ?? ""
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
TagsInBOM.Add(new TagInBOM()
|
||||
{
|
||||
objectTypeId = tag.ObjectTypeID,
|
||||
TagNumber = TrimTagNubmer(tag.TagNumber),// 如 A-B1,A-B2,
|
||||
vendor = allProp.FirstOrDefault(x => x.EngineDataID == tag.EngineDataID && x.PropertyName == "厂商")?.PropertyValue ?? "",
|
||||
model = allProp.FirstOrDefault(x => x.EngineDataID == tag.EngineDataID && x.PropertyName == "设备型号")?.PropertyValue ?? "",
|
||||
Name = ""
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
var groups = TagsInBOM.GroupBy(x => new { x.objectTypeId, x.TagNumber, x.vendor, x.model, x.Name }).ToList();
|
||||
|
||||
foreach (var group in groups)
|
||||
{
|
||||
var text = group.Key.TagNumber; //A-ABC, 正常情况下A是system,放下面;B是tag,放上面
|
||||
var upper_text_Part1 = text.Split('-')[1];//ABC
|
||||
var upper_text_Part2 = "";//seq
|
||||
#region seq的不同情况
|
||||
//TAG如果一样的就取这个TAG就行???
|
||||
|
||||
//数里小于等于2个
|
||||
if (group.Count() <= 2)
|
||||
{
|
||||
//遍历每一个group下的原始 ec_enginedataEntity.TagNumber里的数字。比如2个分别是 1 2 那么就显示1,2
|
||||
upper_text_Part2 = "1,2";
|
||||
}
|
||||
else
|
||||
{
|
||||
//遍历每一个group下的原始 ec_enginedataEntity.TagNumber里的数字
|
||||
bool isContinue = true;//是否是连续的
|
||||
if (isContinue)
|
||||
{
|
||||
//如果是连续的就显示 1~5
|
||||
upper_text_Part2 = "1~5";
|
||||
}
|
||||
else
|
||||
{
|
||||
//还要分段去判断是否有部分连续的。如1~3,5,7~9
|
||||
|
||||
upper_text_Part2 = "1~3,5,7~9";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
var BOMGroupInfo = new BOMGroupInfo
|
||||
{
|
||||
upper_text = upper_text_Part1 + upper_text_Part2,
|
||||
lower_text = text.Split('-')[0],//A
|
||||
Count = group.Count(),
|
||||
Remark = group.Key.vendor,
|
||||
Spec = group.Key.model,
|
||||
FileId = GetSymbolForBOM(group.Key.objectTypeId)
|
||||
};
|
||||
|
||||
if (BOMGroupInfo.upper_text == BOMGroupInfo.lower_text)
|
||||
{
|
||||
//如果SYSTEM等于TAG,那么隐藏SYSTEM
|
||||
BOMGroupInfo.lower_text = "";//
|
||||
}
|
||||
res.Add(BOMGroupInfo);
|
||||
}
|
||||
|
||||
return Success(res);
|
||||
}
|
||||
/// <summary>
|
||||
/// 决定应该用哪个symbol
|
||||
/// </summary>
|
||||
/// <param name="objectTypeId"></param>
|
||||
/// <returns></returns>
|
||||
string GetSymbolForBOM(string objectTypeId)
|
||||
{
|
||||
//马达,圆形
|
||||
//通讯设备-外通设备-天线,三角形
|
||||
return "";
|
||||
}
|
||||
/// <summary>
|
||||
/// 去除tagnumber下的右侧数字
|
||||
/// </summary>
|
||||
/// <param name="tagNumber"></param>
|
||||
/// <returns></returns>
|
||||
string TrimTagNubmer(string tagNumber)
|
||||
{
|
||||
//1MAC-PT1 和 1MAC-PT2 归为一组,剩下的是1MAC-PT ,而不是MAC-PT
|
||||
// 还要考虑1A 1B这种后缀情况
|
||||
//1MAC-PT1A 1MAC-PT1B 归为一组,剩下的是1MAC-PT,而不是变成1MAC-PT1A 和 1MAC-PT1B
|
||||
return tagNumber;
|
||||
}
|
||||
}
|
||||
public class TagInBOM
|
||||
{
|
||||
public string objectTypeId { set; get; }
|
||||
public string TagNumber { set; get; }
|
||||
public string vendor { set; get; }
|
||||
public string model { set; get; }
|
||||
/// <summary>
|
||||
/// 中文名称
|
||||
/// </summary>
|
||||
public string Name { set; get; }
|
||||
}
|
||||
public class BOMGroupInfo
|
||||
{
|
||||
public string upper_text { set; get; }
|
||||
public string lower_text { set; get; }
|
||||
/// <summary>
|
||||
/// 每一行用的symbol是什么
|
||||
/// </summary>
|
||||
public string FileId { set; get; }
|
||||
public int Count { set; get; }
|
||||
public string Remark { set; get; }
|
||||
public string Spec { set; get; }
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -370,6 +370,7 @@
|
||||
<Compile Include="AppApi\LookupTableApiController.cs" />
|
||||
<Compile Include="AppApi\PDBApiController.cs" />
|
||||
<Compile Include="AppApi\CaseApiController.cs" />
|
||||
<Compile Include="AppApi\PlotBOMApiController.cs" />
|
||||
<Compile Include="AppApi\UpdateApiController.cs" />
|
||||
<Compile Include="AppApi\WireGroupApiController.cs" />
|
||||
<Compile Include="AppApi\WireGroupTemplateApiController.cs" />
|
||||
|
@ -14,7 +14,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
|
||||
|
||||
private static string redisKey = "_ec_project";//不需要后缀
|
||||
/// <summary>
|
||||
/// 按项目取表名公用方法
|
||||
/// 按项目取表名
|
||||
/// </summary>
|
||||
/// <typeparam name="T">实体类Entity</typeparam>
|
||||
/// <param name="projectIdOrIndex">项目ID或Index</param>
|
||||
|
@ -101,6 +101,8 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
|
||||
}
|
||||
#endregion
|
||||
#region 扩展字段
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// import Drawing用
|
||||
/// </summary>
|
||||
|
@ -31,7 +31,7 @@ namespace Learun.Application.TwoDevelopment.ZZDT_EC
|
||||
public string Panel_Loc_ID { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 可用的IO类型
|
||||
/// 可用的IO类型。多个类型逗号分开?然后新建端子排时,就会出现对应的IO背后的模板信息(projSetting_IOCardProfile)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string allowedIOTypes { get; set; } = "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user