From ea9ab51324547ce3264e73931018a3e477c7a7b6 Mon Sep 17 00:00:00 2001 From: shicf <shi_chongfu@163.com> Date: 星期三, 25 九月 2024 11:24:52 +0800 Subject: [PATCH] 表单获取 --- src/main/java/com/product/mobile/core/service/FaceMobileService.java | 326 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 292 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/product/mobile/core/service/FaceMobileService.java b/src/main/java/com/product/mobile/core/service/FaceMobileService.java index bb12302..e35c3a7 100644 --- a/src/main/java/com/product/mobile/core/service/FaceMobileService.java +++ b/src/main/java/com/product/mobile/core/service/FaceMobileService.java @@ -5,12 +5,16 @@ import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.drew.metadata.Face; +import com.google.common.collect.Sets; import com.product.common.lang.StringUtils; +import com.product.core.cache.DataPoolCacheImpl; import com.product.core.entity.DataTableEntity; import com.product.core.entity.FieldSetEntity; import com.product.core.exception.BaseException; import com.product.core.service.support.AbstractBaseService; import com.product.mobile.core.config.MobileCoreCode; +import com.product.mobile.core.config.MobileCoreConst; import com.product.mobile.core.entity.FaceFieldEntity; import com.product.tool.flow.config.CmnConst; import com.product.tool.flow.service.FlowDetailService; @@ -30,11 +34,134 @@ @Resource FlowDetailService flowDetailService; - + + ///鑾峰彇琛ㄥ崟鎬诲叆鍙� + /** + * + * @param fse浼犲叆琛ㄥ悕锛屾垨 琛║UID + * @return + */ + public List<FaceFieldEntity> getFaceConfig(FieldSetEntity fse) { + + String tableUuid=fse.getString("table_uuid"); + if (tableUuid==null && StringUtils.isNotEmpty(fse.getString("uuid")) + && StringUtils.isEmpty(fse.getString("table_name"))) { + //閫氳繃涓氬姟琛ㄤ俊鎭煡琛ㄥ崟淇℃伅 + FieldSetEntity detailFse = getBaseDao().getFieldSetEntity(CmnConst.TABLE_FLOW_DETAIL, fse.getString(CmnConst.FIELD_UUID), false); + if(detailFse!=null) { + //鑾峰彇琛ㄥ悕 + fse.setValue("table_name", detailFse.getString("table_name")); + } + + } + //閫氳繃瀹℃壒浠诲姟鐨剈uid鏉ユ煡琛ㄥ崟淇℃伅 + if (tableUuid==null && StringUtils.isNotEmpty(fse.getString("table_name"))) { + FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("鎵�鏈夎〃淇℃伅", new String[]{fse.getString("table_name")}); + if (!FieldSetEntity.isEmpty(tableInfo)) { + tableUuid = tableInfo.getString("uuid"); + fse.setValue("table_uuid", tableUuid); + } + } + + if(tableUuid!=null) { + + FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("鎵�鏈夎〃淇℃伅(uuid)", new String[]{tableUuid}); + if (!FieldSetEntity.isEmpty(tableInfo)) { + //鑾峰彇琛ㄥ悕 + fse.setValue("table_name", tableInfo.getString("table_name")); + } + } + + List<FaceFieldEntity> ls=getFaceFieldByTable(fse); + + addproperty(tableUuid,fse.getString("table_name"),ls); + //鎵�鏈夎〃鍗晆uid鑷姩娣诲姞锛屽苟涓篽idden + return ls; + + } + //閫掑綊鎶婁富琛ㄥ拰瀛愯〃鐨勫瓧娈靛睘鎬ф坊鍔犺繘鍘伙紝濡傛灉娌℃湁閰嶈〃鍗曪紝鍒欏彇琛ㄦ暟鎹粨鏋勮繘琛屽睍绀� + /** + * + * @param ls鏌ュ嚭鏉ョ殑琛ㄥ崟淇℃伅 + * @param tables 璁板綍鐨勬墍鏈夎〃锛屽搴旂殑琛ㄥ崟淇℃伅 + */ + private void addproperty(String table_uuid,String table_name,List<FaceFieldEntity> ls) { + if(ls==null) { + ls=new ArrayList<FaceFieldEntity>(); + } + if(ls.size()>0) { + for(int i=0;i<ls.size();i++) { + String subTableName=ls.get(i).getSubTableName();///鍙兘鏄瓙琛� + if(StringUtils.isEmpty(subTableName)) {///涓昏〃瀛楁 + DataTableEntity dt = DataPoolCacheImpl.getInstance().getCacheData("琛ㄥ瓧娈典俊鎭�" + ,new String[] {table_uuid,ls.get(i).getField()}); + + if(!DataTableEntity.isEmpty(dt)) { +// if(StringUtils.isEmpty(ls.get(i).getType())) { +// ls.get(i).setType(dt.getFieldSetEntity(0).getString("field_type")); +// } + if(StringUtils.isEmpty(ls.get(i).getPrompt()) && + !StringUtils.isEmpty(dt.getFieldSetEntity(0).getString("field_reference"))) { + ls.get(i).setPrompt(dt.getFieldSetEntity(0).getString("field_reference")); + } + if(StringUtils.isEmpty(ls.get(i).getRequired()) && + !StringUtils.isEmpty(dt.getFieldSetEntity(0).getString("is_required"))) { + ls.get(i).setRequired(dt.getFieldSetEntity(0).getString("is_required")); + } + if(StringUtils.isEmpty(ls.get(i).getName()) && + !StringUtils.isEmpty(dt.getFieldSetEntity(0).getString("field_show_name"))) { + ls.get(i).setName(dt.getFieldSetEntity(0).getString("field_show_name")); + } + } + ls.get(i).setTable(table_name); + }else { + //============鎶婂瓙琛ㄥ瓧娈典篃澶勭悊涓�涓� + //瀛愯〃 + FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("鎵�鏈夎〃淇℃伅", new String[]{subTableName}); + if (!FieldSetEntity.isEmpty(tableInfo)) { + addproperty(tableInfo.getString("uuid"),tableInfo.getString("table_name"),ls.get(i).getSubField()); + } + } + + } + DataTableEntity dt = DataPoolCacheImpl.getInstance().getCacheData("琛ㄥ瓧娈典俊鎭�",new String[] {table_uuid,"uuid"}); + if(!DataTableEntity.isEmpty(dt)) { + FaceFieldEntity uuid=new FaceFieldEntity(); + uuid.setField("uuid"); + uuid.setType("String"); + uuid.setTable(table_name); + uuid.setDisabled("0"); + ls.add(uuid); + } + + }else {///浠ヨ〃鍗曡璁′负鍑嗭紝濡傛灉娌℃湁閰嶇疆琛ㄥ崟锛屽垯浠ユ暟鎹〃涓哄噯锛屽叏閮ㄤ繚鐣� + DataTableEntity dte = DataPoolCacheImpl.getInstance().getCacheData("鎵�鏈夊瓧娈典俊鎭苟鎸夎〃鍒嗙粍",new String[] {table_uuid}); + for(int j=0;j<dte.getRows();j++) { + FaceFieldEntity uuid=new FaceFieldEntity(); + FieldSetEntity f=dte.getFieldSetEntity(j); + if("pk".equals(f.getString("field_type")) + ||"updated_by".equals(f.getString("field_name")) + ||"uuid".equals(f.getString("field_name")) + ||"updated_utc_datetime".equals(f.getString("field_name"))) { + continue; + } + uuid.setPrompt(f.getString("field_reference")); + uuid.setName(f.getString("field_show_name")); + uuid.setField(f.getString("field_name")); + uuid.setType(f.getString("field_type")); + uuid.setTable(table_name); + ls.add(uuid); + } + } + } + + + public List<FaceFieldEntity> getFaceFieldByTable(FieldSetEntity fse) { String tableUuid = fse.getString("table_uuid"); - if (StringUtils.isEmpty(tableUuid)) { - FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("鎵�鏈夎〃淇℃伅", new String[]{fse.getString("table_name")}); + String tableName = fse.getString("table_name"); + if (StringUtils.isEmpty(tableUuid) && !StringUtils.isEmpty(tableName)) { + FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("鎵�鏈夎〃淇℃伅", new String[]{tableName}); if (!FieldSetEntity.isEmpty(tableInfo)) { tableUuid = tableInfo.getString("uuid"); } @@ -43,6 +170,7 @@ throw new BaseException(MobileCoreCode.SYSTEM_FORM_COUNT); } FieldSetEntity faceFse = getBaseDao().getFieldSetByFilter("product_sys_face", "table_uuid=?", new Object[]{tableUuid}, true); + faceFse.setTableName(tableName); return getFaceField(faceFse); } @@ -91,8 +219,18 @@ List<FieldSetEntity> tagFieldSetEntityList = new ArrayList<>(); //鏍规嵁group_uuid 鍒嗙粍 Map<String, List<FieldSetEntity>> groupMap = new HashMap<>(); + Map<String, List<FieldSetEntity>> parentMap = new HashMap<>(); for (FieldSetEntity fieldSetEntity : productSysFaceControlProperty.getData()) { String groupUuid = fieldSetEntity.getString("group_uuid"); + String parentUuid = fieldSetEntity.getString("parent_uuid"); + if (!StringUtils.isEmpty(parentUuid)) { + List<FieldSetEntity> fieldSetEntities = parentMap.get(parentUuid); + if (fieldSetEntities == null) { + fieldSetEntities = new ArrayList<>(); + parentMap.put(parentUuid, fieldSetEntities); + } + fieldSetEntities.add(fieldSetEntity); + } if ("tag".equals(fieldSetEntity.getString("property_name"))) { tagFieldSetEntityList.add(fieldSetEntity); } @@ -110,6 +248,7 @@ } List<FaceFieldEntity> result = new ArrayList<>(); + List<List<FieldSetEntity>> subTableField = new ArrayList<>(); for (FieldSetEntity fs : tagFieldSetEntityList) { String groupUuid = fs.getString("group_uuid"); String parentUuid = fs.getString("parent_uuid"); @@ -120,57 +259,176 @@ if (CollectionUtil.isEmpty(fieldSetEntity)) { continue; } - FieldSetEntity parent = fieldSetEntity.get(0); - String groupUuid1 = parent.getString("group_uuid"); - if (StringUtils.isEmpty(groupUuid1)) { - continue; + + to(groupMap, fieldSetEntity, subTableField, result,parentMap); + } + if (!CollectionUtil.isEmpty(subTableField)) { + //鏍规嵁瀛愯〃琛ㄥ悕瑁呰浇 + Map<String, FaceFieldEntity> tableByFaceField = new HashMap<>(); + for (List<FieldSetEntity> fieldSetEntities : subTableField) { + String parentUuid = fieldSetEntities.get(0).getString("parent_uuid"); + //鍏堟壘鍒癱hildren + List<FieldSetEntity> fieldSetEntity = productSysFaceControlProperty.getFieldSetEntity(parentUuid); + if (CollectionUtil.isEmpty(fieldSetEntities)) { + continue; + } + //鎵惧埌浜哻hildren + FieldSetEntity fieldSetEntity1 = fieldSetEntity.get(0); + String p = fieldSetEntity1.getString("parent_uuid"); + String cGroupUuid = fieldSetEntity1.getString("group_uuid"); + if (StringUtils.isEmpty(p) || StringUtils.isEmpty(cGroupUuid)) { + continue; + } + List<FieldSetEntity> childrenGroup = groupMap.get(cGroupUuid); + List<FieldSetEntity> fieldSetEntity2 = productSysFaceControlProperty.getFieldSetEntity(p); + if (CollectionUtil.isEmpty(fieldSetEntity2) || CollectionUtil.isEmpty(childrenGroup)) { + continue; + } + //鎵惧埌浜� __config__ + FieldSetEntity fieldSetEntity3 = fieldSetEntity2.get(0); + String groupUuid = fieldSetEntity3.getString("group_uuid"); + if (StringUtils.isEmpty(groupUuid)) { + continue; + } + String uuid = fieldSetEntity3.getUUID(); + + FaceFieldEntity faceFieldEntity = tableByFaceField.get(uuid); + if (faceFieldEntity == null) { + faceFieldEntity = new FaceFieldEntity(); + } + faceFieldEntity.setComponentType("subTable"); + boolean isSub = CollectionUtil.isNotEmpty(faceFieldEntity.getSubField()); + if (!isSub) { + for (FieldSetEntity setEntity : childrenGroup) { + String propertyName = setEntity.getString("property_name"); + if ("tag".equals(propertyName) && "lx-form-sub-table".equals(setEntity.getString("property_value"))) { + isSub = true; + break; + } + } + } + if (!isSub) { + //涓嶆槸瀛愯〃缁勪欢 + continue; + } + for (FieldSetEntity setEntity : groupMap.get(groupUuid)) { + String propertyName = setEntity.getString("property_name"); + if ("subTableName".equals(propertyName)) { + faceFieldEntity.setSubTableName(setEntity.getString("property_value")); + tableByFaceField.put(faceFieldEntity.getSubTableName(), faceFieldEntity); + } else if ("add".equals(propertyName)) { + faceFieldEntity.setAllowAdd(setEntity.getBoolean("property_value")); + } else if ("delete".equals(propertyName)) { + faceFieldEntity.setAllowDelete(setEntity.getBoolean("property_value")); + } + } + List<FaceFieldEntity> subFieldList = faceFieldEntity.getSubField(); + if (CollectionUtil.isEmpty(subFieldList)) { + subFieldList = new ArrayList<>(); + faceFieldEntity.setSubField(subFieldList); + } + + for (List<FieldSetEntity> setEntities : subTableField) { + to(groupMap, setEntities, null, subFieldList, parentMap); + } + if (!tableByFaceField.containsKey(uuid)) { + tableByFaceField.put(uuid, faceFieldEntity); + result.add(faceFieldEntity); + } + break; + } - List<FieldSetEntity> parentGroup = groupMap.get(groupUuid1); - FaceFieldEntity faceFieldEntity = new FaceFieldEntity(); + } + return result; + } + + + + private void to(Map<String, List<FieldSetEntity>> groupMap, List<FieldSetEntity> fieldSetEntity, List<List<FieldSetEntity>> subTableField, List<FaceFieldEntity> result, Map<String, List<FieldSetEntity>> parentMap) { + FieldSetEntity parent = fieldSetEntity.get(0); + String groupUuid1 = parent.getString("group_uuid"); + if (StringUtils.isEmpty(groupUuid1)) { + return; + } + List<FieldSetEntity> parentGroup = groupMap.get(groupUuid1); + FaceFieldEntity faceFieldEntity = new FaceFieldEntity(); + boolean parentType = false; + String __config__ = null; + List<FieldSetEntity> other = null; + do { for (FieldSetEntity setEntity : parentGroup) { //鎵惧埌灞炴�у悕绉�= __vModel__ String propertyName = setEntity.getString("property_name"); + if ("parentType".equals(propertyName) && "subTable".equals(setEntity.getString("property_value")) && subTableField != null) { + //瀛愯〃瀛楁 + subTableField.add(parentGroup); + result.remove(faceFieldEntity); + break; + } if ("__vModel__".equals(setEntity.getString("property_name"))) { result.add(faceFieldEntity); - propertyName = "fieldName"; - }else if ("defaultNow".equals(propertyName)){ - propertyName="defaultValue"; + propertyName = "field"; + } else if ("defaultNow".equals(propertyName)) { + propertyName = "defaultValue"; + } else if ("__config__".equals(propertyName)) { + __config__ = setEntity.getUUID(); + } + if (!StringUtils.isAnyEmpty(__config__) ) { + //璇诲彇瀛愯〃灞炴�� + if (parentMap != null) { + other = parentMap.get(__config__); + } } propertyName = StrUtil.toCamelCase(propertyName); if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName)) { if ("defaultValue".equals(propertyName)) { ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getBoolean("property_value")); - continue; } else { ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getObject("property_value")); } } - System.out.println(propertyName); } - if (StringUtils.isEmpty(faceFieldEntity.getFieldName())) { - result.remove(faceFieldEntity); - continue; + if (StringUtils.isEmpty(faceFieldEntity.getField())) { + return; } - List<FieldSetEntity> configGroup = groupMap.get(groupUuid); - for (FieldSetEntity setEntity : configGroup) { - //鎵惧埌灞炴�у悕绉�= __vModel__ - String propertyName = setEntity.getString("property_name"); - if ("tag".equals(propertyName)) { - propertyName = "component_type"; - } else if ("field".equals(propertyName)) { - propertyName = "fileField"; - } else if ("tableName".equals(propertyName)) { - propertyName = "fileTableName"; - } - propertyName = StrUtil.toCamelCase(propertyName); - if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName)) { - ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getObject("property_value")); - } + if (parentGroup == other) { + break; } - + if (other != null) { + parentGroup = other; + parentMap = null; + } + } while (other != null); + Set<FieldSetEntity> configGroup = Sets.newHashSet(groupMap.get(fieldSetEntity.get(0).getString("group_uuid"))); + if (other != null) { + if (configGroup == null) { + configGroup = Sets.newHashSet(other); + } else { + configGroup.addAll(other); + } } - return result; + parentGroup = groupMap.get(groupUuid1); + if (configGroup != null && parentGroup != null) { + configGroup.addAll(parentGroup); + } + + for (FieldSetEntity setEntity : configGroup) { + //鎵惧埌灞炴�у悕绉�= __vModel__ + String propertyName = setEntity.getString("property_name"); + if ("tag".equals(propertyName)) { + propertyName = "component_type"; + } else if ("field".equals(propertyName)) { + propertyName = "fileField"; + } else if ("tableName".equals(propertyName)) { + propertyName = "fileTableName"; + } + propertyName = StrUtil.toCamelCase(propertyName); + if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName)) { + ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getObject("property_value")); + } + } + } } -- Gitblit v1.9.2