|
|
@@ -3,6 +3,7 @@ package thyyxxk.webserver.service.targetmanagement;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.dao.his.highreport.HighReportDao;
|
|
|
@@ -13,6 +14,7 @@ import thyyxxk.webserver.dao.his.targetmanagement.ZbReportCycleDao;
|
|
|
import thyyxxk.webserver.dao.his.targetmanagement.ZbReportCycleScoreDao;
|
|
|
import thyyxxk.webserver.dao.his.targetmanagement.ZbZdBaseInfoDao;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
+import thyyxxk.webserver.entity.archive.ArchiveUpload;
|
|
|
import thyyxxk.webserver.entity.highreport.HighReportDto;
|
|
|
import thyyxxk.webserver.entity.highreport.ReportBaseInfo;
|
|
|
import thyyxxk.webserver.entity.highreport.ReportType;
|
|
|
@@ -28,6 +30,7 @@ import thyyxxk.webserver.entity.login.UserInfo;
|
|
|
import thyyxxk.webserver.entity.targetmanagement.TargetDictTree;
|
|
|
import thyyxxk.webserver.entity.targetmanagement.TargetManagement;
|
|
|
import thyyxxk.webserver.entity.targetmanagement.ZbZdBaseInfo;
|
|
|
+import thyyxxk.webserver.service.archive.ArchiveServer;
|
|
|
import thyyxxk.webserver.service.hutoolcache.UserCache;
|
|
|
import thyyxxk.webserver.utils.DateUtil;
|
|
|
import thyyxxk.webserver.utils.DecimalUtil;
|
|
|
@@ -74,7 +77,11 @@ public class TargetManagementService {
|
|
|
|
|
|
private final ZbReportCycleScoreDao scoreDao;
|
|
|
|
|
|
-
|
|
|
+ private final ArchiveServer archiveServer;
|
|
|
+
|
|
|
+ @Value("${is-prod}")
|
|
|
+ private boolean isProd;
|
|
|
+ private static final String TARGET_PATH = "/testZb";
|
|
|
|
|
|
/**
|
|
|
* @description: 查询指标字典基本信息
|
|
|
@@ -1413,4 +1420,102 @@ public class TargetManagementService {
|
|
|
return ResultVoUtil.success(list);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Description 上传指标文件
|
|
|
+ * @Author hsh
|
|
|
+ * @param result 指标结果信息
|
|
|
+ * @return map
|
|
|
+ * @Date 2025/5/10 0010 15:48
|
|
|
+ */
|
|
|
+ public ResultVo<Map<String, Object>> uploadTargetFile(ZbReportResult result){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ ZbReportResult re = reportDao.selectReportResultByYear(result.getId(), result.getPid(), result.getYear());
|
|
|
+ if(null == re){
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到对应的指标结果,请检查!");
|
|
|
+ }
|
|
|
+ ArchiveServer.UploadResult uploadResult = archiveServer.uploadFile(result.getFile(), TARGET_PATH);
|
|
|
+ String url = uploadResult.getPath();
|
|
|
+ map.put("url", url);
|
|
|
+ String fileId = re.getFileId();
|
|
|
+ if(StringUtil.isEmpty(fileId)){
|
|
|
+ result.setFileId(uploadResult.getId());
|
|
|
+ } else {
|
|
|
+ fileId = fileId + "," + uploadResult.getId();
|
|
|
+ result.setFileId(fileId);
|
|
|
+ }
|
|
|
+ reportDao.updateZbReportResultFileIdById(result);
|
|
|
+ return ResultVoUtil.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description 查询指标文件
|
|
|
+ * @Author hsh
|
|
|
+ * @param result 指标信息
|
|
|
+ * @return map
|
|
|
+ * @Date 2025/5/12 0012 19:29
|
|
|
+ */
|
|
|
+ public ResultVo<Map<String, Object>> selectTargetFileById(ZbReportResult result){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ List<ArchiveUpload> list = new ArrayList<>();
|
|
|
+ if(!StringUtil.isEmpty(result.getFileId())){
|
|
|
+ String[] f = result.getFileId().split(",");
|
|
|
+ for(String id : f){
|
|
|
+ if(!StringUtil.isEmpty(id)){
|
|
|
+ ArchiveUpload pu = zbZdDao.selectTargetFileById(id);
|
|
|
+ if(null != pu){
|
|
|
+ pu.setPath(pu.getPath().replace("/mnt/archive", "/thyyarchive"));
|
|
|
+ list.add(pu);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(isProd){
|
|
|
+ map.put("targetPath", "/thyyarchive/archive" + TARGET_PATH);
|
|
|
+ } else {
|
|
|
+ map.put("targetPath", "/thyyarchive/archive-test" + TARGET_PATH);
|
|
|
+ }
|
|
|
+ map.put("fileList", list);
|
|
|
+ return ResultVoUtil.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description 根据文件路径删除文件
|
|
|
+ * @Author hsh
|
|
|
+ * @param id 文件id
|
|
|
+ * @return map
|
|
|
+ * @Date 2025/5/13 0013 15:31
|
|
|
+ */
|
|
|
+ public ResultVo<Map<String, Object>> deleteTargetFileByFileId(String fileId, String id, String pid, String year){
|
|
|
+ if(StringUtil.isEmpty(fileId)){
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到删除的文件id,请检查!");
|
|
|
+ }
|
|
|
+ if(StringUtil.isEmpty(id) || StringUtil.isEmpty(pid) || StringUtil.isEmpty(year)){
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到删除的文件id,请检查!");
|
|
|
+ }
|
|
|
+ ZbReportResult re = reportDao.selectReportResultByYear(id, pid, year);
|
|
|
+ if(null == re){
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到对应的指标结果,请检查!");
|
|
|
+ }
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ try {
|
|
|
+ archiveServer.delUploadById(fileId);
|
|
|
+
|
|
|
+ if(null != re.getFileId() && re.getFileId().contains(fileId)){
|
|
|
+ // 删除对应指标的fileId
|
|
|
+ ZbReportResult result = new ZbReportResult();
|
|
|
+ result.setId(id);
|
|
|
+ result.setPid(pid);
|
|
|
+ result.setYear(year);
|
|
|
+ String str = re.getFileId().replace(fileId + ",", "")
|
|
|
+ .replace("," + fileId, "").replace(fileId, "");
|
|
|
+ result.setFileId(",".equals(str) ? "" : str);
|
|
|
+ reportDao.updateZbReportResultFileIdById(result);
|
|
|
+ }
|
|
|
+ } catch(Exception e){
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "根据【" + fileId + "】删除的文件失败,请检查!");
|
|
|
+ }
|
|
|
+ map.put("cg", "删除指标文件成功!");
|
|
|
+ return ResultVoUtil.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
}
|