2024-10-18 18:41:02 +08:00
|
|
|
|
using Abp.Auditing;
|
|
|
|
|
using Abp.Authorization;
|
|
|
|
|
using Abp.Collections.Extensions;
|
|
|
|
|
using Abp.Domain.Repositories;
|
|
|
|
|
using Abp.Domain.Uow;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
using Amazon.Runtime.Internal.Transform;
|
2024-10-18 18:41:02 +08:00
|
|
|
|
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;
|
2024-12-10 11:25:08 +08:00
|
|
|
|
using System.Text;
|
2024-10-18 18:41:02 +08:00
|
|
|
|
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;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
using YunDa.ISAS.Redis.Repositories;
|
2024-10-18 18:41:02 +08:00
|
|
|
|
using YunDa.ISMS.BASE.Entities.Models;
|
2024-12-06 16:32:13 +08:00
|
|
|
|
using YunDa.SOMS.DataTransferObject.CommonDto;
|
2024-10-18 18:41:02 +08:00
|
|
|
|
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto;
|
|
|
|
|
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto.HistoryData;
|
|
|
|
|
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto.SearchCondition;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionSettingDto;
|
2024-12-06 16:50:46 +08:00
|
|
|
|
using YunDa.SOMS.DataTransferObject.MainStationMaintenanceInfo.OperationReport;
|
2024-10-18 18:41:02 +08:00
|
|
|
|
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;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
private readonly IRepository<ProtectionDeviceType, Guid> _protectionDeviceTypeRepository;
|
|
|
|
|
|
2024-10-18 18:41:02 +08:00
|
|
|
|
private readonly IRepository<ProtectionDeviceHistory, Guid> _protectionDeviceHistoryRepository;
|
|
|
|
|
private readonly IRepository<BoardCardInfo, Guid> _boardCardInfoRepository;
|
|
|
|
|
private readonly IRepository<BoardCardHistory, Guid> _boardCardHistoryRepository;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
private readonly IRepository<ManufacturerInfo, Guid> _manufacturerInfoRepository;
|
|
|
|
|
|
2024-10-18 18:41:02 +08:00
|
|
|
|
private readonly IRepository<ImProtectDevice,string> _imProtectDeviceRepository;
|
|
|
|
|
private readonly IUnitOfWorkManager _unitOfWorkManager;
|
2024-12-06 16:50:46 +08:00
|
|
|
|
IRedisRepository<DeviceBoardStates, string> _deviceBoardStatesRedis;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
string deviceIORedisKey = "deviceIO";
|
|
|
|
|
IRedisRepository<IOState, string> _deviceIOsRedis;
|
2024-10-18 18:41:02 +08:00
|
|
|
|
|
2024-11-26 13:45:28 +08:00
|
|
|
|
// 定义 BoardType 与 BoardTypeId 的映射字典
|
|
|
|
|
Dictionary<string, string> boardTypeMapping = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "CPU插件", "J2CA" },
|
|
|
|
|
{ "交流插件", "J2JA" },
|
|
|
|
|
{ "开入插件", "J2IA" },
|
|
|
|
|
{ "开出插件", "J2OA" },
|
|
|
|
|
{ "操作插件", "J2OC" },
|
|
|
|
|
{ "电源插件", "J2IA" },
|
|
|
|
|
{ "液晶", "液晶" }
|
|
|
|
|
};
|
2024-10-18 18:41:02 +08:00
|
|
|
|
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,
|
2024-11-26 13:45:28 +08:00
|
|
|
|
IRepository<ManufacturerInfo, Guid> manufacturerInfoRepository,
|
2024-12-06 16:50:46 +08:00
|
|
|
|
IRedisRepository<DeviceBoardStates, string> deviceBoardStatesRedis,
|
2024-11-26 13:45:28 +08:00
|
|
|
|
IRedisRepository<IOState, string> deviceIOsRedis,
|
|
|
|
|
IRepository<ProtectionDeviceType, Guid> protectionDeviceTypeRepository,
|
2024-10-18 18:41:02 +08:00
|
|
|
|
ISessionAppService sessionAppService
|
|
|
|
|
) :
|
|
|
|
|
base(sessionAppService)
|
|
|
|
|
{
|
|
|
|
|
_unitOfWorkManager = unitOfWorkManager;
|
|
|
|
|
_equipmentInfoRepository = equipmentInfoRepository;
|
|
|
|
|
_imProtectDeviceRepository = imProtectDeviceRepository;
|
|
|
|
|
_protectionDeviceInfoRepository = protectionDeviceInfoRepository;
|
|
|
|
|
_protectionDeviceHistoryRepository = protectionDeviceHistoryRepository;
|
|
|
|
|
_boardCardInfoRepository = boardCardInfoRepository;
|
|
|
|
|
_boardCardHistoryRepository = boardCardHistoryRepository;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
_manufacturerInfoRepository = manufacturerInfoRepository;
|
|
|
|
|
_deviceBoardStatesRedis = deviceBoardStatesRedis;
|
|
|
|
|
_deviceIOsRedis = deviceIOsRedis;
|
|
|
|
|
_protectionDeviceTypeRepository = protectionDeviceTypeRepository;
|
|
|
|
|
|
2024-10-18 18:41:02 +08:00
|
|
|
|
}
|
|
|
|
|
public async Task<RequestResult<BoardCardInfoOutput>> CreateOrUpdateAsync(EditBoardCardInput input)
|
|
|
|
|
{
|
|
|
|
|
RequestResult<BoardCardInfoOutput> rst = new RequestResult<BoardCardInfoOutput>();
|
|
|
|
|
try
|
|
|
|
|
{
|
2024-11-26 13:45:28 +08:00
|
|
|
|
if (boardTypeMapping.ContainsKey(input.BoardType))
|
|
|
|
|
{
|
|
|
|
|
input.BoardTypeId = boardTypeMapping[input.BoardType];
|
|
|
|
|
}
|
2024-10-18 18:41:02 +08:00
|
|
|
|
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)
|
|
|
|
|
{
|
2024-12-10 11:25:08 +08:00
|
|
|
|
if (deviceBoardCard.SerialNumber != input.SerialNumber
|
|
|
|
|
|| deviceBoardCard.MaintenanceRecord != input.MaintenanceRecord
|
|
|
|
|
|| deviceBoardCard.VerificationRecords != input.VerificationRecords
|
|
|
|
|
|| deviceBoardCard.VerificationDate != input.VerificationDate
|
|
|
|
|
|| deviceBoardCard.VerificationPerson != input.VerificationPerson
|
|
|
|
|
|| deviceBoardCard.ProductionDate != input.ProductionDate
|
|
|
|
|
)
|
2024-10-18 18:41:02 +08:00
|
|
|
|
{
|
|
|
|
|
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;
|
2024-12-10 11:25:08 +08:00
|
|
|
|
// 记录变更内容
|
|
|
|
|
var eventDescription = new StringBuilder();
|
|
|
|
|
// 通过判定每个字段是否发生变化,动态生成描述
|
|
|
|
|
if (deviceBoardCard.SerialNumber != input.SerialNumber)
|
|
|
|
|
{
|
|
|
|
|
eventDescription.AppendLine($"更换了设备的厂商序列号: {deviceBoardCard.SerialNumber} -> {input.SerialNumber}");
|
|
|
|
|
}
|
|
|
|
|
if (deviceBoardCard.MaintenanceRecord != input.MaintenanceRecord)
|
|
|
|
|
{
|
|
|
|
|
eventDescription.AppendLine($"更新了设备的维修记录: {deviceBoardCard.MaintenanceRecord} -> {input.MaintenanceRecord}");
|
|
|
|
|
}
|
|
|
|
|
if (deviceBoardCard.VerificationRecords != input.VerificationRecords)
|
|
|
|
|
{
|
|
|
|
|
eventDescription.AppendLine($"更改了设备的验证记录: {deviceBoardCard.VerificationRecords} -> {input.VerificationRecords}");
|
|
|
|
|
}
|
|
|
|
|
if (deviceBoardCard.VerificationDate != input.VerificationDate)
|
|
|
|
|
{
|
|
|
|
|
eventDescription.AppendLine($"修改了设备的验证日期: {deviceBoardCard.VerificationDate} -> {input.VerificationDate}");
|
|
|
|
|
}
|
|
|
|
|
if (deviceBoardCard.VerificationPerson != input.VerificationPerson)
|
|
|
|
|
{
|
|
|
|
|
eventDescription.AppendLine($"更新了设备的验证人员: {deviceBoardCard.VerificationPerson} -> {input.VerificationPerson}");
|
|
|
|
|
}
|
|
|
|
|
if (deviceBoardCard.ProductionDate != input.ProductionDate)
|
|
|
|
|
{
|
|
|
|
|
eventDescription.AppendLine($"更改了设备的生产日期: {deviceBoardCard.ProductionDate} -> {input.ProductionDate}");
|
|
|
|
|
}
|
|
|
|
|
boardHistory.EventDescription = eventDescription.ToString();
|
|
|
|
|
boardHistory.EventRecordType = EventRecordTypeEnum.Board;
|
|
|
|
|
boardHistory.Remark = input.Remark;
|
2024-10-18 18:41:02 +08:00
|
|
|
|
_boardCardHistoryRepository.Insert(boardHistory);
|
|
|
|
|
}
|
2024-12-10 11:25:08 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//rst.Message = "未找到对应板卡";
|
|
|
|
|
}
|
|
|
|
|
rst.Flag = true;
|
2024-10-18 18:41:02 +08:00
|
|
|
|
}
|
2024-12-10 11:25:08 +08:00
|
|
|
|
else
|
2024-10-18 18:41:02 +08:00
|
|
|
|
{
|
2024-12-10 11:25:08 +08:00
|
|
|
|
rst.Message = "未找到对应装置";
|
2024-10-18 18:41:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
{
|
2024-11-26 13:45:28 +08:00
|
|
|
|
var repo = _boardCardInfoRepository.GetAllIncluding(t=>t.ProtectionDeviceInfo,t=>t.ManufacturerInfo)
|
2024-10-18 18:41:02 +08:00
|
|
|
|
.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;
|
|
|
|
|
}
|
2024-12-06 16:32:13 +08:00
|
|
|
|
|
2024-11-26 13:45:28 +08:00
|
|
|
|
string deviceBoardStatesRedisKey = "deviceBoardStates";
|
2024-12-09 11:05:46 +08:00
|
|
|
|
List<NameIntValueProperty> iopositions = new List<NameIntValueProperty>
|
|
|
|
|
{
|
|
|
|
|
new NameIntValueProperty("运行", 0),
|
|
|
|
|
new NameIntValueProperty("告警", 0),
|
|
|
|
|
new NameIntValueProperty("IO插件1", 0),
|
|
|
|
|
new NameIntValueProperty("IO插件2", 0),
|
|
|
|
|
new NameIntValueProperty("IO插件3", 0),
|
|
|
|
|
new NameIntValueProperty("IO插件4", 0),
|
|
|
|
|
new NameIntValueProperty("电源插件(IO5)", 0),
|
|
|
|
|
new NameIntValueProperty("液晶", 0)
|
|
|
|
|
};
|
2024-10-18 18:41:02 +08:00
|
|
|
|
/// <summary>
|
2024-11-26 13:45:28 +08:00
|
|
|
|
/// 获取板卡状态
|
2024-10-18 18:41:02 +08:00
|
|
|
|
/// </summary>
|
2024-11-26 13:45:28 +08:00
|
|
|
|
/// <param name="equipmentId"></param>
|
|
|
|
|
/// <param name="deviceId"></param>
|
2024-10-18 18:41:02 +08:00
|
|
|
|
/// <returns></returns>
|
2024-11-26 13:45:28 +08:00
|
|
|
|
[HttpGet]
|
2024-10-18 18:41:02 +08:00
|
|
|
|
[AbpAllowAnonymous]
|
2024-11-26 13:45:28 +08:00
|
|
|
|
[ShowApi]
|
|
|
|
|
public async Task<RequestResult<List<DeviceRunState>>> GetBoardStateInfo(Guid equipmentId,Guid deviceId)
|
2024-10-18 18:41:02 +08:00
|
|
|
|
{
|
2024-11-26 13:45:28 +08:00
|
|
|
|
RequestResult<List<DeviceRunState>> rst = new RequestResult<List<DeviceRunState>>();
|
2024-10-18 18:41:02 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
2024-11-26 13:45:28 +08:00
|
|
|
|
ProtectionDeviceInfo protectionDeviceInfo = null;
|
|
|
|
|
if (deviceId == default)
|
|
|
|
|
{
|
|
|
|
|
protectionDeviceInfo = _protectionDeviceInfoRepository.GetAll().FirstOrDefault(t => t.EquipmentInfoId == equipmentId);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
protectionDeviceInfo = _protectionDeviceInfoRepository.Get(deviceId);
|
|
|
|
|
}
|
|
|
|
|
if (protectionDeviceInfo != null)
|
2024-10-18 18:41:02 +08:00
|
|
|
|
{
|
|
|
|
|
|
2024-11-26 13:45:28 +08:00
|
|
|
|
var state = await _deviceBoardStatesRedis.HashSetGetAllAsync(deviceBoardStatesRedisKey, protectionDeviceInfo.DeviceAddress.ToString());
|
2024-12-09 11:05:46 +08:00
|
|
|
|
if (state != null)
|
|
|
|
|
{
|
|
|
|
|
rst.ResultData = state.States.Select(t => new DeviceRunState { Name = t.Name, State = t.Value }).ToList();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rst.ResultData = iopositions.Select(t => new DeviceRunState { Name = t.Name, State = t.Value }).ToList();
|
|
|
|
|
|
|
|
|
|
}
|
2024-12-06 16:32:13 +08:00
|
|
|
|
rst.Flag = true;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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 = "液晶" },
|
|
|
|
|
};
|
2024-10-18 18:41:02 +08:00
|
|
|
|
|
2024-11-26 13:45:28 +08:00
|
|
|
|
// 模拟插入插件数据
|
|
|
|
|
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 = "全部通过";
|
2024-10-18 18:41:02 +08:00
|
|
|
|
}
|
2024-11-26 13:45:28 +08:00
|
|
|
|
|
|
|
|
|
// 模拟插入数据库
|
|
|
|
|
_boardCardInfoRepository.Insert(boardCardInfo);
|
2024-10-18 18:41:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2024-11-26 13:45:28 +08:00
|
|
|
|
rst.Flag = true;
|
2024-10-18 18:41:02 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
return rst;
|
|
|
|
|
}
|
2024-11-26 13:45:28 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新版本信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[ShowApi]
|
|
|
|
|
[AbpAllowAnonymous]
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public RequestEasyResult ModifyBoardInfoList(ProtectionDeviceVersionInfo input)
|
|
|
|
|
{
|
|
|
|
|
RequestEasyResult rst = new RequestEasyResult();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var boards = _boardCardInfoRepository.GetAll().ToList();
|
2024-12-10 11:25:08 +08:00
|
|
|
|
var devices = _protectionDeviceInfoRepository.GetAll().Where(t => t.DeviceAddress == input.DeviceAddr).ToList();
|
2024-11-26 13:45:28 +08:00
|
|
|
|
var protectionDeviceTypes = _protectionDeviceTypeRepository.GetAll().ToList();
|
2024-12-10 11:25:08 +08:00
|
|
|
|
if (devices.Count > 0)
|
2024-11-26 13:45:28 +08:00
|
|
|
|
{
|
|
|
|
|
var device = devices[0];
|
2024-12-10 11:25:08 +08:00
|
|
|
|
device.ProtectionDeviceTypeId = protectionDeviceTypes.FirstOrDefault(t => t.Model == input.DeviceType)?.Id;
|
|
|
|
|
|
|
|
|
|
var deviceBoards = boards.Where(t => t.ProtectionDeviceInfoId == device.Id).ToList();
|
|
|
|
|
|
|
|
|
|
// 记录历史数据的方法
|
|
|
|
|
void RecordBoardCardHistory(BoardCardInfo oldCardInfo, BoardCardInfo newCardInfo, string boardId)
|
|
|
|
|
{
|
|
|
|
|
if (oldCardInfo != null && newCardInfo != null)
|
|
|
|
|
{
|
|
|
|
|
var eventDescription = new StringBuilder();
|
|
|
|
|
var eventRecordType = EventRecordTypeEnum.Software; // 默认修改事件类型
|
|
|
|
|
// 比较各个字段,如果不一致则记录
|
|
|
|
|
if (oldCardInfo.FpgaVersion != newCardInfo.FpgaVersion)
|
|
|
|
|
eventDescription.AppendLine($"FPGA版本更改: {oldCardInfo.FpgaVersion} -> {newCardInfo.FpgaVersion}");
|
|
|
|
|
if (oldCardInfo.InterfaceDatabaseVersion != newCardInfo.InterfaceDatabaseVersion)
|
|
|
|
|
eventDescription.AppendLine($"接口数据库版本更改: {oldCardInfo.InterfaceDatabaseVersion} -> {newCardInfo.InterfaceDatabaseVersion}");
|
|
|
|
|
if (oldCardInfo.InterfaceVersion != newCardInfo.InterfaceVersion)
|
|
|
|
|
eventDescription.AppendLine($"接口版本更改: {oldCardInfo.InterfaceVersion} -> {newCardInfo.InterfaceVersion}");
|
|
|
|
|
if (oldCardInfo.InterfaceChecksum != newCardInfo.InterfaceChecksum)
|
|
|
|
|
eventDescription.AppendLine($"接口校验和更改: {oldCardInfo.InterfaceChecksum} -> {newCardInfo.InterfaceChecksum}");
|
|
|
|
|
if (oldCardInfo.SystemVersion != newCardInfo.SystemVersion)
|
|
|
|
|
eventDescription.AppendLine($"系统版本更改: {oldCardInfo.SystemVersion} -> {newCardInfo.SystemVersion}");
|
|
|
|
|
if (oldCardInfo.ProtectionChecksum != newCardInfo.ProtectionChecksum)
|
|
|
|
|
eventDescription.AppendLine($"保护校验和更改: {oldCardInfo.ProtectionChecksum} -> {newCardInfo.ProtectionChecksum}");
|
|
|
|
|
if (oldCardInfo.ProtectionDatabaseVersion != newCardInfo.ProtectionDatabaseVersion)
|
|
|
|
|
eventDescription.AppendLine($"保护数据库版本更改: {oldCardInfo.ProtectionDatabaseVersion} -> {newCardInfo.ProtectionDatabaseVersion}");
|
|
|
|
|
if (oldCardInfo.ProtectionVersion != newCardInfo.ProtectionVersion)
|
|
|
|
|
eventDescription.AppendLine($"保护版本更改: {oldCardInfo.ProtectionVersion} -> {newCardInfo.ProtectionVersion}");
|
|
|
|
|
if (oldCardInfo.YjVersion != newCardInfo.YjVersion)
|
|
|
|
|
eventDescription.AppendLine($"液晶版本更改: {oldCardInfo.YjVersion} -> {newCardInfo.YjVersion}");
|
|
|
|
|
if (oldCardInfo.YjCrc != newCardInfo.YjCrc)
|
|
|
|
|
eventDescription.AppendLine($"液晶CRC更改: {oldCardInfo.YjCrc} -> {newCardInfo.YjCrc}");
|
|
|
|
|
|
|
|
|
|
if (eventDescription.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
var json = JsonConvert.SerializeObject(oldCardInfo);
|
|
|
|
|
var newJson = JsonConvert.SerializeObject(newCardInfo);
|
|
|
|
|
|
|
|
|
|
// 创建历史记录
|
|
|
|
|
var historyRecord = new BoardCardHistory
|
|
|
|
|
{
|
|
|
|
|
ProtectionDeviceInfoId = device.Id,
|
|
|
|
|
BoardCardInfoId = oldCardInfo.Id,
|
|
|
|
|
BoardId = boardId,
|
|
|
|
|
RecodeDate = DateTime.Now,
|
|
|
|
|
ContentJson = json,
|
|
|
|
|
ContentNewJson = newJson,
|
|
|
|
|
EventDescription = eventDescription.ToString(),
|
|
|
|
|
EventRecordType = eventRecordType,
|
|
|
|
|
SeqNo = deviceBoards.Count > 0 ? deviceBoards.Max(t => t.SeqNo) + 1 : 1,
|
|
|
|
|
IsSend = false // 默认为未发送,您可以根据需要调整
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 记录历史
|
|
|
|
|
_boardCardHistoryRepository.Insert(historyRecord);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 保护板卡
|
2024-11-26 13:45:28 +08:00
|
|
|
|
BoardCardInfo cpuCardInfo = deviceBoards.FirstOrDefault(t => t.BoardId == "B01");
|
2024-12-10 11:25:08 +08:00
|
|
|
|
if (cpuCardInfo != null)
|
2024-11-26 13:45:28 +08:00
|
|
|
|
{
|
2024-12-10 11:25:08 +08:00
|
|
|
|
var newCpuCardInfo = new BoardCardInfo
|
|
|
|
|
{
|
|
|
|
|
FpgaVersion = input.FpgaVer,
|
|
|
|
|
InterfaceDatabaseVersion = input.CommcpuCfgVer,
|
|
|
|
|
InterfaceVersion = input.CommcpuVer,
|
|
|
|
|
InterfaceChecksum = input.CommcpuCrc,
|
|
|
|
|
SystemVersion = input.LinuxVer,
|
|
|
|
|
ProtectionChecksum = input.ProtectCrc,
|
|
|
|
|
ProtectionDatabaseVersion = input.ProtectCfgVer,
|
|
|
|
|
ProtectionVersion = input.ProtectVer
|
|
|
|
|
};
|
2024-10-18 18:41:02 +08:00
|
|
|
|
|
2024-12-10 11:25:08 +08:00
|
|
|
|
RecordBoardCardHistory(cpuCardInfo, newCpuCardInfo, "B01");
|
|
|
|
|
}
|
2024-11-26 13:45:28 +08:00
|
|
|
|
|
2024-12-10 11:25:08 +08:00
|
|
|
|
// 液晶板卡
|
|
|
|
|
BoardCardInfo ioyjCardInfo = deviceBoards.FirstOrDefault(t => t.BoardId == "液晶");
|
|
|
|
|
if (ioyjCardInfo != null)
|
|
|
|
|
{
|
|
|
|
|
var newIoyjCardInfo = new BoardCardInfo
|
|
|
|
|
{
|
|
|
|
|
YjVersion = input.YjVer,
|
|
|
|
|
YjCrc = input.YjCrc
|
|
|
|
|
};
|
2024-11-26 13:45:28 +08:00
|
|
|
|
|
2024-12-10 11:25:08 +08:00
|
|
|
|
RecordBoardCardHistory(ioyjCardInfo, newIoyjCardInfo, "液晶");
|
|
|
|
|
}
|
2024-11-26 13:45:28 +08:00
|
|
|
|
|
2024-12-10 11:25:08 +08:00
|
|
|
|
// IO板卡
|
|
|
|
|
if (input.IoVersion.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var boardIdMap = new Dictionary<string, int>
|
|
|
|
|
{
|
|
|
|
|
{ "B03", 0 },
|
|
|
|
|
{ "B04", 1 },
|
|
|
|
|
{ "B05", 2 },
|
|
|
|
|
{ "B06", 3 },
|
|
|
|
|
{ "B07", 4 }
|
|
|
|
|
};
|
2024-11-26 13:45:28 +08:00
|
|
|
|
|
2024-12-10 11:25:08 +08:00
|
|
|
|
foreach (var boardId in boardIdMap.Keys)
|
|
|
|
|
{
|
|
|
|
|
var boardCardInfo = deviceBoards.FirstOrDefault(t => t.BoardId == boardId);
|
|
|
|
|
if (boardCardInfo != null)
|
|
|
|
|
{
|
|
|
|
|
var ioVersion = input.IoVersion[boardIdMap[boardId]];
|
|
|
|
|
var newIoCardInfo = new BoardCardInfo
|
|
|
|
|
{
|
|
|
|
|
IOVersion = ioVersion.IoVer,
|
|
|
|
|
IOCrc = ioVersion.IoCrc
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
RecordBoardCardHistory(boardCardInfo, newIoCardInfo, boardId);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-26 13:45:28 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-10 11:25:08 +08:00
|
|
|
|
|
2024-11-26 13:45:28 +08:00
|
|
|
|
rst.Flag = true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2024-12-10 11:25:08 +08:00
|
|
|
|
rst.Message = ex.Message;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
}
|
2024-10-18 18:41:02 +08:00
|
|
|
|
/// <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
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|