瀏覽代碼

Merge branch 'V0.0.5' of http://10.87.21.221:8000/jzyd_yyds/soc into V0.0.5

zhulu 1 年之前
父節點
當前提交
d0926e2bfa

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

@@ -785,9 +785,9 @@ public class CoreDrillTaskServiceImpl extends ServiceImpl<CoreDrillTaskMapper, C
         data.put("typeText", StringUtils.isNotEmpty(typeText) ? typeText : StringUtil.EMPTY_STRING);
         data.put("fileImage", 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);
-        data.put("comment", StringUtils.isNotEmpty(comment) ? "点评总结: " + comment : StringUtil.EMPTY_STRING);
+        data.put("presetCase", StringUtils.isNotEmpty(presetCase) ? presetCase : StringUtil.EMPTY_STRING);
+        data.put("drillSituation", StringUtils.isNotEmpty(drillSituation) ? drillSituation : StringUtil.EMPTY_STRING);
+        data.put("comment", StringUtils.isNotEmpty(comment) ? comment : StringUtil.EMPTY_STRING);
         List<CoreDrillTaskToUser> taskUserList = task.getTaskUserList();
         if (ObjectUtil.isEmpty(taskUserList)) {
             data.put("signImage", new ArrayList<>());

+ 4 - 4
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/impl/AppPlanServiceImpl.java

@@ -573,7 +573,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
 
                     child = baseMapper.selectById(newChildPlanId);
                 }
