批处理应用支持表格类型属性

This commit is contained in:
446052889@qq.com 2022-09-09 11:33:22 +08:00
parent d4e8eab923
commit 97cb0f291d
9 changed files with 212 additions and 8 deletions

View File

@ -326,6 +326,9 @@ public class ImportProcessExcel {
model.setRelationShapeText(roleObj.toString());
relationList.add(model);
}
} else if ("table".equals(type)) {
attrValue = cellData.getString("tableValue");
property.setPropertyValue(attrValue);
} else {
attrValue = cellData.getString("value");
property.setPropertyValue(attrValue);
@ -537,6 +540,9 @@ public class ImportProcessExcel {
model.setRelationShapeText(roleObj.toString());
relationList.add(model);
}
} else if ("table".equals(type)) {
attrValue = cellData.getString("tableValue");
property.setPropertyValue(attrValue);
} else {
attrValue = cellData.getString("value");
property.setPropertyValue(attrValue);

View File

@ -9,8 +9,7 @@ import java.util.regex.Pattern;
import com.actionsoft.apps.coe.pal.batch.util.BatchUtil;
import com.actionsoft.apps.coe.pal.batch.web.create.process.model.ExcelRowModel;
import com.actionsoft.apps.coe.pal.batch.web.create.process.model.RepositoryInfoModel;
import com.actionsoft.apps.coe.pal.batch.web.create.process.valid.impl.type.ValidAwsOrg;
import com.actionsoft.apps.coe.pal.batch.web.create.process.valid.impl.type.ValidSelect;
import com.actionsoft.apps.coe.pal.batch.web.create.process.valid.impl.type.*;
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
@ -27,8 +26,6 @@ import com.actionsoft.apps.coe.pal.batch.web.create.process.valid.Valid;
import com.actionsoft.apps.coe.pal.batch.web.create.process.valid.impl.ValidName;
import com.actionsoft.apps.coe.pal.batch.web.create.process.valid.impl.ValidNo;
import com.actionsoft.apps.coe.pal.batch.web.create.process.valid.impl.ValidType;
import com.actionsoft.apps.coe.pal.batch.web.create.process.valid.impl.type.ValidRelation;
import com.actionsoft.apps.coe.pal.batch.web.create.process.valid.impl.type.ValidString;
import com.actionsoft.apps.coe.pal.batch.util.POIUtil;
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
import com.actionsoft.bpms.util.UtilString;
@ -303,6 +300,8 @@ public class ValidProcessExcel {
rowJson.add(JSONObject.parseObject(new Valid(new ValidAwsOrg()).execute(param).toString()));
} else if ("select_m".equals(attrType) || "select".equals(attrType)) {// 单多选
rowJson.add(JSONObject.parseObject(new Valid(new ValidSelect()).execute(param).toString()));
} else if ("table".equals(attrType)) {// 表格
rowJson.add(JSONObject.parseObject(new Valid(new ValidTable()).execute(param).toString()));
} else {// 其他按照string对待
rowJson.add(JSONObject.parseObject(new Valid(new ValidString()).execute(param).toString()));
}

View File

@ -0,0 +1,96 @@
package com.actionsoft.apps.coe.pal.batch.web.create.process.valid.impl.type;
import com.actionsoft.apps.coe.pal.batch.util.BatchUtil;
import com.actionsoft.apps.coe.pal.batch.web.create.process.valid.ValidCell;
import com.actionsoft.apps.coe.pal.batch.web.create.shape.ShapeConst;
import com.actionsoft.apps.coe.pal.batch.web.create.shape.valid.ValidShapeCell;
import com.actionsoft.bpms.util.UUIDGener;
import com.actionsoft.bpms.util.UtilString;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.HashSet;
import java.util.Set;
public class ValidTable implements ValidCell {
@Override
public Object validTableCell(Object param) {
JSONObject paramObj = JSONObject.parseObject(param.toString());
boolean isOk = true;
String msg = "";
String value = paramObj.getString("value");
String title = paramObj.getString("title");
JSONObject attr = paramObj.getJSONObject("attr");
JSONObject ref =attr.getJSONObject("ref");
String firstColumn = ref.getString("firstColumn");
String secondColumn = ref.getString("secondColumn");
JSONArray valueArr = new JSONArray();// 存储解析后的值
if (!UtilString.isEmpty(value)) {
if (BatchUtil.containHtmlEles(value)) {
isOk = false;
msg = BatchUtil.eleErrMsg;
} else {
// if (!value.contains("##")) {
// isOk = false;
// msg = "格式错误按照name##desc$$name##desc格式来填写";
// }
String [] tableRows = value.split("\\$\\$");
for (int i = 0; i < tableRows.length; i++) {
String row = tableRows[i];
if (UtilString.isEmpty(row)) {
continue;
}
String [] content = row.split("##");
if (content.length != 2) {
isOk = false;
msg = "格式错误请按照name##desc$$name##desc格式来填写";
break;
}
JSONObject obj = new JSONObject();
obj.put("name", content[0].replace("**", "\n"));
obj.put("desc", content[1].replace("**", "\n"));
obj.put("id", UUIDGener.getObjectId());
valueArr.add(obj);
}
}
}
JSONObject tableValue = new JSONObject();
tableValue.put("name", title);
JSONArray tableArr = new JSONArray();
// 添加表头
JSONObject tableHeader = new JSONObject();
tableHeader.put("id", "table_head");
tableHeader.put("name", firstColumn);
tableHeader.put("desc", secondColumn);
tableArr.add(tableHeader);
// 添加内容
tableArr.addAll(valueArr);
tableValue.put("table", tableArr);
JSONObject result = new JSONObject();
result.put("name", title);
result.put("name2", ShapeConst.EXTEND_PROP_PREFIX + title + ShapeConst.EXTEND_PROP_SUFFIX);
result.put("isOk", isOk);
result.put("msg", BatchUtil.specialCharTransfer(msg));
result.put("value", BatchUtil.specialCharTransfer(value));
result.put("tableValue", tableValue);
return result;
}
/**
* 获取选择范围
* @param scopeStr
* @return
*/
private Set<String> getSelectScope(String scopeStr) {
Set<String> result = new HashSet<>();
String [] refArr = scopeStr.split(",");
for (int i = 0; i < refArr.length; i++) {
result.add(refArr[i]);
}
return result;
}
}

View File

@ -350,6 +350,9 @@ public class ImportShapeExcel {
relationList.add(model);
}
updateAttrDataJson.put(attrId, object2);
} else if ("table".equals(type)) {// 表格类型
object2.put("value", cellData.getJSONObject("tableValue"));
updateAttrDataJson.put(attrId, object2);
} else {// 剩余的当作string处理
attrValue = cellData.getString("value");
if (UtilString.isEmpty(attrValue)) {
@ -628,6 +631,9 @@ public class ImportShapeExcel {
relationList.add(model);
}
attributesJsonArray.add(object2);
} else if ("table".equals(type)) {// 表格类型
object2.put("value", cellData.getJSONObject("tableValue"));
attributesJsonArray.add(object2);
} else {// 剩余的当作string处理
attrValue = cellData.getString("value");
if (UtilString.isEmpty(attrValue)) {

View File

@ -11,7 +11,7 @@ import com.actionsoft.apps.coe.pal.batch.web.create.process.valid.impl.ValidName
import com.actionsoft.apps.coe.pal.batch.web.create.shape.model.ExcelRepositoryModel;
import com.actionsoft.apps.coe.pal.batch.web.create.shape.model.ExcelShapeModel;
import com.actionsoft.apps.coe.pal.batch.web.create.shape.model.RepositoryShapeInfoModel;
import com.actionsoft.apps.coe.pal.batch.web.create.shape.valid.impl.type.ValidShapeSelect;
import com.actionsoft.apps.coe.pal.batch.web.create.shape.valid.impl.type.*;
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager;
import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache;
@ -35,9 +35,6 @@ import com.actionsoft.apps.coe.pal.batch.web.create.shape.valid.ValidShape;
import com.actionsoft.apps.coe.pal.batch.web.create.shape.valid.impl.ValidShapeName;
import com.actionsoft.apps.coe.pal.batch.web.create.shape.valid.impl.ValidShapeNo;
import com.actionsoft.apps.coe.pal.batch.web.create.shape.valid.impl.ValidShapeType;
import com.actionsoft.apps.coe.pal.batch.web.create.shape.valid.impl.type.ValidShapeAwsOrg;
import com.actionsoft.apps.coe.pal.batch.web.create.shape.valid.impl.type.ValidShapeRelation;
import com.actionsoft.apps.coe.pal.batch.web.create.shape.valid.impl.type.ValidShapeString;
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.util.UtilString;
@ -498,6 +495,8 @@ public class ValidShapeExcel {
rowJson.add(JSONObject.parseObject(new ValidShape(new ValidShapeAwsOrg()).execute(param).toString()));
} else if ("select_m".equals(attrType) || "select".equals(attrType)) {// 单多选
rowJson.add(JSONObject.parseObject((new ValidShape(new ValidShapeSelect()).execute(param).toString())));
} else if ("table".equals(attrType)) {// 表格
rowJson.add(JSONObject.parseObject((new ValidShape(new ValidShapeTable()).execute(param).toString())));
} else {// 其他按照string对待
rowJson.add(JSONObject.parseObject(new ValidShape(new ValidShapeString()).execute(param).toString()));
}

View File

@ -0,0 +1,98 @@
package com.actionsoft.apps.coe.pal.batch.web.create.shape.valid.impl.type;
import com.actionsoft.apps.coe.pal.batch.util.BatchUtil;
import com.actionsoft.apps.coe.pal.batch.web.create.shape.ShapeConst;
import com.actionsoft.apps.coe.pal.batch.web.create.shape.valid.ValidShapeCell;
import com.actionsoft.bpms.util.UUIDGener;
import com.actionsoft.bpms.util.UtilString;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class ValidShapeTable implements ValidShapeCell {
@Override
public Object validTableCell(Object param) {
JSONObject paramObj = JSONObject.parseObject(param.toString());
boolean isOk = true;
String msg = "";
String value = paramObj.getString("value");
String title = paramObj.getString("title");
JSONObject attr = paramObj.getJSONObject("attr");
JSONObject ref =attr.getJSONObject("ref");
String firstColumn = ref.getString("firstColumn");
String secondColumn = ref.getString("secondColumn");
JSONArray valueArr = new JSONArray();// 存储解析后的值
if (!UtilString.isEmpty(value)) {
if (BatchUtil.containHtmlEles(value)) {
isOk = false;
msg = BatchUtil.eleErrMsg;
} else {
// if (!value.contains("##")) {
// isOk = false;
// msg = "格式错误按照name##desc$$name##desc格式来填写";
// }
String [] tableRows = value.split("\\$\\$");
for (int i = 0; i < tableRows.length; i++) {
String row = tableRows[i];
if (UtilString.isEmpty(row)) {
continue;
}
String [] content = row.split("##");
if (content.length != 2) {
isOk = false;
msg = "格式错误请按照name##desc$$name##desc格式来填写";
break;
}
JSONObject obj = new JSONObject();
obj.put("name", content[0].replace("**", "\n"));
obj.put("desc", content[1].replace("**", "\n"));
obj.put("id", UUIDGener.getObjectId());
valueArr.add(obj);
}
}
}
JSONObject tableValue = new JSONObject();
tableValue.put("name", title);
JSONArray tableArr = new JSONArray();
// 添加表头
JSONObject tableHeader = new JSONObject();
tableHeader.put("id", "table_head");
tableHeader.put("name", firstColumn);
tableHeader.put("desc", secondColumn);
tableArr.add(tableHeader);
// 添加内容
tableArr.addAll(valueArr);
tableValue.put("table", tableArr);
JSONObject result = new JSONObject();
result.put("name", title);
result.put("name2", ShapeConst.EXTEND_PROP_PREFIX + title + ShapeConst.EXTEND_PROP_SUFFIX);
result.put("isOk", isOk);
result.put("msg", BatchUtil.specialCharTransfer(msg));
result.put("value", BatchUtil.specialCharTransfer(value));
result.put("tableValue", tableValue);
return result;
}
/**
* 获取选择范围
* @param scopeStr
* @return
*/
private Set<String> getSelectScope(String scopeStr) {
Set<String> result = new HashSet<>();
String [] refArr = scopeStr.split(",");
for (int i = 0; i < refArr.length; i++) {
result.add(refArr[i]);
}
return result;
}
}