From 3dd42db83150803f29ee7361090295dfaffdd428 Mon Sep 17 00:00:00 2001 From: shicf <shi_chongfu@163.com> Date: 星期二, 08 十月 2024 10:57:38 +0800 Subject: [PATCH] 未配置表单情况下返回数据结构 --- src/main/java/com/product/mobile/core/service/FaceMobileService.java | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 173 insertions(+), 4 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 1f3332c..79a39a4 100644 --- a/src/main/java/com/product/mobile/core/service/FaceMobileService.java +++ b/src/main/java/com/product/mobile/core/service/FaceMobileService.java @@ -9,6 +9,7 @@ import com.google.common.collect.Sets; import com.product.common.lang.StringUtils; import com.product.core.cache.DataPoolCacheImpl; +import com.product.core.dao.BaseDao; import com.product.core.entity.DataTableEntity; import com.product.core.entity.FieldSetEntity; import com.product.core.exception.BaseException; @@ -19,6 +20,8 @@ import com.product.tool.flow.config.CmnConst; import com.product.tool.flow.service.FlowDetailService; import com.product.util.BaseUtil; + +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -34,7 +37,171 @@ @Resource FlowDetailService flowDetailService; - + + @Autowired + public BaseDao baseDao; + + ///鑾峰彇琛ㄥ崟鎬诲叆鍙� + /** + * + * @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 && fse.getString("table_name")==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); + if(ls==null)ls=new ArrayList<FaceFieldEntity>(); + 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.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.setComponentType("uuid"); + uuid.setField("uuid"); + uuid.setName("缂� 鐮�"); + uuid.setType("String"); + uuid.setTable(table_name); + uuid.setHidden("1"); + ls.add(uuid); + } + + }else {///浠ヨ〃鍗曡璁′负鍑嗭紝濡傛灉娌℃湁閰嶇疆琛ㄥ崟锛屽垯浠ユ暟鎹〃涓哄噯锛屽叏閮ㄤ繚鐣� + toConvertFace(table_uuid,table_name,ls,null); + //杩斿洖瀛愯〃 + Object [][]sub=baseDao.getSubTableName(table_name); + if(sub!=null && sub.length>0&&sub[0].length>0) { + for(int i=0;i<sub[0].length;i++) { + toConvertFace(sub[0][i].toString(),sub[1][i].toString(),new ArrayList<FaceFieldEntity>(),ls); + } + } + + } + } + /** + * 鏁版嵁搴撹〃瀛楁瀹氫箟杞崲鎴愯〃鍗曞畾涔� + * @param table_uuid + * @param table_name + * @param ls + * @param pls 鐖剁晫闈� + */ + private void toConvertFace(String table_uuid,String table_name,List<FaceFieldEntity> ls,List<FaceFieldEntity> pls) { + if(ls==null) { + ls=new ArrayList<FaceFieldEntity>(); + } + 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")) + ||"updated_utc_datetime".equals(f.getString("field_name"))) { + continue; + } + if("uuid".equals(f.getString("field_name"))) { + uuid.setHidden("1"); + } + if("userids".equals(f.getString("field_type")) ||"orgUuids".equals(f.getString("field_type")) ) { + uuid.setMultiple("1"); + }else { + uuid.setMultiple("0"); + } + + uuid.setComponentType(""); + 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); + } + if(pls!=null) { + FaceFieldEntity uuid=new FaceFieldEntity(); + uuid.setHidden(""); + uuid.setComponentType("subTable"); + uuid.setPrompt(""); + uuid.setName(""); + uuid.setField(""); + uuid.setType(""); + uuid.setSubField(ls); + uuid.setSubTableName(table_name); + pls.add(uuid); + } + } + public List<FaceFieldEntity> getFaceFieldByTable(FieldSetEntity fse) { String tableUuid = fse.getString("table_uuid"); String tableName = fse.getString("table_name"); @@ -48,6 +215,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); } @@ -89,7 +257,8 @@ private List<FaceFieldEntity> getFaceField(FieldSetEntity faceFse) { if (FieldSetEntity.isEmpty(faceFse) || DataTableEntity.isEmpty(faceFse.getSubDataTable("product_sys_face_control_property"))) { - throw new BaseException(MobileCoreCode.GET_FACE_CONFIG_FAIL); + return null; +// throw new BaseException(MobileCoreCode.GET_FACE_CONFIG_FAIL); } DataTableEntity productSysFaceControlProperty = faceFse.getSubDataTable("product_sys_face_control_property"); @@ -242,7 +411,7 @@ } if ("__vModel__".equals(setEntity.getString("property_name"))) { result.add(faceFieldEntity); - propertyName = "fieldName"; + propertyName = "field"; } else if ("defaultNow".equals(propertyName)) { propertyName = "defaultValue"; } else if ("__config__".equals(propertyName)) { @@ -267,7 +436,7 @@ faceFieldEntity.putOtherParam(propertyName, setEntity.getObject("property_value")); } } - if (StringUtils.isEmpty(faceFieldEntity.getFieldName())) { + if (StringUtils.isEmpty(faceFieldEntity.getField())) { return; } if (parentGroup == other) { -- Gitblit v1.9.2