From 036ffc1b770cf0a3247890b8fdd88884376d8b6d Mon Sep 17 00:00:00 2001 From: 许鹏程 <1821349743@qq.com> Date: 星期二, 26 十一月 2024 15:25:38 +0800 Subject: [PATCH] 排序 parent --- src/main/java/com/product/mobile/core/service/FaceMobileService.java | 181 +++++++++++++++++++++++++++++--------------- 1 files changed, 119 insertions(+), 62 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 fe05088..3a012b3 100644 --- a/src/main/java/com/product/mobile/core/service/FaceMobileService.java +++ b/src/main/java/com/product/mobile/core/service/FaceMobileService.java @@ -3,11 +3,13 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ReflectUtil; 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.Lists; import com.google.common.collect.Sets; import com.product.common.lang.StringUtils; import com.product.core.cache.DataPoolCacheImpl; @@ -30,6 +32,7 @@ import java.io.File; import java.nio.charset.Charset; import java.util.*; +import java.util.stream.Collectors; /** * @Author cheng @@ -53,19 +56,19 @@ */ public List<FaceFieldEntity> getFaceConfig(FieldSetEntity fse) { - String tableUuid=fse.getString("table_uuid"); - if (tableUuid==null && StringUtils.isNotEmpty(fse.getString("uuid")) + 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) { + if (detailFse != null) { //鑾峰彇琛ㄥ悕 fse.setValue("table_name", detailFse.getString("table_name")); } } //閫氳繃瀹℃壒浠诲姟鐨剈uid鏉ユ煡琛ㄥ崟淇℃伅 - if (tableUuid==null && StringUtils.isNotEmpty(fse.getString("table_name"))) { + 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"); @@ -73,7 +76,7 @@ } } - if(tableUuid!=null && fse.getString("table_name")==null) { + if (tableUuid != null && fse.getString("table_name") == null) { FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("鎵�鏈夎〃淇℃伅(uuid)", new String[]{tableUuid}); if (!FieldSetEntity.isEmpty(tableInfo)) { @@ -82,58 +85,69 @@ } } - List<FaceFieldEntity> ls=getFaceFieldByTable(fse); - if(ls==null)ls=new ArrayList<FaceFieldEntity>(); - addproperty(tableUuid,fse.getString("table_name"),ls); + 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)) {///涓昏〃瀛楁 + 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()}); + , new String[]{table_uuid, ls.get(i).getField()}); - if(!DataTableEntity.isEmpty(dt)) { + 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()) && + 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()) && + 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()) && + 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")); } + if ("file".indexOf(ls.get(i).getComponentType()) != -1) { + //闄勪欢 + //鑾峰彇瀛楁绫诲瀷 + String fieldType = dt.getString(0, "field_type"); + if ("file-image".equals(fieldType)) { + ls.get(i).putOtherParam("fieldType", "image"); + } else { +// ls.get(i).putOtherParam("fieldType", "file"); + } + } } ls.get(i).setTable(table_name); - }else { + } else { //============鎶婂瓙琛ㄥ瓧娈典篃澶勭悊涓�涓� //瀛愯〃 FieldSetEntity tableInfo = BaseUtil.getSingleInfoByCache("鎵�鏈夎〃淇℃伅", new String[]{subTableName}); if (!FieldSetEntity.isEmpty(tableInfo)) { - addproperty(tableInfo.getString("uuid"),tableInfo.getString("table_name"),ls.get(i).getSubField()); + 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(); + 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("缂� 鐮�"); @@ -143,18 +157,19 @@ ls.add(uuid); } - }else {///浠ヨ〃鍗曡璁′负鍑嗭紝濡傛灉娌℃湁閰嶇疆琛ㄥ崟锛屽垯浠ユ暟鎹〃涓哄噯锛屽叏閮ㄤ繚鐣� - toConvertFace(table_uuid,table_name,ls,null); + } 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); + 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 @@ -162,25 +177,25 @@ * @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>(); + 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"))) { + 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"))) { + if ("uuid".equals(f.getString("field_name"))) { uuid.setHidden("1"); } - if("userids".equals(f.getString("field_type")) ||"orgUuids".equals(f.getString("field_type")) ) { + if ("userids".equals(f.getString("field_type")) || "orgUuids".equals(f.getString("field_type"))) { uuid.setMultiple("1"); - }else { + } else { uuid.setMultiple("0"); } @@ -189,11 +204,12 @@ uuid.setName(f.getString("field_show_name")); uuid.setField(f.getString("field_name")); uuid.setType(f.getString("field_type")); + uuid.setRequired(f.getString("is_required")); uuid.setTable(table_name); ls.add(uuid); } - if(pls!=null) { - FaceFieldEntity uuid=new FaceFieldEntity(); + if (pls != null) { + FaceFieldEntity uuid = new FaceFieldEntity(); uuid.setHidden(""); uuid.setComponentType("subTable"); uuid.setPrompt(""); @@ -298,7 +314,7 @@ } List<FaceFieldEntity> result = new ArrayList<>(); - List<List<FieldSetEntity>> subTableField = new ArrayList<>(); + Map<String, List<FieldSetEntity>> subTableFieldMap = new HashMap<>(); for (FieldSetEntity fs : tagFieldSetEntityList) { String groupUuid = fs.getString("group_uuid"); String parentUuid = fs.getString("parent_uuid"); @@ -306,16 +322,21 @@ continue; } List<FieldSetEntity> fieldSetEntity = productSysFaceControlProperty.getFieldSetEntity(parentUuid); - if (CollectionUtil.isEmpty(fieldSetEntity)) { - continue; + int i = result.size(); + to(groupMap, fieldSetEntity, subTableFieldMap, result, parentMap); + String parentUuid1 = fieldSetEntity.get(0).getString("parent_uuid"); + if (!CollectionUtil.isEmpty(fieldSetEntity) && !StringUtils.isEmpty(parentUuid1)) { + if (i + 1 == result.size()) { + result.get(i).putOtherParam("parent_uuid", parentUuid1); + } } - - to(groupMap, fieldSetEntity, subTableField, result, parentMap); } - if (!CollectionUtil.isEmpty(subTableField)) { + //鏍规嵁group_uuid 灏嗗瓙琛ㄥ瓧娈靛垎缁�5 + if (!CollectionUtil.isEmpty(subTableFieldMap)) { //鏍规嵁瀛愯〃琛ㄥ悕瑁呰浇 Map<String, FaceFieldEntity> tableByFaceField = new HashMap<>(); - for (List<FieldSetEntity> fieldSetEntities : subTableField) { + for (Map.Entry<String, List<FieldSetEntity>> entry : subTableFieldMap.entrySet()) { + List<FieldSetEntity> fieldSetEntities = entry.getValue(); String parentUuid = fieldSetEntities.get(0).getString("parent_uuid"); //鍏堟壘鍒癱hildren List<FieldSetEntity> fieldSetEntity = productSysFaceControlProperty.getFieldSetEntity(parentUuid); @@ -361,6 +382,12 @@ //涓嶆槸瀛愯〃缁勪欢 continue; } + List<FaceFieldEntity> fields = new ArrayList<>(); + for (FieldSetEntity setEntity : fieldSetEntities) { + to(groupMap, Lists.newArrayList(setEntity), null, fields, parentMap); + } + + faceFieldEntity.setSubField(fields); for (FieldSetEntity setEntity : groupMap.get(groupUuid)) { String propertyName = setEntity.getString("property_name"); if ("subTableName".equals(propertyName)) { @@ -370,6 +397,8 @@ faceFieldEntity.setAllowAdd(setEntity.getBoolean("property_value")); } else if ("delete".equals(propertyName)) { faceFieldEntity.setAllowDelete(setEntity.getBoolean("property_value")); + } else if ("control_sequence".equals(propertyName)) { + faceFieldEntity.putOtherParam("controlSequence", setEntity.getInteger("property_value")); } } List<FaceFieldEntity> subFieldList = faceFieldEntity.getSubField(); @@ -377,18 +406,24 @@ 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; - } + } + result.sort((item, item2) -> { + Object o = item.getOtherParams().get("controlSequence"); + if (o == null) { + return -1; + } + Object o1 = item2.getOtherParams().get("controlSequence"); + if (o1 == null) { + return 1; + } + return NumberUtil.parseInt(item.getOtherParams().get("controlSequence").toString()) - NumberUtil.parseInt(item2.getOtherParams().get("controlSequence").toString()); + }); return result; } @@ -419,7 +454,7 @@ } - private void to(Map<String, List<FieldSetEntity>> groupMap, List<FieldSetEntity> fieldSetEntity, List<List<FieldSetEntity>> subTableField, List<FaceFieldEntity> result, Map<String, List<FieldSetEntity>> parentMap) { + private void to(Map<String, List<FieldSetEntity>> groupMap, List<FieldSetEntity> fieldSetEntity, Map<String, 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)) { @@ -433,9 +468,18 @@ for (FieldSetEntity setEntity : parentGroup) { //鎵惧埌灞炴�у悕绉�= __vModel__ String propertyName = setEntity.getString("property_name"); + if ("componentType".equals(propertyName) || "prompt".equals(propertyName)) { + continue; + } if ("parentType".equals(propertyName) && "subTable".equals(setEntity.getString("property_value")) && subTableField != null) { //瀛愯〃瀛楁 - subTableField.add(parentGroup); + String parentUuid = setEntity.getString("parent_uuid"); + List<FieldSetEntity> fieldSetEntities = subTableField.get(parentUuid); + if (fieldSetEntities == null) { + fieldSetEntities = new ArrayList<>(); + subTableField.put(parentUuid, fieldSetEntities); + } + fieldSetEntities.add(setEntity); result.remove(faceFieldEntity); break; } @@ -445,7 +489,7 @@ } else if ("label".equals(setEntity.getString("property_name"))) { propertyName = "name"; } else if ("advanceName".equals(setEntity.getString("property_name"))) { - propertyName = "field"; + propertyName = "prompt"; } else if ("__config__".equals(propertyName)) { __config__ = setEntity.getUUID(); } @@ -456,7 +500,10 @@ } } propertyName = StrUtil.toCamelCase(propertyName); - if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName) && !"field".equals(setEntity.getString("property_name"))) { + if ("defaultValue".equals(propertyName) && !"0".equals(setEntity.getString("property_value")) && !"1".equals(setEntity.getString("property_value"))) { + continue; + } + if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName) && !"field".equals(setEntity.getString("property_name")) && !"prompt".equals(setEntity.getString("property_name"))) { ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getObject("property_value")); } else if (!StringUtils.isEmpty(setEntity.getObject("property_value"))) { @@ -491,15 +538,25 @@ for (FieldSetEntity setEntity : configGroup) { //鎵惧埌灞炴�у悕绉�= __vModel__ String propertyName = setEntity.getString("property_name"); + if ("componentType".equals(propertyName) || "prompt".equals(propertyName)) { + continue; + } if ("tag".equals(propertyName)) { propertyName = "component_type"; } else if ("field".equals(propertyName)) { propertyName = "fileField"; } else if ("tableName".equals(propertyName)) { propertyName = "fileTableName"; + } else if ("label".equals(setEntity.getString("property_name"))) { + propertyName = "name"; + } else if ("advanceName".equals(setEntity.getString("property_name"))) { + propertyName = "prompt"; } propertyName = StrUtil.toCamelCase(propertyName); - if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName)) { + if ("defaultValue".equals(propertyName) && !"0".equals(setEntity.getString("property_value")) && !"1".equals(setEntity.getString("property_value"))) { + continue; + } + if (ReflectUtil.hasField(FaceFieldEntity.class, propertyName) && !"field".equals(setEntity.getString("property_name")) && !"prompt".equals(setEntity.getString("property_name"))) { ReflectUtil.setFieldValue(faceFieldEntity, propertyName, setEntity.getObject("property_value")); } } -- Gitblit v1.9.2