130 lines
4.2 KiB
C#
130 lines
4.2 KiB
C#
![]() |
|
|||
|
using EasyEncryption;
|
|||
|
using Newtonsoft.Json;
|
|||
|
using Newtonsoft.Json.Linq;
|
|||
|
using SWS.CAD.Models;
|
|||
|
using SWS.CAD.Models.NoEntity;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Net.Http;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace SWS.CAD.Services
|
|||
|
{
|
|||
|
public class EnginedataService : HttpService
|
|||
|
{
|
|||
|
public EnginedataService() : base()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 获取位号的pixel对象(仅有位号).
|
|||
|
/// 插件端的设计浏览处用到
|
|||
|
/// </summary>
|
|||
|
/// <param name="objectTypeID"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public async Task<List<ec_enginedata_pixel>> GetTagPixelsById(string objectTypeID)
|
|||
|
{
|
|||
|
|
|||
|
var res = await this.GetAsync<List<ec_enginedata_pixel>>($"EnginedataApi/GetTagPixelsById?projectId={GlobalObject.curProject.ProjectId}&EngineDataID={objectTypeID}");
|
|||
|
if (res.code == 200)
|
|||
|
{
|
|||
|
return res.data;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 批量的去判断位号是否存在
|
|||
|
/// </summary>
|
|||
|
/// <param name="tagNumber">位号</param>
|
|||
|
/// <returns>true:有重复,false:无重复</returns>
|
|||
|
public async Task<bool> CheckTagsExist(string tagNumber, string objectTypeId)
|
|||
|
{
|
|||
|
List<string> listResult = new List<string>();
|
|||
|
List<string> listTagNumber = new List<string>();
|
|||
|
listTagNumber.Add($"{tagNumber},{objectTypeId}");
|
|||
|
var res = await this.PostBodyAsync<List<string>, List<string>>($"EnginedataApi/CheckTagsExist?projId={GlobalObject.curProject?.ProjectId}", listTagNumber);
|
|||
|
if (res.code == 200)
|
|||
|
{
|
|||
|
if (res.data.Any())
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取位号的pixel对象(仅有位号).
|
|||
|
/// 解锁、加锁
|
|||
|
/// </summary>
|
|||
|
/// <param name="Enginedataids">逗号分开</param>
|
|||
|
/// <param name="action">加锁1或解锁0</param>
|
|||
|
/// <returns></returns>
|
|||
|
public async Task<string> LockTag(string Enginedataids, string action)
|
|||
|
{
|
|||
|
|
|||
|
var res = await this.PostBodyAsync<object, object>($"EnginedataApi/LockTag?projectId={GlobalObject.curProject.ProjectId}&Enginedataids={Enginedataids}&action={action}", null);
|
|||
|
if (res.code == 200 && res.info.ToUpper().Contains("OK"))
|
|||
|
{
|
|||
|
return "";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return res.info;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取最新流水号
|
|||
|
/// </summary>
|
|||
|
/// <param name="projectId">项目ID</param>
|
|||
|
/// <param name="TagLeftPart">位号前面的内容</param>
|
|||
|
/// <returns></returns>
|
|||
|
public async Task<List<string>> GetLatestSerialNumber(string TagLeftPart, int Number = 1)
|
|||
|
{
|
|||
|
|
|||
|
var res = await this.GetAsync<List<string>>($"EnginedataApi/GetLatestSerialNumber?projectId={GlobalObject.curProject.ProjectId}&TagLeftPart={TagLeftPart}&Number={Number}");
|
|||
|
if (res.code == 200)
|
|||
|
{
|
|||
|
return res.data;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取某个图上的所有pixel对象
|
|||
|
/// </summary>
|
|||
|
/// <param name="projectId"></param>
|
|||
|
/// <param name="drawingFileID"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public async Task<List<ec_enginedata_pixel>> GetTagPixelsByDrawing(string drawingFileID)
|
|||
|
{
|
|||
|
|
|||
|
var res = await this.GetAsync<List<ec_enginedata_pixel>>($"EnginedataApi/GetTagPixelsByDrawing?projectId={GlobalObject.curProject.ProjectId}&drawingFileID={drawingFileID}");
|
|||
|
if (res.code == 200)
|
|||
|
{
|
|||
|
return res.data;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|