<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          SpringBoot實現(xiàn)電子文件簽字+合同系統(tǒng)!

          共 21471字,需瀏覽 43分鐘

           ·

          2022-11-08 21:04

          關(guān)注我們,設(shè)為星標,每天7:40不見不散,架構(gòu)路上與您共享

          回復架構(gòu)師獲取資源


          大家好,我是你們的朋友架構(gòu)君,一個會寫代碼吟詩的架構(gòu)師。

          'javajgs.com';



          原文:
          blog.csdn.net/weixin_44385486/article/details/126481493


          一、前言

          今天公司領(lǐng)導提出一個功能,說實現(xiàn)一個文件的簽字+蓋章功能,然后自己進行了簡單的學習,對文檔進行數(shù)字簽名與簽署紙質(zhì)文檔的原因大致相同,數(shù)字簽名通過使用計算機加密來驗證 (身份驗證:驗證人員和產(chǎn)品所聲明的身份是否屬實的過程。例如,通過驗證用于簽名代碼的數(shù)字簽名來確認軟件發(fā)行商的代碼來源和完整性。)數(shù)字信息,如文檔、電子郵件和宏。數(shù)字簽名有助于確保:真實性,完整性,不可否認性。目前市面上的電子簽章產(chǎn)品也是多樣化,但是不管是哪個廠家的產(chǎn)品,在線簽章簡單易用,同時也能保證簽章的有效性,防篡改,防偽造,穩(wěn)定,可靠就是好產(chǎn)品。

          此次開源的系統(tǒng)模擬演示了文件在OA系統(tǒng)中的流轉(zhuǎn),主要為辦公系統(tǒng)跨平臺在線處理Office文檔提供了完美的解決方案。Word文檔在線處理的核心環(huán)節(jié),包括:起草文檔、領(lǐng)導審批、核稿、領(lǐng)導蓋章、正式發(fā)文。PageOffice產(chǎn)品支持PC端Word文檔在線處理的所有環(huán)節(jié);MobOffice產(chǎn)品支持了移動端領(lǐng)導審批和領(lǐng)導蓋章的功能。支持PC端和移動端對文檔審批和蓋章的互認。然后此次博客中使用的卓正軟件的電子簽章采用自主知識產(chǎn)權(quán)的核心智能識別驗證技術(shù),確保文檔安全可靠。采用 COM、ActiveX嵌入式技術(shù)開發(fā),確保軟件能夠支持多種應(yīng)用。遵循《中華人民共和國電子簽名法》關(guān)于電子簽名的規(guī)范,同時支持國際通用的 RSA算法,符合國家安全標準。

          PageOffice和MobOffice產(chǎn)品結(jié)合使用為跨平臺處理Office文件提供了完美的解決方案,主要功能有word在線編輯保存和留痕,word和pdf文件在線蓋章(電子印章)。


          二、項目源碼及部署

          1、項目結(jié)構(gòu)及使用框架

          該簽字+蓋章流程系統(tǒng)使用了SpringBoot+thymeleaf實現(xiàn)的,然后jar包依賴使用了maven


          • 控制層
          @Controller
          @RequestMapping("/mobile")
          public class MobileOfficeController {

              @Value("${docpath}")
              private  String docPath;

              @Value("${moblicpath}")
              private  String moblicpath;

              @Autowired
              DocService m_docService;

              /**
               * 添加MobOffice的服務(wù)器端授權(quán)程序Servlet(必須)
               *
               */

              @RequestMapping("/opendoc")
              public void opendoc(HttpServletRequest request, HttpServletResponse response, HttpSession session,String type,String userName)throws  Exception {
                  String fileName = "";
                  userName= URLDecoder.decode(userName,"utf-8");

                  Doc doc=m_docService.getDocById(1);
                  if(type.equals("word")){
                      fileName = doc.getDocName();
                  }else{
                      fileName = doc.getPdfName();
                  }
                  OpenModeType openModeType = OpenModeType.docNormalEdit;

                  if (fileName.endsWith(".doc")) {
                      openModeType = OpenModeType.docNormalEdit;
                  } else if (fileName.endsWith(".pdf")) {
                      String mode = request.getParameter("mode");
                      if (mode.equals("normal")) {
                          openModeType = OpenModeType.pdfNormal;
                      } else {
                          openModeType = OpenModeType.pdfReadOnly;
                      }
                  }

                  MobOfficeCtrl mobCtrl = new MobOfficeCtrl(request,response);
                  mobCtrl.setSysPath(moblicpath);
                  mobCtrl.setServerPage("/mobserver.zz");
                  //mobCtrl.setZoomSealServer("http://xxx.xxx.xxx.xxx:8080/ZoomSealEnt/enserver.zz");
                  mobCtrl.setSaveFilePage("/mobile/savedoc?testid="+Math.random());
                  mobCtrl.webOpen("file://"+docPath+fileName,  openModeType , userName);
              }

              @RequestMapping("/savedoc")
              public  void  savedoc(HttpServletRequest request,  HttpServletResponse response){
                  FileSaver fs = new FileSaver(request, response);
                  fs.saveToFile(docPath+fs.getFileName());
                  fs.close();
              }
          }
          • 項目業(yè)務(wù)層源碼
          @Service
          public class DocServiceImpl implements DocService {
              @Autowired
              DocMapper docMapper;
              @Override
              public Doc getDocById(int id) throws Exception {
                  Doc  doc=docMapper.getDocById(id);
                  //如果doc為null的話,頁面所有doc.屬性都報錯
                  if(doc==null) {
                      doc=new Doc();
                  }
                  return doc;
              }

              @Override
              public Integer addDoc(Doc doc) throws Exception {
                 int id=docMapper.addDoc(doc);
                  return id;
              }

              @Override
              public Integer updateStatusForDocById(Doc doc) throws Exception {
                  int id=docMapper.updateStatusForDocById(doc);
                  return id;
              }

              @Override
              public Integer updateDocNameForDocById(Doc doc) throws Exception {
                  int id=docMapper.updateDocNameForDocById(doc);
                  return id;
              }

              @Override
              public Integer updatePdfNameForDocById(Doc doc) throws Exception {
                  int id=docMapper.updatePdfNameForDocById(doc);
                  return id;
              }
          }
          • 拷貝文件
          public class CopyFileUtil {
            //拷貝文件
            public static boolean copyFile(String oldPath, String newPath) throws Exception {
                boolean copyStatus=false;

                int bytesum = 0;
                int byteread = 0;
                File oldfile = new File(oldPath);
                if (oldfile.exists()) { //文件存在時
                    InputStream inStream = new FileInputStream(oldPath); //讀入原文件
                    FileOutputStream fs = new FileOutputStream(newPath);

                    byte[] buffer = new byte[1444];
                    int length;
                    while ((byteread = inStream.read(buffer)) != -1) {
                        bytesum += byteread; //字節(jié)數(shù) 文件大小
                        //System.out.println(bytesum);
                        fs.write(buffer, 0, byteread);
                    }
                    fs.close();
                    inStream.close();
                    copyStatus=true;
                }else{
                    copyStatus=false;
                }
                return copyStatus;
            }
          }
          • 二維碼源碼
          public class QRCodeUtil {
              private String codeText;//二維碼內(nèi)容
              private BarcodeFormat barcodeFormat;//二維碼類型
              private int width;//圖片寬度
              private int height;//圖片高度
              private String imageformat;//圖片格式
              private int backColorRGB;//背景色,顏色RGB的數(shù)值既可以用十進制表示,也可以用十六進制表示
              private int codeColorRGB;//二維碼顏色
              private ErrorCorrectionLevel errorCorrectionLevel;//二維碼糾錯能力
              private String encodeType;

              public QRCodeUtil() {
                  codeText = "www.zhuozhengsoft.com";
                  barcodeFormat = BarcodeFormat.PDF_417;
                  width = 400;
                  height = 400;
                  imageformat = "png";
                  backColorRGB = 0xFFFFFFFF;
                  codeColorRGB = 0xFF000000;
                  errorCorrectionLevel = ErrorCorrectionLevel.H;
                  encodeType = "UTF-8";
              }
              public QRCodeUtil(String text) {
                  codeText = text;
                  barcodeFormat = BarcodeFormat.PDF_417;
                  width = 400;
                  height = 400;
                  imageformat = "png";
                  backColorRGB = 0xFFFFFFFF;
                  codeColorRGB = 0xFF000000;
                  errorCorrectionLevel = ErrorCorrectionLevel.H;
                  encodeType = "UTF-8";
              }

              public String getCodeText() {
                  return codeText;
              }

              public void setCodeText(String codeText) {
                  this.codeText = codeText;
              }

              public BarcodeFormat getBarcodeFormat() {
                  return barcodeFormat;
              }

              public void setBarcodeFormat(BarcodeFormat barcodeFormat) {
                  this.barcodeFormat = barcodeFormat;
              }

              public int getWidth() {
                  return width;
              }

              public void setWidth(int width) {
                  this.width = width;
              }

              public int getHeight() {
                  return height;
              }

              public void setHeight(int height) {
                  this.height = height;
              }

              public String getImageformat() {
                  return imageformat;
              }

              public void setImageformat(String imageformat) {
                  this.imageformat = imageformat;
              }

              public int getBackColorRGB() {
                  return backColorRGB;
              }

              public void setBackColorRGB(int backColorRGB) {
                  this.backColorRGB = backColorRGB;
              }

              public int getCodeColorRGB() {
                  return codeColorRGB;
              }

              public void setCodeColorRGB(int codeColorRGB) {
                  this.codeColorRGB = codeColorRGB;
              }

              public ErrorCorrectionLevel getErrorCorrectionLevel() {
                  return errorCorrectionLevel;
              }

              public void setErrorCorrectionLevel(ErrorCorrectionLevel errorCorrectionLevel) {
                  this.errorCorrectionLevel = errorCorrectionLevel;
              }

              private BufferedImage toBufferedImage(BitMatrix bitMatrix) {
                  int width = bitMatrix.getWidth();
                  int height = bitMatrix.getHeight();
                  BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
                  for (int x = 0; x < width; x++) {
                      for (int y = 0; y < height; y++) {
                          image.setRGB(x, y, bitMatrix.get(x, y) ? this.codeColorRGB: this.backColorRGB);
                      }
                  }
                  return image;
              }

              private byte[] writeToBytes(BitMatrix bitMatrix)
                      throws IOException {

                  try {
                      BufferedImage bufferedimage = toBufferedImage(bitMatrix);

                      //將圖片保存到臨時路徑中
                      File file = java.io.File.createTempFile("~pic","."this.imageformat);
                      //System.out.println("臨時圖片路徑:"+file.getPath());
                      ImageIO.write(bufferedimage,this.imageformat,file);

                      //獲取圖片轉(zhuǎn)換成的二進制數(shù)組
                      FileInputStream fis = new FileInputStream(file);
                      int fileSize = fis.available();
                      byte[] imageBytes = new byte[fileSize];
                      fis.read(imageBytes);
                      fis.close();

                      //刪除臨時文件
                      if (file.exists()) {
                          file.delete();
                      }

                      return imageBytes;
                  } catch (Exception e) {
                      System.out.println(" Image err :" + e.getMessage());
                      return null;
                  }

              }

              //獲取二維碼圖片的字節(jié)數(shù)組
              public byte[] getQRCodeBytes()
                      throws IOException {

                  try {
                      MultiFormatWriter multiFormatWriter = new MultiFormatWriter();

                      //設(shè)置二維碼參數(shù)
                      Map hints = new HashMap();
                      if (this.errorCorrectionLevel != null) {
                          //設(shè)置二維碼的糾錯級別
                          hints.put(EncodeHintType.ERROR_CORRECTION, this.errorCorrectionLevel);
                      }

                      if (this.encodeType!=null && this.encodeType.trim().length() > 0) {
                          //設(shè)置編碼方式
                          hints.put(EncodeHintType.CHARACTER_SET, this.encodeType);
                      }

                      BitMatrix bitMatrix = multiFormatWriter.encode(this.codeText, BarcodeFormat.QR_CODE, this.width, this.height, hints);
                      byte[] bytes = writeToBytes(bitMatrix);

                      return bytes;
                  } catch (Exception e) {
                      e.printStackTrace();
                      return null;
                  }
              }
          }

          2、項目下載及部署

          • 項目源碼下載地址:https://download.csdn.net/download/weixin_44385486/86427996
          • 下載項目源碼后,使用idea導入slndemo項目并運行

          • 將項目slndemo下的slndemodata.zip壓縮包拷貝到本地D盤根目錄下并解壓

          • 點擊啟動項目



          三、功能展示

          1、項目啟動后登錄首頁

          • 項目地址:http://localhost:8888/pc/login
          • 賬戶:張三 密碼:123456

          2、系統(tǒng)首頁功能簡介

          這是一個簡單的Demo項目,模擬Word文件在辦公系統(tǒng)中的主要流轉(zhuǎn)環(huán)節(jié),并不意味著PageOffice產(chǎn)品只能支持這樣的文檔處理流程。PageOffice產(chǎn)品只提供文檔在線處理的功能,包括:打開、編輯、保存、動態(tài)填充、文檔合并、套紅、留痕、蓋章等上百項功能(詳細請參考PageOffice產(chǎn)品開發(fā)包中的示例),不提供流程控制功能,所以不管開發(fā)什么樣的Web系統(tǒng),只要是需要在線處理Office文檔,都可以根據(jù)自己的項目需要,調(diào)用PageOffice產(chǎn)品相應(yīng)的功能即可。「注意:為了簡化代碼邏輯,此演示程序只能創(chuàng)建一個文檔進行流轉(zhuǎn)?!?/strong>

          3、點擊起草文檔

          • 點擊起草文檔,點擊提交

          • 點擊代辦文檔,然后點擊編輯,當你點擊編輯時你沒有下載PageOffice,他會提醒你安裝,你點擊安裝之后,關(guān)閉瀏覽器,重新打開瀏覽器就能編輯了!

          • 我們使用了PageOffice企業(yè)版,必須要注冊序列化
          • 版 本:PageOffice企業(yè)版5(試用)
          • 序列號:35N8V-2YUC-LY77-W14XL

          • 當我們注冊成功以后,就可以編輯發(fā)布的文件或者公告了

          • 編輯好以后點擊保存

          • 點擊審批

          4、審批

          • 登錄李總審批

          • 退出系統(tǒng),然后輸入李總

          • 然后點擊批閱,下一步
          • 登錄趙六進行審核稿子

          5、審稿

          • 審稿
          • 審核然后到蓋章環(huán)節(jié)

          • 使用王總登錄進行蓋章

          6、蓋章和簽字的實現(xiàn)

          • 王總登錄

          • 點擊蓋章

          • 點擊加蓋印章

          • 我們蓋章前需要輸入姓名+密碼,需要輸入錯誤報錯

          • 正確的賬戶密碼是:
          • 賬戶:王五
          • 密碼:123456

          • 登錄成功后有選擇王五的個人章進行簽字

          • 簽字成功

          • 公司蓋章,重復以上步驟

          • 簽字蓋章成功

          7、完整簽字蓋章文件

          • 保存之后發(fā)布文件

          • 公司文件展示

          • 蓋章簽字后的文件


          到此文章就結(jié)束了。Java架構(gòu)師必看一個集公眾號、小程序、網(wǎng)站(3合1的文章平臺,給您架構(gòu)路上一臂之力,javajgs.com)。如果今天的文章對你在進階架構(gòu)師的路上有新的啟發(fā)和進步,歡迎轉(zhuǎn)發(fā)給更多人。歡迎加入架構(gòu)師社區(qū)技術(shù)交流群,眾多大咖帶你進階架構(gòu)師,在后臺回復“加群”即可入群。

          第23期已結(jié)束!第24期已開始,11月1號截止



          這些年小編給你分享過的干貨


          1.idea永久激活碼(親測可用)

          2.優(yōu)質(zhì)ERP系統(tǒng)帶進銷存財務(wù)生產(chǎn)功能(附源碼)

          3.優(yōu)質(zhì)SpringBoot帶工作流管理項目(附源碼)

          4.最好用的OA系統(tǒng),拿來即用(附源碼)

          5.SBoot+Vue外賣系統(tǒng)前后端都有(附源碼

          6.SBoot+Vue可視化大屏拖拽項目(附源碼)


          轉(zhuǎn)發(fā)在看就是最大的支持??

          瀏覽 58
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  精品黄色电影 | 亚洲成人免费视频 | 第四色婷婷五月天 | 成人性生活视预 | 人妻洗澡被强公日日澡 |