Quellcode durchsuchen

新增电签尺寸修改\任务查看废除人\导入表格日期不回显

DengLinLang vor 2 Wochen
Ursprung
Commit
a9e973209d

+ 42 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java

@@ -1443,6 +1443,48 @@ public class TaskController extends BladeController {
                 })
                 .filter(Objects::nonNull) //过滤掉为null的任务
                 .collect(Collectors.toList());
+        //所有满足条件的任务 转map
+        Map<Long, Task> taskMap = new HashMap<>();
+        Map<String, List<OperationLog>> operationLogMap = new HashMap<>();
+        List<Long> taskIds = pageList.stream().filter(b -> "已废除".equals(b.getTaskStatusName())).map(BusinessTaskPageVO::getTaskId).collect(Collectors.toList());
+        if (ObjectUtil.isNotEmpty(taskIds)){
+            String joinTaskIds = StringUtils.join(taskIds, ",");
+            List<Task> tasks = jdbcTemplate.query("select id, create_time,form_data_id from u_task where id in ( " + joinTaskIds+")", new BeanPropertyRowMapper<>(Task.class));
+             taskMap = tasks.stream()
+                    .collect(Collectors.toMap(
+                            Task::getId,
+                            task -> task));
+        }
+        //所有满足条件的日志 转map
+        String logQuery = "select business_id,create_user_name ,create_time from u_operation_log where  operation_content like '%废除%'";
+        List<OperationLog> operationLogs = jdbcTemplate.query(logQuery, new BeanPropertyRowMapper<>(OperationLog.class));
+        if(ObjectUtil.isNotEmpty(operationLogs)){
+             operationLogMap = operationLogs.stream().collect(Collectors.groupingBy(OperationLog::getBusinessId));
+        }
+        for (BusinessTaskPageVO businessTaskPageVO : pageList) {
+            if("已废除".equals(businessTaskPageVO.getTaskStatusName())){
+                Long taskId = businessTaskPageVO.getTaskId();
+                Task task = taskMap.get(taskId);
+                if (ObjectUtil.isEmpty(task)){
+                    continue;
+                }
+                //任务创建时间
+                Date createTime = task.getCreateTime();
+                //废除时间肯定在任务创建时间之后  选择距离当前任务创建时间最近的一条数据
+                List<OperationLog> operationLogsF = operationLogMap.get(task.getFormDataId());
+                /*List<OperationLog> operationLogs = jdbcTemplate.query("select create_user_name ,create_time from u_operation_log where business_id = '" +
+                                task.getFormDataId() + "'and operation_content like '%废除%' and create_time >= '"+format+"' ORDER BY ABS(TIMESTAMPDIFF(SECOND, '"+format+"', create_time)) LIMIT 1"
+                        , new BeanPropertyRowMapper<>(OperationLog.class));*/
+                if(ObjectUtil.isNotEmpty(operationLogsF)){
+                    Optional<OperationLog> min = operationLogsF.stream().filter(o -> o.getCreateTime().compareTo(createTime) >= 0)
+                            .min(Comparator.comparing(t -> t.getCreateTime().getTime() - createTime.getTime()));
+                    if (min.isPresent()){
+                        OperationLog operationLog = min.get();
+                        businessTaskPageVO.setEVisaStatus(businessTaskPageVO.getEVisaStatus()+":"+operationLog.getCreateUserName()+"-"+operationLog.getCreateTime());
+                    }
+                }
+            }
+        }
         page.setRecords(pageList);
         page.setTotal(totalCount);
         return R.data(page);

+ 2 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeContractController.java

