Bladeren bron

培训/演练登记簿生成处理

jingyuanchao 1 jaar geleden
bovenliggende
commit
21d0b476b3

+ 27 - 14
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/drill/service/impl/CoreDrillTaskServiceImpl.java

@@ -811,7 +811,8 @@ public class CoreDrillTaskServiceImpl extends ServiceImpl<CoreDrillTaskMapper, C
 
     private Map<String, Object> getFtlDrill(CoreDrillTaskDetailVo task) {
         Map<String, Object> data = new HashMap<>();
-
+        String prefixPath = RemoteCallHandlerExecutor.executeRemoteCall(() -> fileService.getLocalPathPrefix(), ErrorMsgConstants.QUERY_FILE_PATH_ERROR);
+        String staticsPath = RemoteCallHandlerExecutor.executeRemoteCall(() -> fileService.getStaticPathPrefix(), ErrorMsgConstants.QUERY_FILE_PATH_ERROR);
         String orgName = task.getOrgName();
         String drillSite = task.getDrillSite();
         String imageData = task.getImageList();
@@ -829,7 +830,7 @@ public class CoreDrillTaskServiceImpl extends ServiceImpl<CoreDrillTaskMapper, C
         data.put("drillTime", StringUtils.isNotEmpty(drillTime) ? drillTime : StringUtil.EMPTY_STRING);
         data.put("hostName", StringUtils.isNotEmpty(hostName) ? hostName : StringUtil.EMPTY_STRING);
         data.put("typeText", StringUtils.isNotEmpty(typeText) ? typeText : StringUtil.EMPTY_STRING);
-        data.put("imageData", StringUtils.isNotEmpty(imageData) ? Arrays.asList(imageData.split(",")) : StringUtil.EMPTY_STRING);
+        data.put("imageData", getFileRealPath(Arrays.asList(task.getImageList().split(",")), prefixPath, staticsPath));
         data.put("recorderName", StringUtils.isNotEmpty(recorderName) ? recorderName : StringUtil.EMPTY_STRING);
         data.put("presetCase", StringUtils.isNotEmpty(presetCase) ? "预设案由: " + presetCase : StringUtil.EMPTY_STRING);
         data.put("drillSituation", StringUtils.isNotEmpty(drillSituation) ? "演练情况: " + drillSituation : StringUtil.EMPTY_STRING);
@@ -837,23 +838,35 @@ public class CoreDrillTaskServiceImpl extends ServiceImpl<CoreDrillTaskMapper, C
         if (ObjectUtil.isEmpty(taskUserList)) {
             data.put("image", new ArrayList<>());
         } else {
-            String prefixPath = RemoteCallHandlerExecutor.executeRemoteCall(() -> fileService.getLocalPathPrefix(), ErrorMsgConstants.QUERY_FILE_PATH_ERROR);
-            String staticsPath = RemoteCallHandlerExecutor.executeRemoteCall(() -> fileService.getStaticPathPrefix(), ErrorMsgConstants.QUERY_FILE_PATH_ERROR);
             List<String> collect = taskUserList.stream().filter(item -> item.getType() == 1 && ObjectUtil.isNotEmpty(item.getSignImage())).map(CoreDrillTaskToUser::getSignImage).collect(Collectors.toList());
-            List<String> list = new ArrayList<>();
-            for (String path : collect) {
-                if (path.contains(staticsPath)) {
-                    //删除 /statics 前缀路径
-                    path = path.replace(staticsPath, StringUtil.EMPTY_STRING);
-                }
-                list.add(prefixPath + path);
-            }
-
-            data.put("image", list);
+            data.put("image", getFileRealPath(collect, prefixPath, staticsPath));
         }
         return data;
     }
 
