|
@@ -131,6 +131,35 @@ public class EntityProcess {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ protected <T> List<T> addEntity(JSONObject aiOut, EntityEnum entityType, Class<T> t, EntityEnum[] subEntityTypes, Object[] subNames) throws Exception {
|
|
|
+ List<T> list = new ArrayList<>();
|
|
|
+ List<Map<String, String>> entityList = processJson(aiOut, entityType.toString());
|
|
|
+ for (Map<String, String> entityMap : entityList) {
|
|
|
+ if (StringUtils.isEmpty(entityMap.get(entityType.toString()))) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ T o = t.newInstance();
|
|
|
+ for (String key : entityMap.keySet()) {
|
|
|
+ if (key.equals(entityType.toString())) {
|
|
|
+ BeanUtils.copyProperty(o, "name", entityMap.get(key));
|
|
|
+ } else {
|
|
|
+ for (int i = 0; i < subEntityTypes.length; i++) {
|
|
|
+ if (key.equals(subEntityTypes[i].toString())) {
|
|
|
+ if (subNames[i] instanceof String) {
|
|
|
+ BeanUtils.copyProperty(o, subNames[i].toString(), StringUtils.isEmpty(entityMap.get(key)) ? "" : entityMap.get(key));
|
|
|
+ } else {
|
|
|
+ BeanUtils.copyProperty(subNames[i], "name", StringUtils.isEmpty(entityMap.get(key)) ? "" : entityMap.get(key));
|
|
|
+ BeanUtils.copyProperty(o, subNames[i].getClass().getSimpleName(), subNames[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list.add(o);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public String[] extract_digit(String value) {
|
|
|
String[] res = new String[2];
|