diff --git a/pom.xml b/pom.xml index 2b3fa387f3722aa7b31e393eb7cb7605d8b82e22..691df7a4a8413fd97b035a913f61c7d8753897ac 100644 --- a/pom.xml +++ b/pom.xml @@ -54,26 +54,30 @@ <version>3.32.3.2</version> </dependency> - - <!-- 添加PageOffice依赖(必须) --> + <!-- 添加PageOffice依赖(必须) –> <dependency> <groupId>com.zhuozhengsoft</groupId> <artifactId>pageoffice</artifactId> <version>5.2.0.1</version> + </dependency>--> + + <dependency> + <groupId>com.zhuozhengsoft</groupId> <!--自定义--> + <artifactId>pageoffice</artifactId> <!--自定义--> + <version>5.2.0.1</version> <!--自定义--> + <scope>system</scope> + <!--system,类似provided,需要显式提供依赖的jar以后,Maven就不会在Repository中查找它--> + <!--${project.basedir}为springboot内置属性--> + <systemPath>${project.basedir}/src/main/resources/lib/pageoffice5.2.0.1.jar</systemPath> </dependency> - <!-- 生成二维码用到的两个jar,一个Google的zxing,一个自己封装的zzyutils --> + <!-- 生成二维码用到的jar,Google的zxing --> <!-- https://mvnrepository.com/artifact/com.google.zxing/core --> <dependency> <groupId>com.google.zxing</groupId> <artifactId>core</artifactId> <version>3.3.3</version> </dependency> - <dependency> - <groupId>com.zhuozhengsoft</groupId> - <artifactId>zzzyutils</artifactId> - <version>1.0.0.1</version> - </dependency> <!-- base64转换工具 --> <!-- https://mvnrepository.com/artifact/commons-codec/commons-codec --> @@ -90,10 +94,10 @@ <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> + <!--includeSystemScope需要显式提供依赖的jar以后,这里必须是true,否则打包的时候会找不到syspath下的jar--> + <configuration> + <includeSystemScope>true</includeSystemScope> + </configuration> <dependencies> <!-- spring热部署 --> <dependency> diff --git a/src/main/java/com/zhuozhengsoft/slndemo/SlndemoApplication.java b/src/main/java/com/zhuozhengsoft/slndemo/SlndemoApplication.java index 7e4d876b46b9471ca62aa54c617144802bd036e0..01ee58381fc37f2927331de631f70b688abb4dea 100644 --- a/src/main/java/com/zhuozhengsoft/slndemo/SlndemoApplication.java +++ b/src/main/java/com/zhuozhengsoft/slndemo/SlndemoApplication.java @@ -1,6 +1,4 @@ package com.zhuozhengsoft.slndemo; - -import com.zhuozhengsoft.moboffice.Server; import org.mybatis.spring.annotation.MapperScan; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; @@ -11,42 +9,28 @@ import org.springframework.context.annotation.Bean; @MapperScan("com.zhuozhengsoft.slndemo.mapper") @SpringBootApplication public class SlndemoApplication { - @Value("${mobsyspath}") - private String mobSysPath; + @Value("${moblicpath}") + private String moblicpath; - @Value("${posyspath}") - private String poSysPath; + @Value("${policpath}") + private String policpath; @Value("${popassword}") private String poPassWord; + public static void main(String[] args) { SpringApplication.run(SlndemoApplication.class, args); } - - @Bean - public ServletRegistrationBean pageServletRegistrationBean() { - com.zhuozhengsoft.pageoffice.poserver.Server poserver = new com.zhuozhengsoft.pageoffice.poserver.Server(); - poserver.setSysPath(poSysPath);//设置PageOffice注册成功后,license.lic文件存放的目录 - ServletRegistrationBean srb = new ServletRegistrationBean(poserver); - srb.addUrlMappings("/poserver.zz"); - srb.addUrlMappings("/posetup.exe"); - srb.addUrlMappings("/pageoffice.js"); - srb.addUrlMappings("/jquery.min.js"); - srb.addUrlMappings("/pobstyle.css"); - srb.addUrlMappings("/sealsetup.exe"); - return srb;// - } - /** * moboffice的这个注册bean必须放pageoffice的后面,否则会找不到pageoffice.js * @return */ @Bean public ServletRegistrationBean mobServletRegistrationBean() { - Server moserver = new com.zhuozhengsoft.moboffice.Server(); - moserver.setSysPath(mobSysPath); + com.zhuozhengsoft.moboffice.Server moserver = new com.zhuozhengsoft.moboffice.Server(); + moserver.setSysPath(moblicpath); ServletRegistrationBean srb2 = new ServletRegistrationBean(moserver); srb2.setName("mobserver"); srb2.addUrlMappings("/mobserver.zz"); @@ -55,6 +39,22 @@ public class SlndemoApplication { return srb2; } + + @Bean + public ServletRegistrationBean pageServletRegistrationBean() { + com.zhuozhengsoft.pageoffice.poserver.Server poserver = new com.zhuozhengsoft.pageoffice.poserver.Server(); + poserver.setSysPath(policpath);//设置PageOffice注册成功后,license.lic文件存放的目录 + ServletRegistrationBean srb = new ServletRegistrationBean(poserver); + srb.addUrlMappings("/poserver.zz"); + srb.addUrlMappings("/posetup.exe"); + srb.addUrlMappings("/pageoffice.js"); + // srb.addUrlMappings("/jquery.min.js"); + srb.addUrlMappings("/pobstyle.css"); + srb.addUrlMappings("/sealsetup.exe"); + return srb;// + } + + /** * 添加印章管理程序Servlet(可选) * @return @@ -63,7 +63,7 @@ public class SlndemoApplication { public ServletRegistrationBean servletRegistrationBean2() { com.zhuozhengsoft.pageoffice.poserver.AdminSeal adminSeal = new com.zhuozhengsoft.pageoffice.poserver.AdminSeal(); adminSeal.setAdminPassword(poPassWord);//设置印章管理员admin的登录密码 - adminSeal.setSysPath(poSysPath);//设置印章数据库文件poseal.db存放的目录 + adminSeal.setSysPath(policpath);//设置印章数据库文件poseal.db存放的目录 ServletRegistrationBean srb3 = new ServletRegistrationBean(adminSeal); srb3.addUrlMappings("/adminseal.zz"); srb3.addUrlMappings("/sealimage.zz"); diff --git a/src/main/java/com/zhuozhengsoft/slndemo/config/IndexView.java b/src/main/java/com/zhuozhengsoft/slndemo/config/IndexView.java deleted file mode 100644 index 9cabeb6b95c2338d1e9d19c2e283962e56cfb68f..0000000000000000000000000000000000000000 --- a/src/main/java/com/zhuozhengsoft/slndemo/config/IndexView.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.zhuozhengsoft.slndemo.config; - -import org.springframework.context.annotation.Configuration; -import org.springframework.core.Ordered; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -/** - * @Author: dong - * @Date: 2020/10/10 10:55 - * @Version 1.0 - */ -@Configuration -public class IndexView extends WebMvcConfigurerAdapter { - @Override - public void addViewControllers( ViewControllerRegistry registry ) { - registry.addViewController( "/" ).setViewName( "forward:/index.html" ); - registry.setOrder( Ordered.HIGHEST_PRECEDENCE ); - super.addViewControllers( registry ); - } -} diff --git a/src/main/java/com/zhuozhengsoft/slndemo/config/LoginConfig.java b/src/main/java/com/zhuozhengsoft/slndemo/config/LoginConfig.java index 33b7720eaad6a51bb5795a2713b8db534d7a9f8a..6788d1035c44d56fe32873996b8b558cc346e174 100644 --- a/src/main/java/com/zhuozhengsoft/slndemo/config/LoginConfig.java +++ b/src/main/java/com/zhuozhengsoft/slndemo/config/LoginConfig.java @@ -9,7 +9,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; * @Date: 2020/9/29 17:37 * @Version 1.0 */ + @Configuration + public class LoginConfig implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { @@ -19,12 +21,11 @@ public class LoginConfig implements WebMvcConfigurer { "/", "/index", //首页 "/pc/login", //pc登录 - "/mobile/login", //mobile登录 "/pc/loginAction", //pc登录后台 - "/mobile/loginAction", //mobile登录后台 "/pc/restart", //首页的复位,这时候还没有登录呢,没有userName + "/mobile/**", //mobile所有都不拦截,但是在mobofficecontroller中加了判断是否有session,原因是moboffice打开文件没有session,而且跳转到pc登录页不合适 "/assets/**", //css,js静态资源 - "/mobile/*.html", + "/doc/**", //doc,pdf静态文件 "/pc/*.html", "/posetup.exe", //pageoffice相关 "/sealsetup.exe", @@ -33,8 +34,12 @@ public class LoginConfig implements WebMvcConfigurer { "/moboffice.js", "/pobstyle.css", "/poserver.zz", - "/mobserver.zz" + "/mobserver.zz", + "/loginseal.zz", + "/adminseal.zz", + "/sealimage.zz" ); } } + diff --git a/src/main/java/com/zhuozhengsoft/slndemo/config/LoginInterceptor.java b/src/main/java/com/zhuozhengsoft/slndemo/config/LoginInterceptor.java index b1f71110454931804bae20c6ea3b708f3197ffe3..12aece8ed2f2ee1f48805493045c275684dfd53a 100644 --- a/src/main/java/com/zhuozhengsoft/slndemo/config/LoginInterceptor.java +++ b/src/main/java/com/zhuozhengsoft/slndemo/config/LoginInterceptor.java @@ -12,10 +12,13 @@ import java.io.IOException; * @Date: 2020/9/29 17:35 * @Version 1.0 */ + public class LoginInterceptor implements HandlerInterceptor { - /** + +/** * 在请求处理之前进行调用(Controller方法调用之前) */ + @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { // System.out.println("执行了TestInterceptor的preHandle方法"); @@ -32,19 +35,24 @@ public class LoginInterceptor implements HandlerInterceptor { return false; } - /** + +/** * 请求处理之后进行调用,但是在视图被渲染之前(Controller方法调用之后) */ + @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) { // System.out.println("执行了TestInterceptor的postHandle方法"); } - /** + +/** * 在整个请求结束之后被调用,也就是在DispatcherServlet 渲染了对应的视图之后执行(主要是用于进行资源清理工作) */ + @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { // System.out.println("执行了TestInterceptor的afterCompletion方法"); } } + diff --git a/src/main/java/com/zhuozhengsoft/slndemo/controller/IndexController.java b/src/main/java/com/zhuozhengsoft/slndemo/controller/IndexController.java index 818861788b51e28e0304b7f8eaf7140e77bbedc8..db911859f051cf04bbd569e502af5ded4483faca 100644 --- a/src/main/java/com/zhuozhengsoft/slndemo/controller/IndexController.java +++ b/src/main/java/com/zhuozhengsoft/slndemo/controller/IndexController.java @@ -1,7 +1,7 @@ package com.zhuozhengsoft.slndemo.controller; import com.zhuozhengsoft.slndemo.utils.Base64Util; -import com.zoomsoft.QRCode; +import com.zhuozhengsoft.slndemo.utils.QRCodeUtil; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -29,13 +29,13 @@ public class IndexController { String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path; if(!request.getServerName().equals("127.0.0.1") && !request.getServerName().toLowerCase().equals("localhost")){ - QRCode qrCode = new QRCode(basePath+"/mobile/login.html"); + QRCodeUtil qrCode = new QRCodeUtil(basePath+"/mobile/login"); byte[] imageBytes = qrCode.getQRCodeBytes(); FileOutputStream fos = new FileOutputStream(imgPath+"/mobile_qrcode.png"); fos.write(imageBytes); fos.close(); - QRCode qrCode2 = new QRCode(basePath+"/mobile/PoDroid_5.apk"); + QRCodeUtil qrCode2 = new QRCodeUtil(basePath+"/apk/PoDroid_5.apk"); byte[] imageBytes2 = qrCode2.getQRCodeBytes(); FileOutputStream fos2 = new FileOutputStream(imgPath+"/apk_qrcode.png"); fos2.write(imageBytes2); diff --git a/src/main/java/com/zhuozhengsoft/slndemo/controller/MobileController.java b/src/main/java/com/zhuozhengsoft/slndemo/controller/MobileController.java index eeab31bc599b4e4629637febdf4503a7d91c757a..3f11e3a5cb3d65f259ce2d6ed03125dcd1624241 100644 --- a/src/main/java/com/zhuozhengsoft/slndemo/controller/MobileController.java +++ b/src/main/java/com/zhuozhengsoft/slndemo/controller/MobileController.java @@ -31,8 +31,7 @@ public class MobileController { @RequestMapping("/loginAction") public void loginAction(HttpServletRequest request,HttpServletResponse response, String name, HttpSession session)throws Exception { if(name!=""&& name!=null){ - String userName = new String(name.getBytes("iso-8859-1"), "utf-8"); - session.setAttribute("userName", userName); + session.setAttribute("userName", name); request.getRequestDispatcher("/mobile/index").forward(request, response); }else{ request.getRequestDispatcher("/mobile/login").forward(request, response); @@ -45,42 +44,60 @@ public class MobileController { } @RequestMapping("/todolist") - public String todolist(HttpServletRequest request, HttpServletResponse response)throws Exception { + public String todolist(HttpServletRequest request, HttpServletResponse response,HttpSession session)throws Exception { request.setCharacterEncoding("utf-8");//解决form表单提交中文乱码问题 response.setCharacterEncoding("utf-8");//解决返回的页面中文乱码问题 response.setContentType("text/html;charset=utf-8"); - //查询数据库,获取当前doc表中的status给index页面加上待办图标 - Doc doc=m_docService.getDocById(1); - String docStatus=doc.getStatus(); + String returnUrl=""; + + Object userName = session.getAttribute("userName"); + if(null == userName) { + returnUrl="/mobile/login"; + response.sendRedirect(returnUrl); + }else { + userName = java.net.URLEncoder.encode(userName.toString(), "UTF-8"); + request.setAttribute("userName", userName); + + //查询数据库,获取当前doc表中的status给index页面加上待办图标 + Doc doc = m_docService.getDocById(1); + String docStatus = doc.getStatus(); + + if ("".equals(docStatus)) { + docStatus = "起草"; + } + request.setAttribute("docStatus", docStatus); + request.setAttribute("doc", doc); + returnUrl="/mobile/todolist"; - if("".equals(docStatus)){ - docStatus = "起草"; } - request.setAttribute("docStatus", docStatus); - request.setAttribute("doc",doc); - return "/mobile/todolist"; + return returnUrl; } @RequestMapping("/issuelist") public String issuelist(HttpServletRequest request, HttpServletResponse response,HttpSession session)throws Exception { - Object user = session.getAttribute("userName"); - if(null == user) { - response.sendRedirect("/mobile/login"); - } - - String userName = user.toString(); - userName = java.net.URLEncoder.encode(userName, "UTF-8"); - request.setCharacterEncoding("utf-8");//解决form表单提交中文乱码问题 response.setCharacterEncoding("utf-8");//解决返回的页面中文乱码问题 response.setContentType("text/html;charset=utf-8"); - //查询数据库,获取当前doc表中的status给index页面加上待办图标 - Doc doc=m_docService.getDocById(1); - String docStatus=doc.getStatus(); + String returnUrl=""; + + Object userName = session.getAttribute("userName"); + if(null == userName) { + returnUrl="/mobile/login"; + response.sendRedirect(returnUrl); + }else { + userName = java.net.URLEncoder.encode(userName.toString(), "UTF-8"); + request.setAttribute("userName", userName); + + //查询数据库,获取当前doc表中的status给index页面加上待办图标 + Doc doc = m_docService.getDocById(1); + String docStatus = doc.getStatus(); + + request.setAttribute("docStatus", docStatus); + request.setAttribute("doc", doc); + returnUrl="/mobile/issuelist"; + } + return returnUrl; - request.setAttribute("docStatus", docStatus); - request.setAttribute("doc",doc); - return "/mobile/issuelist"; } } diff --git a/src/main/java/com/zhuozhengsoft/slndemo/controller/MobileOfficeController.java b/src/main/java/com/zhuozhengsoft/slndemo/controller/MobileOfficeController.java index 70faa1a6824fd5a0a99aacd7456033afa1b55a18..edd9f7ff8ddab17fd4f61f9ff7820b54d17dfc68 100644 --- a/src/main/java/com/zhuozhengsoft/slndemo/controller/MobileOfficeController.java +++ b/src/main/java/com/zhuozhengsoft/slndemo/controller/MobileOfficeController.java @@ -10,7 +10,14 @@ import org.springframework.web.bind.annotation.RequestMapping; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + import com.zhuozhengsoft.moboffice.*; +import org.springframework.web.multipart.MultipartHttpServletRequest; + + +import java.io.*; +import java.net.URLDecoder; /** * @Author: dong @@ -22,8 +29,11 @@ import com.zhuozhengsoft.moboffice.*; public class MobileOfficeController { - @Value("${rootpath}") - private String rootPath; + @Value("${docpath}") + private String docPath; + + @Value("${moblicpath}") + private String moblicpath; @Autowired DocService m_docService; @@ -33,13 +43,17 @@ public class MobileOfficeController { * @return */ - @RequestMapping("opendoc") - public String opendoc(HttpServletRequest request,HttpServletResponse response)throws Exception { + @RequestMapping("/opendoc") + public void opendoc(HttpServletRequest request, HttpServletResponse response, HttpSession session,String type,String userName)throws Exception { String fileName = ""; - String userName = request.getParameter("user"); - userName = java.net.URLDecoder.decode(userName, "UTF-8"); + 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")) { @@ -54,19 +68,18 @@ public class MobileOfficeController { } MobOfficeCtrl mobCtrl = new MobOfficeCtrl(request,response); - mobCtrl.setServerPage("mobserver.zz"); + mobCtrl.setSysPath(moblicpath); + mobCtrl.setServerPage("/mobserver.zz"); //mobCtrl.setZoomSealServer("http://xxx.xxx.xxx.xxx:8080/ZoomSealEnt/enserver.zz"); mobCtrl.setSaveFilePage("/mobile/savedoc"); - mobCtrl.webOpen("file://"+rootPath+fileName, openModeType, userName); - - return "/mobile/opendoc"; + mobCtrl.webOpen("file://"+docPath+fileName, openModeType , userName); } @RequestMapping("/savedoc") - public void savedoc(HttpServletRequest request, HttpServletResponse response)throws Exception{ - String sepa = java.io.File.separator; + public void savedoc(HttpServletRequest request, HttpServletResponse response)throws Exception{ FileSaver fs = new FileSaver(request, response); - fs.saveToFile(rootPath + sepa+ fs.getFileName()); + System.out.println(docPath+fs.getFileName()); + fs.saveToFile(docPath+fs.getFileName()); fs.close(); } } diff --git a/src/main/java/com/zhuozhengsoft/slndemo/controller/PCController.java b/src/main/java/com/zhuozhengsoft/slndemo/controller/PCController.java index 88bd21519ffba5c71291c9f672092e2daaeb6b0e..ac5e6b442df8f848a177376e0ddbbc89b537a195 100644 --- a/src/main/java/com/zhuozhengsoft/slndemo/controller/PCController.java +++ b/src/main/java/com/zhuozhengsoft/slndemo/controller/PCController.java @@ -2,8 +2,8 @@ package com.zhuozhengsoft.slndemo.controller; import com.zhuozhengsoft.slndemo.entity.Doc; import com.zhuozhengsoft.slndemo.service.DocService; -import com.zhuozhengsoft.slndemo.utils.CopyFileUtils; -import com.zhuozhengsoft.slndemo.utils.UtilDateConvertStringDate; +import com.zhuozhengsoft.slndemo.utils.CopyFileUtil; +import com.zhuozhengsoft.slndemo.utils.ConvertStringDateUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; @@ -26,8 +26,8 @@ import java.util.Date; @Controller @RequestMapping("/pc") public class PCController { - @Value("${rootpath}") - private String rootPath; + @Value("${docpath}") + private String docPath; @Value("${dbpath}") private String dbPath; @@ -133,9 +133,9 @@ public class PCController { //拷贝文件 //将此模板复制一份,重命名成doc001.docx String sepa = java.io.File.separator; - String templatePath = rootPath + sepa + doc.getTemplateName(); - String filePath = rootPath + sepa+ "doc001.docx"; - boolean result =CopyFileUtils.copyFile(templatePath, filePath); + String templatePath = docPath + sepa + doc.getTemplateName(); + String filePath = docPath + sepa+ "doc001.docx"; + boolean result = CopyFileUtil.copyFile(templatePath, filePath); if(!result){ new Exception("拷贝文件失败!"); response.getWriter().println("<script type=\"text/javascript\">alert('起草失败,拷贝文件失败!')</script>"); @@ -166,7 +166,7 @@ public class PCController { } Doc doc=m_docService.getDocById(1);//查询数据库记录 if(doc.getId()==1){ - String nowDate =UtilDateConvertStringDate.convert(doc.getIssueDate()); + String nowDate =ConvertStringDateUtil.convert(doc.getIssueDate()); request.setAttribute("nowDate",nowDate); } request.setAttribute("doc",doc); @@ -224,10 +224,10 @@ public class PCController { String sepa = java.io.File.separator; String dbfileBakPath = dbPath +"slndata_bak.db"; String dbfilePath =dbPath+"slndata.db"; - CopyFileUtils.copyFile(dbfileBakPath, dbfilePath); + CopyFileUtil.copyFile(dbfileBakPath, dbfilePath); - File docfile = new File(rootPath +"doc001.docx"); - File pdffile = new File(rootPath +"doc001.pdf"); + File docfile = new File(docPath +"doc001.docx"); + File pdffile = new File(docPath +"doc001.pdf"); if(docfile.exists()){ docfile.delete(); } diff --git a/src/main/java/com/zhuozhengsoft/slndemo/controller/PageOfficeController.java b/src/main/java/com/zhuozhengsoft/slndemo/controller/PageOfficeController.java index 012b602758240ac3895fc19311f7222d3cd10c8a..a01ed77e9f60a1e746a02c04a38a7434717a6652 100644 --- a/src/main/java/com/zhuozhengsoft/slndemo/controller/PageOfficeController.java +++ b/src/main/java/com/zhuozhengsoft/slndemo/controller/PageOfficeController.java @@ -4,11 +4,9 @@ import com.zhuozhengsoft.pageoffice.*; import com.zhuozhengsoft.pageoffice.wordwriter.*; import com.zhuozhengsoft.slndemo.entity.Doc; import com.zhuozhengsoft.slndemo.service.DocService; -import com.zhuozhengsoft.slndemo.utils.UtilDateConvertStringDate; +import com.zhuozhengsoft.slndemo.utils.ConvertStringDateUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.servlet.ServletRegistrationBean; -import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -26,8 +24,8 @@ public class PageOfficeController { @Autowired DocService m_docService; - @Value("${rootpath}") - private String rootPath; + @Value("${docpath}") + private String docPath; /** * 添加PageOffice的服务器端授权程序Servlet(必须) @@ -52,13 +50,13 @@ public class PageOfficeController { dept.setValue(doc.getIssueDept()); DataRegion date = wordDocument.openDataRegion("PO_IssueDate");//日期 - date.setValue(UtilDateConvertStringDate.convert(doc.getIssueDate())); + date.setValue(ConvertStringDateUtil.convert(doc.getIssueDate())); DataRegion theme = wordDocument.openDataRegion("PO_TopicWords");//主题词 theme.setValue(doc.getTopicWords()); DataRegion year =wordDocument.openDataRegion("PO_Year");//年 - year.setValue(UtilDateConvertStringDate.convert(doc.getIssueDate()).substring(0, 4)); + year.setValue(ConvertStringDateUtil.convert(doc.getIssueDate()).substring(0, 4)); DataRegion title = wordDocument.openDataRegion("PO_Title");//标题 title.setValue(doc.getTitle()); @@ -67,7 +65,6 @@ public class PageOfficeController { copies.setValue(String.valueOf(doc.getCopies())); String id=request.getParameter("id"); String name=request.getParameter("name"); - System.out.println("id="+id+"\r\n name="+name ); PageOfficeCtrl poCtrl1 = new PageOfficeCtrl(request); poCtrl1.setCaption("XX办公系统"); //添加保存文件按钮 @@ -76,7 +73,7 @@ public class PageOfficeController { poCtrl1.setWriter(wordDocument); poCtrl1.setSaveFilePage("/pc/saveFile"); //打开Word文件 - poCtrl1.webOpen("file://"+rootPath+"doc001.docx", OpenModeType.docNormalEdit, "张三"); + poCtrl1.webOpen("file://"+docPath+"doc001.docx", OpenModeType.docNormalEdit, "张三"); request.setAttribute("pageoffice",poCtrl1.getHtmlCode("PageOfficeCtrl1")); return "/pc/wordEdit"; } @@ -99,7 +96,7 @@ public class PageOfficeController { poCtrl1.setServerPage(request.getContextPath() + "/poserver.zz"); //此行必须 poCtrl1.setSaveFilePage("/pc/saveFile"); //打开Word文件 - poCtrl1.webOpen("file://"+rootPath+"doc001.docx", OpenModeType.docRevisionOnly,userName); + poCtrl1.webOpen("file://"+docPath+"doc001.docx", OpenModeType.docRevisionOnly,userName); request.setAttribute("pageoffice",poCtrl1.getHtmlCode("PageOfficeCtrl1")); return "/pc/wordRevision"; } @@ -123,7 +120,7 @@ public class PageOfficeController { poCtrl1.setServerPage(request.getContextPath() + "/poserver.zz"); //此行必须 poCtrl1.setSaveFilePage("/pc/saveFile"); //打开Word文件 - poCtrl1.webOpen("file://"+rootPath+"doc001.docx", OpenModeType.docAdmin, userName); + poCtrl1.webOpen("file://"+docPath+"doc001.docx", OpenModeType.docAdmin, userName); request.setAttribute("pageoffice",poCtrl1.getHtmlCode("PageOfficeCtrl1")); return "/pc/wordAcceptRevision"; } @@ -167,7 +164,7 @@ public class PageOfficeController { pdfCtrl1.addCustomToolButton("-", "", 0); pdfCtrl1.addCustomToolButton("向左旋转90度", "SetRotateLeft()", 12); pdfCtrl1.addCustomToolButton("向右旋转90度", "SetRotateRight()", 13); - pdfCtrl1.webOpen("file://"+rootPath+"doc001.pdf"); + pdfCtrl1.webOpen("file://"+docPath+"doc001.pdf"); request.setAttribute("pageoffice",pdfCtrl1.getHtmlCode("PDFCtrl1")); return "/pc/pdfAddSeal"; } @@ -197,7 +194,7 @@ public class PageOfficeController { pdfCtrl1.addCustomToolButton("-", "", 0); pdfCtrl1.addCustomToolButton("向左旋转90度", "SetRotateLeft()", 12); pdfCtrl1.addCustomToolButton("向右旋转90度", "SetRotateRight()", 13); - pdfCtrl1.webOpen("file://"+rootPath+"doc001.pdf"); + pdfCtrl1.webOpen("file://"+docPath+"doc001.pdf"); request.setAttribute("pageoffice",pdfCtrl1.getHtmlCode("PDFCtrl1")); return "/pc/pdfReadOnly"; } @@ -209,7 +206,7 @@ public class PageOfficeController { FileSaver fs = new FileSaver(request,response); if (".pdf".equals(fs.getFileExtName())) { //保存pdf文件并更新数据库信息 - fs.saveToFile(rootPath + sepa+ "doc001.pdf"); + fs.saveToFile(docPath + sepa+ "doc001.pdf"); //链接数据库,更新pdf名称。下面的代码只在核稿环节第一次点保存必须执行,有待优化 doc.setId(1); doc.setPdfName("doc001.pdf"); @@ -220,7 +217,7 @@ public class PageOfficeController { } if (".docx".equals(fs.getFileExtName())) { //起草完的文件保存成doc001.docx - fs.saveToFile(rootPath + sepa+ "doc001.docx"); + fs.saveToFile(docPath + sepa+ "doc001.docx"); //链接数据库,更新doc名称。下面的代码只在起草环节第一次点保存必须执行,有待优化 doc.setId(1); doc.setDocName("doc001.docx"); diff --git a/src/main/java/com/zhuozhengsoft/slndemo/entity/Doc.java b/src/main/java/com/zhuozhengsoft/slndemo/entity/Doc.java index 1b13a9b6b1013b1304a84da0edc48f8150362895..bd38336f1c3d112633094c60b623ba144484af47 100644 --- a/src/main/java/com/zhuozhengsoft/slndemo/entity/Doc.java +++ b/src/main/java/com/zhuozhengsoft/slndemo/entity/Doc.java @@ -1,4 +1,6 @@ package com.zhuozhengsoft.slndemo.entity; +import org.springframework.format.annotation.DateTimeFormat; + import java.util.Date; /** * @Author: dong diff --git a/src/main/java/com/zhuozhengsoft/slndemo/utils/UtilDateConvertStringDate.java b/src/main/java/com/zhuozhengsoft/slndemo/utils/ConvertStringDateUtil.java similarity index 87% rename from src/main/java/com/zhuozhengsoft/slndemo/utils/UtilDateConvertStringDate.java rename to src/main/java/com/zhuozhengsoft/slndemo/utils/ConvertStringDateUtil.java index a5d40f4785ee82675cd57bea456d33239c0d24e6..ccaca117776e8d99eac5e8257061ef735bc1a8e8 100644 --- a/src/main/java/com/zhuozhengsoft/slndemo/utils/UtilDateConvertStringDate.java +++ b/src/main/java/com/zhuozhengsoft/slndemo/utils/ConvertStringDateUtil.java @@ -6,7 +6,7 @@ import java.util.Date; * @Date: 2020/9/27 17:02 * @Version 1.0 */ -public class UtilDateConvertStringDate { +public class ConvertStringDateUtil { public static String convert(Date date){ return (new SimpleDateFormat("yyyy-MM-dd")).format(date); } diff --git a/src/main/java/com/zhuozhengsoft/slndemo/utils/CopyFileUtils.java b/src/main/java/com/zhuozhengsoft/slndemo/utils/CopyFileUtil.java similarity index 97% rename from src/main/java/com/zhuozhengsoft/slndemo/utils/CopyFileUtils.java rename to src/main/java/com/zhuozhengsoft/slndemo/utils/CopyFileUtil.java index d0f9113f6926c94bf3db574d029470d51d633334..6cd0e336d20bbe76a529ec1d17976ad251ace645 100644 --- a/src/main/java/com/zhuozhengsoft/slndemo/utils/CopyFileUtils.java +++ b/src/main/java/com/zhuozhengsoft/slndemo/utils/CopyFileUtil.java @@ -10,7 +10,7 @@ import java.io.*; * @Date: 2020/9/25 10:13 * @Version 1.0 */ -public class CopyFileUtils { +public class CopyFileUtil { //拷贝文件 public static boolean copyFile(String oldPath, String newPath) throws Exception { boolean copyStatus=false; diff --git a/src/main/java/com/zhuozhengsoft/slndemo/utils/QRCodeUtil.java b/src/main/java/com/zhuozhengsoft/slndemo/utils/QRCodeUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..7c63a8c4a9cda3a1df5ab6290c5f5152ab29d93f --- /dev/null +++ b/src/main/java/com/zhuozhengsoft/slndemo/utils/QRCodeUtil.java @@ -0,0 +1,194 @@ +package com.zhuozhengsoft.slndemo.utils; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.EncodeHintType; +import com.google.zxing.MultiFormatWriter; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * @Author: dong + * @Date: 2020/10/19 9:55 + * @Version 1.0 + */ +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; + } + + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 74b79ec3b6f38bcf638778a17b26e3e96eb0ea25..d336c19de6a0a5e45081e3608b150067b7de043c 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -3,7 +3,7 @@ server.port=8888 #servlet����·�� #server.servlet-path=/ #������Ŀ·��http://localhost:8080/ -#server.context-path=/ +#server.context-path=/index #spring.datasource.url=jdbc:sqlite::resource:example.db #date_string_format=yyyy-MM-dd���sqlite3��Date��po��java.util.Date��ƥ������� @@ -32,9 +32,9 @@ spring.devtools.restart.enabled=true ######################################################## ###PageOffice ######################################################## -posyspath=D:/slndemo/lic/ -mobsyspath=D:/slndemo/lic/ +policpath=D:/slndemo/lic +moblicpath=D:/slndemo/lic popassword=111111 -rootpath=D:/slndemo/doc/ +docpath=D:/slndemo/doc/ imgpath=D:/slndemo/img/ dbpath=D:/slndemo/demodata/ diff --git a/src/main/resources/lib/pageoffice5.2.0.1.jar b/src/main/resources/lib/pageoffice5.2.0.1.jar new file mode 100644 index 0000000000000000000000000000000000000000..ad452d16018f9b71079f67e382fc7e1fa64021cd Binary files /dev/null and b/src/main/resources/lib/pageoffice5.2.0.1.jar differ diff --git a/src/main/resources/templates/mobile/PoDroid_5.apk b/src/main/resources/static/apk/PoDroid_5.apk similarity index 96% rename from src/main/resources/templates/mobile/PoDroid_5.apk rename to src/main/resources/static/apk/PoDroid_5.apk index f4781eea20e274b6ef2f8c128fc8e563f70501b2..e89ce8d5e7cc6a7ddd4306df382e15594328c4d1 100644 Binary files a/src/main/resources/templates/mobile/PoDroid_5.apk and b/src/main/resources/static/apk/PoDroid_5.apk differ diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 3f7d6fd8e0c412d09f0e77d735dacd83fd295325..2ec4f25f44395bfaa90adc48491906e25a34cc13 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -101,7 +101,6 @@ <script> //复位 function restart(){ - alert(22); $.ajax({ type: "POST", //提交方式 url: "/pc/restart",//路径 @@ -139,7 +138,7 @@ <p class="indent">此示例“<b>XX办公系统--公文流转</b>”演示了PageOffice和MobOffice在文档流转的各个环节所发挥的作用。准备工作:</p> <p class="indent">1. 手机上安装WPS<br/> 2. 手机上安装MobOffice客户端。用手机浏览器扫码右侧“MobOffice安装”<br/> - 3. 启动MobOffice,扫描右侧二维码,访问“XX办公系统”登录页</p> + 3. 用手机浏览器,或启动MobOffice(推荐),扫码访问“XX办公系统”登录页</p> <p style="color:orangered;">推荐:请按文字说明的步骤操作</p> <div id="img2_relative" ><img src="${mobImgPath!''}" />MobOffice安装</div> <div id="img_relative" ><img src="${webImgPath!''}" />XX办公系统</div> diff --git a/src/main/resources/templates/mobile/issuelist.html b/src/main/resources/templates/mobile/issuelist.html index 3646866c0c9330e60de1e97685890972c3b8f2f5..8850a98a9b43f225d4f84cdb58d43abe69bb247d 100644 --- a/src/main/resources/templates/mobile/issuelist.html +++ b/src/main/resources/templates/mobile/issuelist.html @@ -46,7 +46,7 @@ <span style="background-image:url(/assets/mobile/img/pdf.png)"></span> </div> <div class="ui-list-info"> - <h4 class="ui-nowrap" onclick="MobAPP.openWindow('opendoc.jsp?id=${doc.id}&type=pdf&mode=readonly&user=${userName}');" >${doc.subject!""}</h4> + <h4 class="ui-nowrap" onclick="MobAPP.openWindow('/mobile/opendoc?id=${doc.id}&type=pdf&mode=readonly&userName=${userName}');" >${doc.subject!""}</h4> </div> </li> </ul> diff --git a/src/main/resources/templates/mobile/todolist.html b/src/main/resources/templates/mobile/todolist.html index fd6eba113353934ad98b37b2410560f30eef3815..5dae1dc9652587fd842ede36cab347692296c9c4 100644 --- a/src/main/resources/templates/mobile/todolist.html +++ b/src/main/resources/templates/mobile/todolist.html @@ -49,7 +49,7 @@ <span style="background-image:url(img/word.png)"></span> </div> <div class="ui-list-info"> - <h4 class="ui-nowrap" onclick="MobAPP.openWindow('opendoc.jsp?id=${doc.id}&type=word&user=${userName}');">${docSubject}</h4> + <h4 class="ui-nowrap" onclick="MobAPP.openWindow('/mobile/opendoc?id=${doc.id}&type=word&userName=${userName}');">${doc.subject}</h4> </div> </li> @@ -82,7 +82,7 @@ <span style="background-image:url(/assets/mobile/img/pdf.png)"></span> </div> <div class="ui-list-info"> - <h4 class="ui-nowrap" onclick="MobAPP.openWindow('opendoc.jsp?id=${doc.id}&type=pdf&mode=normal&user=${userName}');" >${docSubject}</h4> + <h4 class="ui-nowrap" onclick="MobAPP.openWindow('/mobile/opendoc?id=${doc.id}&type=pdf&mode=normal&userName=${userName}');" >${doc.subject}</h4> </div> </li> diff --git a/src/test/java/com/zhuozhengsoft/slndemo/SlndemoApplicationTests.java b/src/test/java/com/zhuozhengsoft/slndemo/SlndemoApplicationTests.java index d6a2a18d0f9271e3b14a5b08b65fa07f52168c81..8b137891791fe96927ad78e64b0aad7bded08bdc 100644 --- a/src/test/java/com/zhuozhengsoft/slndemo/SlndemoApplicationTests.java +++ b/src/test/java/com/zhuozhengsoft/slndemo/SlndemoApplicationTests.java @@ -1,14 +1 @@ -package com.zhuozhengsoft.slndemo; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class SlndemoApplicationTests { - - @Test - void contextLoads() { - - } - -}