-                if (needRebuildOnEdit(existPlan)) {
+                if (needRebuildOnEdit(child,existPlan.getTaskHasCompleted())) {
                     needRebuildPlans.add(child);
                 }
 
@@ -724,7 +724,7 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
             plan.setPlanCreateOrgName(null);
             baseMapper.updateById(plan);
 
-            if (needRebuildOnEdit(existPlan)) {
+            if (needRebuildOnEdit(existPlan,existPlan.getTaskHasCompleted())) {
                 needRebuildPlans.add(baseMapper.selectById(plan.getId()));
             }
             resumptionTaskBusiness.rebuildCurrentCycleTask(needRebuildPlans);
@@ -778,10 +778,10 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
      * @param plan
      * @return
      */
-    private Boolean needRebuildOnEdit(AppPlan plan) {
+    private Boolean needRebuildOnEdit(AppPlan plan,Integer taskHasCompleted) {
         if (ObjectUtil.equal(plan.getPlanStatus(), PlanStatus.USING.getCode())
                 && ObjectUtil.equal(plan.getPlanOfOrgType(), OrgTypeEnum.HANG_SHE.getCode())
-                && (ObjectUtil.isNull(plan.getTaskHasCompleted()) || ObjectUtil.equal(plan.getTaskHasCompleted(), 0))
+                && ObjectUtil.notEqual(taskHasCompleted,1)
                 && !new Date().before(plan.getEffectiveTime())) {
             return true;
         }

+ 1 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/task/ResumptionTaskBusiness.java

@@ -196,7 +196,7 @@ public class ResumptionTaskBusiness extends TaskCreatingServiceImplBase<Resumpti
                 .le(Resumption::getYmdDate, dr.getEndTime())
                 .ne(Resumption::getStatus, ResumptionTaskStatus.Completed.getCode())
                 .in(Resumption::getSolidId, appPlans.stream().map(p -> p.getSolidId()).collect(Collectors.toList()));
-        baseMapper.delete(wrapper);
+        int count = baseMapper.delete(wrapper);
 
 
 //        AppPlan plan = appPlans.get(0);

+ 4 - 4
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/safetyCheck/service/impl/CoreSafecheckPlanServiceImpl.java

@@ -625,7 +625,7 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
             }
         }
 
-        if (needRebuildOnEdit(coreSafecheckPlan, planStatus)) {
+        if (needRebuildOnEdit(coreSafecheckPlan, planStatus,coreSafecheckPlan.getTaskHasCompleted())) {
             CoreSafecheckPlan plan = baseMapper.selectById(coreSafecheckPlan.getId());
             safetyCheckJobBusiness.createTaskByPlans(Arrays.asList(plan));
         }
@@ -659,7 +659,7 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
 
                 child = baseMapper.selectById(newChildPlanId);
             }
-            if (needRebuildOnEdit(p, p.getPlanStatus())) {
+            if (needRebuildOnEdit(p, p.getPlanStatus(),coreSafecheckPlan.getTaskHasCompleted())) {
                 needRebuildPlans.add(child);
             }
             child.setUpdateTime(DateUtils.getNowDate());
@@ -805,10 +805,10 @@ public class CoreSafecheckPlanServiceImpl extends ServiceImpl<CoreSafecheckPlanM
      * @param plan
      * @return
      */
-    private Boolean needRebuildOnEdit(CoreSafecheckPlan plan, Integer planStatus) {
+    private Boolean needRebuildOnEdit(CoreSafecheckPlan plan, Integer planStatus,Integer taskHasCompleted) {
         if (ObjectUtil.equal(planStatus, PlanStatus.USING.getCode())
                 && (ObjectUtil.equal(plan.getPlanOfOrgType(), OrgTypeEnum.HANG_SHE.getCode()) || ObjectUtil.equal(plan.getExecOrgType(), OrgTypeEnum.BAN_SHI_CHU.getCode()) || ObjectUtil.equal(plan.getExecOrgType(), OrgTypeEnum.SHEGN_LIAN_SHE.getCode()))
-                && (ObjectUtil.isNull(plan.getTaskHasCompleted()) || ObjectUtil.equal(plan.getTaskHasCompleted(), 0))
+                && ObjectUtil.notEqual (taskHasCompleted,1)
                 && !new Date().before(plan.getEffectiveTime())) {
             return true;
         }

+ 8 - 7
soc-modules/soc-modules-file/src/main/java/com/xunmei/file/service/LocalSysFileServiceImpl.java

@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson2.JSON;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.lowagie.text.*;
 import com.lowagie.text.pdf.*;
 import com.xunmei.common.core.constant.CacheConstants;
@@ -111,6 +112,7 @@ public class LocalSysFileServiceImpl implements ISysFileService {
 
         PdfFilePathVo pathVo = new PdfFilePathVo();
         pathVo.setAbsolutePath(localFilePath + path + fileName);
+        pathVo.setTempFileName(localFilePath + path + IdWorker.getId()+".pdf");
         pathVo.setRelativePath(path + fileName);
         return pathVo;
     }
@@ -232,16 +234,15 @@ public class LocalSysFileServiceImpl implements ISysFileService {
         String fileName = filterPath(data.get("fileName").toString());
 
         PdfFilePathVo pathVo = getLocalFilePath("edu", fileName);
-        String afterStr = StringEscapeUtils.escapeEcmaScript(pathVo.getAbsolutePath());
+        String afterStr = StringEscapeUtils.escapeEcmaScript(pathVo.getTempFileName());
         log.info("开始生成教育培训登记簿,当前绝对地址为:{}", afterStr);
-        final ItextPdfTableVo pdfTableVo = PdfUtil.createTable(pathVo.getAbsolutePath(), 6, 10);
+        final ItextPdfTableVo pdfTableVo = PdfUtil.createTable(pathVo.getTempFileName(), 6, 10);
         final Document document = pdfTableVo.getDocument();
         final PdfWriter writer = pdfTableVo.getWriter();
         final PdfPTable table = pdfTableVo.getTable();
         final BaseFont fs = pdfTableVo.getFs();
         final Font tableFont = pdfTableVo.getTableFont();
 
-        writer.setPageEvent(new PdfPageHelperEvent(ListUtil.split((List<String>) data.get("fileImage"), 6).size() + 1, writer, fs, tableFont));
         document.open();
         PdfUtil.dealHeader(document, fs, "学 习 教 育 记 录", 24);
         PdfUtil.dealEduBody(document, table, tableFont, data);
@@ -249,6 +250,7 @@ public class LocalSysFileServiceImpl implements ISysFileService {
 
         document.close();
         writer.close();
+        PdfUtil.addPageNum(pathVo.getTempFileName(),pathVo.getAbsolutePath(),fs,tableFont);
         log.info("教育培训登记簿生成结束,当前绝对地址为:{}", afterStr);
         //此处返回  /statics/edu/xxx.pdf
         return this.prefix + pathVo.getRelativePath();
@@ -411,23 +413,22 @@ public class LocalSysFileServiceImpl implements ISysFileService {
     @Override
     public String generateDrillPdf(Map<String, Object> data) throws Exception {
         PdfFilePathVo pathVo = getLocalFilePath("drill", data.get("fileName").toString());
-        String afterStr = StringEscapeUtils.escapeEcmaScript(pathVo.getAbsolutePath());
+        String afterStr = StringEscapeUtils.escapeEcmaScript(pathVo.getTempFileName());
         log.info("开始生成预案演练登记簿,当前绝对地址为:{}", afterStr);
-        final ItextPdfTableVo pdfTableVo = PdfUtil.createTable(pathVo.getAbsolutePath(), 6, 10);
+        final ItextPdfTableVo pdfTableVo = PdfUtil.createTable(pathVo.getTempFileName(), 6, 10);
         final Document document = pdfTableVo.getDocument();
         final PdfWriter writer = pdfTableVo.getWriter();
 
         final PdfPTable table = pdfTableVo.getTable();
         final BaseFont fs = pdfTableVo.getFs();
         final Font tableFont = pdfTableVo.getTableFont();
-
-        writer.setPageEvent(new PdfPageHelperEvent(ListUtil.split((List<String>) data.get("fileImage"), 6).size() + 1, writer, fs, tableFont));
         document.open();
         PdfUtil.dealHeader(document, fs, "预 案 演 练 记 录", 24);
         PdfUtil.dealDrillBody(document, table, tableFont, data);
         document.close();
         writer.close();
         log.info("预案演练登记簿生成结束,当前绝对地址为:{}", afterStr);
+        PdfUtil.addPageNum(pathVo.getTempFileName(),pathVo.getAbsolutePath(),fs,tableFont);
         //此处返回  /statics/edu/xxx.pdf
         return this.prefix + pathVo.getRelativePath();
 

+ 0 - 14
soc-modules/soc-modules-file/src/main/java/com/xunmei/file/utils/PdfPageHelperEvent.java

@@ -40,20 +40,6 @@ public class PdfPageHelperEvent implements PdfPageEvent {
 
     @Override
     public void onEndPage(PdfWriter pdfWriter, Document document) {
-       /* PdfContentByte cb = writer.getDirectContent();// 得到层
-        cb.saveState(); // 开始
-        cb.beginText();
-        cb.setFontAndSize(fs, 10); // Header
-   *//*             float x = document.top(-20);// 位置 // 左
-                cb.showTextAligned(PdfContentByte.ALIGN_LEFT, "H-Left", document.left(), x, 0); // 中
-                cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "第" + writer.getCurrentPageNumber() + "页", (document.right() + document.left()) / 2, x, 0); // 右
-                cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, "H-Right", document.right(), x, 0); *//*
-        float y = document.bottom(-80); // 左
-        cb.showTextAligned(PdfContentByte.ALIGN_LEFT, "", document.left(), y, 0); // 中
-        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "第" + writer.getCurrentPageNumber() + "页/共" + totalPageSize + "页", (document.right() + document.left()) / 2, y, 0); // 右
-        cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, "", document.right(), y, 0);
-        cb.endText();
-        cb.restoreState();*/
 
         try {
             // PDF文档内容

+ 19 - 17
soc-modules/soc-modules-file/src/main/java/com/xunmei/file/utils/PdfUtil.java

@@ -29,12 +29,14 @@ import java.util.Map;
 public class PdfUtil {
 
 
+    public static Document createDocument(float marginLeft, float marginRight, float marginTop, float marginBottom) {
+        return new Document(PageSize.A4, marginLeft, marginRight, marginTop, marginBottom);
+    }
+
     public static ItextPdfTableVo createTable(String filename, int numColumns, int fontSize) throws Exception {
-        Document document = new Document(PageSize.A4, 0, 0, 50, 100);//SUPPRESS
+        Document document = createDocument(0, 0, 50, 50);
         File file = FileUtils.getFile(filename);
         FileOutputStream fos = new FileOutputStream(file);
-        String afterStr_1 = StringEscapeUtils.escapeEcmaScript(filename);
-        log.info("filename,{}", afterStr_1);
         final PdfWriter writer = PdfWriter.getInstance(document, fos);
         document.open();
         // 使用语言包字
@@ -372,11 +374,11 @@ public class PdfUtil {
             //一行展示一张图片
             dealEduImageCell(new ArrayList<>(stringList), innerTable, 2, 150, 200);
             document.newPage();
-             document.add(innerTable);
-         }
+            document.add(innerTable);
+        }
     }
 
-    public static void dealDrillImageCell( List<String> imageList, PdfPTable table) throws Exception {
+    public static void dealDrillImageCell(List<String> imageList, PdfPTable table) throws Exception {
         //签字区域
         PdfPCell outCell = new PdfPCell();
         outCell.setColspan(5);
@@ -509,7 +511,8 @@ public class PdfUtil {
             throw new RuntimeException(e);
         }
     }
-    public static void dealAccessPBody(Document document, PdfPTable table, Font tableFont, Font tableTitleFont, List<AccessDataVo> data)throws DocumentException {
+
+    public static void dealAccessPBody(Document document, PdfPTable table, Font tableFont, Font tableTitleFont, List<AccessDataVo> data) throws DocumentException {
 
         PdfUtil.createPDFCell(tableTitleFont, table, "序号", Element.ALIGN_MIDDLE, 3, 0);
         PdfUtil.createPDFCell(tableTitleFont, table, "硬盘录像机", Element.ALIGN_MIDDLE, 16, 0);
@@ -523,9 +526,10 @@ public class PdfUtil {
             PdfUtil.createPDFCell(tableFont, table, data.get(i - 1).getProject(), Element.ALIGN_MIDDLE, 9, 0, 10);
          //   PdfUtil.createPDFCell(tableFont, table, data.get(i - 1).getSituation().equals("0") ? "正常" : "异常", Element.ALIGN_MIDDLE, 2, 0, 10);
             PdfUtil.createPDFCell(tableFont, table, data.get(i - 1).getAbnormalIllustrate(), Element.ALIGN_MIDDLE, 9, 0, 10);
-     }
+        }
         document.add(table);
     }
+
     public static void dealSafeCheckPBody(Document document, PdfPTable table, Font tableFont, Font tableTitleFont, List<CheckDataVo> data) throws DocumentException {
         PdfUtil.createPDFCell(tableTitleFont, table, "序号", Element.ALIGN_MIDDLE, 2, 0);
         PdfUtil.createPDFCell(tableTitleFont, table, "检查内容", Element.ALIGN_MIDDLE, 5, 0);
@@ -544,25 +548,21 @@ public class PdfUtil {
         document.add(table);
     }
 
-    public static void addPageNum(String srcPdfPath, String tagetPdfPath) {
+    public static void addPageNum(String srcPdfPath, String targetPdfPath, BaseFont fs, Font tableFont) {
         try {
             // 输出文件 流
-            FileOutputStream fos = new FileOutputStream(tagetPdfPath);
-
+            FileOutputStream fos = new FileOutputStream(targetPdfPath);
             // 读取 源PDF文件,进行一页一页复制,才能触发 添加页码的  页面监听事件
             PdfReader reader = new PdfReader(srcPdfPath);
             // 获取 源文件总页数
             int num = reader.getNumberOfPages();
-
             // 新建文档,默认A4大小
-            Document document = new Document(PageSize.A4);
+            Document document =createDocument(0,0,50,50);
             PdfWriter writer = PdfWriter.getInstance(document, fos);
-            // 设置页面监听事件,必须在open方法前
-           // writer.setPageEvent(new PdfPageHelperEvent(num,writer,document,));
+            writer.setPageEvent(new PdfPageHelperEvent(num, writer, fs, tableFont));
             document.open();
             // PDF内容体
             PdfContentByte pdfContent = writer.getDirectContent();
-            //System.out.println("总页数:" + num);
             // 页面数是从1开始的
             for (int i = 1; i <= num; i++) {
                 document.newPage();
@@ -574,7 +574,9 @@ public class PdfUtil {
             }
             document.close();
             reader.close();
-        }catch (Exception e){
+            final File file = new File(srcPdfPath);
+            file.delete();
+        } catch (Exception e) {
             e.printStackTrace();
         }
     }

+ 2 - 0
soc-modules/soc-modules-file/src/main/java/com/xunmei/file/vo/PdfFilePathVo.java

@@ -14,4 +14,6 @@ public class PdfFilePathVo {
     private String absolutePath;
     @ApiModelProperty(value = "相对地址")
     private String relativePath;
+    @ApiModelProperty(value = "临时文件(处理页码时需要临时保存一份文件)")
+    private String tempFileName;
 }