From d2388576a997fa2b4bf7c4f6d58bdd64532fec4f Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Thu, 28 May 2026 16:27:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E7=AE=A1=E7=90=86=E5=BE=AE?= =?UTF-8?q?=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .../SocketContrastResponseService.java | 9 +-- .../service/impl/PreDetectionServiceImpl.java | 9 ++- .../gather/plan/service/AsyncPlanHandler.java | 17 ++--- .../plan/service/impl/AdPlanServiceImpl.java | 8 ++- .../service/impl/PqReportServiceImpl.java | 67 +++++++++---------- .../service/impl/PqScriptDtlsServiceImpl.java | 24 ++++--- entrance/src/main/resources/application.yml | 34 +++++----- .../njcn/gather/system/config/PathConfig.java | 50 ++++++++++++++ .../controller/ResourceManageController.java | 14 ++++ .../enums/ResourceManageResponseEnum.java | 3 +- .../pojo/param/ResourceManageParam.java | 12 ++++ .../service/IResourceManageService.java | 2 + .../impl/ResourceManageServiceImpl.java | 36 ++++++++-- 14 files changed, 200 insertions(+), 86 deletions(-) create mode 100644 system/src/main/java/com/njcn/gather/system/config/PathConfig.java diff --git a/.gitignore b/.gitignore index 4c12dd82..eb913770 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,4 @@ rebel.xml # 个人工作文档,不与团队共享 CLAUDE.md docs/ +data/ \ No newline at end of file diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketContrastResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketContrastResponseService.java index 2eb62eed..a4f52e96 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketContrastResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketContrastResponseService.java @@ -46,6 +46,7 @@ import com.njcn.gather.storage.pojo.po.ContrastNonHarmonicResult; import com.njcn.gather.storage.service.DetectionDataDealService; import com.njcn.gather.system.cfg.pojo.po.SysTestConfig; import com.njcn.gather.system.cfg.service.ISysTestConfigService; +import com.njcn.gather.system.config.PathConfig; import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum; import com.njcn.gather.system.dictionary.pojo.po.DictData; import com.njcn.gather.system.dictionary.pojo.po.DictTree; @@ -57,7 +58,6 @@ import com.njcn.gather.tools.comtrade.comparewave.service.ICompareWaveService; import com.njcn.gather.util.StorageUtil; import com.njcn.web.utils.ExcelUtil; import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.io.FileInputStream; @@ -127,8 +127,9 @@ public class SocketContrastResponseService { // private SysRegRes contrastRegRes = null; - @Value("${report.reportDir}") - private String alignDataFilePath; +// @Value("${report.reportDir}") +// private String alignDataFilePath; + private final PathConfig pathConfig; public static final Map> testItemCodeMap = new HashMap() {{ put("FREQ", Arrays.asList(DetectionCodeEnum.FREQ.getCode())); @@ -2314,7 +2315,7 @@ public class SocketContrastResponseService { }); }); - ExcelUtil.saveExcel(alignDataFilePath, "对齐数据.xlsx", sheetsList); + ExcelUtil.saveExcel(pathConfig.getDataPath(), "对齐数据.xlsx", sheetsList); } /** diff --git a/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java b/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java index 6758c483..a48a0681 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java @@ -41,6 +41,7 @@ import com.njcn.gather.script.service.IPqScriptDtlsService; import com.njcn.gather.source.pojo.po.SourceInitialize; import com.njcn.gather.source.service.IPqSourceService; import com.njcn.gather.system.cfg.service.ISysTestConfigService; +import com.njcn.gather.system.config.PathConfig; import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum; import com.njcn.gather.system.dictionary.service.IDictDataService; import com.njcn.web.utils.HttpServletUtil; @@ -53,6 +54,7 @@ import org.springframework.stereotype.Service; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; +import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -81,8 +83,9 @@ public class PreDetectionServiceImpl implements PreDetectionService { private final ISysTestConfigService sysTestConfigService; - @Value("${report.reportDir}") - private String alignDataFilePath; +// @Value("${report.reportDir}") +// private String alignDataFilePath; + private final PathConfig pathConfig; @Override @@ -353,7 +356,7 @@ public class PreDetectionServiceImpl implements PreDetectionService { response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); response.setContentType("application/octet-stream;charset=UTF-8"); try { - InputStream inputStream = new FileInputStream(alignDataFilePath + "\\" + fileName); + InputStream inputStream = new FileInputStream(pathConfig.getDataPath() + File.separator + fileName); byte[] buffer = new byte[1024]; int len = 0; ServletOutputStream outputStream = response.getOutputStream(); diff --git a/detection/src/main/java/com/njcn/gather/plan/service/AsyncPlanHandler.java b/detection/src/main/java/com/njcn/gather/plan/service/AsyncPlanHandler.java index cdf67c5c..fb8b7c8c 100644 --- a/detection/src/main/java/com/njcn/gather/plan/service/AsyncPlanHandler.java +++ b/detection/src/main/java/com/njcn/gather/plan/service/AsyncPlanHandler.java @@ -23,6 +23,7 @@ import com.njcn.gather.monitor.service.IPqMonitorService; import com.njcn.gather.plan.pojo.po.AdPlan; import com.njcn.gather.plan.pojo.vo.AdPlanCheckDataVO; import com.njcn.gather.plan.service.util.BatchFileReader; +import com.njcn.gather.system.config.PathConfig; import com.njcn.gather.system.config.handler.NonWebAutoFillValueHandler; import com.njcn.gather.tools.report.model.constant.ReportConstant; import com.njcn.gather.type.pojo.po.DevType; @@ -64,11 +65,11 @@ public class AsyncPlanHandler { private final JdbcTemplate jdbcTemplate; - - @Value("${report.reportDir}") - private String reportPath; - @Value("${data.homeDir}") - private String dataPath; + private final PathConfig pathConfig; +// @Value("${report.reportDir}") +// private String reportPath; +// @Value("${data.homeDir}") +// private String dataPath; private static final int BATCH_SIZE = 10000; private static final int FINAL_STEP = 85; @@ -199,13 +200,13 @@ public class AsyncPlanHandler { // 创建 ZIP 文件 String zipFileName = plan.getName() + "_检测数据包.zip"; - File zipFile = FileUtil.file(dataPath + File.separator + TEST_DATA_DIR + File.separator, zipFileName); + File zipFile = FileUtil.file(pathConfig.getDataPath() + File.separator + TEST_DATA_DIR + File.separator, zipFileName); // 添加检测报告文件 if (ObjectUtil.isNotNull(report) && report.equals(1)) { for (PqDev dev : devList) { DevType devType = devTypeService.getById(dev.getDevType()); - String dirPath = reportPath.concat(File.separator).concat(devType.getName()); + String dirPath = pathConfig.getReportPath().concat(File.separator).concat(devType.getName()); File reportFile = new File(dirPath.concat(File.separator).concat(dev.getCreateId()).concat(ReportConstant.DOCX)); // 如果reportFile存在,则将reportFile中的文件添加到已有的zip文件中 if (FileUtil.exist(reportFile)) { @@ -344,7 +345,7 @@ public class AsyncPlanHandler { for (File docx : docxFiles) { for (PqDev dev : devList) { DevType devType = devTypeService.getById(dev.getDevType()); - String dirPath = reportPath.concat(File.separator).concat(devType.getName()); + String dirPath = pathConfig.getReportPath().concat(File.separator).concat(devType.getName()); File reportFile = new File(dirPath.concat(File.separator).concat(dev.getCreateId()).concat(ReportConstant.DOCX)); // 文件名匹配,复制到对应目录下 if (docx.getName().equals(reportFile.getName())) { diff --git a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java index d1b36972..8ea2d4da 100644 --- a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java @@ -77,6 +77,7 @@ import com.njcn.gather.storage.service.TableGenService; import com.njcn.gather.system.cfg.pojo.enums.SceneEnum; import com.njcn.gather.system.cfg.pojo.po.SysTestConfig; import com.njcn.gather.system.cfg.service.ISysTestConfigService; +import com.njcn.gather.system.config.PathConfig; import com.njcn.gather.system.dictionary.pojo.po.DictData; import com.njcn.gather.system.dictionary.pojo.po.DictTree; import com.njcn.gather.system.dictionary.pojo.po.DictType; @@ -154,8 +155,9 @@ public class AdPlanServiceImpl extends ServiceImpl impleme private final IPqDevCheckHistoryService pqDevCheckHistoryService; private final JdbcTemplate jdbcTemplate; - @Value("${report.reportDir}") - private String reportPath; +// @Value("${report.reportDir}") +// private String reportPath; + private final PathConfig pathConfig; @Override public List listAdPlan(AdPlanParam.QueryParam queryParam) { @@ -2333,7 +2335,7 @@ public class AdPlanServiceImpl extends ServiceImpl impleme if (ObjectUtil.isNotNull(report) && report.equals(1)) { for (PqDev dev : devList) { DevType devType = devTypeService.getById(dev.getDevType()); - String dirPath = reportPath.concat(File.separator).concat(devType.getName()); + String dirPath = pathConfig.getReportPath().concat(File.separator).concat(devType.getName()); File reportFile = new File(dirPath.concat(File.separator).concat(dev.getCreateId()).concat(ReportConstant.DOCX)); // 如果reportFile存在,则将reportFile中的文件添加到已有的zip文件中 if (FileUtil.exist(reportFile)) { diff --git a/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java b/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java index 89bac02a..d58532c3 100644 --- a/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java @@ -68,16 +68,13 @@ import com.njcn.gather.storage.service.SimAndDigHarmonicService; import com.njcn.gather.storage.service.SimAndDigNonHarmonicService; import com.njcn.gather.system.cfg.pojo.enums.SceneEnum; import com.njcn.gather.system.cfg.service.ISysTestConfigService; +import com.njcn.gather.system.config.PathConfig; import com.njcn.gather.system.dictionary.pojo.po.DictData; import com.njcn.gather.system.dictionary.service.IDictDataService; import com.njcn.gather.system.pojo.enums.SystemResponseEnum; import com.njcn.gather.tools.report.model.constant.ReportConstant; import com.njcn.gather.tools.report.service.IWordReportService; -import com.njcn.gather.tools.report.util.BookmarkUtil; -import com.njcn.gather.tools.report.util.Docx4jUtil; -import com.njcn.gather.tools.report.util.DocxMergeUtil; -import com.njcn.gather.tools.report.util.FilePathSanitizer; -import com.njcn.gather.tools.report.util.WordDocumentUtil; +import com.njcn.gather.tools.report.util.*; import com.njcn.gather.type.pojo.po.DevType; import com.njcn.gather.type.service.IDevTypeService; import com.njcn.gather.user.user.pojo.po.SysUser; @@ -145,13 +142,13 @@ public class PqReportServiceImpl extends ServiceImpl i */ private static final String RESULT_MAP_NO_DATA_FLAG = "__internal_no_data__"; - @Value("${report.template:D:\\template}") - private String templatePath; - - @Value("${report.reportDir:D:\\report}") - private String reportPath; - - + // @Value("${report.template:D:\\template}") +// private String templatePath; +// +// @Value("${report.reportDir:D:\\report}") +// private String reportPath; + private final PathConfig pathConfig; + @Value("${qr.cloud}") private String cloudUrl; @@ -328,7 +325,7 @@ public class PqReportServiceImpl extends ServiceImpl i MultipartFile baseFile = reportParam.getBaseFile(); MultipartFile detailFile = reportParam.getDetailFile(); String relativePath = reportParam.getName() + File.separator + reportParam.getVersion() + File.separator; - String newDir = templatePath + File.separator + relativePath; + String newDir = pathConfig.getReportTemplatePath() + File.separator + relativePath; long FILE_SIZE_LIMIT = 5 * 1024 * 1024; if (isAdd) { @@ -405,13 +402,13 @@ public class PqReportServiceImpl extends ServiceImpl i // 文件夹重命名 String oldBasePathStr = oldPqReport.getBasePath(); String baseName = oldBasePathStr.substring(oldBasePathStr.lastIndexOf(File.separator) + 1); - Path oldBasePath = Paths.get(templatePath + File.separator + oldBasePathStr); + Path oldBasePath = Paths.get(pathConfig.getReportTemplatePath() + File.separator + oldBasePathStr); Path newBasePath = Paths.get(newDir + baseName); pqReport.setBasePath(relativePath + baseName); String oldDetailPathStr = oldPqReport.getDetailPath(); String detailName = oldDetailPathStr.substring(oldDetailPathStr.lastIndexOf(File.separator) + 1); - Path oldDetailPath = Paths.get(templatePath + File.separator + oldDetailPathStr); + Path oldDetailPath = Paths.get(pathConfig.getReportTemplatePath() + File.separator + oldDetailPathStr); Path newDetailPath = Paths.get(newDir + detailName); pqReport.setDetailPath(relativePath + detailName); @@ -422,13 +419,13 @@ public class PqReportServiceImpl extends ServiceImpl i Files.move(oldBasePath, newBasePath); Files.move(oldDetailPath, newDetailPath); if (!oldPqReport.getName().equals(reportParam.getName()) && !this.existSameName(pqReport.getId(), oldPqReport.getName())) { - this.recursionDeleteDirectory(templatePath + File.separator + oldPqReport.getName()); + this.recursionDeleteDirectory(pathConfig.getReportTemplatePath() + File.separator + oldPqReport.getName()); } else { - Paths.get(templatePath + oldDir).toFile().delete(); + Paths.get(pathConfig.getReportTemplatePath() + oldDir).toFile().delete(); } } else { // 文件夹重命名 - Paths.get(templatePath + oldDir).toFile().renameTo(Paths.get(newDir).toFile()); + Paths.get(pathConfig.getReportTemplatePath() + oldDir).toFile().renameTo(Paths.get(newDir).toFile()); } } catch (IOException e) { throw new BusinessException(ReportResponseEnum.FILE_RENAME_FAILED); @@ -437,13 +434,13 @@ public class PqReportServiceImpl extends ServiceImpl i if (!baseFileOriginalFilename.isEmpty()) { pqReport.setBasePath(relativePath + baseFileOriginalFilename); - Paths.get(templatePath + File.separator + oldPqReport.getBasePath()).toFile().delete(); + Paths.get(pathConfig.getReportTemplatePath() + File.separator + oldPqReport.getBasePath()).toFile().delete(); Paths.get(newDir + oldPqReport.getBasePath().substring(oldPqReport.getBasePath().lastIndexOf(File.separator) + 1)).toFile().delete(); this.uploadFile(baseFile, newDir + baseFileOriginalFilename); } if (!detailFileOriginalFilename.isEmpty()) { pqReport.setDetailPath(relativePath + detailFileOriginalFilename); - Paths.get(templatePath + File.separator + oldPqReport.getDetailPath()).toFile().delete(); + Paths.get(pathConfig.getReportTemplatePath() + File.separator + oldPqReport.getDetailPath()).toFile().delete(); Paths.get(newDir + oldPqReport.getDetailPath().substring(oldPqReport.getDetailPath().lastIndexOf(File.separator) + 1)).toFile().delete(); this.uploadFile(detailFile, newDir + detailFileOriginalFilename); } @@ -528,7 +525,7 @@ public class PqReportServiceImpl extends ServiceImpl i private void deleteFile(List ids) { List pqReports = this.listByIds(ids); for (PqReport pqReport : pqReports) { - String uploadDir = templatePath + File.separator + pqReport.getName() + File.separator + pqReport.getVersion() + File.separator; + String uploadDir = pathConfig.getReportTemplatePath() + File.separator + pqReport.getName() + File.separator + pqReport.getVersion() + File.separator; Path uploadPath = Paths.get(uploadDir); if (Files.exists(uploadPath)) { //清空目录下的文件 @@ -540,7 +537,7 @@ public class PqReportServiceImpl extends ServiceImpl i } } file1.delete(); - String dir = templatePath + File.separator + pqReport.getName() + File.separator; + String dir = pathConfig.getReportTemplatePath() + File.separator + pqReport.getName() + File.separator; Path dirPath = Paths.get(dir); File dirFile = dirPath.toFile(); File[] fileArr2 = dirFile.listFiles(); @@ -634,8 +631,8 @@ public class PqReportServiceImpl extends ServiceImpl i InputStream finalWordStream = DocxMergeUtil.mergeDocuments(wordFileInputStreams); // 处理需要输出的目录地址 基础路径+设备类型+装置编号.docx // 最终文件输出的路径 -// String dirPath = reportPath.concat(File.separator).concat(devType.getName()); - String dirPath = reportPath; +// String dirPath = pathConfig.getReportPath().concat(File.separator).concat(devType.getName()); + String dirPath = pathConfig.getReportPath(); // 确保目录存在 ensureDirectoryExists(dirPath); String reportFullPath = dirPath.concat(File.separator).concat(pqDevVO.getCreateId()).concat(ReportConstant.DOCX); @@ -828,8 +825,8 @@ public class PqReportServiceImpl extends ServiceImpl i if (Objects.isNull(report)) { throw new BusinessException(ReportResponseEnum.REPORT_TEMPLATE_NOT_EXIST); } - Path basePath = Paths.get(templatePath + File.separator + report.getBasePath()); - Path detailPath = Paths.get(templatePath + File.separator + report.getDetailPath()); + Path basePath = Paths.get(pathConfig.getReportTemplatePath() + File.separator + report.getBasePath()); + Path detailPath = Paths.get(pathConfig.getReportTemplatePath() + File.separator + report.getDetailPath()); try (InputStream baseInputStream = Files.newInputStream(basePath); InputStream detailInputStream = Files.newInputStream(detailPath)) { WordprocessingMLPackage detailModelDocument = WordprocessingMLPackage.load(detailInputStream); @@ -843,7 +840,7 @@ public class PqReportServiceImpl extends ServiceImpl i MainDocumentPart detailDocumentPart = detailModelDocument.getMainDocumentPart(); dealDataModelScatteredByBookmarkByPlanContrast(baseDocumentPart, detailDocumentPart, devReportParam, pqDevVO); // 保存新的文档 - String dirPath = reportPath.concat(File.separator).concat(FilePathSanitizer.toSafeFileName(plan.getName())); + String dirPath = pathConfig.getReportPath().concat(File.separator).concat(FilePathSanitizer.toSafeFileName(plan.getName())); // 确保目录存在 ensureDirectoryExists(dirPath); // 构建文件名:cityName_gdName_subName_name.docx @@ -910,8 +907,8 @@ public class PqReportServiceImpl extends ServiceImpl i if (Objects.isNull(report)) { throw new BusinessException(ReportResponseEnum.REPORT_TEMPLATE_NOT_EXIST); } - Path basePath = Paths.get(templatePath + File.separator + report.getBasePath()); - Path detailPath = Paths.get(templatePath + File.separator + report.getDetailPath()); + Path basePath = Paths.get(pathConfig.getReportTemplatePath() + File.separator + report.getBasePath()); + Path detailPath = Paths.get(pathConfig.getReportTemplatePath() + File.separator + report.getDetailPath()); try (InputStream baseInputStream = Files.newInputStream(basePath); InputStream detailInputStream = Files.newInputStream(detailPath)) { WordprocessingMLPackage detailModelDocument = WordprocessingMLPackage.load(detailInputStream); @@ -926,7 +923,7 @@ public class PqReportServiceImpl extends ServiceImpl i dealDataModelScatteredByBookmark(baseDocumentPart, detailDocumentPart, devReportParam, pqDevVO); // 保存新的文档 - String dirPath = reportPath.concat(File.separator).concat(FilePathSanitizer.toSafeFileName(devType.getName())); + String dirPath = pathConfig.getReportPath().concat(File.separator).concat(FilePathSanitizer.toSafeFileName(devType.getName())); // 确保目录存在 ensureDirectoryExists(dirPath); baseModelDocument.save(new File(dirPath.concat(File.separator).concat(pqDevVO.getCreateId()).concat(ReportConstant.DOCX))); @@ -1937,7 +1934,7 @@ public class PqReportServiceImpl extends ServiceImpl i if (SceneEnum.LEAVE_FACTORY_TEST.getValue().equals(currrentScene)) { // 出厂测试场景 - filePath = reportPath.concat(File.separator).concat(pqDevVO.getCreateId()).concat(ReportConstant.DOCX); + filePath = pathConfig.getReportPath().concat(File.separator).concat(pqDevVO.getCreateId()).concat(ReportConstant.DOCX); downloadFileName = pqDevVO.getCreateId() + ReportConstant.DOCX; } else if (plan != null) { // 根据计划模式确定路径结构 @@ -1949,16 +1946,16 @@ public class PqReportServiceImpl extends ServiceImpl i pqDevVO.getGdName() != null ? pqDevVO.getGdName() : "未知供电公司", pqDevVO.getSubName() != null ? pqDevVO.getSubName() : "未知电站", pqDevVO.getName() != null ? pqDevVO.getName() : "未知设备"); - filePath = reportPath.concat(File.separator).concat(FilePathSanitizer.toSafeFileName(plan.getName())).concat(File.separator).concat(fileName); + filePath = pathConfig.getReportPath().concat(File.separator).concat(FilePathSanitizer.toSafeFileName(plan.getName())).concat(File.separator).concat(fileName); downloadFileName = fileName; } else { // 数字/模拟模式:使用原来的路径结构 - filePath = reportPath.concat(File.separator).concat(FilePathSanitizer.toSafeFileName(devType.getName())).concat(File.separator).concat(pqDevVO.getCreateId()).concat(ReportConstant.DOCX); + filePath = pathConfig.getReportPath().concat(File.separator).concat(FilePathSanitizer.toSafeFileName(devType.getName())).concat(File.separator).concat(pqDevVO.getCreateId()).concat(ReportConstant.DOCX); downloadFileName = pqDevVO.getCreateId() + ReportConstant.DOCX; } } else { // 兜底:使用旧的路径结构 - filePath = reportPath.concat(File.separator).concat(FilePathSanitizer.toSafeFileName(devType.getName())).concat(File.separator).concat(pqDevVO.getCreateId()).concat(ReportConstant.DOCX); + filePath = pathConfig.getReportPath().concat(File.separator).concat(FilePathSanitizer.toSafeFileName(devType.getName())).concat(File.separator).concat(pqDevVO.getCreateId()).concat(ReportConstant.DOCX); downloadFileName = pqDevVO.getCreateId() + ReportConstant.DOCX; } @@ -2486,7 +2483,7 @@ public class PqReportServiceImpl extends ServiceImpl i return; } log.info("找到{}台设备需要上传报告", devices.size()); - String dirPath = reportPath; + String dirPath = pathConfig.getReportPath(); // 确保目录存在 ensureDirectoryExists(dirPath); // 异步批量上传每台设备的报告 diff --git a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java index ce13576f..d877ff2e 100644 --- a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java @@ -75,14 +75,11 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl update(@RequestBody @Validated ResourceManageParam.UpdateParam updateParam) { + String methodDescribe = getMethodDescribe("update"); + LogUtil.njcnDebug(log, "{},编辑资源参数为:{}", methodDescribe, updateParam); + boolean result = resourceManageService.update(updateParam); + if (result) { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe); + } + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe); + } + @OperateInfo(info = LogEnum.SYSTEM_COMMON) @GetMapping("/play") @ApiOperation("获取视频播放地址") diff --git a/system/src/main/java/com/njcn/gather/system/resource/pojo/enums/ResourceManageResponseEnum.java b/system/src/main/java/com/njcn/gather/system/resource/pojo/enums/ResourceManageResponseEnum.java index 760199bb..fb6472af 100644 --- a/system/src/main/java/com/njcn/gather/system/resource/pojo/enums/ResourceManageResponseEnum.java +++ b/system/src/main/java/com/njcn/gather/system/resource/pojo/enums/ResourceManageResponseEnum.java @@ -19,7 +19,8 @@ public enum ResourceManageResponseEnum { PLAY_TOKEN_INVALID("A013009", "播放授权无效"), PLAY_TOKEN_EXPIRED("A013010", "播放授权已过期"), RANGE_INVALID("A013011", "视频请求范围非法"), - DISK_SPACE_NOT_ENOUGH("A013012", "磁盘空间不足"); + DISK_SPACE_NOT_ENOUGH("A013012", "磁盘空间不足"), + ID_NOT_BLANK("A013013", "资源id不能为空"); private final String code; private final String message; diff --git a/system/src/main/java/com/njcn/gather/system/resource/pojo/param/ResourceManageParam.java b/system/src/main/java/com/njcn/gather/system/resource/pojo/param/ResourceManageParam.java index 0c631b3f..02f8fc99 100644 --- a/system/src/main/java/com/njcn/gather/system/resource/pojo/param/ResourceManageParam.java +++ b/system/src/main/java/com/njcn/gather/system/resource/pojo/param/ResourceManageParam.java @@ -21,6 +21,18 @@ public class ResourceManageParam { @ApiModelProperty(value = "视频文件", required = true) private MultipartFile file; + @Data + public static class UpdateParam { + @ApiModelProperty(value = "资源id", required = true) + private String id; + + @ApiModelProperty(value = "资源名称", required = true) + private String name; + + @ApiModelProperty(value = "备注", required = true) + private String remark; + } + @Data @EqualsAndHashCode(callSuper = true) public static class QueryParam extends BaseParam { diff --git a/system/src/main/java/com/njcn/gather/system/resource/service/IResourceManageService.java b/system/src/main/java/com/njcn/gather/system/resource/service/IResourceManageService.java index 7440d382..dd5078ab 100644 --- a/system/src/main/java/com/njcn/gather/system/resource/service/IResourceManageService.java +++ b/system/src/main/java/com/njcn/gather/system/resource/service/IResourceManageService.java @@ -18,6 +18,8 @@ public interface IResourceManageService extends IService { boolean add(ResourceManageParam resourceManageParam); + boolean update(ResourceManageParam.UpdateParam updateParam); + PlayVO play(String id); void stream(String id, String token, String rangeHeader, HttpServletResponse response); diff --git a/system/src/main/java/com/njcn/gather/system/resource/service/impl/ResourceManageServiceImpl.java b/system/src/main/java/com/njcn/gather/system/resource/service/impl/ResourceManageServiceImpl.java index 92d96f0f..07c149cd 100644 --- a/system/src/main/java/com/njcn/gather/system/resource/service/impl/ResourceManageServiceImpl.java +++ b/system/src/main/java/com/njcn/gather/system/resource/service/impl/ResourceManageServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.gather.system.config.PathConfig; import com.njcn.gather.system.resource.mapper.ResourceManageMapper; import com.njcn.gather.system.resource.pojo.enums.ResourceManageResponseEnum; import com.njcn.gather.system.resource.pojo.param.ResourceManageParam; @@ -19,7 +20,6 @@ import com.njcn.web.utils.RequestUtil; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; @@ -53,8 +53,9 @@ public class ResourceManageServiceImpl extends ServiceImpl PLAY_TOKEN_CACHE = new ConcurrentHashMap<>(); - @Value("${resource.videoDir:D:/data/resources/videos}") - private String videoDir; + // @Value("${resource.videoDir:D:/data/resources/videos}") +// private String videoDir; + private final PathConfig pathConfig; @Override public Page list(ResourceManageParam.QueryParam queryParam) { @@ -93,7 +94,7 @@ public class ResourceManageServiceImpl extends ServiceImpl