设置图片
|
|
@ -66,10 +66,34 @@
|
|||
},
|
||||
"icons" : {
|
||||
"android" : {
|
||||
"hdpi" : "static/72.png",
|
||||
"xhdpi" : "static/96.png",
|
||||
"xxhdpi" : "static/144.png",
|
||||
"xxxhdpi" : "static/192.png"
|
||||
"hdpi" : "unpackage/res/icons/72x72.png",
|
||||
"xhdpi" : "unpackage/res/icons/96x96.png",
|
||||
"xxhdpi" : "unpackage/res/icons/144x144.png",
|
||||
"xxxhdpi" : "unpackage/res/icons/192x192.png"
|
||||
},
|
||||
"ios" : {
|
||||
"appstore" : "unpackage/res/icons/1024x1024.png",
|
||||
"ipad" : {
|
||||
"app" : "unpackage/res/icons/76x76.png",
|
||||
"app@2x" : "unpackage/res/icons/152x152.png",
|
||||
"notification" : "unpackage/res/icons/20x20.png",
|
||||
"notification@2x" : "unpackage/res/icons/40x40.png",
|
||||
"proapp@2x" : "unpackage/res/icons/167x167.png",
|
||||
"settings" : "unpackage/res/icons/29x29.png",
|
||||
"settings@2x" : "unpackage/res/icons/58x58.png",
|
||||
"spotlight" : "unpackage/res/icons/40x40.png",
|
||||
"spotlight@2x" : "unpackage/res/icons/80x80.png"
|
||||
},
|
||||
"iphone" : {
|
||||
"app@2x" : "unpackage/res/icons/120x120.png",
|
||||
"app@3x" : "unpackage/res/icons/180x180.png",
|
||||
"notification@2x" : "unpackage/res/icons/40x40.png",
|
||||
"notification@3x" : "unpackage/res/icons/60x60.png",
|
||||
"settings@2x" : "unpackage/res/icons/58x58.png",
|
||||
"settings@3x" : "unpackage/res/icons/87x87.png",
|
||||
"spotlight@2x" : "unpackage/res/icons/80x80.png",
|
||||
"spotlight@3x" : "unpackage/res/icons/120x120.png"
|
||||
}
|
||||
}
|
||||
},
|
||||
"splashscreen" : {
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 262 KiB After Width: | Height: | Size: 1.2 MiB |
BIN
odf-uniapp/unpackage/res/icons/1024x1024.png
Normal file
|
After Width: | Height: | Size: 404 KiB |
BIN
odf-uniapp/unpackage/res/icons/120x120.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
odf-uniapp/unpackage/res/icons/144x144.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
odf-uniapp/unpackage/res/icons/152x152.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
odf-uniapp/unpackage/res/icons/167x167.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
odf-uniapp/unpackage/res/icons/180x180.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
odf-uniapp/unpackage/res/icons/192x192.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
odf-uniapp/unpackage/res/icons/20x20.png
Normal file
|
After Width: | Height: | Size: 951 B |
BIN
odf-uniapp/unpackage/res/icons/29x29.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
odf-uniapp/unpackage/res/icons/40x40.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
odf-uniapp/unpackage/res/icons/58x58.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
odf-uniapp/unpackage/res/icons/60x60.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
odf-uniapp/unpackage/res/icons/72x72.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
odf-uniapp/unpackage/res/icons/76x76.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
odf-uniapp/unpackage/res/icons/80x80.png
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
BIN
odf-uniapp/unpackage/res/icons/87x87.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
odf-uniapp/unpackage/res/icons/96x96.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
|
|
@ -88,7 +88,77 @@ namespace ZR.Admin.WebApi.Controllers.Business
|
|||
{
|
||||
return ToResponse(ResultCode.FAIL, "没有要导出的数据");
|
||||
}
|
||||
var result = ExportExcelMini(list.Result, "故障列表", "故障列表");
|
||||
|
||||
// 将英文属性名转换为中文列头
|
||||
var exportList = new List<Dictionary<string, object>>();
|
||||
foreach (var item in list.Result)
|
||||
{
|
||||
var props = item.GetType().GetProperties();
|
||||
var dict = props.ToDictionary(p => p.Name, p => p.GetValue(item));
|
||||
var row = new Dictionary<string, object>
|
||||
{
|
||||
["编号"] = dict.GetValueOrDefault("Id"),
|
||||
["光缆编号"] = dict.GetValueOrDefault("CableId"),
|
||||
["故障时间"] = dict.GetValueOrDefault("FaultTime"),
|
||||
["人员"] = dict.GetValueOrDefault("Personnel"),
|
||||
["故障原因"] = dict.GetValueOrDefault("FaultReason"),
|
||||
["表显故障里程"] = dict.GetValueOrDefault("Mileage"),
|
||||
["地点"] = dict.GetValueOrDefault("Location"),
|
||||
["纬度"] = dict.GetValueOrDefault("Latitude"),
|
||||
["经度"] = dict.GetValueOrDefault("Longitude"),
|
||||
["备注"] = dict.GetValueOrDefault("Remark"),
|
||||
["创建时间"] = dict.GetValueOrDefault("CreatedAt"),
|
||||
["所属光缆"] = dict.GetValueOrDefault("CableName")
|
||||
};
|
||||
exportList.Add(row);
|
||||
}
|
||||
|
||||
var result = ExportExcelMini(exportList, "故障列表", "故障列表");
|
||||
return ExportExcel(result.Item2, result.Item1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量导入故障
|
||||
/// </summary>
|
||||
[HttpPost("importData")]
|
||||
[Log(Title = "干线故障导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false)]
|
||||
[ActionPermissionFilter(Permission = "odfcablefaults:import")]
|
||||
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
|
||||
{
|
||||
if (formFile == null || formFile.Length <= 0)
|
||||
{
|
||||
return ToResponse(ResultCode.FAIL, "请选择要导入的文件");
|
||||
}
|
||||
|
||||
List<OdfCableFaultImportDto> list = new();
|
||||
using (var stream = formFile.OpenReadStream())
|
||||
{
|
||||
list = stream.Query<OdfCableFaultImportDto>(startCell: "A1").ToList();
|
||||
}
|
||||
|
||||
if (list.Count <= 0)
|
||||
{
|
||||
return ToResponse(ResultCode.FAIL, "导入数据为空");
|
||||
}
|
||||
|
||||
var (successCount, errorCount, errorMsg) = _OdfCableFaultsService.ImportFaults(list);
|
||||
var msg = $"导入成功{successCount}条,失败{errorCount}条";
|
||||
if (!string.IsNullOrEmpty(errorMsg))
|
||||
{
|
||||
msg += $"。{errorMsg}";
|
||||
}
|
||||
return SUCCESS(msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 干线故障导入模板下载
|
||||
/// </summary>
|
||||
[HttpGet("importTemplate")]
|
||||
[Log(Title = "干线故障模板", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
|
||||
[AllowAnonymous]
|
||||
public IActionResult ImportTemplateExcel()
|
||||
{
|
||||
var result = DownloadImportTemplate(new List<OdfCableFaultImportDto>() { }, "OdfCableFaults");
|
||||
return ExportExcel(result.Item2, result.Item1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ namespace ZR.Admin.WebApi.Controllers.Business
|
|||
return new OdfPortsMDto { Id = it.Id, Name = it.Name, Status = it.Status, Tips = tips };
|
||||
}).ToList();
|
||||
|
||||
row.Add(new OdfPortsMDtot() { RowList = li, Name = (g.Key + 1).ToString() });
|
||||
row.Add(new OdfPortsMDtot() { RowList = li, Name = g.Key.ToString() });
|
||||
});
|
||||
item.OdfPortsList = row;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using MiniExcelLibs.Attributes;
|
||||
|
||||
namespace ZR.Model.Business.Dto
|
||||
{
|
||||
|
|
@ -49,4 +50,46 @@ namespace ZR.Model.Business.Dto
|
|||
|
||||
public IFormFile[] Images { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 干线故障导入对象(列头与导出一致)
|
||||
/// </summary>
|
||||
public class OdfCableFaultImportDto
|
||||
{
|
||||
[ExcelColumnName("编号")]
|
||||
public int? Id { get; set; }
|
||||
|
||||
[ExcelColumnName("光缆编号")]
|
||||
public int? CableId { get; set; }
|
||||
|
||||
[ExcelColumnName("故障时间")]
|
||||
public DateTime? FaultTime { get; set; }
|
||||
|
||||
[ExcelColumnName("人员")]
|
||||
public string Personnel { get; set; }
|
||||
|
||||
[ExcelColumnName("故障原因")]
|
||||
public string FaultReason { get; set; }
|
||||
|
||||
[ExcelColumnName("表显故障里程")]
|
||||
public string Mileage { get; set; }
|
||||
|
||||
[ExcelColumnName("地点")]
|
||||
public string Location { get; set; }
|
||||
|
||||
[ExcelColumnName("纬度")]
|
||||
public decimal? Latitude { get; set; }
|
||||
|
||||
[ExcelColumnName("经度")]
|
||||
public decimal? Longitude { get; set; }
|
||||
|
||||
[ExcelColumnName("备注")]
|
||||
public string Remark { get; set; }
|
||||
|
||||
[ExcelColumnName("创建时间")]
|
||||
public DateTime? CreatedAt { get; set; }
|
||||
|
||||
[ExcelColumnName("所属光缆")]
|
||||
public string CableName { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,5 +33,10 @@ namespace ZR.Service.Business.IBusinessService
|
|||
/// 导出故障列表
|
||||
/// </summary>
|
||||
PagedInfo<dynamic> ExportList(OdfCableFaultsQueryDto parm);
|
||||
|
||||
/// <summary>
|
||||
/// 批量导入故障
|
||||
/// </summary>
|
||||
(int successCount, int errorCount, string errorMsg) ImportFaults(List<OdfCableFaultImportDto> list);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -234,5 +234,70 @@ namespace ZR.Service.Business
|
|||
|
||||
return predicate;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量导入故障(导出的文件可直接导入)
|
||||
/// </summary>
|
||||
public (int successCount, int errorCount, string errorMsg) ImportFaults(List<OdfCableFaultImportDto> list)
|
||||
{
|
||||
int successCount = 0;
|
||||
int errorCount = 0;
|
||||
var errorMsgs = new List<string>();
|
||||
|
||||
// 预查所有光缆,用于按名称匹配CableId
|
||||
var cableNames = list.Where(x => !string.IsNullOrWhiteSpace(x.CableName)).Select(x => x.CableName.Trim()).Distinct().ToList();
|
||||
var cables = Context.Queryable<OdfCables>().Where(c => cableNames.Contains(c.CableName)).ToList();
|
||||
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
var item = list[i];
|
||||
int rowNum = i + 2; // Excel行号(第1行是表头)
|
||||
try
|
||||
{
|
||||
// 确定CableId:优先用光缆编号,其次按所属光缆名称匹配
|
||||
int? cableId = item.CableId;
|
||||
if ((cableId == null || cableId == 0) && !string.IsNullOrWhiteSpace(item.CableName))
|
||||
{
|
||||
var cable = cables.Find(c => c.CableName == item.CableName.Trim());
|
||||
if (cable != null)
|
||||
{
|
||||
cableId = cable.Id;
|
||||
}
|
||||
}
|
||||
if (cableId == null || cableId == 0)
|
||||
{
|
||||
errorCount++;
|
||||
errorMsgs.Add($"第{rowNum}行:未找到匹配的光缆");
|
||||
continue;
|
||||
}
|
||||
|
||||
var model = new OdfCableFaults
|
||||
{
|
||||
CableId = cableId.Value,
|
||||
FaultTime = item.FaultTime ?? DateTime.Now,
|
||||
Personnel = item.Personnel,
|
||||
FaultReason = item.FaultReason,
|
||||
Mileage = item.Mileage,
|
||||
Location = item.Location,
|
||||
Latitude = item.Latitude ?? 0,
|
||||
Longitude = item.Longitude ?? 0,
|
||||
Remark = item.Remark,
|
||||
CreatedAt = DateTime.Now,
|
||||
UpdatedAt = DateTime.Now
|
||||
};
|
||||
|
||||
Insertable(model).ExecuteCommand();
|
||||
successCount++;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorCount++;
|
||||
errorMsgs.Add($"第{rowNum}行:导入失败");
|
||||
}
|
||||
}
|
||||
|
||||
string errorMsg = errorMsgs.Count > 0 ? string.Join(";", errorMsgs.Take(10)) : "";
|
||||
return (successCount, errorCount, errorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,21 @@
|
|||
{{ $t('btn.export') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-dropdown trigger="click" v-hasPermi="['odfcablefaults:import']">
|
||||
<el-button type="info" plain icon="Upload">导入</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="upload">
|
||||
<importData
|
||||
templateUrl="business/OdfCableFaults/importTemplate"
|
||||
importUrl="/business/OdfCableFaults/importData"
|
||||
@success="handleFileSuccess"></importData>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</el-col>
|
||||
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
|
||||
</el-row>
|
||||
|
|
@ -125,6 +140,7 @@
|
|||
<script setup name="odfcablefaults">
|
||||
import { listOdfCableFaults, getOdfCableFaults, delOdfCableFaults } from '@/api/business/odfcablefaults.js'
|
||||
import { listOdfCables } from '@/api/business/odfcables.js'
|
||||
import importData from '@/components/ImportData'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const ids = ref([])
|
||||
|
|
@ -297,5 +313,11 @@ function handleExport() {
|
|||
})
|
||||
}
|
||||
|
||||
// 导入成功回调
|
||||
function handleFileSuccess(response) {
|
||||
proxy.$modal.msgSuccess(response.msg || '导入成功')
|
||||
getList()
|
||||
}
|
||||
|
||||
handleQuery()
|
||||
</script>
|
||||
|
|
|
|||