From 4e70e6115dfa034b1a37631b87a3e5ee3eecd961 Mon Sep 17 00:00:00 2001 From: lihongyu <504404568@qq.com> Date: Thu, 13 Oct 2022 15:48:03 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=84=E4=BB=B6=E6=89=B9=E9=87=8F=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../util/readtable/ReadTable.java | 145 +++++++++++++----- 1 file changed, 108 insertions(+), 37 deletions(-) diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readtable/ReadTable.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readtable/ReadTable.java index 4b12b967..136a9957 100644 --- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readtable/ReadTable.java +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readtable/ReadTable.java @@ -5,7 +5,9 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -26,6 +28,7 @@ import com.actionsoft.apps.coe.pal.datamigration.model.po.WordAttribute; import com.actionsoft.apps.coe.pal.datamigration.model.po.WordField; import com.actionsoft.apps.coe.pal.datamigration.util.ShapeUtil; import com.actionsoft.apps.coe.pal.datamigration.util.readword.ReadWordUtil; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager; import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel; import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil; @@ -93,46 +96,53 @@ public class ReadTable { // 批量上传附件 public void dataFile_import(UserContext userContext, String wsId, String groupValue, String fileValue, String fileName) { + fileName = fileName.trim(); + String fileName2 = fileName; HashMap logMaps = new HashMap(); + if(fileName.substring(0, 4).contains("、")) { + fileName2 = fileName2.substring(fileName2.indexOf("、")+1); + } + if(fileName.substring(0, 4).contains(".")) { + fileName2 = fileName2.substring(fileName2.indexOf(".")+1); + } logMaps.put("FILENAME", fileName); try { String name = ""; - if(fileName.contains("-附件")) { - name = fileName.substring(0, fileName.indexOf("-附件")); + if(fileName2.contains("-附件")) { + name = fileName2.substring(0, fileName2.indexOf("-附件")); + }else if(fileName2.contains("+附件")){ + name = fileName2.substring(0, fileName2.indexOf("+附件")); }else { - name = fileName.substring(0, fileName.lastIndexOf(".")); + name = fileName2.substring(0, fileName2.lastIndexOf(".")); } + PALRepositoryModel palRepositoryModel = null; //String name = fileName.substring(0, fileName.lastIndexOf(".")); - - PALRepositoryModel palRepositoryModel = ReadWordUtil.getRepositoryByName2(wsId, name); - if (palRepositoryModel == null) { - PALRepositoryModel palRepositoryModel_s = ReadWordUtil.getRepositoryByName2(wsId, "酸奶" + name); - if (palRepositoryModel_s != null) { - palRepositoryModel = palRepositoryModel_s; - } - PALRepositoryModel palRepositoryModel_y = ReadWordUtil.getRepositoryByName2(wsId, "液奶" + name); - if (palRepositoryModel_y != null) { - palRepositoryModel = palRepositoryModel_y; - } - PALRepositoryModel palRepositoryModel_l = ReadWordUtil.getRepositoryByName2(wsId, "冷饮" + name); - if (palRepositoryModel_l != null) { - palRepositoryModel = palRepositoryModel_l; - } - PALRepositoryModel palRepositoryModel_n = ReadWordUtil.getRepositoryByName2(wsId, "奶粉" + name); - if (palRepositoryModel_n != null) { - palRepositoryModel = palRepositoryModel_n; - } - if (palRepositoryModel == null) { - if (name.startsWith("酸奶") || name.startsWith("液奶") || name.startsWith("冷饮") - || name.startsWith("奶粉")) { - PALRepositoryModel palRepositoryModel_ss = ReadWordUtil.getRepositoryByName2(wsId, - name.substring(2)); - if (palRepositoryModel_ss != null) { - palRepositoryModel = palRepositoryModel_ss; - } - } - } + String sqlss = "select id from App_Act_Coe_Pal_Repository where plname = '"+name+"' and ISUSE = '1'"; + String plid = DBSql.getString(sqlss); + if(UtilString.isNotEmpty(plid)) { + palRepositoryModel = PALRepositoryCache.getCache().get(plid); } + //PALRepositoryModel palRepositoryModel = ReadWordUtil.getRepositoryByName2(wsId, name); + /* + * if (palRepositoryModel == null) { PALRepositoryModel palRepositoryModel_s = + * ReadWordUtil.getRepositoryByName2(wsId, "酸奶" + name); if + * (palRepositoryModel_s != null) { palRepositoryModel = palRepositoryModel_s; } + * PALRepositoryModel palRepositoryModel_y = + * ReadWordUtil.getRepositoryByName2(wsId, "液奶" + name); if + * (palRepositoryModel_y != null) { palRepositoryModel = palRepositoryModel_y; } + * PALRepositoryModel palRepositoryModel_l = + * ReadWordUtil.getRepositoryByName2(wsId, "冷饮" + name); if + * (palRepositoryModel_l != null) { palRepositoryModel = palRepositoryModel_l; } + * PALRepositoryModel palRepositoryModel_n = + * ReadWordUtil.getRepositoryByName2(wsId, "奶粉" + name); if + * (palRepositoryModel_n != null) { palRepositoryModel = palRepositoryModel_n; } + * if (palRepositoryModel == null) { if (name.startsWith("酸奶") || + * name.startsWith("液奶") || name.startsWith("冷饮") || name.startsWith("奶粉")) { + * PALRepositoryModel palRepositoryModel_ss = + * ReadWordUtil.getRepositoryByName2(wsId, name.substring(2)); if + * (palRepositoryModel_ss != null) { palRepositoryModel = palRepositoryModel_ss; + * } } } } + */ if (null == palRepositoryModel) { logMaps.put("UPFILESTATE", "文件没有匹配到模型!"); @@ -179,15 +189,32 @@ public class ReadTable { "com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, fileName); if(fileName.contains("-附件")) { - fileName = fileName.substring(fileName.lastIndexOf("-附件")+4); + fileName = fileName.substring(fileName.indexOf("-附件")+1); + } + if(fileName.contains("+附件")) { + fileName = fileName.substring(fileName.indexOf("+附件")+1); + } + + if(fileName.length()>4) { + if(fileName.substring(0, 4).contains("、")) { + fileName = fileName.substring(fileName.indexOf("、")+1); + } + if(fileName.substring(0, 4).contains(".")) { + fileName = fileName.substring(fileName.indexOf(".")+1); + } + } // 删除已有文件 StringBuffer sql = new StringBuffer(); sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY) .append(" WHERE SHAPEID = '" + shpId + "'"); - int update = DBSql.update(sql.toString()); InputStream originfile = SDK.getDCAPI().read(dcContextorigin); try { + logMaps.put("PLNAME", palRepositoryModel.getName()); + PALRepositoryModel prmodel = PALRepositoryCache.getCache().get(palRepositoryModel.getParentId()); + if (prmodel != null) { + logMaps.put("FRNAME", prmodel.getName()); + } boolean writeFileTodisk = new ReadWordUtil().writeFileTodisk(userContext, shpId, fileName, originfile, id, "s"); if (writeFileTodisk) { @@ -203,8 +230,10 @@ public class ReadTable { logMaps.put("PALID", id); if (palRepositoryModel.getMethodId().contains("process")) { logMaps.put("MODLETYPE", "流程模型"); + logMaps.put("PLNAME", palRepositoryModel.getName()); } else { logMaps.put("MODLETYPE", "制度模型"); + logMaps.put("PLNAME", palRepositoryModel.getName()); } DCPluginProfile dcProfilepdfdoc = DCProfileManager .getDCProfile("com.actionsoft.apps.coe.pal.datamigration", "migration"); @@ -213,21 +242,63 @@ public class ReadTable { "com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, fileName); if(fileName.contains("-附件")) { - fileName = fileName.substring(fileName.lastIndexOf("-附件")+4); + fileName = fileName.substring(fileName.indexOf("-附件")+1); } - // 删除已有文件 + if(fileName.contains("+附件")) { + fileName = fileName.substring(fileName.indexOf("+附件")+1); + } + + if(fileName.length()>4) { + if(fileName.substring(0, 4).contains("、")) { + fileName = fileName.substring(fileName.indexOf("、")+1); + } + if(fileName.substring(0, 4).contains(".")) { + fileName = fileName.substring(fileName.indexOf(".")+1); + } + + } + StringBuffer sql = new StringBuffer(); sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY) .append(" WHERE FILENAME = '" + fileName + "' AND PALREPOSITORYID = '"+id+"'"); - int update = DBSql.update(sql.toString()); + + /* + * if(!fileName.contains("附件")) { // 删除已有文件 Date d = new Date(); StringBuffer + * sql = new StringBuffer(); SimpleDateFormat sdf = new + * SimpleDateFormat("yyyy/MM/dd"); String formatDate = sdf.format(d); + * sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY). + * append(" WHERE CREATETIME < to_date ('" + * +formatDate+"','yyyy-mm-dd') and PALREPOSITORYID = '"+id+"'"); int update = + * DBSql.update(sql.toString()); + * + * } + */ + /* + * if(!fileName.contains("附件")) { // 删除已有文件 Date d = new Date(); StringBuffer + * sql = new StringBuffer(); SimpleDateFormat sdf = new + * SimpleDateFormat("yyyy-MM-dd"); String formatDate = sdf.format(d); + * sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY) + * .append(" WHERE CREATETIME < '"+formatDate+"' and PALREPOSITORYID = '"+id+"'" + * ); int update = DBSql.update(sql.toString()); + * + * } + */ + InputStream originfile = SDK.getDCAPI().read(dcContextorigin); try { + logMaps.put("PLNAME", palRepositoryModel.getName()); + PALRepositoryModel prmodel = PALRepositoryCache.getCache().get(palRepositoryModel.getParentId()); + if (prmodel != null) { + logMaps.put("FRNAME", prmodel.getName()); + } boolean writeFileTodisk = new ReadWordUtil().writeFileTodisk(userContext, "", fileName, originfile, id, "f"); if (writeFileTodisk) { logMaps.put("UPFILESTATE", "上传成功!"); + } else { logMaps.put("UPFILESTATE", "上传失败!"); + } } catch (FileNotFoundException e1) { e1.printStackTrace();