diff --git a/odf-uniapp/manifest.json b/odf-uniapp/manifest.json index 9ea54b6..165584f 100644 --- a/odf-uniapp/manifest.json +++ b/odf-uniapp/manifest.json @@ -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" : { diff --git a/odf-uniapp/static/144.png b/odf-uniapp/static/144.png deleted file mode 100644 index 860d783..0000000 Binary files a/odf-uniapp/static/144.png and /dev/null differ diff --git a/odf-uniapp/static/192.png b/odf-uniapp/static/192.png deleted file mode 100644 index c8dc884..0000000 Binary files a/odf-uniapp/static/192.png and /dev/null differ diff --git a/odf-uniapp/static/72.png b/odf-uniapp/static/72.png deleted file mode 100644 index 91aab56..0000000 Binary files a/odf-uniapp/static/72.png and /dev/null differ diff --git a/odf-uniapp/static/96.png b/odf-uniapp/static/96.png deleted file mode 100644 index b45ea07..0000000 Binary files a/odf-uniapp/static/96.png and /dev/null differ diff --git a/odf-uniapp/static/logo.png b/odf-uniapp/static/logo.png index 8e4c2c6..3c800f9 100644 Binary files a/odf-uniapp/static/logo.png and b/odf-uniapp/static/logo.png differ diff --git a/odf-uniapp/unpackage/res/icons/1024x1024.png b/odf-uniapp/unpackage/res/icons/1024x1024.png new file mode 100644 index 0000000..a719e86 Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/1024x1024.png differ diff --git a/odf-uniapp/unpackage/res/icons/120x120.png b/odf-uniapp/unpackage/res/icons/120x120.png new file mode 100644 index 0000000..777b266 Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/120x120.png differ diff --git a/odf-uniapp/unpackage/res/icons/144x144.png b/odf-uniapp/unpackage/res/icons/144x144.png new file mode 100644 index 0000000..f05a3fd Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/144x144.png differ diff --git a/odf-uniapp/unpackage/res/icons/152x152.png b/odf-uniapp/unpackage/res/icons/152x152.png new file mode 100644 index 0000000..24b7007 Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/152x152.png differ diff --git a/odf-uniapp/unpackage/res/icons/167x167.png b/odf-uniapp/unpackage/res/icons/167x167.png new file mode 100644 index 0000000..974c4b7 Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/167x167.png differ diff --git a/odf-uniapp/unpackage/res/icons/180x180.png b/odf-uniapp/unpackage/res/icons/180x180.png new file mode 100644 index 0000000..40e418e Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/180x180.png differ diff --git a/odf-uniapp/unpackage/res/icons/192x192.png b/odf-uniapp/unpackage/res/icons/192x192.png new file mode 100644 index 0000000..b72803c Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/192x192.png differ diff --git a/odf-uniapp/unpackage/res/icons/20x20.png b/odf-uniapp/unpackage/res/icons/20x20.png new file mode 100644 index 0000000..658eb07 Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/20x20.png differ diff --git a/odf-uniapp/unpackage/res/icons/29x29.png b/odf-uniapp/unpackage/res/icons/29x29.png new file mode 100644 index 0000000..ed159b1 Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/29x29.png differ diff --git a/odf-uniapp/unpackage/res/icons/40x40.png b/odf-uniapp/unpackage/res/icons/40x40.png new file mode 100644 index 0000000..299c9c4 Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/40x40.png differ diff --git a/odf-uniapp/unpackage/res/icons/58x58.png b/odf-uniapp/unpackage/res/icons/58x58.png new file mode 100644 index 0000000..0dc3ea7 Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/58x58.png differ diff --git a/odf-uniapp/unpackage/res/icons/60x60.png b/odf-uniapp/unpackage/res/icons/60x60.png new file mode 100644 index 0000000..bb17544 Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/60x60.png differ diff --git a/odf-uniapp/unpackage/res/icons/72x72.png b/odf-uniapp/unpackage/res/icons/72x72.png new file mode 100644 index 0000000..78739d1 Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/72x72.png differ diff --git a/odf-uniapp/unpackage/res/icons/76x76.png b/odf-uniapp/unpackage/res/icons/76x76.png new file mode 100644 index 0000000..44207e4 Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/76x76.png differ diff --git a/odf-uniapp/unpackage/res/icons/80x80.png b/odf-uniapp/unpackage/res/icons/80x80.png new file mode 100644 index 0000000..d01ed22 Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/80x80.png differ diff --git a/odf-uniapp/unpackage/res/icons/87x87.png b/odf-uniapp/unpackage/res/icons/87x87.png new file mode 100644 index 0000000..ef6c6ad Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/87x87.png differ diff --git a/odf-uniapp/unpackage/res/icons/96x96.png b/odf-uniapp/unpackage/res/icons/96x96.png new file mode 100644 index 0000000..c64495f Binary files /dev/null and b/odf-uniapp/unpackage/res/icons/96x96.png differ diff --git a/server/ZR.Admin.WebApi/Controllers/Business/OdfCableFaultsController.cs b/server/ZR.Admin.WebApi/Controllers/Business/OdfCableFaultsController.cs index a2c08cf..5842229 100644 --- a/server/ZR.Admin.WebApi/Controllers/Business/OdfCableFaultsController.cs +++ b/server/ZR.Admin.WebApi/Controllers/Business/OdfCableFaultsController.cs @@ -88,7 +88,77 @@ namespace ZR.Admin.WebApi.Controllers.Business { return ToResponse(ResultCode.FAIL, "没有要导出的数据"); } - var result = ExportExcelMini(list.Result, "故障列表", "故障列表"); + + // 将英文属性名转换为中文列头 + var exportList = new List>(); + 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 + { + ["编号"] = 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); + } + + /// + /// 批量导入故障 + /// + [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 list = new(); + using (var stream = formFile.OpenReadStream()) + { + list = stream.Query(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); + } + + /// + /// 干线故障导入模板下载 + /// + [HttpGet("importTemplate")] + [Log(Title = "干线故障模板", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)] + [AllowAnonymous] + public IActionResult ImportTemplateExcel() + { + var result = DownloadImportTemplate(new List() { }, "OdfCableFaults"); return ExportExcel(result.Item2, result.Item1); } } diff --git a/server/ZR.Admin.WebApi/Controllers/Business/OdfPortsController.cs b/server/ZR.Admin.WebApi/Controllers/Business/OdfPortsController.cs index a221f6b..17b4792 100644 --- a/server/ZR.Admin.WebApi/Controllers/Business/OdfPortsController.cs +++ b/server/ZR.Admin.WebApi/Controllers/Business/OdfPortsController.cs @@ -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; } diff --git a/server/ZR.Model/Business/Dto/OdfCableFaultsDto.cs b/server/ZR.Model/Business/Dto/OdfCableFaultsDto.cs index 5747daa..f85f421 100644 --- a/server/ZR.Model/Business/Dto/OdfCableFaultsDto.cs +++ b/server/ZR.Model/Business/Dto/OdfCableFaultsDto.cs @@ -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; } } + + /// + /// 干线故障导入对象(列头与导出一致) + /// + 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; } + } } diff --git a/server/ZR.Service/Business/IBusinessService/IOdfCableFaultsService.cs b/server/ZR.Service/Business/IBusinessService/IOdfCableFaultsService.cs index ea1bf3e..c6ee2cf 100644 --- a/server/ZR.Service/Business/IBusinessService/IOdfCableFaultsService.cs +++ b/server/ZR.Service/Business/IBusinessService/IOdfCableFaultsService.cs @@ -33,5 +33,10 @@ namespace ZR.Service.Business.IBusinessService /// 导出故障列表 /// PagedInfo ExportList(OdfCableFaultsQueryDto parm); + + /// + /// 批量导入故障 + /// + (int successCount, int errorCount, string errorMsg) ImportFaults(List list); } } diff --git a/server/ZR.Service/Business/OdfCableFaultsService.cs b/server/ZR.Service/Business/OdfCableFaultsService.cs index d6d4447..4af9195 100644 --- a/server/ZR.Service/Business/OdfCableFaultsService.cs +++ b/server/ZR.Service/Business/OdfCableFaultsService.cs @@ -234,5 +234,70 @@ namespace ZR.Service.Business return predicate; } + + /// + /// 批量导入故障(导出的文件可直接导入) + /// + public (int successCount, int errorCount, string errorMsg) ImportFaults(List list) + { + int successCount = 0; + int errorCount = 0; + var errorMsgs = new List(); + + // 预查所有光缆,用于按名称匹配CableId + var cableNames = list.Where(x => !string.IsNullOrWhiteSpace(x.CableName)).Select(x => x.CableName.Trim()).Distinct().ToList(); + var cables = Context.Queryable().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); + } } } diff --git a/server/ZR.Vue/src/views/business/OdfCableFaults.vue b/server/ZR.Vue/src/views/business/OdfCableFaults.vue index 1021835..e0b8343 100644 --- a/server/ZR.Vue/src/views/business/OdfCableFaults.vue +++ b/server/ZR.Vue/src/views/business/OdfCableFaults.vue @@ -49,6 +49,21 @@ {{ $t('btn.export') }} + + + 导入 + + + @@ -125,6 +140,7 @@