@@ -591,7 +591,8 @@ public class WbsTreeContractController extends BladeController {
         };
         for (String pattern : patterns) {
             Pattern regex = Pattern.compile(pattern);
-            Matcher matcher = regex.matcher(inputDateStr);
+            String inputDateStrNew = inputDateStr.replace(" ", "");
+            Matcher matcher = regex.matcher(inputDateStrNew);
             if (matcher.find()) {
                 String startDateStr = matcher.group(1);
                 String endDateStr = matcher.group(2);

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/SignPfxFilePreServiceImpl.java

@@ -178,7 +178,7 @@ public class SignPfxFilePreServiceImpl implements ISignPfxFilePreService {
         }else {
             FileUtils.compressImage(file1.getInputStream(),compressImgPath, wide,high);
         }
-        PdfAddimgUtil.pdfAddImgInfoNew(pdfPath, String.join(",", sign),textMap,compressImgPath);
+        PdfAddimgUtil.PrepdfAddImgInfoNew(pdfPath, String.join(",", sign),textMap,compressImgPath);
         //压缩后的图片上传oss
         SignPfxFilePreVo signPfxFilePreVo = new SignPfxFilePreVo();
         signPfxFilePreVo.setWide(wide);

+ 81 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/PdfAddimgUtil.java

@@ -142,6 +142,87 @@ public class PdfAddimgUtil {
         stamper.close();
         reader.close();
     }
+    //后管新增电签预览添加图片信息方法
+    public static void PrepdfAddImgInfoNew(String pdfUrl, String keyword, Map<Long, TextdictInfo> textMap ,String signImg) throws Exception {
+        File pdfFile = new File(pdfUrl);
+        byte[] pdfData = new byte[(int) pdfFile.length()];
+        FileInputStream inputStream = null;
+        try {
+            inputStream = new FileInputStream(pdfFile);
+            inputStream.read(pdfData);
+        } catch (IOException e) {
+            throw e;
+        } finally {
+            if (inputStream != null) {
+                try {
+                    inputStream.close();
+                } catch (IOException e) {
+                    inputStream.close();
+                }
+            }
+        }
+
+
+        List<PDFIndexInfo> positions = findKeywordPostions(pdfData, keyword);
+
+        System.out.println("total:" + positions.size());
+        if (positions != null && positions.size() > 0) {
+
+            for (int i = 0; i < positions.size(); i++) {
+
+                PDFIndexInfo pdfIndexInfo = positions.get(i);
+                float[] position = pdfIndexInfo.getDataInfo();
+                TextdictInfo textdictInfo = textMap.get(Func.toLong(pdfIndexInfo.getPkeyid()));
+                float pyzbx = 0;
+                float pyzby = 0;
+                String type ="2";
+                if(textdictInfo!=null){
+                    pyzbx = Func.toFloat(textdictInfo.getPyzbx());
+                    pyzby = Func.toFloat(textdictInfo.getPyzby());
+                    type = textdictInfo.getType()+"";
+                }
+                PreGaizhang(pdfFile, new File(pdfUrl), (int) position[0], position[1], position[2], signImg,pyzbx,pyzby,type);
+            }
+        }
+    }
+
+
+    //后管新增电签预览盖章方法
+    public static void PreGaizhang(File src, File dest, int page, float x, float y, String imagePath,float pyzbx,float pyzby,String type) throws Exception {
+        // 读取模板文件
+        InputStream input = new FileInputStream(src);
+        PdfReader reader = new PdfReader(input);
+        PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
+        Rectangle pageSize = reader.getPageSize(1);
+        float height = pageSize.getHeight();
+        float width = pageSize.getWidth();
+        if(type.equals("6")){
+            x = width * x - 27+pyzbx;
+            y = height - height * y - 30+pyzby;
+            imagePath = "/Users/hongchuangyanfa/Desktop/print/ht1234567890.png";
+        }else{
+            x = width * x - 20+pyzbx;
+            y = height - height * y - 8+pyzby;
+        }
+
+        // 读图片
+        Image image = Image.getInstance(imagePath);
+
+        // 获取操作的页面
+        PdfContentByte under = stamper.getOverContent(page);
+        // 添加图片
+
+        /*// 设置图片的新宽度和高度
+        float newWidth = 75f; // 新的宽度
+        float newHeight = image.getScaledHeight() * (newWidth / image.getScaledWidth()); // 根据宽度计算高度
+        image.scaleAbsolute(newWidth, newHeight); // 设置图片的新尺寸*/
+        //调整图片尺寸
+        image.setAbsolutePosition(x, y);
+        under.addImage(image);
+        // 假设的under.addImage方法,需要传入图片路径和大小参数
+        stamper.close();
+        reader.close();
+    }
 
     /**
      * 【功能描述:添加图片和文字水印】 【功能详细描述:功能详细描述】