Merge remote-tracking branch 'origin/apps_dev' into apps_dev
This commit is contained in:
commit
fabf0823f2
@ -121,7 +121,7 @@ public class DataMigrationController {
|
||||
public void run() {
|
||||
String[] fileNameArr = fileName.split(",");
|
||||
for(String name : fileNameArr){
|
||||
new ReadTable().getTableInfo(me,wsId,groupValue,fileValue,fileName);
|
||||
new ReadTable().formDataFile_import(me,wsId,groupValue,fileValue,name);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -39,11 +39,13 @@ import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.web.CoeProcessLevelWeb;
|
||||
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.server.fs.DCContext;
|
||||
import com.actionsoft.bpms.server.fs.dc.DCProfileManager;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.bpms.util.UUIDGener;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
@ -142,11 +144,93 @@ public class ReadTable {
|
||||
}finally {
|
||||
SDK.getBOAPI().createDataBO("BO_ACT_DATAMIGRATION_LOG_T", new BO().setAll(logMaps), userContext);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//导入表单附件
|
||||
public void formDataFile_import(UserContext userContext, String wsId, String groupValue, String fileValue, String fileName) {
|
||||
HashMap<String,Object> logMaps = new HashMap<String,Object>();
|
||||
logMaps.put("FILENAME", fileName);
|
||||
try {
|
||||
String name = fileName.substring(0,fileName.lastIndexOf("."));
|
||||
PALRepositoryModel palRepositoryModel = ReadWordUtil.getRepositoryByName(wsId, name);
|
||||
if(null==palRepositoryModel) {
|
||||
logMaps.put("UPFILESTATE", "文件没有匹配到表单模型!");
|
||||
}else {
|
||||
String shpId = "";
|
||||
String id = palRepositoryModel.getId();
|
||||
logMaps.put("PALID",id);
|
||||
//查询对应绩效模型中数据模型进行填充数据
|
||||
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(id, 0);
|
||||
if(null==defineModel) {
|
||||
shpId = createOneMap2(wsId, name, userContext);
|
||||
if("".equals(shpId)) {
|
||||
logMaps.put("UPFILESTATE", "表单图形创建失败!");
|
||||
|
||||
}
|
||||
}else {
|
||||
String define = defineModel.getDefinition();
|
||||
JSONObject definition = JSONObject.parseObject(define);
|
||||
JSONObject elements = definition.getJSONObject("elements");
|
||||
for (String key : elements.keySet()) {
|
||||
JSONObject shape1 = elements.getJSONObject(key);
|
||||
if("form".equals(shape1.getString("name"))) {
|
||||
shpId = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if("".equals(shpId)) {
|
||||
//画一个图形 并返回图形ID
|
||||
shpId = createOneMap2(wsId, name, userContext);
|
||||
if("".equals(shpId)) {
|
||||
logMaps.put("UPFILESTATE", "表单图形创建失败!");
|
||||
|
||||
}
|
||||
}
|
||||
String fileName_shap = "";
|
||||
UpFileDao upFileDao = new UpFileDao();
|
||||
StringBuilder sqlWhere = new StringBuilder();
|
||||
sqlWhere.append(" and PALREPOSITORYID ='").append(id).append("'");
|
||||
List<UpfileModel> fileList = upFileDao.search(sqlWhere.toString());
|
||||
if (fileList != null && fileList.size() > 0)
|
||||
for (UpfileModel upfileModel : fileList) {
|
||||
if ("s".equals(upfileModel.getType())) {
|
||||
String fileName_shaps= upfileModel.getFileName();
|
||||
if(UtilString.isNotEmpty(fileName_shaps)) {
|
||||
fileName_shap = fileName_shaps.substring(0,fileName_shaps.lastIndexOf("."));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(name.equals(fileName_shap)) {
|
||||
logMaps.put("UPFILESTATE", "此文件已存在,已忽略!");
|
||||
}else {
|
||||
DCPluginProfile dcProfilepdfdoc = DCProfileManager.getDCProfile("com.actionsoft.apps.coe.pal.datamigration", "migration");
|
||||
//将文件挂载到附件里面
|
||||
DCContext dcContextorigin = new DCContext(userContext, dcProfilepdfdoc, "com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, fileName);
|
||||
InputStream originfile = SDK.getDCAPI().read(dcContextorigin);
|
||||
try {
|
||||
boolean writeFileTodisk = new ReadWordUtil().writeFileTodisk(userContext, shpId, fileName, originfile, id, "s");
|
||||
if(writeFileTodisk) {
|
||||
logMaps.put("UPFILESTATE", "上传成功!");
|
||||
}else {
|
||||
logMaps.put("UPFILESTATE", "上传失败!");
|
||||
}
|
||||
} catch (FileNotFoundException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}finally {
|
||||
SDK.getBOAPI().createDataBO("BO_ACT_FORMDATDFILE_LOG_F", new BO().setAll(logMaps), userContext);
|
||||
}
|
||||
}
|
||||
|
||||
//导入表单属性及附件
|
||||
public void getTableInfo(UserContext userContext, String wsId, String groupValue, String fileValue, String fileName) {
|
||||
DCPluginProfile dcProfilepdf = DCProfileManager.getDCProfile("com.actionsoft.apps.coe.pal.datamigration", "migration");
|
||||
DCContext dcContextpdf = new DCContext(userContext, dcProfilepdf, "com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, fileName);
|
||||
@ -252,6 +336,56 @@ public class ReadTable {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建表单图形,用于挂附件
|
||||
*
|
||||
* @param plId
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public String createOneMap2(String plId, String name, UserContext userContext) {
|
||||
PALRepositoryModel palRepositoryModel = ReadWordUtil.getRepositoryByName(plId, name);
|
||||
if (palRepositoryModel == null) {
|
||||
return "";
|
||||
}
|
||||
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(palRepositoryModel.getId(), 0);
|
||||
if (defineModel == null) {
|
||||
defineModel = CoeDesignerUtil.createModel(palRepositoryModel.getId(), 0);
|
||||
defineModel.setCreateHistory(false);
|
||||
}
|
||||
String define = defineModel.getDefinition();
|
||||
JSONObject definition = JSONObject.parseObject(define);
|
||||
JSONObject elements = definition.getJSONObject("elements");
|
||||
if (StringUtils.isNotEmpty(definition.getString("commonShapeConfig"))) {
|
||||
definition.remove("commonShapeConfig");
|
||||
}
|
||||
//增加一个表单图形
|
||||
JSONObject shapeze = ShapeUtil.getProcessShapeDefinitionByName("data.form", "form");
|
||||
String shapeIdz = UUIDGener.getObjectId();
|
||||
shapeze.put("text", name);//不生效
|
||||
shapeze.put("level", 0);
|
||||
JSONObject props1 = shapeze.getJSONObject("props");// 位置大小
|
||||
shapeze.put("id", shapeIdz);
|
||||
props1.put("x", 200);
|
||||
props1.put("y", 173);
|
||||
props1.put("w", 150);
|
||||
props1.put("h", 66);
|
||||
props1.put("zindex", 0);
|
||||
elements.put(shapeIdz, shapeze);
|
||||
|
||||
// Map<String, Map<String, JSONObject>> methodAttrsMap = new HashMap<>();
|
||||
//handleShapeDefaultAttr("", palRepositoryModel, elements, methodAttrsMap, docfile);
|
||||
// 设置画布大小
|
||||
defineModel.setDefinition(definition.toString());
|
||||
// 保存文件
|
||||
CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作
|
||||
return shapeIdz;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建表单图形
|
||||
*
|
||||
@ -287,10 +421,10 @@ public class ReadTable {
|
||||
shapeze.put("level", 0);
|
||||
JSONObject props1 = shapeze.getJSONObject("props");// 位置大小
|
||||
shapeze.put("id", shapeIdz);
|
||||
props1.put("x", 100);
|
||||
props1.put("y", 277);
|
||||
props1.put("w", 110);
|
||||
props1.put("h", 50);
|
||||
props1.put("x", 200);
|
||||
props1.put("y", 173);
|
||||
props1.put("w", 150);
|
||||
props1.put("h", 66);
|
||||
props1.put("zindex", 0);
|
||||
elements.put(shapeIdz, shapeze);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user