12
This commit is contained in:
parent
33083bd06e
commit
073bffccfe
|
|
@ -510,22 +510,21 @@ namespace ZR.Admin.WebApi.Controllers.Business
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 导出端口
|
/// 导出端口(与导入模板格式一致)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Log(Title = "导出端口数据", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
|
[Log(Title = "导出端口数据", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
|
||||||
[HttpGet("export")]
|
[HttpGet("export")]
|
||||||
[ActionPermissionFilter(Permission = "odfports:export")]
|
[ActionPermissionFilter(Permission = "odfports:export")]
|
||||||
|
|
||||||
public IActionResult Export([FromQuery] OdfPortsQueryDto parm)
|
public IActionResult Export([FromQuery] OdfPortsQueryDto parm)
|
||||||
{
|
{
|
||||||
var list = _OdfPortsService.ExportList(parm).Result;
|
var list = _OdfPortsService.ExportListForImport(parm).Result;
|
||||||
if (list == null || list.Count <= 0)
|
if (list == null || list.Count <= 0)
|
||||||
{
|
{
|
||||||
return ToResponse(ResultCode.FAIL, "没有要导出的数据");
|
return ToResponse(ResultCode.FAIL, "没有要导出的数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = ExportExcelMini(list, "端口", "端口");
|
var result = ExportExcelMini(list, "端口数据", "端口数据");
|
||||||
return ExportExcel(result.Item2, result.Item1);
|
return ExportExcel(result.Item2, result.Item1);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -645,4 +645,78 @@ namespace ZR.Model.Business.Dto
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FaultReason { get; set; }
|
public string FaultReason { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 端口导出对象(与导入模板格式一致,导出后可直接导入)
|
||||||
|
/// </summary>
|
||||||
|
public class OdfPortsExportForImportDto
|
||||||
|
{
|
||||||
|
[ExcelColumn(Name = "机房名称", Width = 15)]
|
||||||
|
[ExcelColumnName("机房名称")]
|
||||||
|
public string RoomName { get; set; }
|
||||||
|
|
||||||
|
[ExcelColumn(Name = "机架名称", Width = 15)]
|
||||||
|
[ExcelColumnName("机架名称")]
|
||||||
|
public string RackName { get; set; }
|
||||||
|
|
||||||
|
[ExcelColumn(Name = "机框名称", Width = 15)]
|
||||||
|
[ExcelColumnName("机框名称")]
|
||||||
|
public string FrameName { get; set; }
|
||||||
|
|
||||||
|
[ExcelColumn(Name = "行号(1-6)", Width = 12)]
|
||||||
|
[ExcelColumnName("行号(1-6)")]
|
||||||
|
public int RowNumber { get; set; }
|
||||||
|
|
||||||
|
[ExcelColumn(Name = "端口号(1-12)", Width = 12)]
|
||||||
|
[ExcelColumnName("端口号(1-12)")]
|
||||||
|
public int PortNumber { get; set; }
|
||||||
|
|
||||||
|
[ExcelColumn(Name = "连接状态,0断开,1连接", Width = 20)]
|
||||||
|
[ExcelColumnName("连接状态,0断开,1连接")]
|
||||||
|
public int Status { get; set; }
|
||||||
|
|
||||||
|
[ExcelColumn(Name = "备注", Width = 30)]
|
||||||
|
[ExcelColumnName("备注")]
|
||||||
|
public string Remarks { get; set; }
|
||||||
|
|
||||||
|
[ExcelColumn(Name = "光衰值(dB)", Width = 12)]
|
||||||
|
[ExcelColumnName("光衰值(dB)")]
|
||||||
|
public string OpticalAttenuation { get; set; }
|
||||||
|
|
||||||
|
[ExcelColumn(Name = "历史故障记录", Width = 30)]
|
||||||
|
[ExcelColumnName("历史故障记录")]
|
||||||
|
public string HistoryRemarks { get; set; }
|
||||||
|
|
||||||
|
[ExcelColumn(Name = "部门名称", Width = 15)]
|
||||||
|
[ExcelColumnName("部门名称")]
|
||||||
|
public string DeptName { get; set; }
|
||||||
|
|
||||||
|
[ExcelColumn(Name = "光缆段信息", Width = 25)]
|
||||||
|
[ExcelColumnName("光缆段信息")]
|
||||||
|
public string OpticalCableOffRemarks { get; set; }
|
||||||
|
|
||||||
|
[ExcelColumn(Name = "设备型号", Width = 15)]
|
||||||
|
[ExcelColumnName("设备型号")]
|
||||||
|
public string EquipmentModel { get; set; }
|
||||||
|
|
||||||
|
[ExcelColumn(Name = "业务类型", Width = 15)]
|
||||||
|
[ExcelColumnName("业务类型")]
|
||||||
|
public string BusinessType { get; set; }
|
||||||
|
|
||||||
|
[ExcelColumn(Name = "业务名称", Width = 15)]
|
||||||
|
[ExcelColumnName("业务名称")]
|
||||||
|
public string YeWuMingCheng { get; set; }
|
||||||
|
|
||||||
|
[ExcelColumn(Name = "1号端口", Width = 12)]
|
||||||
|
[ExcelColumnName("1号端口")]
|
||||||
|
public string One { get; set; }
|
||||||
|
|
||||||
|
[ExcelColumn(Name = "2号端口", Width = 12)]
|
||||||
|
[ExcelColumnName("2号端口")]
|
||||||
|
public string Two { get; set; }
|
||||||
|
|
||||||
|
[ExcelColumn(Name = "3号端口", Width = 12)]
|
||||||
|
[ExcelColumnName("3号端口")]
|
||||||
|
public string Three { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -20,5 +20,10 @@ namespace ZR.Service.Business.IBusinessService
|
||||||
|
|
||||||
PagedInfo<OdfPortsfDto> ExportList(OdfPortsQueryDto parm);
|
PagedInfo<OdfPortsfDto> ExportList(OdfPortsQueryDto parm);
|
||||||
PagedInfo<OdfPortsfDto> ExportList(OdfPortsQuerysDto parm);
|
PagedInfo<OdfPortsfDto> ExportList(OdfPortsQuerysDto parm);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 导出端口(与导入模板格式一致)
|
||||||
|
/// </summary>
|
||||||
|
PagedInfo<OdfPortsExportForImportDto> ExportListForImport(OdfPortsQueryDto parm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,103 @@ namespace ZR.Service.Business
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 导出端口(与导入模板格式一致,导出后可直接导入)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public PagedInfo<OdfPortsExportForImportDto> ExportListForImport(OdfPortsQueryDto parm)
|
||||||
|
{
|
||||||
|
parm.PageNum = 1;
|
||||||
|
parm.PageSize = 10000000;
|
||||||
|
parm.Sort = string.Empty; // 清除排序,避免字段不存在报错
|
||||||
|
var predicate = QueryExp(parm);
|
||||||
|
|
||||||
|
var response = Queryable()
|
||||||
|
.Where(predicate.ToExpression())
|
||||||
|
.OrderBy("RoomId asc,RackId asc,FrameId asc,RowNumber asc,PortNumber Asc")
|
||||||
|
.Select((it) => new OdfPortsExportForImportDto()
|
||||||
|
{
|
||||||
|
RoomName = it.RoomName,
|
||||||
|
RackName = it.RackName,
|
||||||
|
FrameName = it.FrameName,
|
||||||
|
RowNumber = it.RowNumber,
|
||||||
|
PortNumber = it.PortNumber,
|
||||||
|
Status = it.Status,
|
||||||
|
Remarks = it.Remarks,
|
||||||
|
OpticalAttenuation = it.OpticalAttenuation,
|
||||||
|
HistoryRemarks = it.HistoryRemarks,
|
||||||
|
DeptName = it.DeptName,
|
||||||
|
OpticalCableOffRemarks = it.OpticalCableOffRemarks,
|
||||||
|
EquipmentModel = it.EquipmentModel,
|
||||||
|
BusinessType = it.BusinessType
|
||||||
|
})
|
||||||
|
.ToPage(parm);
|
||||||
|
|
||||||
|
// 反向解析 Remarks 字段,拆分出 业务名称、1号端口、2号端口、3号端口
|
||||||
|
foreach (var item in response.Result)
|
||||||
|
{
|
||||||
|
ParseRemarksToFields(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 反向解析 Remarks 字段
|
||||||
|
/// 格式:{业务名称} {设备型号} {业务类型} {1号端口}/{2号端口}/{3号端口}
|
||||||
|
/// </summary>
|
||||||
|
private void ParseRemarksToFields(OdfPortsExportForImportDto item)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(item.Remarks))
|
||||||
|
{
|
||||||
|
item.YeWuMingCheng = "";
|
||||||
|
item.One = "";
|
||||||
|
item.Two = "";
|
||||||
|
item.Three = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var remarks = item.Remarks.Trim();
|
||||||
|
|
||||||
|
// 尝试按空格分割
|
||||||
|
var parts = remarks.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
if (parts.Length >= 1)
|
||||||
|
{
|
||||||
|
item.YeWuMingCheng = parts[0]; // 第一部分是业务名称
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查找最后一个包含 "/" 的部分,那是端口信息
|
||||||
|
var lastPart = parts.Length > 0 ? parts[parts.Length - 1] : "";
|
||||||
|
if (lastPart.Contains("/"))
|
||||||
|
{
|
||||||
|
var portParts = lastPart.Split('/');
|
||||||
|
item.One = portParts.Length > 0 ? portParts[0] : "";
|
||||||
|
item.Two = portParts.Length > 1 ? portParts[1] : "";
|
||||||
|
item.Three = portParts.Length > 2 ? portParts[2] : "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.YeWuMingCheng = "";
|
||||||
|
item.One = "";
|
||||||
|
item.Two = "";
|
||||||
|
item.Three = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// 解析失败,设为空
|
||||||
|
item.YeWuMingCheng = "";
|
||||||
|
item.One = "";
|
||||||
|
item.Two = "";
|
||||||
|
item.Three = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询导出表达式
|
/// 查询导出表达式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user