From a19d8fd639e32dc45394864f0c9786dc5c1dc78c Mon Sep 17 00:00:00 2001 From: zhouc Date: Fri, 20 Sep 2024 18:18:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E5=90=88=E5=90=8C?= =?UTF-8?q?=E7=AD=BE=E7=AB=A0=E5=8F=AA=E5=90=8C=E6=AD=A5pdf=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E6=96=87=E4=BB=B6=202.=E5=A2=9E=E5=8A=A0=E5=9B=9E?= =?UTF-8?q?=E7=AD=BE=E7=A1=AE=E8=AE=A4=E5=BF=85=E9=A1=BB=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E9=99=84=E4=BB=B6=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Utils/ObjectToJsonUtils.java | 2 +- .../ia/intebilllogon/commom/CommonUtils.java | 64 +++++++++++++------ .../dynamic/ContractResignEdit.java | 40 ++++++------ 3 files changed, 68 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/yem/ia/intebilllogon/Utils/ObjectToJsonUtils.java b/src/main/java/com/yem/ia/intebilllogon/Utils/ObjectToJsonUtils.java index 2c18203a..59a5f5b6 100644 --- a/src/main/java/com/yem/ia/intebilllogon/Utils/ObjectToJsonUtils.java +++ b/src/main/java/com/yem/ia/intebilllogon/Utils/ObjectToJsonUtils.java @@ -164,7 +164,7 @@ public class ObjectToJsonUtils { } //是否附件 if (yem_isattachment) { - JSONArray jsonArray = CommonUtils.GetAttachment(entityName, pkid, yem_attachmentkey); + JSONArray jsonArray = CommonUtils.GetAttachment(entityName, pkid, yem_attachmentkey,dataEntity); if (jsonArray != null && jsonArray.size() > 0) { widgetValueObject.put(yem_iaformid, jsonArray); } diff --git a/src/main/java/com/yem/ia/intebilllogon/commom/CommonUtils.java b/src/main/java/com/yem/ia/intebilllogon/commom/CommonUtils.java index 684f1e4c..cc149454 100644 --- a/src/main/java/com/yem/ia/intebilllogon/commom/CommonUtils.java +++ b/src/main/java/com/yem/ia/intebilllogon/commom/CommonUtils.java @@ -286,7 +286,8 @@ public class CommonUtils { * @param attachKey 附件标识 * @return JSONArray */ - public static JSONArray GetAttachment(String formId, Object pkId, String attachKey) { + public static JSONArray GetAttachment(String formId, Object pkId, String attachKey, DynamicObject dataEntity) { + boolean yem_ispdf = dataEntity.getBoolean("yem_ispdf"); JSONArray jsonArray = new JSONArray(); try { List> attachments = AttachmentServiceHelper.getAttachments(formId, pkId, attachKey); @@ -296,31 +297,56 @@ public class CommonUtils { for (int i = 0; i < attachments.size(); i++) { Map map = attachments.get(i); String fileurl = (String) map.get("url"); + String filename = (String) map.get("name"); if (fileurl.contains("http://localhost:8080/ierp/")) { fileurl = fileurl.replace("http://localhost:8080/", "http://10.64.112.152:8022/"); } - - String result = YunzhijiaUtils.uploadfile(fileurl, accessToken, (String) map.get("name")); - JSONObject json = JSONObject.parseObject(result); - Boolean success = json.getBoolean("success"); - if (success) { - JSONArray data = json.getJSONArray("data"); - for (int j = 0; j < data.size(); j++) { - JSONObject object = new JSONObject(); - JSONObject jsonObject = data.getJSONObject(j); - if (jsonObject != null) { + if (yem_ispdf && filename.endsWith(".pdf")) { + String result = YunzhijiaUtils.uploadfile(fileurl, accessToken, (String) map.get("name")); + JSONObject json = JSONObject.parseObject(result); + Boolean success = json.getBoolean("success"); + if (success) { + JSONArray data = json.getJSONArray("data"); + for (int j = 0; j < data.size(); j++) { + JSONObject object = new JSONObject(); + JSONObject jsonObject = data.getJSONObject(j); + if (jsonObject != null) { // object.put("fileName", jsonObject.getString("fileName")); - object.put("fileName", map.get("name").toString()); - object.put("fileId", jsonObject.getString("fileId")); - object.put("fileSize", jsonObject.getString("length")); - object.put("fileType", jsonObject.getString("fileType")); - object.put("fileExt", map.get("type").toString()); - jsonArray.add(object); - //创建ERP与云之家对照表 - Addattyunzhijia(formId, pkId, map, attachKey, jsonObject); + object.put("fileName", map.get("name").toString()); + object.put("fileId", jsonObject.getString("fileId")); + object.put("fileSize", jsonObject.getString("length")); + object.put("fileType", jsonObject.getString("fileType")); + object.put("fileExt", map.get("type").toString()); + jsonArray.add(object); + //创建ERP与云之家对照表 + Addattyunzhijia(formId, pkId, map, attachKey, jsonObject); + } + } + } + } else { + String result = YunzhijiaUtils.uploadfile(fileurl, accessToken, (String) map.get("name")); + JSONObject json = JSONObject.parseObject(result); + Boolean success = json.getBoolean("success"); + if (success) { + JSONArray data = json.getJSONArray("data"); + for (int j = 0; j < data.size(); j++) { + JSONObject object = new JSONObject(); + JSONObject jsonObject = data.getJSONObject(j); + if (jsonObject != null) { +// object.put("fileName", jsonObject.getString("fileName")); + object.put("fileName", map.get("name").toString()); + object.put("fileId", jsonObject.getString("fileId")); + object.put("fileSize", jsonObject.getString("length")); + object.put("fileType", jsonObject.getString("fileType")); + object.put("fileExt", map.get("type").toString()); + jsonArray.add(object); + //创建ERP与云之家对照表 + Addattyunzhijia(formId, pkId, map, attachKey, jsonObject); + } } } } + } } } else { diff --git a/src/main/java/com/yem/wm/es/salesorder/dynamic/ContractResignEdit.java b/src/main/java/com/yem/wm/es/salesorder/dynamic/ContractResignEdit.java index b622dea7..7b4e53e2 100644 --- a/src/main/java/com/yem/wm/es/salesorder/dynamic/ContractResignEdit.java +++ b/src/main/java/com/yem/wm/es/salesorder/dynamic/ContractResignEdit.java @@ -32,14 +32,12 @@ import java.util.*; * @Created by ZZSLL */ -public class ContractResignEdit extends AbstractFormPlugin implements UploadListener -{ +public class ContractResignEdit extends AbstractFormPlugin implements UploadListener { private static final Log log = LogFactory.getLog(ContractResignEdit.class); @Override - public void registerListener(EventObject e) - { + public void registerListener(EventObject e) { super.registerListener(e); AttachmentPanel attachmentPanel = this.getView().getControl("yem_attachmentpanel"); @@ -123,8 +121,7 @@ public class ContractResignEdit extends AbstractFormPlugin implements UploadList } @Override - public void click(EventObject e) - { + public void click(EventObject e) { super.click(e); Control source = (Control) e.getSource(); String key = source.getKey(); @@ -142,16 +139,21 @@ public class ContractResignEdit extends AbstractFormPlugin implements UploadList HashMap hashMap = new HashMap<>(); IPageCache cache = this.getPageCache(); List> addAttachmentData = getCache(cache); - hashMap.put("attach", addAttachmentData); - long user = dataEntity.getLong("yem_user.id"); - Date date = dataEntity.getDate("yem_date"); - hashMap.put("user", user); - hashMap.put("date", date); - log.error("关闭界面之前:" + addAttachmentData); - this.getView().returnDataToParent(hashMap); - this.getView().close(); - addAttachmentData.clear();//关闭界面清空上传附件 - log.error("关闭界面:" + addAttachmentData); + if (addAttachmentData.size() > 0) { + hashMap.put("attach", addAttachmentData); + long user = dataEntity.getLong("yem_user.id"); + Date date = dataEntity.getDate("yem_date"); + hashMap.put("user", user); + hashMap.put("date", date); + log.error("关闭界面之前:" + addAttachmentData); + this.getView().returnDataToParent(hashMap); + this.getView().close(); + addAttachmentData.clear();//关闭界面清空上传附件 + log.error("关闭界面:" + addAttachmentData); + } + else{ + this.getView().showErrorNotification("请上传附件或等待附件上传完毕后重试!"); + } } @Override @@ -171,7 +173,7 @@ public class ContractResignEdit extends AbstractFormPlugin implements UploadList AttachmentPanel panel = view.getControl("yem_attachmentpanel"); for (Map map : attach) { map.put("lastModified", new Date().getTime()); - filtername.add((String)map.get("name")); + filtername.add((String) map.get("name")); } panel.upload(attach); view.updateView("yem_attachmentpanel"); @@ -181,6 +183,7 @@ public class ContractResignEdit extends AbstractFormPlugin implements UploadList /** * 从缓存中获取附件 + * * @param cache * @return */ @@ -189,7 +192,7 @@ public class ContractResignEdit extends AbstractFormPlugin implements UploadList List> addAttachmentData = null; if (attach != null) { addAttachmentData = getJson(attach) == null ? new ArrayList<>() : getJson(attach); - }else { + } else { addAttachmentData = new ArrayList<>(); } return addAttachmentData; @@ -197,6 +200,7 @@ public class ContractResignEdit extends AbstractFormPlugin implements UploadList /** * 将从缓存中取到的附件转换成List> + * * @param attach * @return */ From 9b919c44a1de8075b3afddd33eed11ef638b6907 Mon Sep 17 00:00:00 2001 From: zhouc Date: Fri, 20 Sep 2024 18:19:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BF=BD=E7=95=A5.imi?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7c01d507..8a3e6e1a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ out/ src/main/java/kd/cosmic/ /font/ +*.iml \ No newline at end of file