zhuzeyu 11 months ago
parent
commit
f24aada52f

+ 7 - 3
src/main/java/cn/ezhizao/common/utils/pdf/PdfUtils.java

@@ -121,7 +121,7 @@ public class PdfUtils {
      * @throws DocumentException
      */
     public static ByteArrayOutputStream addImage(String inputFile, String imagePath, float x, float y, float width,
-                                                 float height,int rotation) throws IOException, DocumentException {
+                                                 float height,int rotation,float opacity) throws IOException, DocumentException {
         // 读取原pdf
         PdfReader reader = new PdfReader(inputFile);
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -131,14 +131,14 @@ public class PdfUtils {
         // 给每一页添加水印
         for (int i = 1; i <= reader.getNumberOfPages(); i++) {
             PdfContentByte waterMark = stamper.getOverContent(i);
-            addImage(waterMark, imagePath, x, y, width, height,rotation);
+            addImage(waterMark, imagePath, x, y, width, height,rotation,opacity);
         }
         stamper.close();
 
         return bos;
     }
 
-    private static void addImage(PdfContentByte waterMar, String imagePath, float x, float y, float width, float height,int rotation)
+    private static void addImage(PdfContentByte waterMar, String imagePath, float x, float y, float width, float height,int rotation, float opacity)
             throws DocumentException, IOException {
         waterMar.beginText();
         // 设置水印对齐方式 水印内容 X坐标 Y坐标 旋转角度
@@ -146,7 +146,11 @@ public class PdfUtils {
         img.setAbsolutePosition(x, y);
         img.scaleAbsolute(width, height);
         System.out.println(img.getImageRotation()+rotation);
+        PdfGState gs = new PdfGState();
+        // 设置填充字体不透明度为0.2f
+        gs.setFillOpacity(opacity);
         img.setRotationDegrees(rotation);
+        waterMar.setGState(gs);
         waterMar.addImage(img);
         // 设置水印颜色
         waterMar.setColorFill(BaseColor.GRAY);

+ 64 - 30
src/main/java/cn/ezhizao/project/business/technologicalProcessDetailDrawing/controller/BizTechnologicalProcessDetailDrawingController.java

@@ -158,6 +158,12 @@ public class BizTechnologicalProcessDetailDrawingController extends BaseControll
         person.setUserId(SecurityUtils.getLoginUser().getUser().getUserId());
         String filePath = RuoYiConfig.getProfile();
         List<BizPersonalSeal> personList = bizPersonalSealService.getList(person);
+        // 获取当前日期
+        LocalDate currentDate = LocalDate.now();
+        // 定义日期格式
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
+        // 格式化日期
+        String formattedDate = currentDate.format(formatter);
         if(personList.isEmpty()){
             return error("请先上传个人章");
         }
@@ -175,9 +181,10 @@ public class BizTechnologicalProcessDetailDrawingController extends BaseControll
                 //上传调整尺寸
 
 
-                PdfUtils.reSized(filePath + url,filePath +url.substring(0, url.length()-4) + "制作" + url.substring(url.length()-4),60,"height");
+                PdfUtils.reSized(filePath + url,filePath +url.substring(0, url.length()-4) + "制作" + url.substring(url.length()-4),100,"height");
                 addText(filePath +url.substring(0, url.length()-4) + "制作" + url.substring(url.length()-4),filePath+url.substring(0, url.length()-4) + "制作人" + url.substring(url.length()-4),"制定人:",550,75,12,270);
-                addImage(filePath+url.substring(0, url.length()-4) + "制作人" + url.substring(url.length()-4),filePath+url.substring(0, url.length()-4) + "制作完成" + url.substring(url.length()-4),filePath+personalSeal,530,30,45,15,270);
+                addText(filePath +url.substring(0, url.length()-4) + "制作人" + url.substring(url.length()-4),filePath+url.substring(0, url.length()-4) + "制作时间" + url.substring(url.length()-4),formattedDate,500,75,12,270);
+                addImage(filePath+url.substring(0, url.length()-4) + "制作时间" + url.substring(url.length()-4),filePath+url.substring(0, url.length()-4) + "制作完成" + url.substring(url.length()-4),filePath+personalSeal,515,40,30,30,270,1);
                 item.setUrl("/profile/"+url.substring(0, url.length()-4) + "制作完成" + url.substring(url.length()-4));
                 bizTechnologicalProcessDetailDrawingService.save(item);
                 break;
@@ -189,8 +196,8 @@ public class BizTechnologicalProcessDetailDrawingController extends BaseControll
                         item.setReviewer(SecurityUtils.getLoginUser().getUser().getNickName());
                         item.setStatus(1);
                         addText(filePath+ url,filePath +url.substring(0, url.length()-4) + "审核" + url.substring(url.length()-4),"审核人:",470,75,12,270);
-
-                        addImage(filePath +url.substring(0, url.length()-4) + "审核" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "审核完成" + url.substring(url.length()-4),filePath+personalSeal,450,30,45,15,270);
+                        addText(filePath +url.substring(0, url.length()-4) + "审核" + url.substring(url.length()-4),filePath+url.substring(0, url.length()-4) + "审核时间" + url.substring(url.length()-4),formattedDate,420,75,12,270);
+                        addImage(filePath +url.substring(0, url.length()-4) + "审核时间" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "审核完成" + url.substring(url.length()-4),filePath+personalSeal,435,40,30,30,270,1);
                         item.setUrl("/profile/"+url.substring(0, url.length()-4) + "审核完成" + url.substring(url.length()-4));
                         bizTechnologicalProcessDetailDrawingService.updateById(item);
                         break;
@@ -209,6 +216,7 @@ public class BizTechnologicalProcessDetailDrawingController extends BaseControll
      * 批准逻辑
      * @param item
      */
+    @Transactional
     public void issuer (BizTechnologicalProcessDetailDrawing item,String personalSeal) throws DocumentException, IOException {
         item.setIssuerId(SecurityUtils.getLoginUser().getUser().getUserId());
         item.setIssuer(SecurityUtils.getLoginUser().getUser().getNickName());
@@ -236,23 +244,27 @@ public class BizTechnologicalProcessDetailDrawingController extends BaseControll
             String urlItem = "";
             urlItem = byId.getUrl();
             urlItem = urlItem.substring("/profile".length());
-            byId.setStatus(1);
+            byId.setStatus(2);
             byId.setAbandoned(1);
             byId.setVoided(SecurityUtils.getLoginUser().getUser().getNickName());
             byId.setVoidedId(SecurityUtils.getLoginUser().getUser().getUserId());
+            byId.setPattern("作废产品");
+            addImage(filePath+ urlItem,filePath +urlItem.substring(0, urlItem.length()-4) + "zf" + urlItem.substring(urlItem.length()-4),filePath+rem,290,880,40,15,300,0.8F);
+            addText(filePath +urlItem.substring(0, urlItem.length()-4) + "zf" + urlItem.substring(urlItem.length()-4),filePath +urlItem.substring(0, urlItem.length()-4) + "zfr" + urlItem.substring(urlItem.length()-4),"作废申请人:",310,75,12,270);
+            addText(filePath +urlItem.substring(0, urlItem.length()-4) + "zfr" + urlItem.substring(urlItem.length()-4),filePath+urlItem.substring(0, urlItem.length()-4) + "zfdate" + urlItem.substring(urlItem.length()-4),formattedDate,500,75,12,270);
 
-            addImage(filePath+ urlItem,filePath +urlItem.substring(0, urlItem.length()-4) + "zf" + urlItem.substring(urlItem.length()-4),filePath+rem,275,810,40,15,300);
-            addText(filePath +urlItem.substring(0, urlItem.length()-4) + "zf" + urlItem.substring(urlItem.length()-4),filePath +urlItem.substring(0, urlItem.length()-4) + "zfr" + urlItem.substring(urlItem.length()-4),"作废人:",310,75,12,270);
-            addImage(filePath +urlItem.substring(0, urlItem.length()-4) + "zfr" + urlItem.substring(urlItem.length()-4),filePath +urlItem.substring(0, urlItem.length()-4) + "zfover" + urlItem.substring(urlItem.length()-4),filePath+personalSeal,290,30,45,15,270);
+            addImage(filePath +urlItem.substring(0, urlItem.length()-4) + "zfdate" + urlItem.substring(urlItem.length()-4),filePath +urlItem.substring(0, urlItem.length()-4) + "zfover" + urlItem.substring(urlItem.length()-4),filePath+personalSeal,275,40,30,30,270,1);
            byId.setUrl("/profile/" +urlItem.substring(0, urlItem.length()-4) + "zfover" + urlItem.substring(urlItem.length()-4));
             bizTechnologicalProcessDetailDrawingService.updateById(byId);
         }
         //判断盖章逻辑
         if (item.getAbandoned() ==1){
             //加盖废弃章,不需要盖其他章
-            addImage(filePath+ url,filePath +url.substring(0, url.length()-4) + "zf" + url.substring(url.length()-4),filePath+rem,290,820,40,15,300);
-            addText(filePath +url.substring(0, url.length()-4) + "zf" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "zfr" + url.substring(url.length()-4),"作废人:",310,75,12,270);
-            addImage(filePath +url.substring(0, url.length()-4) + "zfr" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "zfover" + url.substring(url.length()-4),filePath+personalSeal,290,30,45,15,270);
+            addImage(filePath+ url,filePath +url.substring(0, url.length()-4) + "zf" + url.substring(url.length()-4),filePath+rem,290,880,40,15,300,0.8F);
+            addText(filePath +url.substring(0, url.length()-4) + "zf" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "zfr" + url.substring(url.length()-4),"作废批准人:",230,75,12,270);
+            addText(filePath +url.substring(0, url.length()-4) + "zfr" + url.substring(url.length()-4),filePath+url.substring(0, url.length()-4) + "zfdate" + url.substring(url.length()-4),formattedDate,180,75,12,270);
+
+            addImage(filePath +url.substring(0, url.length()-4) + "zfdate" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "zfover" + url.substring(url.length()-4),filePath+personalSeal,195,40,30,30,270,1);
             item.setUrl("/profile/"+url.substring(0, url.length()-4) + "zfover" + url.substring(url.length()-4));
             bizTechnologicalProcessDetailDrawingService.updateById(item);
             return;
@@ -260,26 +272,29 @@ public class BizTechnologicalProcessDetailDrawingController extends BaseControll
         //盖批准和审核章还有批准日期
         addText(filePath+ url,filePath +url.substring(0, url.length()-4) + "pz" + url.substring(url.length()-4),"批准人:",390,75,12,270);
         //批准章
-        addImage(filePath +url.substring(0, url.length()-4) + "pz" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "pzz" + url.substring(url.length()-4),filePath+isu,400,800,60,55,300);
+        addImage(filePath +url.substring(0, url.length()-4) + "pz" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "pzz" + url.substring(url.length()-4),filePath+isu,400,860,60,55,300,0.8F);
         //批准章上的日期
-        addText(filePath +url.substring(0, url.length()-4) + "pzz" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "pzdate" + url.substring(url.length()-4),formattedDate,427,853,8,300);
+        addText(filePath +url.substring(0, url.length()-4) + "pzz" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "pzdate" + url.substring(url.length()-4),formattedDate,427,913,8,300);
         //个人章
-        addImage(filePath +url.substring(0, url.length()-4) + "pzdate" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "pzr" + url.substring(url.length()-4),filePath+personalSeal,370,30,45,15,270);
+        addImage(filePath +url.substring(0, url.length()-4) + "pzdate" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "pzr" + url.substring(url.length()-4),filePath+personalSeal,355,40,30,30,270,1);
+        //批准日期
+        addText(filePath +url.substring(0, url.length()-4) + "pzr" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "pzrdate" + url.substring(url.length()-4),formattedDate,340,75,12,270);
+
         //受控章
-        addImage(filePath +url.substring(0, url.length()-4) + "pzr" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "pzover" + url.substring(url.length()-4),filePath+reviewer,465,810,45,28,300);
+        addImage(filePath +url.substring(0, url.length()-4) + "pzrdate" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "pzover" + url.substring(url.length()-4),filePath+reviewer,465,870,45,28,300,0.8F);
         item.setUrl("/profile/" +url.substring(0, url.length()-4) + "pzover" + url.substring(url.length()-4));
         if (item.getIdentification()){
             //盖重章
-            addImage(filePath +url.substring(0, url.length()-4) + "pzover" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "z" + url.substring(url.length()-4),filePath+heavy,320,810,40,40,300);
+            addImage(filePath +url.substring(0, url.length()-4) + "pzover" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "z" + url.substring(url.length()-4),filePath+heavy,320,870,40,40,300,0.8F);
             item.setUrl("/profile" +url.substring(0, url.length()-4) + "z" + url.substring(url.length()-4));
         }
         if (item.getMarkD() ){
             //因为地址不同判断重章有没有盖到
             //盖D章
             if (!item.getIdentification()){
-                addImage(filePath +url.substring(0, url.length()-4) + "pzover" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "dover" + url.substring(url.length()-4),filePath+D,365,810,40,40,300);
+                addImage(filePath +url.substring(0, url.length()-4) + "pzover" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "dover" + url.substring(url.length()-4),filePath+D,365,870,40,40,300,0.8F);
             }else {
-                addImage(filePath +url.substring(0, url.length()-4) + "z" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "dover" + url.substring(url.length()-4),filePath+D,365,810,40,40,300);
+                addImage(filePath +url.substring(0, url.length()-4) + "z" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "dover" + url.substring(url.length()-4),filePath+D,365,870,40,40,300,0.8F);
             }
             item.setUrl("/profile/" +url.substring(0, url.length()-4) + "dover" + url.substring(url.length()-4));
 
@@ -321,11 +336,28 @@ public String getPublicSeal(String code) {
         if(personList.isEmpty()){
             return error("请先上传个人章");
         }
+        String personalSeal = personList.get(0).getUrl().substring("/profile".length());
+        LocalDate currentDate = LocalDate.now();
+        // 定义日期格式
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
+        // 格式化日期
+        String formattedDate = currentDate.format(formatter);
         for(BizTechnologicalProcessDetailDrawing  item: processDetailDrawing){
+            String url = "";
+            url = item.getUrl();
+            url = url.substring("/profile".length());
+            String filePath = RuoYiConfig.getProfile();
             item.setStatus(1);
             item.setAbandoned(1);
+            item.setPattern("作废产品");
             item.setVoided(SecurityUtils.getLoginUser().getUser().getNickName());
             item.setVoidedId(SecurityUtils.getLoginUser().getUser().getUserId());
+
+            addText(filePath +url.substring(0, url.length()-4) + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "zfr" + url.substring(url.length()-4),"作废申请人:",310,75,12,270);
+            addText(filePath +url.substring(0, url.length()-4) + "zfr" + url.substring(url.length()-4),filePath+url.substring(0, url.length()-4) + "zfdate" + url.substring(url.length()-4),formattedDate,260,75,12,270);
+
+            addImage(filePath +url.substring(0, url.length()-4) + "zfdate" + url.substring(url.length()-4),filePath +url.substring(0, url.length()-4) + "zfover" + url.substring(url.length()-4),filePath+personalSeal,275,40,30,30,270,1);
+            item.setUrl("/profile/"+url.substring(0, url.length()-4) + "zfover" + url.substring(url.length()-4));
             bizTechnologicalProcessDetailDrawingService.updateById(item);
         }
 
@@ -366,11 +398,12 @@ public String getPublicSeal(String code) {
     public AjaxResult replaceDrawing(@RequestBody BizTechnologicalProcessDetailDrawing processDetailDrawing) throws NoSuchFieldException, IllegalAccessException, COSVisitorException, DocumentException, IOException {
         //根据parentId插叙旧图纸
         BizTechnologicalProcessDetailDrawing id = bizTechnologicalProcessDetailDrawingService.query().eq("id", processDetailDrawing.getParentId()).one();
-        id.setStatus(1);
-        id.setAbandoned(1);
-        id.setVoided(SecurityUtils.getLoginUser().getUser().getNickName());
-        id.setVoidedId(SecurityUtils.getLoginUser().getUser().getUserId());
-        bizTechnologicalProcessDetailDrawingService.updateById(id);
+//        id.setStatus(1);
+//        id.setAbandoned(1);
+//        id.setPattern("作废产品");
+//        id.setVoided(SecurityUtils.getLoginUser().getUser().getNickName());
+//        id.setVoidedId(SecurityUtils.getLoginUser().getUser().getUserId());
+//        bizTechnologicalProcessDetailDrawingService.updateById(id);
 
 
 
@@ -387,17 +420,18 @@ public String getPublicSeal(String code) {
         String url = "";
         url = processDetailDrawing.getUrl();
         url = url.substring("/profile".length());
-        processDetailDrawing.setMarkD(id.getMarkD());
-        processDetailDrawing.setIdentification(id.getIdentification());
 
-        processDetailDrawing.setPattern("替换");
+//        processDetailDrawing.setMarkD(id.getMarkD());
+//        processDetailDrawing.setIdentification(id.getIdentification());
+        processDetailDrawing.setDrawingName(id.getDrawingName());
+        processDetailDrawing.setPattern("替换产品");
         processDetailDrawing.setProducerId(SecurityUtils.getLoginUser().getUser().getUserId());
         processDetailDrawing.setProducer(SecurityUtils.getLoginUser().getUser().getNickName());
         processDetailDrawing.setTechnologicalProcessDetailId(id.getTechnologicalProcessDetailId());
         processDetailDrawing.setTechnologicalProcessId(id.getTechnologicalProcessId());
-        PdfUtils.reSized(filePath + url,filePath +url.substring(0, url.length()-4) + "制作" + url.substring(url.length()-4),60,"height");
+        PdfUtils.reSized(filePath + url,filePath +url.substring(0, url.length()-4) + "制作" + url.substring(url.length()-4),100,"height");
         addText(filePath +url.substring(0, url.length()-4) + "制作" + url.substring(url.length()-4),filePath+url.substring(0, url.length()-4) + "制作人" + url.substring(url.length()-4),"制定人:",550,75,12,270);
-        addImage(filePath+url.substring(0, url.length()-4) + "制作人" + url.substring(url.length()-4),filePath+url.substring(0, url.length()-4) + "制作完成" + url.substring(url.length()-4),filePath+personalSeal,530,30,45,15,270);
+        addImage(filePath+url.substring(0, url.length()-4) + "制作人" + url.substring(url.length()-4),filePath+url.substring(0, url.length()-4) + "制作完成" + url.substring(url.length()-4),filePath+personalSeal,530,30,45,15,270,1);
         processDetailDrawing.setUrl("/profile/"+url.substring(0, url.length()-4) + "制作完成" + url.substring(url.length()-4));
 
         return toAjax(bizTechnologicalProcessDetailDrawingService.save(processDetailDrawing));
@@ -591,8 +625,8 @@ public String getPublicSeal(String code) {
      * @throws DocumentException
      * @throws IOException
      */
-    public void addImage(String srcPath,String resultPath,String imgPath,Integer x,Integer y,Integer width,Integer height,Integer rotation) throws DocumentException, IOException {
-        ByteArrayOutputStream bos = PdfUtils.addImage(srcPath, imgPath, x, y, width, height,rotation);
+    public void addImage(String srcPath,String resultPath,String imgPath,Integer x,Integer y,Integer width,Integer height,Integer rotation,float opacity) throws DocumentException, IOException {
+        ByteArrayOutputStream bos = PdfUtils.addImage(srcPath, imgPath, x, y, width, height,rotation, opacity);
         FileOutputStream out = new FileOutputStream(resultPath);
         out.write(bos.toByteArray());
         out.close();

+ 1 - 0
src/main/resources/mybatis/business/technologicalProcessDetailDrawing/BizTechnologicalProcessDetailDrawingMapper.xml

@@ -44,6 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by create_time desc
     </select>
 
+
     <select id="getDrawingList" parameterType="BizTechnologicalProcessDetailDrawing" resultMap="BizTechnologicalProcessDetailDrawingResult">
         SELECT * FROM biz_technological_process_detail_drawing
         <trim prefix=" WHERE" suffix="" suffixOverrides="AND">