+    /**
+     * 获取文件真实地址
+     *
+     * @param fileList    文件数组
+     * @param prefixPath  真实磁盘路径,配置于yml中 D:xxx/xxx
+     * @param staticsPath 转发路径 /statics
+     * @return
+     */
+    private List<String> getFileRealPath(List<String> fileList, String prefixPath, String staticsPath) {
+
+        List<String> list = new ArrayList<>();
+        if (ObjectUtil.isEmpty(fileList)) {
+            return list;
+        }
+        for (String path : fileList) {
+            if (path.contains(staticsPath)) {
+                //删除 /statics 前缀路径
+                path = path.replace(staticsPath, StringUtil.EMPTY_STRING);
+            }
+            list.add(prefixPath + path);
+        }
+        return list;
+    }
 
     @Override
     public String buildDrillTask(Integer cycle, Date date) {

+ 23 - 18
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/edu/service/impl/CoreEduTrainingTaskServiceImpl.java

@@ -823,6 +823,8 @@ public class CoreEduTrainingTaskServiceImpl extends ServiceImpl<CoreEduTrainingT
         String recorderName = task.getRecorderName() == null ? StringUtil.EMPTY_STRING : task.getRecorderName();
         String content = task.getContent();
         String note = task.getNote();
+        String prefixPath = RemoteCallHandlerExecutor.executeRemoteCall(() -> fileService.getLocalPathPrefix(), ErrorMsgConstants.QUERY_FILE_PATH_ERROR);
+        String staticsPath = RemoteCallHandlerExecutor.executeRemoteCall(() -> fileService.getStaticPathPrefix(), ErrorMsgConstants.QUERY_FILE_PATH_ERROR);
         data.put("time", StringUtils.isNotEmpty(time) ? time : StringUtil.EMPTY_STRING);
         data.put("address", StringUtils.isNotEmpty(address) ? time : StringUtil.EMPTY_STRING);
         data.put("hostName", StringUtils.isNotEmpty(hostName) ? hostName : StringUtil.EMPTY_STRING);
@@ -833,32 +835,35 @@ public class CoreEduTrainingTaskServiceImpl extends ServiceImpl<CoreEduTrainingT
         if (ObjectUtil.isEmpty(taskUserList)) {
             data.put("image", new ArrayList<>());
         } else {
-            String prefixPath = RemoteCallHandlerExecutor.executeRemoteCall(() -> fileService.getLocalPathPrefix(), ErrorMsgConstants.QUERY_FILE_PATH_ERROR);
-            String staticsPath = RemoteCallHandlerExecutor.executeRemoteCall(() -> fileService.getStaticPathPrefix(), ErrorMsgConstants.QUERY_FILE_PATH_ERROR);
             List<String> collect = taskUserList.stream().filter(item -> item.getType() == 1 && ObjectUtil.isNotEmpty(item.getSignImage())).map(CoreEduTrainingTaskToUser::getSignImage).collect(Collectors.toList());
-            List<String> list = new ArrayList<>();
-            for (String path : collect) {
-                if (path.contains(staticsPath)) {
-                    //删除 /statics 前缀路径
-                    path = path.replace(staticsPath, StringUtil.EMPTY_STRING);
-                }
-                list.add(prefixPath + path);
-            }
-
-            data.put("image", list);
+            data.put("image", getFileRealPath(collect,prefixPath,staticsPath));
         }
         return data;
     }
 
-    private String generateFilePath(String fileName) {
-        String resource = "cache";
-        File file = new File(resource);
-        if (!file.exists()) {
-            file.mkdirs();
+    /**
+     * 获取文件真实地址
+     * @param fileList 文件数组
+     * @param prefixPath 真实磁盘路径,配置于yml中 D:xxx/xxx
+     * @param staticsPath 转发路径 /statics
+     * @return
+     */
+    private List<String> getFileRealPath(List<String> fileList,String prefixPath,String staticsPath) {
+        List<String> list = new ArrayList<>();
+        if (ObjectUtil.isEmpty(fileList)) {
+            return list;
+        }
+        for (String path : fileList) {
+            if (path.contains(staticsPath)) {
+                //删除 /statics 前缀路径
+                path = path.replace(staticsPath, StringUtil.EMPTY_STRING);
+            }
+            list.add(prefixPath + path);
         }
-        return resource + File.separator + fileName;
+        return list;
     }
 
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String buildEduTask(Integer cycle, Date date) {

+ 6 - 1
soc-modules/soc-modules-file/src/main/java/com/xunmei/file/utils/PdfUtil.java

@@ -12,6 +12,7 @@ import com.xunmei.system.api.domain.ResumptionPdf;
 import com.xunmei.system.api.domain.SafeCheckTaskRegisterBookVo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.ApplicationContext;
 import org.springframework.core.io.Resource;
 
@@ -164,7 +165,8 @@ public class PdfUtil {
         contentCell.addElement(content);
         contentCell.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM);
         table.addCell(contentCell);
-
+        table.setSplitLate(false);
+        table.setSplitRows(true);
         //总结
         PdfPCell noteCell = new PdfPCell();
         noteCell.setColspan(6);
@@ -258,6 +260,8 @@ public class PdfUtil {
     }
 
     public static void dealDrillBody(Document document, PdfPTable table, Font tableFont, Map<String, Object> data) throws Exception {
+        table.setSplitLate(false);
+        table.setSplitRows(true);
         //第一行
         createPDFCell(tableFont, table, "演练单位", Element.ALIGN_CENTER, 1, 1);
         createPDFCell(tableFont, table, data.get("orgName").toString(), Element.ALIGN_CENTER, 2, 1);
@@ -337,6 +341,7 @@ public class PdfUtil {
         document.add(table);
     }
 
+
     public static Image getImage(String image) throws Exception {
         Image imageData = null;
         if (image.contains("black.png")) {