From 00e4715a062585ad8e4f9dbaea8910b06e8ff228 Mon Sep 17 00:00:00 2001
From: whycxzp <perryhsu@163.com>
Date: 星期三, 07 十二月 2022 12:01:45 +0800
Subject: [PATCH] 流程卡和SOP更新

---
 src/main/java/com/whyc/service/WorksheetMainService.java |   88 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 86 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/whyc/service/WorksheetMainService.java b/src/main/java/com/whyc/service/WorksheetMainService.java
index ed0b7de..924551c 100644
--- a/src/main/java/com/whyc/service/WorksheetMainService.java
+++ b/src/main/java/com/whyc/service/WorksheetMainService.java
@@ -14,6 +14,8 @@
 import com.whyc.mapper.WorksheetMainMapper;
 import com.whyc.pojo.*;
 import com.whyc.util.CommonUtil;
+import com.whyc.util.Word2PdfAsposeUtil;
+import com.whyc.util.WordUtil;
 import com.whyc.util.Zip4jUtil;
 import org.aspectj.util.FileUtil;
 import org.springframework.beans.BeanUtils;
@@ -25,6 +27,7 @@
 
 import javax.annotation.Resource;
 import javax.mail.MessagingException;
+import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 import java.io.IOException;
 import java.text.SimpleDateFormat;
@@ -737,12 +740,13 @@
     public Response addProductProcedureAndSOP(ProcedureDocApproving approving, DocUser user) throws IOException, MessagingException {
         WorksheetMain main = new WorksheetMain();
          //瀛樺偍涓婁紶淇℃伅鍒颁富琛�,鑺傜偣琛�
-        //鏂囦欢淇濆瓨鍦�/doc_file/procedure_approving/xxx.doc
+        //鏂囦欢淇濆瓨鍦�/doc_file/procedure_approving/xxx_鏃堕棿鎴�.doc
         MultipartFile multipartFile = approving.getMultipartFile();
         String originalFilename = multipartFile.getOriginalFilename();
         String rootFile = CommonUtil.getRootFile();
         Date date = new Date();
-        String suffixFilePath = "procedure_approving" + File.separator + date.getTime() + "_" + originalFilename;
+        String filename = originalFilename.replace(".doc","_"+date.getTime()+".doc");
+        String suffixFilePath = "procedure_approving" + File.separator + filename;
         String outFilePath = rootFile + suffixFilePath;
         File outFile = new File(outFilePath);
         multipartFile.transferTo(outFile);
@@ -808,4 +812,84 @@
 
         return new Response().setII(1,"涓婁紶瀹屾垚");
     }
+
+    /**
+     * 缁熻鏁伴噺:
+     *  鎴戠殑鎻愪氦
+     *  寰呭鐞�
+     *  宸插鐞�
+     * @param user
+     * @return
+     */
+    public Map<String, Integer> getProcedureDocApprovingStatusStatistic(DocUser user) {
+        Map<String,Integer> map = new HashMap<>();
+
+        //鎴戠殑鎻愪氦
+        QueryWrapper<WorksheetMain> query = Wrappers.query();
+        query.eq("create_user_id",user.getId()).in("type",EnumWorksheetType.ProductProcedure.getType(),EnumWorksheetType.SOP.getType());
+        List<WorksheetMain> worksheetMains = mainMapper.selectList(query);
+        map.put("mySubmit",worksheetMains.size());
+        //寰呭鐞唡宸插鐞�
+        int handlingCount = 0;
+        int handledCount = 0;
+        List<WorksheetLink> links = linkMapper.getProcedureDocApprovingByUserId(user.getId());
+        for (WorksheetLink link : links) {
+            //dealType鐨勫�间负涓昏〃鐨勭姸鎬�
+            if(link.getDealType() == 1 && link.getLinkStatus() == 0){ //鏈鐞嗕笖瀹℃壒鏈粨鏉�
+                handlingCount++;
+            }else if(link.getLinkStatus() == 1 || link.getLinkStatus() ==2){ //宸茬‘璁ゆ垨宸叉嫆缁�
+                handledCount++;
+            }
+        }
+        map.put("handling",handlingCount);
+        map.put("handled",handledCount);
+        return map;
+    }
+
+    public Response procedurePreview(HttpServletResponse response, int mainId) throws IOException {
+        //鏌ヨ褰撳墠鍗曟嵁瀹℃壒浜虹殑纭鐘舵��
+        ProcedureDocApproving approving = procedureDocApprovingService.getByMainId(mainId);
+        List<WorksheetLink> linkList = linkMapper.getList(mainId);
+        String fzr = linkList.get(0).getLinkStatus() == 1 ? linkList.get(0).getDealUsername():"";
+        String bz = linkList.get(1).getLinkStatus() == 1 ? linkList.get(1).getDealUsername():"";
+        String zz = linkList.get(2).getLinkStatus() == 1 ? linkList.get(2).getDealUsername():"";
+        String pb = linkList.get(3).getLinkStatus() == 1 ? linkList.get(3).getDealUsername():"";
+        List<String> list = new LinkedList();
+        list.add(fzr);
+        list.add(bz);
+        list.add(zz);
+        list.add(pb);
+        //鑾峰彇word妯℃澘鍏蜂綋鏂囦欢
+
+        long currentTimeMillis = System.currentTimeMillis();
+        String projectDir = CommonUtil.getProjectDir();
+        String fileRelativePath = approving.getFile();
+        String inFilePath = projectDir + File.separator + fileRelativePath;
+        String outFilePath = inFilePath.replace(".doc","_"+currentTimeMillis+".doc");
+        WordUtil.fillValue(inFilePath,outFilePath,list);
+        //pdf甯︽按鍗扮殑鍦板潃 /doc_file/procedure_approving/xxx.doc
+        String suffixOutPdfFilePath = "doc_file" + File.separator + "procedure_approving" + File.separator + outFilePath.substring(outFilePath.lastIndexOf(File.separator)+1,outFilePath.lastIndexOf(".")) + ".pdf";
+        String outPdfFilePath = projectDir + File.separator + suffixOutPdfFilePath;
+        Word2PdfAsposeUtil.doc2pdfWithWaterMark(outFilePath,outPdfFilePath,true);
+        return new Response().setII(1,suffixOutPdfFilePath);
+        /*try {
+            // 杞爜闃叉涔辩爜
+            //resp.addHeader("Content-Disposition", "attachment;filename=" + new String(softwareName.getBytes("UTF-8"), "ISO8859-1"));
+            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode ( fileRelativePath.substring(fileRelativePath.lastIndexOf(File.separator+1)), "utf-8"));
+            OutputStream out = response.getOutputStream();
+            FileInputStream in = new FileInputStream(outFilePath);
+            int len=0;
+            byte[] buffer =new byte[1024];
+            //7. 灏嗙紦鍐插尯涓殑鏁版嵁杈撳嚭
+            while ((len=in.read(buffer))>0){
+                out.write(buffer,0,len);
+            }
+            in.close();
+            out.close();
+        } catch (FileNotFoundException | UnsupportedEncodingException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }*/
+    }
 }

--
Gitblit v1.9.1