浏览代码

履职登记簿

luojun 1 年之前
父节点
当前提交
93308552b3

+ 16 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/domain/ResumptionPdf.java

@@ -0,0 +1,16 @@
+package com.xunmei.system.api.domain;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class ResumptionPdf implements Serializable {
+    @ApiModelProperty("履职内容")
+    private String pointName;
+    @ApiModelProperty(value = "提交人姓名")
+    private String submitName;
+    @ApiModelProperty(value = "执行结果")
+    private Integer resValue;
+}

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

@@ -38,6 +38,7 @@ import com.xunmei.core.resumption.vo.resumptionRecord.ResumptionRecordVo;
 import com.xunmei.core.thread.ThreadPoolConfig;
 import com.xunmei.system.api.RemoteFileService;
 import com.xunmei.system.api.RemoteOrgService;
+import com.xunmei.system.api.domain.ResumptionPdf;
 import com.xunmei.system.api.domain.SysDept;
 import com.xunmei.system.api.domain.SysOrg;
 import com.xunmei.system.api.function.RemoteCallHandlerExecutor;
@@ -738,14 +739,17 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
     public AjaxResult buildResumptionPdf(Long orgid) {
 
         SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectOrgById(orgid, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
-        String[] strings = sysOrg.getPath().split("-");
+        String[] strings = sysOrg.getTreeShowPath().split("-");
         List<Long> list = Arrays.stream(strings).map(Long::valueOf).collect(Collectors.toList());
         List<SysOrg> sysOrgList = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectOrgByIdList(list, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
-        String orgName = sysOrgList.stream().map(SysOrg::getName).collect(Collectors.joining("_"));
+        String orgName = sysOrgList.stream().map(SysOrg::getShortName).collect(Collectors.joining("_"));
 
-        String fileName = orgName + "_" + "_" + DateUtil.format(new Date(), "yyyyMMddHHmmss") + ".pdf";
+        String fileName = orgName + "_" + DateUtil.format(new Date(), "yyyyMMddHHmmss") + ".pdf";
         Map<String, Object> data = this.getFtlResumption(orgid);
         data.put("fileName", fileName);
+        data.put("orgName", sysOrg.getShortName());
+        data.put("dateStr", DateUtils.getTime());
+        data.put("remark", "");
         CompletableFuture.runAsync(() -> {
             R<String> r = RemoteCallHandlerExecutor.executeRemoteCall(() -> fileService.generateResumptionPdf(data), ErrorMsgConstants.GENERATE_PDF_ERROR);
             if (null == r || null == r.getData()) {
@@ -777,10 +781,12 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
         List<AppResumptionDataInfoVo> ingvos = getItems(ing);
         List<AppResumptionDataInfoVo> aftervos = getItems(after);
         Map<Long, List<AppResumptionDataInfoVo>> bef = beforevos.stream().collect(Collectors.groupingBy(AppResumptionDataInfoVo::getItemId));
+        Map<Long, List<AppResumptionDataInfoVo>> ingf = ingvos.stream().collect(Collectors.groupingBy(AppResumptionDataInfoVo::getItemId));
+        Map<Long, List<AppResumptionDataInfoVo>> afterf = aftervos.stream().collect(Collectors.groupingBy(AppResumptionDataInfoVo::getItemId));
 
-        data.put("营业前", getItems(before));
-        data.put("营业期间", getItems(ing));
-        data.put("营业终了", getItems(after));
+        data.put("营业前", getResult(bef));
+        data.put("营业期间", getResult(ingf));
+        data.put("营业终了", getResult(afterf));
         return data;
     }
 
@@ -797,5 +803,25 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
         }
         return vos;
     }
-
+    public List<ResumptionPdf> getResult(Map<Long, List<AppResumptionDataInfoVo>> bef){
+        List<ResumptionPdf> befs = new ArrayList<>();
+        for (Long l :
+                bef.keySet()) {
+            String pointName = "";
+            StringBuilder submitName = new StringBuilder();
+            int result = 0;
+            for (AppResumptionDataInfoVo vo :
+                    bef.get(l)) {
+                pointName=vo.getPointName();
+                result += vo.getResValue();
+                submitName.append(vo.getSubmitName());
+            }
+            ResumptionPdf tem= new ResumptionPdf();
+            tem.setPointName(pointName);
+            tem.setSubmitName(String.valueOf(submitName));
+            tem.setResValue(result>0?1:0);
+            befs.add(tem);
+        }
+        return befs;
+    }
 }

+ 4 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/vo/resumptionRecord/AppResumptionDataInfoVo.java

@@ -29,9 +29,13 @@ public class AppResumptionDataInfoVo {
 
     @ApiModelProperty(value = "履职点位")
     private String checkName;
+    @ApiModelProperty(value = "提交人姓名")
+    private String submitName;
 
     @ApiModelProperty(value = "执行结果")
     private String executeResult;
+    @ApiModelProperty(value = "执行结果")
+    private Integer resValue;
 //
 //    @ApiModelProperty(value = "标记,仅供前端页面渲染字体颜色使用")
 //    private String executeFlag;

+ 3 - 1
soc-modules/soc-modules-core/src/main/resources/mapper/resumption/ResumptionRecordMapper.xml

@@ -291,7 +291,9 @@
                d.res_remark  AS resRemark,
                d.res_status  AS executeStatus,
                d.id          AS dataId,
-               d.item_id
+               d.item_id,
+               d.res_value,
+               d.submit_name
         FROM core_resumption_data d
                  INNER JOIN core_resumption_rule_point p ON d.item_id = p.id
                  LEFT JOIN sys_area a ON a.id = d.area_id

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

@@ -187,6 +187,21 @@ public class LocalSysFileServiceImpl implements ISysFileService {
         }
         return path;
     }
+    private void dealHeader(Map<String, Object> dataMap, Document document, BaseFont abf, BaseFont fs) throws
+            DocumentException {
+        //处理标题
+        Paragraph p = new Paragraph("日常履职登记簿", new Font(fs, 20, Font.NORMAL));
+        p.setAlignment(Paragraph.ALIGN_CENTER);
+        //段落下空白
+        p.setSpacingAfter(10f);
+        document.add(p);
+        //日期
+        String blankStr1 = "             ";
+        String blankStr2 = "                         ";
+        Paragraph p2 = new Paragraph(dataMap.get("orgName") + blankStr1 + dataMap.get("dateStr") + blankStr2, new Font(abf, 10, Font.NORMAL));
+        p2.setAlignment(Paragraph.ALIGN_RIGHT);
+        document.add(p2);
+    }
 
     @Override
     public String generateEduTrainingPdf(Map<String, Object> data) throws Exception {
@@ -211,13 +226,17 @@ public class LocalSysFileServiceImpl implements ISysFileService {
     public String generateResumptionPdf(Map<String, Object> data) throws Exception {
         PdfFilePathVo pathVo = getLocalFilePath(localFilePath, "resumption", data.get("fileName").toString());
         log.info("开始生成履职登记簿,当前绝对地址为:{}", pathVo.getAbsolutePath());
-        final ItextPdfTableVo pdfTableVo = PdfUtil.createTable(pathVo.getAbsolutePath(), 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();
-        PdfUtil.dealHeader(document, fs, "保 安 履 职", 24);
+        Document document = new Document();
+        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(pathVo.getAbsolutePath()));
+        document.open();
+        // 使用语言包字体
+        BaseFont abf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
+        // 外部字体
+        BaseFont fs = BaseFont.createFont("/fonts/msyh.ttc,1", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
+        Font tableFont = new Font(fs, 12, Font.NORMAL);
+        PdfPTable table = new PdfPTable(8);
+        table.setSpacingBefore(16f);
+        this.dealHeader(data, document, abf, fs);
         PdfUtil.dealResumptionBody(document, table, tableFont, data);
         document.close();
         writer.close();

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

@@ -6,6 +6,7 @@ import cn.hutool.extra.spring.SpringUtil;
 import com.lowagie.text.*;
 import com.lowagie.text.pdf.*;
 import com.xunmei.file.vo.ItextPdfTableVo;
+import com.xunmei.system.api.domain.ResumptionPdf;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.context.ApplicationContext;
 import org.springframework.core.io.Resource;
@@ -14,10 +15,8 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.*;
 import java.util.List;
-import java.util.Map;
 
 @Slf4j
 public class PdfUtil {
@@ -205,33 +204,34 @@ public class PdfUtil {
     public static void dealResumptionBody(Document document, PdfPTable table, Font tableFont, Map<String, Object> data) throws Exception {
         PdfUtil.createPDFCell(tableFont, table, "检查内容", Element.ALIGN_CENTER, 6, 0);
         PdfUtil.createPDFCell(tableFont, table, "检查情况", Element.ALIGN_CENTER, 0, 0);
-        PdfUtil.createPDFCell(tableFont, table, "检查人", Element.ALIGN_CENTER, 0, 0);
+        PdfUtil.createPDFCell(tableFont, table, "登记人", Element.ALIGN_CENTER, 0, 0);
+
+        List<String> names = new ArrayList<>();
+        names.add("营业前");
+        names.add("营业期间");
+        names.add("营业终了");
 
-        final Map<String,List<AppResumptionDataInfoVo>> lists = (Map<String,List<AppResumptionDataInfoVo>>) data.get("items");
-        if (ObjectUtil.isEmpty(lists)) {
-            return;
-        }
-        Iterator<String> iterator=lists.keySet().iterator();
-        while (iterator.hasNext()) {
-            List<AppResumptionDataInfoVo> list = lists.get(iterator.next());
-            //不同的执行时刻
-            String execTimeName = iterator.next();
-            PdfUtil.createPDFCell(tableFont, table, getLineStr(execTimeName), PdfPCell.ALIGN_MIDDLE, 0, list.size());
-            int o=1;
-            for (AppResumptionDataInfoVo listVo : list) {
 
+        for(String s:names){
+            List<LinkedHashMap<String, Object>> lists = (List<LinkedHashMap<String, Object>>) data.get(s);
+            if (ObjectUtil.isEmpty(lists)) {
+                continue;
+            }
+            //不同的执行时刻
+            PdfUtil.createPDFCell(tableFont, table, getLineStr(s), PdfPCell.ALIGN_MIDDLE, 0, lists.size());
+            int o = 1;
+            for (LinkedHashMap<String, Object> listVo : lists) {
                 // 检查内容
-                String rowContent = o+ "、" + listVo.getPointName();
+                String rowContent = o + "、" + listVo.get("pointName");
                 PdfUtil.createPDFCell(tableFont, table, rowContent, Element.ALIGN_LEFT, 5, 0);
                 // 检查情况
-                PdfUtil.createPDFCell(tableFont, table, listVo.getExecuteResult(), Element.ALIGN_CENTER, 0, 0);
+                PdfUtil.createPDFCell(tableFont, table, ((Integer) listVo.get("resValue")) == 0 ? "√" : "×", Element.ALIGN_CENTER, 0, 0);
                 // 检查人
-                PdfUtil.createPDFCell(tableFont, table, listVo.getCheckName(), Element.ALIGN_CENTER, 0, 0);
+                PdfUtil.createPDFCell(tableFont, table, String.valueOf(listVo.get("submitName")), Element.ALIGN_CENTER, 0, 0);
                 o++;
             }
         }
 
-
         // 备注数据
         PdfUtil.createPDFCell(tableFont, table, getLineStr("备注"), PdfPCell.ALIGN_MIDDLE, 0, 0);
         PdfUtil.createPDFCell(tableFont, table, data.get("remark").toString(), Element.ALIGN_LEFT, 7, 0);
@@ -245,8 +245,6 @@ public class PdfUtil {
         document.add(foot);
 
 
-
-
         //
 //
 ////        //段落
@@ -384,7 +382,8 @@ public class PdfUtil {
 //
 //
 //        document.add(table);
-}
+    }
+
     public static String getLineStr(String str) {
         StringBuilder result = new StringBuilder();
         for (int i = 0; i < str.length(); i++) {
@@ -392,6 +391,7 @@ public class PdfUtil {
         }
         return result.toString();
     }
+
     public static void dealDrillBody(Document document, PdfPTable table, Font tableFont, Map<String, Object> data) throws Exception {
         //第一行
         createPDFCell(tableFont, table, "演练单位", Element.ALIGN_CENTER, 1, 1);