688 lines
31 KiB
C#
688 lines
31 KiB
C#
using Abp.Auditing;
|
|
using Abp.Authorization;
|
|
using Abp.Collections.Extensions;
|
|
using Abp.Domain.Repositories;
|
|
using Abp.Domain.Uow;
|
|
using Amazon.Runtime.Internal.Transform;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using MongoDB.Driver.Linq;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Dynamic.Core;
|
|
using System.Threading.Tasks;
|
|
using System.Xml.Serialization;
|
|
using ToolLibrary.LogHelper;
|
|
using YunDa.ISAS.Application.Core;
|
|
using YunDa.ISAS.Application.Core.Session;
|
|
using YunDa.ISAS.Application.Core.SwaggerHelper;
|
|
using YunDa.ISAS.DataTransferObject;
|
|
using YunDa.ISAS.Entities.GeneralInformation;
|
|
using YunDa.ISAS.Redis.Repositories;
|
|
using YunDa.ISMS.BASE.Entities.Models;
|
|
using YunDa.SOMS.DataTransferObject.CommonDto;
|
|
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto;
|
|
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto.HistoryData;
|
|
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto.SearchCondition;
|
|
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionSettingDto;
|
|
using YunDa.SOMS.DataTransferObject.MainStationMaintenanceInfo.OperationReport;
|
|
using YunDa.SOMS.Entities.GeneralInformation;
|
|
|
|
namespace YunDa.ISAS.Application.GeneralInformation
|
|
{
|
|
/// <summary>
|
|
/// 保护装置履历信息管理类
|
|
/// </summary>
|
|
public class BoardCardInfoAppService : ISASAppServiceBase, IBoardCardInfoAppService
|
|
{
|
|
private readonly IRepository<EquipmentInfo, Guid> _equipmentInfoRepository;
|
|
private readonly IRepository<ProtectionDeviceInfo, Guid> _protectionDeviceInfoRepository;
|
|
private readonly IRepository<ProtectionDeviceType, Guid> _protectionDeviceTypeRepository;
|
|
|
|
private readonly IRepository<ProtectionDeviceHistory, Guid> _protectionDeviceHistoryRepository;
|
|
private readonly IRepository<BoardCardInfo, Guid> _boardCardInfoRepository;
|
|
private readonly IRepository<BoardCardHistory, Guid> _boardCardHistoryRepository;
|
|
private readonly IRepository<ManufacturerInfo, Guid> _manufacturerInfoRepository;
|
|
|
|
private readonly IRepository<ImProtectDevice,string> _imProtectDeviceRepository;
|
|
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
|
IRedisRepository<DeviceBoardStates, string> _deviceBoardStatesRedis;
|
|
string deviceIORedisKey = "deviceIO";
|
|
IRedisRepository<IOState, string> _deviceIOsRedis;
|
|
|
|
// 定义 BoardType 与 BoardTypeId 的映射字典
|
|
Dictionary<string, string> boardTypeMapping = new Dictionary<string, string>
|
|
{
|
|
{ "CPU插件", "J2CA" },
|
|
{ "交流插件", "J2JA" },
|
|
{ "开入插件", "J2IA" },
|
|
{ "开出插件", "J2OA" },
|
|
{ "操作插件", "J2OC" },
|
|
{ "电源插件", "J2IA" },
|
|
{ "液晶", "液晶" }
|
|
};
|
|
public BoardCardInfoAppService(
|
|
IRepository<ProtectionDeviceInfo, Guid> protectionDeviceInfoRepository,
|
|
IUnitOfWorkManager unitOfWorkManager,
|
|
IRepository<ImProtectDevice, string> imProtectDeviceRepository,
|
|
IRepository<EquipmentInfo, Guid> equipmentInfoRepository,
|
|
IRepository<ProtectionDeviceHistory, Guid> protectionDeviceHistoryRepository,
|
|
IRepository<BoardCardInfo, Guid> boardCardInfoRepository,
|
|
IRepository<BoardCardHistory, Guid> boardCardHistoryRepository,
|
|
IRepository<ManufacturerInfo, Guid> manufacturerInfoRepository,
|
|
IRedisRepository<DeviceBoardStates, string> deviceBoardStatesRedis,
|
|
IRedisRepository<IOState, string> deviceIOsRedis,
|
|
IRepository<ProtectionDeviceType, Guid> protectionDeviceTypeRepository,
|
|
ISessionAppService sessionAppService
|
|
) :
|
|
base(sessionAppService)
|
|
{
|
|
_unitOfWorkManager = unitOfWorkManager;
|
|
_equipmentInfoRepository = equipmentInfoRepository;
|
|
_imProtectDeviceRepository = imProtectDeviceRepository;
|
|
_protectionDeviceInfoRepository = protectionDeviceInfoRepository;
|
|
_protectionDeviceHistoryRepository = protectionDeviceHistoryRepository;
|
|
_boardCardInfoRepository = boardCardInfoRepository;
|
|
_boardCardHistoryRepository = boardCardHistoryRepository;
|
|
_manufacturerInfoRepository = manufacturerInfoRepository;
|
|
_deviceBoardStatesRedis = deviceBoardStatesRedis;
|
|
_deviceIOsRedis = deviceIOsRedis;
|
|
_protectionDeviceTypeRepository = protectionDeviceTypeRepository;
|
|
|
|
}
|
|
public async Task<RequestResult<BoardCardInfoOutput>> CreateOrUpdateAsync(EditBoardCardInput input)
|
|
{
|
|
RequestResult<BoardCardInfoOutput> rst = new RequestResult<BoardCardInfoOutput>();
|
|
try
|
|
{
|
|
if (boardTypeMapping.ContainsKey(input.BoardType))
|
|
{
|
|
input.BoardTypeId = boardTypeMapping[input.BoardType];
|
|
}
|
|
if (input.Id.HasValue)
|
|
{
|
|
var entity = _boardCardInfoRepository.GetAll().FirstOrDefault(t => t.Id == input.Id);
|
|
if (entity!=null)
|
|
{
|
|
entity.LastModificationTime = DateTime.Now;
|
|
entity.LastModifierUserId = base.GetCurrentUser().Id;
|
|
ObjectMapper.Map(input, entity);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var entity = ObjectMapper.Map<BoardCardInfo>(input);
|
|
entity.CreatorUserId = base.GetCurrentUser().Id;
|
|
entity.CreationTime = DateTime.Now;
|
|
await _boardCardInfoRepository.InsertAsync(entity);
|
|
}
|
|
rst.Flag = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
rst.Message = ex.Message;
|
|
rst.Flag = false;
|
|
Log4Helper.Error(this.GetType(), "线路管理服务", ex);
|
|
}
|
|
|
|
return rst;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 扫码枪输入设备信息
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[ShowApi]
|
|
[AbpAllowAnonymous]
|
|
[HttpPost]
|
|
public RequestEasyResult ScanDeviceQRCode(EditBoardCardQrCodeInput input)
|
|
{
|
|
RequestEasyResult rst = new RequestEasyResult();
|
|
try
|
|
{
|
|
var repo = _protectionDeviceInfoRepository.GetAllIncluding(t => t.EquipmentInfo,t=>t.ProtectionDeviceType).ToList();
|
|
var boardCards = _boardCardInfoRepository.GetAll().ToList();
|
|
var protectionDevice = repo.FirstOrDefault(t => t.Name.Contains(input.ProtectionDeviceName));
|
|
if (protectionDevice != null)
|
|
{
|
|
var deviceBoardCard = boardCards.FirstOrDefault(t => t.ProtectionDeviceInfoId == protectionDevice.Id&&t.BoardId == input.BoardId);
|
|
if (deviceBoardCard!=null)
|
|
{
|
|
if (deviceBoardCard.SerialNumber != input.SerialNumber)
|
|
{
|
|
var deviceBoardCardHistory = _boardCardHistoryRepository.GetAll().Where(t => t.BoardCardInfoId == deviceBoardCard.Id).ToList();
|
|
|
|
var json = JsonConvert.SerializeObject(deviceBoardCard);
|
|
var boardHistory = new BoardCardHistory
|
|
{
|
|
ContentJson = json,
|
|
CreationTime = DateTime.Now,
|
|
CreatorUserId = base.GetCurrentUser().Id,
|
|
Name = protectionDevice.Name,
|
|
RecodeDate = DateTime.Now,
|
|
BoardId = input.BoardId,
|
|
BoardCardInfoId = deviceBoardCard.Id,
|
|
ProtectionDeviceInfoId = protectionDevice.Id,
|
|
SeqNo = deviceBoardCardHistory.Count > 0 ? deviceBoardCardHistory.Max(t => t.SeqNo) + 1 : 1
|
|
};
|
|
deviceBoardCard.SerialNumber = input.SerialNumber;
|
|
deviceBoardCard.ProductionDate = input.ProductionDate;
|
|
deviceBoardCard.VerificationDate = input.VerificationDate;
|
|
deviceBoardCard.VerificationPerson = input.VerificationPerson;
|
|
deviceBoardCard.VerificationRecords = input.VerificationRecords;
|
|
var newjson = JsonConvert.SerializeObject(deviceBoardCard);
|
|
boardHistory.ContentNewJson = newjson;
|
|
_boardCardHistoryRepository.Insert(boardHistory);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_boardCardInfoRepository.Insert(new BoardCardInfo
|
|
{
|
|
SeqNo = 1,
|
|
BoardId=input.BoardId,
|
|
SerialNumber=input.SerialNumber,
|
|
BoardType=input.BoardType,
|
|
ProductionDate=input.ProductionDate,
|
|
VerificationDate=input.VerificationDate,
|
|
VerificationPerson=input.VerificationPerson,
|
|
VerificationRecords=input.VerificationRecords,
|
|
ProtectionDeviceInfoId=deviceBoardCard.Id,
|
|
});
|
|
//rst.Message = "未找到对应板卡";
|
|
}
|
|
rst.Flag = true;
|
|
}
|
|
else
|
|
{
|
|
rst.Message = "未找到对应装置";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
rst.Message = ex.Message;
|
|
rst.Flag = false;
|
|
Log4Helper.Error(this.GetType(), "", ex);
|
|
}
|
|
|
|
return rst;
|
|
}
|
|
|
|
public async Task<RequestEasyResult> DeleteByIdAsync(Guid id)
|
|
{
|
|
RequestEasyResult rst = new RequestEasyResult();
|
|
return rst;
|
|
}
|
|
/// <summary>
|
|
/// 删除板卡信息
|
|
/// </summary>
|
|
/// <param name="ids"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<RequestEasyResult> DeleteByIdsAsync(List<Guid> ids)
|
|
{
|
|
RequestEasyResult rst = new RequestEasyResult();
|
|
try
|
|
{
|
|
await _boardCardInfoRepository.DeleteAsync(t => ids.Contains(t.Id));
|
|
rst.Flag = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
rst.Message = ex.Message;
|
|
rst.Flag = false;
|
|
Log4Helper.Error(this.GetType(), "保护装置信息管理服务", ex);
|
|
}
|
|
return rst;
|
|
}
|
|
/// <summary>
|
|
/// 查询保护装置板卡信息
|
|
/// </summary>
|
|
/// <param name="searchCondition"></param>
|
|
/// <returns></returns>
|
|
[ShowApi]
|
|
[AbpAllowAnonymous]
|
|
[DisableAuditing]
|
|
[HttpPost]
|
|
public RequestPageResult<BoardCardInfoOutput> FindDatas(PageSearchCondition<BoardCardInfoSearchConditionInput> searchCondition)
|
|
{
|
|
RequestPageResult<BoardCardInfoOutput> rst = new RequestPageResult<BoardCardInfoOutput>();
|
|
try
|
|
{
|
|
var repo = _boardCardInfoRepository.GetAllIncluding(t=>t.ProtectionDeviceInfo,t=>t.ManufacturerInfo)
|
|
.WhereIf(searchCondition.SearchCondition.EquipmentInfoId.HasValue, t => t.ProtectionDeviceInfo?.EquipmentInfoId == searchCondition.SearchCondition.EquipmentInfoId)
|
|
.WhereIf(searchCondition.SearchCondition.ProtectionDeviceInfoId.HasValue, t => t.ProtectionDeviceInfoId == searchCondition.SearchCondition.ProtectionDeviceInfoId);
|
|
rst.TotalCount = repo.Count();
|
|
if (searchCondition.PageSize>0&& searchCondition.PageIndex>0)
|
|
{
|
|
int skipCount = searchCondition.PageSize * (searchCondition.PageIndex - 1);
|
|
var tmpData = repo.Skip(skipCount).Take(searchCondition.PageSize);
|
|
rst.ResultData = ObjectMapper.Map<List<BoardCardInfoOutput>>(tmpData);
|
|
}
|
|
else
|
|
{
|
|
rst.ResultData = ObjectMapper.Map<List<BoardCardInfoOutput>>(repo);
|
|
}
|
|
rst.Flag = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
rst.Message = ex.Message;
|
|
rst.Flag = false;
|
|
Log4Helper.Error(this.GetType(), "保护装置信息管理服务", ex);
|
|
}
|
|
|
|
return rst;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询板卡历史数据
|
|
/// </summary>
|
|
/// <param name="equipmentInfoId"></param>
|
|
/// <returns></returns>
|
|
[ShowApi]
|
|
[AbpAllowAnonymous]
|
|
[DisableAuditing]
|
|
[HttpGet]
|
|
public RequestResult<List<BoardCardHistoryOutput>> FindHistoryDataByEquipmentInfoId(Guid? equipmentInfoId)
|
|
{
|
|
RequestResult<List<BoardCardHistoryOutput>> rst = new RequestResult<List<BoardCardHistoryOutput>>();
|
|
try
|
|
{
|
|
List<BoardCardHistoryOutput> historys = new List<BoardCardHistoryOutput>();
|
|
var protectionDevice = _protectionDeviceInfoRepository.GetAllIncluding(t => t.EquipmentInfo)
|
|
.FirstOrDefault(t => t.EquipmentInfoId == equipmentInfoId);
|
|
if (protectionDevice != null)
|
|
{
|
|
var boards = _boardCardHistoryRepository.GetAll().Where(t => t.ProtectionDeviceInfoId == protectionDevice.Id);
|
|
|
|
|
|
foreach (var board in boards)
|
|
{
|
|
BoardCardInfo boardCardInfo1 = JsonConvert.DeserializeObject<BoardCardInfo>(board.ContentJson);
|
|
BoardCardInfo boardCardInfo2 = JsonConvert.DeserializeObject<BoardCardInfo>(board.ContentNewJson);
|
|
BoardCardHistoryOutput boardCardHistoryOutput1 = new BoardCardHistoryOutput()
|
|
{
|
|
RecodeDate = board.RecodeDate,
|
|
BoardId = board.BoardId,
|
|
PostUpdate = ObjectMapper.Map<BoardCardHistoryViewOutput>(boardCardInfo2),
|
|
PrioUpdate = ObjectMapper.Map<BoardCardHistoryViewOutput>(boardCardInfo1),
|
|
SeqNo = board.SeqNo,
|
|
};
|
|
historys.Add(boardCardHistoryOutput1);
|
|
}
|
|
rst.Flag = true;
|
|
rst.ResultData = historys;
|
|
rst.TotalCount = historys.Count;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
rst.Message = ex.Message;
|
|
rst.Flag = false;
|
|
Log4Helper.Error(this.GetType(), "保护装置信息管理服务", ex);
|
|
}
|
|
|
|
return rst;
|
|
}
|
|
|
|
public RequestResult<string> GetProtectionDeviceQRcode(Guid id)
|
|
{
|
|
RequestResult<string> rst = new RequestResult<string>();
|
|
return rst;
|
|
}
|
|
|
|
string deviceBoardStatesRedisKey = "deviceBoardStates";
|
|
/// <summary>
|
|
/// 获取板卡状态
|
|
/// </summary>
|
|
/// <param name="equipmentId"></param>
|
|
/// <param name="deviceId"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[AbpAllowAnonymous]
|
|
[ShowApi]
|
|
public async Task<RequestResult<List<DeviceRunState>>> GetBoardStateInfo(Guid equipmentId,Guid deviceId)
|
|
{
|
|
RequestResult<List<DeviceRunState>> rst = new RequestResult<List<DeviceRunState>>();
|
|
try
|
|
{
|
|
ProtectionDeviceInfo protectionDeviceInfo = null;
|
|
if (deviceId == default)
|
|
{
|
|
protectionDeviceInfo = _protectionDeviceInfoRepository.GetAll().FirstOrDefault(t => t.EquipmentInfoId == equipmentId);
|
|
}
|
|
else
|
|
{
|
|
protectionDeviceInfo = _protectionDeviceInfoRepository.Get(deviceId);
|
|
}
|
|
if (protectionDeviceInfo != null)
|
|
{
|
|
|
|
var state = await _deviceBoardStatesRedis.HashSetGetAllAsync(deviceBoardStatesRedisKey, protectionDeviceInfo.DeviceAddress.ToString());
|
|
rst.ResultData = state.States.Select(t=>new DeviceRunState { Name = t.Name,State = t.Value}).ToList();
|
|
rst.Flag = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
rst.Flag = false;
|
|
rst.Message = ex.Message;
|
|
}
|
|
|
|
return rst;
|
|
}
|
|
/// <summary>
|
|
/// 获取板卡IO信息
|
|
/// </summary>
|
|
/// <param name="equipmentId"></param>
|
|
/// <param name="deviceId"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[AbpAllowAnonymous]
|
|
[ShowApi]
|
|
public async Task<RequestResult<List<IOStateList>>> GetBoardIOState(Guid equipmentId, Guid deviceId)
|
|
{
|
|
RequestResult<List<IOStateList>> rst = new RequestResult<List<IOStateList>>();
|
|
|
|
try
|
|
{
|
|
ProtectionDeviceInfo protectionDeviceInfo = null;
|
|
if (deviceId == default)
|
|
{
|
|
protectionDeviceInfo = _protectionDeviceInfoRepository.GetAll().FirstOrDefault(t => t.EquipmentInfoId == equipmentId);
|
|
}
|
|
else
|
|
{
|
|
protectionDeviceInfo = _protectionDeviceInfoRepository.Get(deviceId);
|
|
}
|
|
if (protectionDeviceInfo != null)
|
|
{
|
|
var states =await _deviceIOsRedis.HashSetGetDicAllAsync(deviceIORedisKey);
|
|
|
|
var datas = states.Where(t => t.Key.Contains($"{protectionDeviceInfo.DeviceAddress}_")).GroupBy(t=>t.Key.Split('_')[1]).Select(t => new IOStateList
|
|
{
|
|
Name ="B0"+ t.Key,
|
|
IOStates =t.Select(x=>x.Value).ToList(),
|
|
}).OrderBy(t=>t.Name);
|
|
rst.ResultData = datas.ToList();
|
|
rst.Flag = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
rst.Flag = false;
|
|
rst.Message = ex.Message;
|
|
}
|
|
|
|
return rst;
|
|
}
|
|
/// <summary>
|
|
/// 生成板卡信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[ShowApi]
|
|
[AbpAllowAnonymous]
|
|
[HttpGet]
|
|
public RequestEasyResult SpwanBoardInfoList()
|
|
{
|
|
RequestEasyResult rst = new RequestEasyResult();
|
|
try
|
|
{
|
|
var boards = _boardCardInfoRepository.GetAll().ToList();
|
|
var devices = _protectionDeviceInfoRepository.GetAll();
|
|
var manfac = _manufacturerInfoRepository.GetAll().FirstOrDefault(t => t.ManufacturerName.Contains("运达"));
|
|
foreach (var device in devices)
|
|
{
|
|
var boardInfos = boards.Where(t => t.ProtectionDeviceInfoId == device.Id);
|
|
if (boardInfos.Count() > 0)
|
|
{
|
|
continue;
|
|
}
|
|
// 插件信息表
|
|
var pluginData = new BoardCardInfo[]
|
|
{
|
|
new BoardCardInfo{ BoardId = "B01", SeqNo = 1, SerialNumber = "1933CA00300001", BoardType = "CPU插件", BoardTypeId = "J2CA", ProductionDate = new DateTime(2019, 8, 13), Remark = "CPU 主插件" },
|
|
new BoardCardInfo{ BoardId = "B02", SeqNo = 2, SerialNumber = "1933JA04100001", BoardType = "交流插件", BoardTypeId = "J2JA", ProductionDate = new DateTime(2019, 8, 13), Remark = "交流插件" },
|
|
new BoardCardInfo{ BoardId = "B03", SeqNo = 3, SerialNumber = "2233IA220V400001", BoardType = "开入插件", BoardTypeId = "J2IA", ProductionDate = new DateTime(2022, 8, 13), Remark = "开入插件1" },
|
|
new BoardCardInfo{ BoardId = "B04", SeqNo = 4, SerialNumber = "2233IA220V400002", BoardType = "开入插件", BoardTypeId = "J2IA", ProductionDate = new DateTime(2022, 8, 13), Remark = "开入插件2" },
|
|
new BoardCardInfo{ BoardId = "B05", SeqNo = 5, SerialNumber = "2233OA0000400001", BoardType = "开出插件", BoardTypeId = "J2OA", ProductionDate = new DateTime(2022, 8, 13), Remark = "开出插件" },
|
|
new BoardCardInfo{ BoardId = "B06", SeqNo = 6, SerialNumber = "2233OC220V400001", BoardType = "操作插件", BoardTypeId = "J2OC", ProductionDate = new DateTime(2022, 8, 13), Remark = "操作插件" },
|
|
new BoardCardInfo{ BoardId = "B07", SeqNo = 7, SerialNumber = "1933DA00100001", BoardType = "电源插件", BoardTypeId = "J2IA", ProductionDate = new DateTime(2019, 8, 13), Remark = "电源插件" },
|
|
new BoardCardInfo{ BoardId = "液晶", SeqNo = 8, SerialNumber = "1933DA00100001", BoardType = "液晶", BoardTypeId = "液晶", ProductionDate = new DateTime(2019, 8, 13), Remark = "液晶" },
|
|
};
|
|
|
|
// 模拟插入插件数据
|
|
foreach (var plugin in pluginData)
|
|
{
|
|
var boardCardInfo = new BoardCardInfo
|
|
{
|
|
SeqNo = plugin.SeqNo,
|
|
BoardId = plugin.BoardId,
|
|
BoardType = plugin.BoardType,
|
|
ManufacturerInfoId = manfac.Id,
|
|
ProtectionDeviceInfoId = device.Id,
|
|
IsActive = true,
|
|
SerialNumber = plugin.SerialNumber,
|
|
ProductionDate = plugin.ProductionDate,
|
|
Remark = plugin.Remark,
|
|
InstallationDate = DateTime.Now.AddMonths(-3) // 默认安装时间
|
|
};
|
|
|
|
if (plugin.SeqNo == 1)
|
|
{
|
|
boardCardInfo.HardwareVersion = "1.0.0";
|
|
boardCardInfo.InterfaceVersion = "2.0.0";
|
|
boardCardInfo.InterfaceChecksum = "8b18";
|
|
boardCardInfo.InterfaceDatabaseVersion = "v1.104";
|
|
boardCardInfo.ProtectionDatabaseVersion = "v1.104";
|
|
boardCardInfo.SystemVersion = "3.10.10-ADI-2013R1";
|
|
boardCardInfo.ProtectionVersion = "v5.3.1";
|
|
boardCardInfo.ProtectionChecksum = "8b18";
|
|
boardCardInfo.BootVersion = "BOOT2024";
|
|
boardCardInfo.Iec61850Version = "IEC61850-V2";
|
|
boardCardInfo.FpgaVersion = "v4.000";
|
|
boardCardInfo.CidChecksum = "CIDCHK2024";
|
|
boardCardInfo.CcdChecksum = "CCDCHK2024";
|
|
boardCardInfo.VerificationPerson = "贺严玲";
|
|
boardCardInfo.VerificationDate = "2024-01-01";
|
|
boardCardInfo.VerificationRecords = "全部通过";
|
|
}
|
|
|
|
// 模拟插入数据库
|
|
_boardCardInfoRepository.Insert(boardCardInfo);
|
|
}
|
|
|
|
}
|
|
rst.Flag = true;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
throw;
|
|
}
|
|
return rst;
|
|
}
|
|
/// <summary>
|
|
/// 更新版本信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[ShowApi]
|
|
[AbpAllowAnonymous]
|
|
[HttpPost]
|
|
public RequestEasyResult ModifyBoardInfoList(ProtectionDeviceVersionInfo input)
|
|
{
|
|
RequestEasyResult rst = new RequestEasyResult();
|
|
try
|
|
{
|
|
var boards = _boardCardInfoRepository.GetAll().ToList();
|
|
var devices = _protectionDeviceInfoRepository.GetAll().Where(t=>t.DeviceAddress == input.DeviceAddr).ToList();
|
|
var protectionDeviceTypes = _protectionDeviceTypeRepository.GetAll().ToList();
|
|
if (devices.Count >0)
|
|
{
|
|
var device = devices[0];
|
|
device.ProtectionDeviceTypeId = protectionDeviceTypes.FirstOrDefault(t=>t.Model == input.DeviceType)?.Id;
|
|
//device.BaselineBoardVersion = input.
|
|
var deviceBoards = boards.Where(t => t.ProtectionDeviceInfoId == device.Id);
|
|
//保护
|
|
BoardCardInfo cpuCardInfo = deviceBoards.FirstOrDefault(t => t.BoardId == "B01");
|
|
cpuCardInfo.FpgaVersion = input.FpgaVer;
|
|
cpuCardInfo.InterfaceDatabaseVersion = input.CommcpuCfgVer;
|
|
cpuCardInfo.InterfaceVersion = input.CommcpuVer;
|
|
cpuCardInfo.InterfaceChecksum = input.CommcpuCrc;
|
|
cpuCardInfo.SystemVersion = input.LinuxVer;
|
|
cpuCardInfo.ProtectionChecksum = input.ProtectCrc;
|
|
cpuCardInfo.ProtectionDatabaseVersion = input.ProtectCfgVer;
|
|
cpuCardInfo.ProtectionVersion = input.ProtectVer;
|
|
//液晶
|
|
BoardCardInfo ioyjCardInfo = deviceBoards.FirstOrDefault(t => t.BoardId == "液晶");
|
|
ioyjCardInfo.YjVersion = input.YjVer;
|
|
ioyjCardInfo.YjCrc = input.YjCrc;
|
|
if (input.IoVersion.Count==5)
|
|
{
|
|
BoardCardInfo io1CardInfo = deviceBoards.FirstOrDefault(t => t.BoardId == "B03");
|
|
io1CardInfo.IOVersion = input.IoVersion[0].IoVer;
|
|
io1CardInfo.IOCrc = input.IoVersion[0].IoCrc;
|
|
|
|
BoardCardInfo io2CardInfo = deviceBoards.FirstOrDefault(t => t.BoardId == "B04");
|
|
io2CardInfo.IOVersion = input.IoVersion[1].IoVer;
|
|
io2CardInfo.IOCrc = input.IoVersion[1].IoCrc;
|
|
|
|
BoardCardInfo io3CardInfo = deviceBoards.FirstOrDefault(t => t.BoardId == "B05");
|
|
io3CardInfo.IOVersion = input.IoVersion[2].IoVer;
|
|
io3CardInfo.IOCrc = input.IoVersion[2].IoCrc;
|
|
|
|
BoardCardInfo io4CardInfo = deviceBoards.FirstOrDefault(t => t.BoardId == "B06");
|
|
io4CardInfo.IOVersion = input.IoVersion[3].IoVer;
|
|
io4CardInfo.IOCrc = input.IoVersion[3].IoCrc;
|
|
|
|
BoardCardInfo io5CardInfo = deviceBoards.FirstOrDefault(t => t.BoardId == "B07");
|
|
io5CardInfo.IOVersion = input.IoVersion[4].IoVer;
|
|
io5CardInfo.IOCrc = input.IoVersion[4].IoCrc;
|
|
|
|
|
|
}
|
|
|
|
}
|
|
rst.Flag = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
|
|
}
|
|
return rst;
|
|
}
|
|
#if DEBUG
|
|
|
|
|
|
/// <summary>
|
|
/// 生成板卡信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[ShowApi]
|
|
[AbpAllowAnonymous]
|
|
public async Task<RequestEasyResult> SpwanBoardMancfactoryJDYDList()
|
|
{
|
|
RequestEasyResult rst = new RequestEasyResult();
|
|
try
|
|
{
|
|
var manfac = _manufacturerInfoRepository.GetAll().FirstOrDefault(t => t.ManufacturerName.Contains("运达"));
|
|
if (manfac!=null)
|
|
{
|
|
using (var unitOfWork = _unitOfWorkManager.Begin())
|
|
{
|
|
var boards = _boardCardInfoRepository.GetAll();
|
|
foreach (var board in boards)
|
|
{
|
|
board.ManufacturerInfoId = manfac.Id;
|
|
board.BoardTypeId = "JDYD";
|
|
}
|
|
await unitOfWork.CompleteAsync();
|
|
}
|
|
using (var unitOfWork = _unitOfWorkManager.Begin())
|
|
{
|
|
var devices = _protectionDeviceInfoRepository.GetAllIncluding(t => t.EquipmentInfo);
|
|
|
|
foreach (var device in devices)
|
|
{
|
|
device.EquipmentInfo.ManufacturerInfoId = manfac.Id;
|
|
}
|
|
await unitOfWork.CompleteAsync();
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
throw;
|
|
}
|
|
return rst;
|
|
}
|
|
/// <summary>
|
|
/// 填充出厂编号
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[ShowApi]
|
|
[AbpAllowAnonymous]
|
|
[HttpGet]
|
|
public async Task<RequestEasyResult> UpdateProtetionInfoForHistoryTest()
|
|
{
|
|
RequestEasyResult rst = new RequestEasyResult();
|
|
try
|
|
{
|
|
List<BoardCardInfo> datas;
|
|
using (var unitOfWork = _unitOfWorkManager.Begin())
|
|
{
|
|
datas = _boardCardInfoRepository.GetAllIncluding(t=>t.ProtectionDeviceInfo).ToList();
|
|
await unitOfWork.CompleteAsync();
|
|
}
|
|
Random random = new Random();
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
foreach (var data in datas)
|
|
{
|
|
EditBoardCardQrCodeInput deviceInfo = new EditBoardCardQrCodeInput
|
|
{
|
|
ProtectionDeviceName = data.ProtectionDeviceInfo.Name,
|
|
BoardId = data.BoardId,
|
|
BoardType = data.BoardType,
|
|
SerialNumber = "210" + random.Next(100000, 1000000).ToString(), // 出厂编号设为 "210" 开头 + 6 位随机数
|
|
ProductionDate = new DateTime(2023, 5, 15), // 示例生产日期
|
|
VerificationPerson = "贺严玲", // 示例检验人员
|
|
VerificationDate = DateTime.Now.AddDays(-100 + i).ToString("yyyy-MM-dd"), // 检验日期设为当前日期
|
|
VerificationRecords = "检验板卡外观及功能,均符合要求" // 示例检验记录
|
|
};
|
|
using (var unitOfWork = _unitOfWorkManager.Begin())
|
|
{
|
|
ScanDeviceQRCode(deviceInfo);
|
|
await unitOfWork.CompleteAsync();
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
throw;
|
|
}
|
|
|
|
|
|
|
|
return rst;
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
}
|