附件批量上传修改
This commit is contained in:
parent
a8d70089b5
commit
4e70e6115d
@ -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<String, Object> logMaps = new HashMap<String, Object>();
|
||||
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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user