本文曾经收录到Github仓库,该仓库蕴含计算机根底、Java根底、多线程、JVM、数据库、Redis、Spring、Mybatis、SpringMVC、SpringBoot、分布式、微服务、设计模式、架构、校招社招分享等外围知识点,欢送star~

Github地址:https://github.com/Tyson0314/...


一、前言

明天公司领导提出一个性能,说实现一个文件的签字+盖章性能,而后本人进行了简略的学习,对文档进行数字签名与签订纸质文档的起因大致相同,数字签名通过应用计算机加密来验证 (身份验证:验证人员和产品所申明的身份是否属实的过程。例如,通过验证用于签名代码的数字签名来确认软件发行商的代码起源和完整性。)数字信息,如文档、电子邮件和宏。数字签名有助于确保:真实性,完整性,不可否认性。目前市面上的电子签章产品也是多样化,然而不论是哪个厂家的产品,在线签章简略易用,同时也能保障签章的有效性,防篡改,防伪造,稳固,牢靠就是好产品。

此次开源的系统模拟演示了文件在OA零碎中的流转,次要为办公零碎跨平台在线解决Office文档提供了完满的解决方案。Word文档在线解决的外围环节,包含:起草文档、领导审批、核稿、领导盖章、正式发文。PageOffice产品反对PC端Word文档在线解决的所有环节;MobOffice产品反对了挪动端领导审批和领导盖章的性能。反对PC端和挪动端对文档审批和盖章的互认。而后此次博客中应用的卓正软件的电子签章采纳自主知识产权的外围智能辨认验证技术,确保文档安全可靠。采纳 COM、ActiveX嵌入式技术开发,确保软件可能反对多种利用。遵循《中华人民共和国电子签名法》对于电子签名的标准,同时反对国内通用的 RSA算法,符合国家平安规范。

PageOffice和MobOffice产品联合应用为跨平台解决Office文件提供了完满的解决方案,次要性能有word在线编辑保留和留痕,word和pdf文件在线盖章(电子印章)。

二、我的项目源码及部署

1、我的项目构造及应用框架

该签字+盖章流程零碎应用了SpringBoot+thymeleaf实现的,而后jar包依赖应用了maven

  • 管制层
@Controller@RequestMapping("/mobile")public class MobileOfficeController {    @Value("${docpath}")    private  String docPath;    @Value("${moblicpath}")    private  String moblicpath;    @Autowired    DocService m_docService;    /**     * 增加MobOffice的服务器端受权程序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();    }}复制代码
  • 我的项目业务层源码
@Servicepublic 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; //字节数 文件大小              //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;//二维码内容    private BarcodeFormat barcodeFormat;//二维码类型    private int width;//图片宽度    private int height;//图片高度    private String imageformat;//图片格式    private int backColorRGB;//背景色,色彩RGB的数值既能够用十进制示意,也能够用十六进制示意    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);            //获取图片转换成的二进制数组            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;        }    }    //获取二维码图片的字节数组    public byte[] getQRCodeBytes()            throws IOException {        try {            MultiFormatWriter multiFormatWriter = new MultiFormatWriter();            //设置二维码参数            Map hints = new HashMap();            if (this.errorCorrectionLevel != null) {                //设置二维码的纠错级别                hints.put(EncodeHintType.ERROR_CORRECTION, this.errorCorrectionLevel);            }            if (this.encodeType!=null && this.encodeType.trim().length() > 0) {                //设置编码方式                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、我的项目下载及部署

  • 我的项目源码下载地址:download.csdn.net/download/we…
  • 下载我的项目源码后,应用idea导入slndemo我的项目并运行

  • 将我的项目slndemo下的slndemodata.zip压缩包拷贝到本地D盘根目录下并解压
  • 点击启动我的项目

三、性能展现

1、我的项目启动后登录首页

  • 我的项目地址:http://localhost:8888/pc/login
  • 账户:张三 明码:123456

2、零碎首页性能简介

这是一个简略的Demo我的项目,模仿Word文件在办公零碎中的次要流转环节,并不意味着PageOffice产品只能反对这样的文档解决流程。PageOffice产品只提供文档在线解决的性能,包含:关上、编辑、保留、动静填充、文档合并、套红、留痕、盖章等上百项性能(具体请参考PageOffice产品开发包中的示例),不提供流程管制性能,所以不论开发什么样的Web零碎,只有是须要在线解决Office文档,都能够依据本人的我的项目须要,调用PageOffice产品相应的性能即可。「留神:为了简化代码逻辑,此演示程序只能创立一个文档进行流转。」

3、点击起草文档

  • 点击起草文档,点击提交
  • 点击代办文档,而后点击编辑,当你点击编辑时你没有下载PageOffice,他会揭示你装置,你点击装置之后,敞开浏览器,从新关上浏览器就能编辑了!

  • 咱们应用了PageOffice企业版,必须要注册序列化
  • 版 本:PageOffice企业版5(试用)
  • 序列号:35N8V-2YUC-LY77-W14XL

  • 当咱们注册胜利当前,就能够编辑公布的文件或者布告了

  • 编辑好当前点击保留
  • 点击审批

4、审批

  • 登录李总审批

  • 退出零碎,而后输出李总

  • 而后点击批阅,下一步

  • 登录赵六进行审核稿子

5、审稿

  • 审稿

  • 审核而后到盖章环节

  • 应用王总登录进行盖章

6、盖章和签字的实现

  • 王总登录

  • 点击盖章
  • 点击加盖印章
  • 咱们盖章前须要输出姓名+明码,须要输出谬误报错

  • 正确的账户明码是:
  • 账户:王五
  • 明码:123456

  • 登录胜利后有抉择王五的集体章进行签字
  • 签字胜利
  • 公司盖章,反复以上步骤
  • 签字盖章胜利

7、残缺签字盖章文件

  • 保留之后公布文件
  • 公司文件展现
  • 盖章签字后的文件


最初给大家分享一个Github仓库,下面有大彬整顿的300多本经典的计算机书籍PDF,包含C语言、C++、Java、Python、前端、数据库、操作系统、计算机网络、数据结构和算法、机器学习、编程人生等,能够star一下,下次找书间接在下面搜寻,仓库继续更新中~

Github地址:https://github.com/Tyson0314/...