处理表单模型生成时 无属性值得情况。
This commit is contained in:
parent
ba084184b5
commit
b8c92ee62a
@ -37,6 +37,7 @@ import java.util.*;
|
||||
public class ReadTable {
|
||||
public static Map<String, WordAttribute> wordAttributeMap = new HashMap<>();
|
||||
public static Map<String, String> nameToIdMap = new HashMap<>();
|
||||
public static Map<String, String> idToNameMap = new HashMap<>();
|
||||
|
||||
//基础字段
|
||||
public Map<String, String> fieldMap = new HashMap<>();
|
||||
@ -59,6 +60,7 @@ public class ReadTable {
|
||||
});
|
||||
nameToId.forEach(wordAttribute -> {
|
||||
nameToIdMap.put(wordAttribute.getTitle(), wordAttribute.getType());
|
||||
idToNameMap.put(wordAttribute.getType(), wordAttribute.getTitle());
|
||||
});
|
||||
}
|
||||
|
||||
@ -110,7 +112,18 @@ public class ReadTable {
|
||||
InputStream docfile = SDK.getDCAPI().read(dcContextpdfdoc);
|
||||
//画一个图形 并返回图形ID
|
||||
String shapId = createOneMap(wsId, docname.replace(".doc", ""), userContext, docfile);
|
||||
|
||||
//先把默认属性给他弄上~~~然后再赋值
|
||||
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");
|
||||
Map<String, Map<String, JSONObject>> methodAttrsMap = new HashMap<>();
|
||||
//handleShapeDefaultAttr("", palRepositoryModel, elements, methodAttrsMap, docfile);
|
||||
//writeAttrbute(userContext, docfile, docname.replace(".doc", ""), elements.getJSONObject(shapId));
|
||||
//解析附件进行复制
|
||||
DCContext dcContextpdf1 = new DCContext(userContext, dcProfilepdfdoc, "com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, docxname);
|
||||
InputStream docxfile = SDK.getDCAPI().read(dcContextpdf1);
|
||||
@ -129,7 +142,7 @@ public class ReadTable {
|
||||
nameToIdMap.forEach((key, value) -> {
|
||||
//根据key去更新
|
||||
WordField tmpw = fileFieldMap.get(key);
|
||||
if (tmpw != null) {
|
||||
/*if (tmpw != null) {
|
||||
JSONObject tmp = new JSONObject();
|
||||
tmp.put("ref", "");
|
||||
tmp.put("icon", "../apps/com.actionsoft.apps.coe.pal/img/icon/shape_attribute.png");
|
||||
@ -142,7 +155,7 @@ public class ReadTable {
|
||||
tmp.put("groupPath", "baseAttribute");
|
||||
tmp.put("key", value);
|
||||
attribute.add(tmp);
|
||||
}
|
||||
}*/
|
||||
});
|
||||
}
|
||||
return shapeze;
|
||||
@ -181,8 +194,10 @@ public class ReadTable {
|
||||
props1.put("w", 110);
|
||||
props1.put("h", 50);
|
||||
props1.put("zindex", 0);
|
||||
writeAttrbute(userContext, docfile, name, shapeze);
|
||||
elements.put(shapeIdz, shapeze);
|
||||
|
||||
Map<String, Map<String, JSONObject>> methodAttrsMap = new HashMap<>();
|
||||
handleShapeDefaultAttr("", palRepositoryModel, elements, methodAttrsMap, docfile);
|
||||
// 设置画布大小
|
||||
defineModel.setDefinition(definition.toString());
|
||||
// 保存文件
|
||||
@ -225,20 +240,20 @@ public class ReadTable {
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
//标题后续直接为table
|
||||
if (nowPara.isInTable()) {
|
||||
Table table = range.getTable(nowPara);
|
||||
Map<String, List<String>> tabelDocText = this.getHorizontalTableMapText(table);
|
||||
tabelDocText.keySet().forEach(key -> {
|
||||
List<String> strings = tabelDocText.get(key);
|
||||
if (!strings.isEmpty()) {
|
||||
fieldMap.put(key.replace(" ",""), strings.get(0));
|
||||
fileFieldMap.put(key.replace(" ",""), new WordField<>(strings.get(0)));
|
||||
}
|
||||
});
|
||||
i += table.numParagraphs();
|
||||
}
|
||||
// continue;
|
||||
//标题后续直接为table
|
||||
if (nowPara.isInTable()) {
|
||||
Table table = range.getTable(nowPara);
|
||||
Map<String, List<String>> tabelDocText = this.getHorizontalTableMapText(table);
|
||||
tabelDocText.keySet().forEach(key -> {
|
||||
List<String> strings = tabelDocText.get(key);
|
||||
if (!strings.isEmpty()) {
|
||||
fieldMap.put(key.replace(" ", ""), strings.get(0));
|
||||
fileFieldMap.put(key.replace(" ", ""), new WordField<>(strings.get(0)));
|
||||
}
|
||||
});
|
||||
i += table.numParagraphs();
|
||||
}
|
||||
// continue;
|
||||
//}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@ -292,4 +307,92 @@ public class ReadTable {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义属性
|
||||
*
|
||||
* @param wsId
|
||||
* @param palModel
|
||||
* @param elements
|
||||
* @param methodAttrsMap
|
||||
*/
|
||||
public void handleShapeDefaultAttr(String wsId, PALRepositoryModel palModel, JSONObject elements, Map<String, Map<String, JSONObject>> methodAttrsMap, InputStream file) {
|
||||
boolean result = analysisWordTable(file);
|
||||
for (String key : elements.keySet()) {
|
||||
JSONObject shape = elements.getJSONObject(key);
|
||||
if ("linker".equals(shape.getString("name"))) {
|
||||
continue;
|
||||
}
|
||||
String shapeMehtodId = shape.getString("category").replace("_", ".");
|
||||
String shapeName = shape.getString("name");
|
||||
|
||||
if (methodAttrsMap.containsKey(palModel.getMethodId()) && methodAttrsMap.containsKey(shapeName)) {
|
||||
} else {
|
||||
if (!methodAttrsMap.containsKey(palModel.getMethodId())) {
|
||||
methodAttrsMap.put(palModel.getMethodId(), new HashMap<>());
|
||||
}
|
||||
JSONObject attrs = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), shapeMehtodId, palModel.getMethodId(), shapeName);
|
||||
if (attrs != null) {
|
||||
methodAttrsMap.get(palModel.getMethodId()).put(shapeName, attrs);
|
||||
}
|
||||
}
|
||||
JSONObject attrs = methodAttrsMap.get(palModel.getMethodId()).get(shapeName);// 最终属性内容
|
||||
attrs = JSONObject.parseObject(attrs.toString());// 复制
|
||||
JSONArray dataAttributes = shape.getJSONArray("dataAttributes");
|
||||
if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
|
||||
for (Object attribute : dataAttributes) {
|
||||
JSONObject obj = (JSONObject) attribute;
|
||||
if (obj.containsKey("attributesJsonArray")) {
|
||||
JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
|
||||
Set<String> attrIds = new HashSet<>();
|
||||
for (int i = 0; i < attributesJsonArray.size(); i++) {
|
||||
if (attributesJsonArray.getJSONObject(i).containsKey("id")) {
|
||||
attrIds.add(attributesJsonArray.getJSONObject(i).getString("id"));
|
||||
}
|
||||
}
|
||||
for (String attrId : attrs.keySet()) {
|
||||
if (!attrIds.contains(attrId)) {
|
||||
JSONObject eleAttrObj = getDefaultAttrObj(attrs.getJSONObject(attrId));
|
||||
String id = eleAttrObj.getString("id");
|
||||
String name = idToNameMap.get(id);
|
||||
WordField tmpw = fileFieldMap.get(name);
|
||||
if (tmpw != null) {
|
||||
eleAttrObj.put("value", tmpw.getData());
|
||||
}
|
||||
attributesJsonArray.add(eleAttrObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认属性内容
|
||||
*
|
||||
* @param attr
|
||||
* @return
|
||||
*/
|
||||
public JSONObject getDefaultAttrObj(JSONObject attr) {
|
||||
String ref = attr.getString("ref");
|
||||
boolean readonly = attr.getBooleanValue("readonly");
|
||||
String scope = attr.getString("scope");
|
||||
String attrName = attr.getString("title");
|
||||
String attrId = attr.getString("id");
|
||||
String type = attr.getString("type");
|
||||
String groupPath = attr.getString("groupPath");
|
||||
String attrKey = attr.getString("key");
|
||||
String attrValue = "";
|
||||
JSONObject object2 = new JSONObject();
|
||||
object2.put("ref", ref);
|
||||
object2.put("readonly", readonly);
|
||||
object2.put("scope", scope);
|
||||
object2.put("name", attrName);
|
||||
object2.put("id", attrId);
|
||||
object2.put("type", type);
|
||||
object2.put("groupPath", groupPath);
|
||||
object2.put("key", attrKey);
|
||||
object2.put("value", "");
|
||||
return object2;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user