From 90389e761696fc423cface6fb282514ace92d09f Mon Sep 17 00:00:00 2001
From: 许鹏程 <1821349743@qq.com>
Date: 星期二, 08 八月 2023 16:03:32 +0800
Subject: [PATCH] xn commit

---
 src/main/java/com/product/file/controller/WebOfficeController.java    |  427 +++++++++++++++++++++++++++--------------------------
 src/main/java/com/product/file/service/OnlineDocumentEditService.java |    2 
 src/main/java/com/product/file/service/FileManagerService.java        |    3 
 src/main/java/com/product/file/util/PdfConcurrenceUtil.java           |    4 
 4 files changed, 221 insertions(+), 215 deletions(-)

diff --git a/src/main/java/com/product/file/controller/WebOfficeController.java b/src/main/java/com/product/file/controller/WebOfficeController.java
index b7fae4b..1ad734e 100644
--- a/src/main/java/com/product/file/controller/WebOfficeController.java
+++ b/src/main/java/com/product/file/controller/WebOfficeController.java
@@ -46,229 +46,234 @@
 @Controller
 public class WebOfficeController extends AbstractBaseController {
 
-    @Autowired
-    FileManagerService fileManagerService;
+	@Autowired
+	FileManagerService fileManagerService;
 
-    @Autowired
-    OnlineDocumentEditService onlineDocumentEditService;
+	@Autowired
+	OnlineDocumentEditService onlineDocumentEditService;
 
-    /**
-     * weboffice 鑾峰彇鏂囦欢
-     *
-     * @param response
-     * @param request
-     */
-    @PostMapping("/get-nest-red-file/{version}")
-    @ApiVersion(1)
-    @ResponseBody
-    public String getNestRedTemplate(HttpServletResponse response, HttpServletRequest request) {
+	/**
+	 * weboffice 鑾峰彇鏂囦欢
+	 *
+	 * @param response
+	 * @param request
+	 */
+	@PostMapping("/get-nest-red-file/{version}")
+	@ApiVersion(1)
+	@ResponseBody
+	public String getNestRedTemplate(HttpServletResponse response, HttpServletRequest request) {
 
-        try {
-            //鑾峰彇鍙傛暟
-            FieldSetEntity fse = null;
-            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
-            File file = null;
-            if (bean != null) {
-                RequestParameterEntity reqp = (RequestParameterEntity) bean;
-                fse = reqp.getFormData();
-                file = reqp.getFiles().values().toArray(new File[1])[0];
-            }
-            onlineDocumentEditService.nestRedDocument(fse, file);
-            //            byte[] document_templates = fileManagerService.getFileContent("1".equals(location) ? fse.getString("document_template") : fse.getString("document_template_tail"));
+		try {
+			//鑾峰彇鍙傛暟
+			FieldSetEntity fse = null;
+			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+			File file = null;
+			if (bean != null) {
+				RequestParameterEntity reqp = (RequestParameterEntity) bean;
+				fse = reqp.getFormData();
+				file = reqp.getFiles().values().toArray(new File[1])[0];
+			}
+			onlineDocumentEditService.nestRedDocument(fse, file);
+			//            byte[] document_templates = fileManagerService.getFileContent("1".equals(location) ? fse.getString("document_template") : fse.getString("document_template_tail"));
 //            IoUtil.write(response.getOutputStream(), true, document_templates);
-            return OK();
-        } catch (BaseException e) {
-            e.printStackTrace();
-            return error(e);
-        } catch (Exception e) {
-            e.printStackTrace();
-            SpringMVCContextHolder.getSystemLogger().error(e);
-            return error(FileCode.NEST_RED_DOCUMENT_FAIL);
-        }
-    }
+			return OK();
+		} catch (BaseException e) {
+			e.printStackTrace();
+			return error(e);
+		} catch (Exception e) {
+			e.printStackTrace();
+			SpringMVCContextHolder.getSystemLogger().error(e);
+			return error(FileCode.NEST_RED_DOCUMENT_FAIL);
+		}
+	}
 
-    /**
-     * weboffice 鑾峰彇鏂囦欢
-     *
-     * @param response
-     * @param request
-     */
-    @GetMapping("/get-file/{version}")
-    @ApiVersion(1)
-    public void getFile(HttpServletResponse response, HttpServletRequest request) {
-        try {
-            //鑾峰彇鍙傛暟
-            FieldSetEntity fse = null;
-            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
-            if (bean != null) {
-                RequestParameterEntity reqp = (RequestParameterEntity) bean;
-                fse = reqp.getFormData();
-            }
-            String uuid = fse.getString("uuid");
-            onlineDocumentEditService.getFile(response, uuid);
+	/**
+	 * weboffice 鑾峰彇鏂囦欢
+	 *
+	 * @param response
+	 * @param request
+	 */
+	@GetMapping("/get-file/{version}")
+	@ApiVersion(1)
+	public void getFile(HttpServletResponse response, HttpServletRequest request) {
+		try {
+			//鑾峰彇鍙傛暟
+			FieldSetEntity fse = null;
+			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+			if (bean != null) {
+				RequestParameterEntity reqp = (RequestParameterEntity) bean;
+				fse = reqp.getFormData();
+			}
+			String uuid = fse.getString("uuid");
+			onlineDocumentEditService.getFile(response, uuid);
 //            IoUtil.write(response.getOutputStream(), true, fileManagerService.getFileContent(uuid));
-        } catch (Exception e) {
-            try {
-                OutputStream outputStream = response.getOutputStream();
-                outputStream.flush();
-                outputStream.close();
-            } catch (IOException ex) {
-                ex.printStackTrace();
-            }
-            e.printStackTrace();
-            SpringMVCContextHolder.getSystemLogger().error(e);
-        }
-    }
+		} catch (Exception e) {
+			try {
+				OutputStream outputStream = response.getOutputStream();
+				outputStream.flush();
+				outputStream.close();
+			} catch (IOException ex) {
+				ex.printStackTrace();
+			}
+			e.printStackTrace();
+			SpringMVCContextHolder.getSystemLogger().error(e);
+		}
+	}
 
-    /**
-     * weboffice 淇濆瓨鏂囦欢锛堣嚜鍔ㄣ�佹墜鍔級
-     *
-     * @param request
-     * @return
-     */
-    @PostMapping("/save-office/{version}")
-    @ApiVersion(1)
-    @ResponseBody
-    public String saveOffice(HttpServletRequest request) {
-        try {
-            //鑾峰彇鍙傛暟
-            FieldSetEntity fse = null;
-            Map<String, File> files = null;
-            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
-            if (bean != null) {
-                RequestParameterEntity reqp = (RequestParameterEntity) bean;
-                files = reqp.getFiles();
-                fse = reqp.getFormData();
-            }
-            if (fse == null || StringUtils.isEmpty(fse.getUUID()) || files == null || files.size() <= 0 || StringUtils.isEmpty(fse.getString("key"))) {
-                return error(FileCode.GET_DATA_FAIL);
-            }
-            onlineDocumentEditService.uploadFile(fse.getUUID(), files);
-            return BaseUtil.success(null);
-        } catch (BaseException e) {
-            return error(e);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return error(FileCode.OFFICE_SAVE_FILE_FAIL);
-        }
-    }
+	/**
+	 * weboffice 淇濆瓨鏂囦欢锛堣嚜鍔ㄣ�佹墜鍔級
+	 *
+	 * @param request
+	 * @return
+	 */
+	@PostMapping("/save-office/{version}")
+	@ApiVersion(1)
+	@ResponseBody
+	public String saveOffice(HttpServletRequest request) {
+		try {
+			//鑾峰彇鍙傛暟
+			FieldSetEntity fse = null;
+			Map<String, File> files = null;
+			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+			if (bean != null) {
+				RequestParameterEntity reqp = (RequestParameterEntity) bean;
+				files = reqp.getFiles();
+				fse = reqp.getFormData();
+			}
+			if (fse == null || StringUtils.isEmpty(fse.getUUID()) || files == null || files.size() <= 0 || StringUtils.isEmpty(fse.getString("key"))) {
+				return error(FileCode.GET_DATA_FAIL);
+			}
+			onlineDocumentEditService.uploadFile(fse.getUUID(), files);
+			return BaseUtil.success(null);
+		} catch (BaseException e) {
+			return error(e);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return error(FileCode.OFFICE_SAVE_FILE_FAIL);
+		}
+	}
 
-    /**
-     * weboffice 璺宠浆 mvc
-     *
-     * @param model
-     * @param request
-     * @return
-     */
-    @GetMapping("/open-office/{version}")
-    @ApiVersion(1)
-    public String openOffice(Model model, HttpServletRequest request) {
+	/**
+	 * weboffice 璺宠浆 mvc
+	 *
+	 * @param model
+	 * @param request
+	 * @return
+	 */
+	@GetMapping("/open-office/{version}")
+	@ApiVersion(1)
+	public String openOffice(Model model, HttpServletRequest request) {
 
-        //鑾峰彇鍙傛暟
-        FieldSetEntity fse = null;
-        Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
-        if (bean != null) {
-            RequestParameterEntity reqp = (RequestParameterEntity) bean;
-            fse = reqp.getFormData();
+		try {
+			//鑾峰彇鍙傛暟
+			FieldSetEntity fse = null;
+			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+			if (bean != null) {
+				RequestParameterEntity reqp = (RequestParameterEntity) bean;
+				fse = reqp.getFormData();
 //            System.out.println(formJson);
-            System.out.println(SignUtil.getHmacSHA1(reqp.getFormJson(), Global.getSystemConfig("signature.key", "")));
-        }
-        //鏂囦欢鍚嶏紙绐楀彛鐨勫悕瀛楋級
-        String file_title = fse.getString("fileName");
-        if (file_title == null) {
-            file_title = "";
-        } else {
-            file_title = UnicodeUtil.toString(file_title);
-        }
-        SystemUser currentUser = SpringMVCContextHolder.getCurrentUser();
-        //
-        Boolean allowNestRed = false;
-        String node_uuid = fse.getString("nodeUuid");
-        String fileType = fse.getString("fileType");
-        List<Object> nestRedDocumentParams = new ArrayList<>();
-        // 鍒ゆ柇鏄惁涓� 娴佺▼鑺傜偣涓墦寮�鐨勬枃妗�  涓旀槸 word 绫诲瀷
-        if (!StringUtils.isEmpty(node_uuid) && ("doc".equals(fileType) || "docx".equals(fileType) || "wps".equals(fileType) || "wpt".equals(fileType))) {
-            //鑾峰彇娴佺▼鑺傜偣淇℃伅
-            FieldSetEntity node = onlineDocumentEditService.getBaseDao().getFieldSetEntity("product_sys_flow_node", node_uuid, false);
-            if (!FieldSetEntity.isEmpty(node)) {
-                //鍏佽濂楃孩
-                allowNestRed = node.getBoolean("allow_nest_red");
-                if (allowNestRed) {
-                    //鏌ヨ濂楃孩閰嶇疆妯℃澘
-                    DataTableEntity dt = onlineDocumentEditService.getBaseDao().listTable("product_sys_document_nest_red_config");
-                    if (!DataTableEntity.isEmpty(dt)) {
-                        for (int i = 0; i < dt.getRows(); i++) {
-                            FieldSetEntity fs = dt.getFieldSetEntity(i);
-                            Map<Object, Object> values = fs.getValues();
+				System.out.println(SignUtil.getHmacSHA1(reqp.getFormJson(), Global.getSystemConfig("signature.key", "")));
+			}
+			//鏂囦欢鍚嶏紙绐楀彛鐨勫悕瀛楋級
+			String file_title = fse.getString("fileName");
+			if (file_title == null) {
+				file_title = "";
+			} else {
+				file_title = UnicodeUtil.toString(file_title);
+			}
+			SystemUser currentUser = SpringMVCContextHolder.getCurrentUser();
+			//
+			Boolean allowNestRed = false;
+			String node_uuid = fse.getString("nodeUuid");
+			String fileType = fse.getString("fileType");
+			List<Object> nestRedDocumentParams = new ArrayList<>();
+			// 鍒ゆ柇鏄惁涓� 娴佺▼鑺傜偣涓墦寮�鐨勬枃妗�  涓旀槸 word 绫诲瀷
+			if (!StringUtils.isEmpty(node_uuid) && ("doc".equals(fileType) || "docx".equals(fileType) || "wps".equals(fileType) || "wpt".equals(fileType))) {
+				//鑾峰彇娴佺▼鑺傜偣淇℃伅
+				FieldSetEntity node = onlineDocumentEditService.getBaseDao().getFieldSetEntity("product_sys_flow_node", node_uuid, false);
+				if (!FieldSetEntity.isEmpty(node)) {
+					//鍏佽濂楃孩
+					allowNestRed = node.getBoolean("allow_nest_red");
+					if (allowNestRed) {
+						//鏌ヨ濂楃孩閰嶇疆妯℃澘
+						DataTableEntity dt = onlineDocumentEditService.getBaseDao().listTable("product_sys_document_nest_red_config");
+						if (!DataTableEntity.isEmpty(dt)) {
+							for (int i = 0; i < dt.getRows(); i++) {
+								FieldSetEntity fs = dt.getFieldSetEntity(i);
+								Map<Object, Object> values = fs.getValues();
 
-                            values.put("token", SpringMVCContextHolder.getCurrentUser().getToken_info());
-                            values.put("~table~", "product_sys_document_nest_red_config");
-                            values.put("file_uuid", fse.getUUID());
-                            //灏嗘ā鏉块厤缃俊鎭� 杞负瀛楃涓�
-                            HashMap<Object, Object> v = (HashMap<Object, Object>) values;
-                            v = (HashMap<Object, Object>) v.clone();
-                            v.remove("title");
-                            v.remove("description");
-                            String params = JSON.toJSONString(v);
-                            // 閰嶇疆淇℃伅绛惧悕 锛堢敤浜庡绾㈡椂 GET 璇锋眰锛�
-                            String signature = SignUtil.getHmacSHA1(params, Global.getSystemConfig("signature.key", ""));
-                            values.put("signature", signature);
-                            values.put("formJson", params);
-                            nestRedDocumentParams.add(values);
-                        }
-                    }
-                }
-            }
-        }
-        model.addAttribute("nestDocument", nestRedDocumentParams);
-        model.addAttribute("allow_nest_red", allowNestRed);
-        model.addAttribute("file_title", file_title);
-        model.addAttribute(CmnConst.UUID, fse.getUUID());
-        model.addAttribute("user_name", currentUser.getUser_name());
-        //涓嶈兘淇敼姝ゅ弬鏁帮紝鍙傛暟鍜岀鍚嶇粦瀹氫慨鏀瑰弬鏁伴渶瑕佹洿鏂扮鍚�
-        model.addAttribute(CoreConst.API_POST_REQUEST_DATA + "Temp", request.getParameter("formData"));
-        //浣跨敤绗竴娆′紶杈撹繃鏉ョ殑绛惧悕鐢ㄤ簬鑾峰彇鏂囦欢 銆佷繚瀛樻枃浠�
-        model.addAttribute("signature", request.getParameter("signature"));
-        model.addAttribute("transportProtocols", "http");
-        model.addAttribute("port", Global.getSystemConfig("server.port", ""));
-        return "webOffice";
-    }
+								values.put("token", SpringMVCContextHolder.getCurrentUser().getToken_info());
+								values.put("~table~", "product_sys_document_nest_red_config");
+								values.put("file_uuid", fse.getUUID());
+								//灏嗘ā鏉块厤缃俊鎭� 杞负瀛楃涓�
+								HashMap<Object, Object> v = (HashMap<Object, Object>) values;
+								v = (HashMap<Object, Object>) v.clone();
+								v.remove("title");
+								v.remove("description");
+								String params = JSON.toJSONString(v);
+								// 閰嶇疆淇℃伅绛惧悕 锛堢敤浜庡绾㈡椂 GET 璇锋眰锛�
+								String signature = SignUtil.getHmacSHA1(params, Global.getSystemConfig("signature.key", ""));
+								values.put("signature", signature);
+								values.put("formJson", params);
+								nestRedDocumentParams.add(values);
+							}
+						}
+					}
+				}
+			}
+			model.addAttribute("nestDocument", nestRedDocumentParams);
+			model.addAttribute("allow_nest_red", allowNestRed);
+			model.addAttribute("file_title", file_title);
+			model.addAttribute(CmnConst.UUID, fse.getUUID());
+			model.addAttribute("user_name", currentUser.getUser_name());
+			//涓嶈兘淇敼姝ゅ弬鏁帮紝鍙傛暟鍜岀鍚嶇粦瀹氫慨鏀瑰弬鏁伴渶瑕佹洿鏂扮鍚�
+			model.addAttribute(CoreConst.API_POST_REQUEST_DATA + "Temp", request.getParameter("formData"));
+			//浣跨敤绗竴娆′紶杈撹繃鏉ョ殑绛惧悕鐢ㄤ簬鑾峰彇鏂囦欢 銆佷繚瀛樻枃浠�
+			model.addAttribute("signature", request.getParameter("signature"));
+			model.addAttribute("transportProtocols", "http");
+			model.addAttribute("port", Global.getSystemConfig("server.port", ""));
+			return "webOffice";
+		} catch (Exception e) {
+			e.printStackTrace();
+			return "404";
+		}
+	}
 
-    /**
-     * 璁″垝缂栬緫鏂囨。
-     *
-     * @param request
-     * @return
-     */
-    @PostMapping("/document-edit-plan/{version}")
-    @ResponseBody
-    @ApiVersion(1)
-    public String documentEditPlan(HttpServletRequest request) {
-        try {
-            //鑾峰彇鍙傛暟
-            FieldSetEntity fse = null;
-            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
-            if (bean != null) {
-                RequestParameterEntity reqp = (RequestParameterEntity) bean;
-                fse = reqp.getFormData();
-            }
-            if (fse == null || StringUtils.isEmpty(fse.getUUID())) {
-                return error(FileCode.GET_DATA_FAIL);
-            }
-            /**
-             * 浣跨敤鍚屾閿� 闃叉骞跺彂鎵撳紑鐩稿悓鐨勬枃浠�
-             */
-            synchronized (fse.getUUID().intern()) {
-                onlineDocumentEditService.signDocumentEdit(fse.getUUID());
-            }
-            return OK();
-        } catch (BaseException e) {
-            return error(e);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return error(FileCode.SIGN_DOCUMENT_EDIT_STATUS_FAIL);
-        }
-    }
+	/**
+	 * 璁″垝缂栬緫鏂囨。
+	 *
+	 * @param request
+	 * @return
+	 */
+	@PostMapping("/document-edit-plan/{version}")
+	@ResponseBody
+	@ApiVersion(1)
+	public String documentEditPlan(HttpServletRequest request) {
+		try {
+			//鑾峰彇鍙傛暟
+			FieldSetEntity fse = null;
+			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+			if (bean != null) {
+				RequestParameterEntity reqp = (RequestParameterEntity) bean;
+				fse = reqp.getFormData();
+			}
+			if (fse == null || StringUtils.isEmpty(fse.getUUID())) {
+				return error(FileCode.GET_DATA_FAIL);
+			}
+			/**
+			 * 浣跨敤鍚屾閿� 闃叉骞跺彂鎵撳紑鐩稿悓鐨勬枃浠�
+			 */
+			synchronized (fse.getUUID().intern()) {
+				onlineDocumentEditService.signDocumentEdit(fse.getUUID());
+			}
+			return OK();
+		} catch (BaseException e) {
+			return error(e);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return error(FileCode.SIGN_DOCUMENT_EDIT_STATUS_FAIL);
+		}
+	}
 
 //    /**
 //     * 閲嶇疆鏂囨。缂栬緫鏃堕棿
diff --git a/src/main/java/com/product/file/service/FileManagerService.java b/src/main/java/com/product/file/service/FileManagerService.java
index dee9482..3448466 100644
--- a/src/main/java/com/product/file/service/FileManagerService.java
+++ b/src/main/java/com/product/file/service/FileManagerService.java
@@ -560,7 +560,8 @@
 	 */
 	public byte[] getFileContent(FieldSetEntity attachmentFse) throws BaseException {
 		if (attachmentFse == null || !CmnConst.PRODUCT_SYS_ATTACHMENTS.equals(attachmentFse.getTableName())) {
-			return new byte[16];
+			//杩斿洖涓�涓┖鐨勫瓧鑺傛暟缁�
+			return new byte[0];
 		}
 		try (ByteArrayOutputStream os = new ByteArrayOutputStream();) {
 			FTPService ftpService = new FTPService();
diff --git a/src/main/java/com/product/file/service/OnlineDocumentEditService.java b/src/main/java/com/product/file/service/OnlineDocumentEditService.java
index 15cb9c9..817138c 100644
--- a/src/main/java/com/product/file/service/OnlineDocumentEditService.java
+++ b/src/main/java/com/product/file/service/OnlineDocumentEditService.java
@@ -288,7 +288,7 @@
 					//姝e湪琚紪杈�
 					String existsKey = keys.toArray(new String[]{})[0];
 					//杩欓噷浼氭姏鍑烘鍦ㄧ紪杈戠殑寮傚父
-					throwBeingEditDocument(existsKey.substring(existsKey.lastIndexOf("-")));
+					throwBeingEditDocument(existsKey.substring(existsKey.lastIndexOf("-")+1));
 				} else if (remove) {
 					RedisUtil.setOutTime(key, getExpirationTime());
 					return;
diff --git a/src/main/java/com/product/file/util/PdfConcurrenceUtil.java b/src/main/java/com/product/file/util/PdfConcurrenceUtil.java
index 80d0204..5d053be 100644
--- a/src/main/java/com/product/file/util/PdfConcurrenceUtil.java
+++ b/src/main/java/com/product/file/util/PdfConcurrenceUtil.java
@@ -190,7 +190,7 @@
         File outFile = null;
         OfficeManager officeManager = null;
         try {
-        	if(Global.getPropertyToBoolean("open.office.isEnable", "true")) {//鍚敤oepn office杞崲
+        	if(Global.getPropertyToBoolean("open.office.isEnable", "false")) {//鍚敤oepn office杞崲
         		officeManager = officeManagerQueue.take();
                 inputFile = new File(input);
                 outFile = new File(output);
@@ -200,7 +200,7 @@
             }else{
             	outFile = new File(AsposeUtil.OfficeToPdf(input, output,officeType));
         	}
-            
+
         }catch (Exception e) {
             outFile = null;
             throw e;

--
Gitblit v1.9.2