From 5839384228e2f10d880d23c7a1c99ba86430634c Mon Sep 17 00:00:00 2001 From: 许鹏程 <1821349743@qq.com> Date: 星期三, 24 五月 2023 14:59:07 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- product-server-admin/src/main/java/com/product/admin/service/SystemFaceService.java | 422 ++++++++++++++++++++++++++-------------------------- 1 files changed, 211 insertions(+), 211 deletions(-) diff --git a/product-server-admin/src/main/java/com/product/admin/service/SystemFaceService.java b/product-server-admin/src/main/java/com/product/admin/service/SystemFaceService.java index 3348b6d..45a4c4f 100644 --- a/product-server-admin/src/main/java/com/product/admin/service/SystemFaceService.java +++ b/product-server-admin/src/main/java/com/product/admin/service/SystemFaceService.java @@ -28,231 +28,231 @@ @Service public class SystemFaceService extends AbstractBaseService implements ISystemFaceService { - /** - * 缂撳瓨璧峰Key - */ - public static final String FACE_LIST_KEY = "face:fieldList:"; + /** + * 缂撳瓨璧峰Key + */ + public static final String FACE_LIST_KEY = "face:fieldList:"; - @Autowired - QueryFilterService queryFilterService; + @Autowired + QueryFilterService queryFilterService; - @Autowired - RolesService rolesService; + @Autowired + RolesService rolesService; - /** - * 鑾峰彇妯″潡鍔熻兘鏍� - * - * @return - * @throws BaseException - */ - @Override - public DataTableEntity getModuleFunctionTree() throws BaseException { + /** + * 鑾峰彇妯″潡鍔熻兘鏍� + * + * @return + * @throws BaseException + */ + @Override + public DataTableEntity getModuleFunctionTree() throws BaseException { - return rolesService.getModuleFunctions(); - } + return rolesService.getModuleFunctions(); + } - /** - * 琛ㄥ崟鍒楄〃 - * - * @param fse - * @return - * @throws BaseException - */ - @Override - public DataTableEntity getFaceList(FieldSetEntity fse) throws BaseException { - String queryFilter = queryFilterService.getQueryFilter(fse); - String filter = fse.getString("filter"); - if (StringUtils.isEmpty(filter)) { - filter = queryFilter; - } else if (!StringUtils.isEmpty(queryFilter)) { - filter += " and (" + queryFilter + ") "; - } - DataTableEntity dataTableEntity = getBaseDao().listTable(CmnConst.PRODUCT_SYS_FACE, filter, new Object[]{}, null, null, fse.getInteger(CmnConst.PAGESIZE), fse.getInteger(CmnConst.CPAGE)); - getBaseDao().loadPromptData(dataTableEntity); - return dataTableEntity; - } + /** + * 琛ㄥ崟鍒楄〃 + * + * @param fse + * @return + * @throws BaseException + */ + @Override + public DataTableEntity getFaceList(FieldSetEntity fse) throws BaseException { + String queryFilter = queryFilterService.getQueryFilter(fse); + String filter = fse.getString("filter"); + if (StringUtils.isEmpty(filter)) { + filter = queryFilter; + } else if (!StringUtils.isEmpty(queryFilter)) { + filter += " and (" + queryFilter + ") "; + } + DataTableEntity dataTableEntity = getBaseDao().listTable(CmnConst.PRODUCT_SYS_FACE, filter, new Object[]{}, null, null, fse.getInteger(CmnConst.PAGESIZE), fse.getInteger(CmnConst.CPAGE)); + getBaseDao().loadPromptData(dataTableEntity); + return dataTableEntity; + } - /** - * 鑾峰彇琛ㄥ崟璇︽儏鏍规嵁uuid - * - * @param fse - * @return - * @throws BaseException - */ - @Override - public FieldSetEntity getFaceInfoByUuid(FieldSetEntity fse) throws BaseException { - return getBaseDao().getFieldSetEntity(CmnConst.PRODUCT_SYS_FACE, fse.getUUID(), true); - } + /** + * 鑾峰彇琛ㄥ崟璇︽儏鏍规嵁uuid + * + * @param fse + * @return + * @throws BaseException + */ + @Override + public FieldSetEntity getFaceInfoByUuid(FieldSetEntity fse) throws BaseException { + return getBaseDao().getFieldSetEntity(CmnConst.PRODUCT_SYS_FACE, fse.getUUID(), true); + } - /** - * 淇濆瓨琛ㄥ崟璇︽儏鏍规嵁uuid - * - * @param fse - * @return - * @throws BaseException - */ - @Override - @Transactional - public String saveFaceInfo(FieldSetEntity fse) throws BaseException { - BaseUtil.createCreatorAndCreationTime(SpringMVCContextHolder.getCurrentUser(), fse); - Map<String, DataTableEntity> subData = fse.getSubData(); - subData.forEach((k, v) -> { - BaseUtil.createCreatorAndCreationTime(SpringMVCContextHolder.getCurrentUser(), v); - }); - getBaseDao().saveFieldSetEntity(fse); - this.initialFieldCache(fse.getUUID()); - return fse.getUUID(); - } + /** + * 淇濆瓨琛ㄥ崟璇︽儏鏍规嵁uuid + * + * @param fse + * @return + * @throws BaseException + */ + @Override + @Transactional + public String saveFaceInfo(FieldSetEntity fse) throws BaseException { + BaseUtil.createCreatorAndCreationTime(SpringMVCContextHolder.getCurrentUser(), fse); + Map<String, DataTableEntity> subData = fse.getSubData(); + subData.forEach((k, v) -> { + BaseUtil.createCreatorAndCreationTime(SpringMVCContextHolder.getCurrentUser(), v); + }); + getBaseDao().saveFieldSetEntity(fse); + this.initialFieldCache(fse.getUUID()); + return fse.getUUID(); + } - /** - * 鍒犻櫎琛ㄥ崟璇︽儏鏍规嵁uuid - * - * @param uuids - * @return - * @throws BaseException - */ - @Override - @Transactional - public boolean deleteFaceInfoByUuids(String[] uuids) throws BaseException { - boolean delete = getBaseDao().delete(CmnConst.PRODUCT_SYS_FACE, uuids); - deleteFieldCache(uuids); - return delete; - } + /** + * 鍒犻櫎琛ㄥ崟璇︽儏鏍规嵁uuid + * + * @param uuids + * @return + * @throws BaseException + */ + @Override + @Transactional + public boolean deleteFaceInfoByUuids(String[] uuids) throws BaseException { + boolean delete = getBaseDao().delete(CmnConst.PRODUCT_SYS_FACE, uuids); + deleteFieldCache(uuids); + return delete; + } - @Override - public FaceListEntity getFaceFieldList(String face_uuid) throws BaseException { - if (StringUtils.isEmpty(face_uuid)) { - return null; - } - if (!RedisUtil.exists(this.FACE_LIST_KEY + face_uuid)) { - this.initialFieldCache(face_uuid); - } - FaceListEntity faceListEntity = (FaceListEntity) RedisUtil.get(this.FACE_LIST_KEY + face_uuid); - if (faceListEntity == null) { - initialFieldCache(face_uuid); - faceListEntity = (FaceListEntity) RedisUtil.get(this.FACE_LIST_KEY + face_uuid); - } - return faceListEntity; - } + @Override + public FaceListEntity getFaceFieldList(String face_uuid) throws BaseException { + if (StringUtils.isEmpty(face_uuid)) { + return null; + } + if (!RedisUtil.exists(this.FACE_LIST_KEY + face_uuid)) { + this.initialFieldCache(face_uuid); + } + FaceListEntity faceListEntity = (FaceListEntity) RedisUtil.get(this.FACE_LIST_KEY + face_uuid); + if (faceListEntity == null) { + initialFieldCache(face_uuid); + faceListEntity = (FaceListEntity) RedisUtil.get(this.FACE_LIST_KEY + face_uuid); + } + return faceListEntity; + } - /** - * 鑾峰彇鍒楄〃杩囨护鏉′欢 - * - * @param aliasTable 琛ㄥ埆鍚嶉泦鍚� - * @param face_uuid 琛ㄥ崟uuid - * @param val 妯$硦鎼滅储鍊� - * @return sql杩囨护鏉′欢 - * @throws BaseException - */ - @Override - public String getListFilter(Map<String, List<String>> aliasTable, Map<String, List<String>> aliasField, String face_uuid, String val) throws BaseException { - if (StringUtils.isEmpty(val)) { - return ""; - } - FaceListEntity face = (FaceListEntity) RedisUtil.get(this.FACE_LIST_KEY + face_uuid); - if (face != null) { - String tableAlias = null; - String tableName = face.getTableName(); - List<String> t = aliasTable.get(tableName); - if (t != null && t.size() > 0) { - tableAlias = t.get(0); - } - Map<String, List<String>> params = face.getFilters(tableAlias, aliasField); - List<String> fieldNames = params.get("fields"); - List<String> filters = params.get("filter"); - String filter = ""; - for (int i = 0; i < fieldNames.size(); i++) { - if (i > 0) { - filter += " or "; - } - filter += " " + fieldNames.get(i) + " LIKE BINARY concat('%','" + val + "','%')"; - } - for (int i = 0; i < filters.size(); i++) { - if (!"".equals(filter)) { - filter += " or "; - } - filter += filters.get(i).replace("~val~", val); - } - return "".equals(filter) ? "" : "( " + filter + " )"; - } - return ""; - } + /** + * 鑾峰彇鍒楄〃杩囨护鏉′欢 + * + * @param aliasTable 琛ㄥ埆鍚嶉泦鍚� + * @param face_uuid 琛ㄥ崟uuid + * @param val 妯$硦鎼滅储鍊� + * @return sql杩囨护鏉′欢 + * @throws BaseException + */ + @Override + public String getListFilter(Map<String, List<String>> aliasTable, Map<String, List<String>> aliasField, String face_uuid, String val) throws BaseException { + if (StringUtils.isEmpty(val)) { + return ""; + } + FaceListEntity face = (FaceListEntity) RedisUtil.get(this.FACE_LIST_KEY + face_uuid); + if (face != null) { + String tableAlias = null; + String tableName = face.getTableName(); + List<String> t = aliasTable.get(tableName); + if (t != null && t.size() > 0) { + tableAlias = t.get(0); + } + Map<String, List<String>> params = face.getFilters(tableAlias, aliasField); + List<String> fieldNames = params.get("fields"); + List<String> filters = params.get("filter"); + String filter = ""; + for (int i = 0; i < fieldNames.size(); i++) { + if (i > 0) { + filter += " or "; + } + filter += " " + fieldNames.get(i) + " LIKE BINARY concat('%','" + val + "','%')"; + } + for (int i = 0; i < filters.size(); i++) { + if (!"".equals(filter)) { + filter += " or "; + } + filter += filters.get(i).replace("~val~", val); + } + return "".equals(filter) ? "" : "( " + filter + " )"; + } + return ""; + } - /** - * 鍒犻櫎琛ㄥ崟瀛楁缂撳瓨鏍规嵁琛ㄥ崟uuid - * - * @param uuid - */ - private void deleteFieldCache(String[] uuid) { - if (uuid != null && uuid.length > 0) { - String[] keys = new String[uuid.length]; - for (int i = 0; i < uuid.length; i++) { - keys[i] = this.FACE_LIST_KEY + uuid[i]; - } - if (keys.length > 0) { - RedisUtil.del(keys); - } - } - } + /** + * 鍒犻櫎琛ㄥ崟瀛楁缂撳瓨鏍规嵁琛ㄥ崟uuid + * + * @param uuid + */ + private void deleteFieldCache(String[] uuid) { + if (uuid != null && uuid.length > 0) { + String[] keys = new String[uuid.length]; + for (int i = 0; i < uuid.length; i++) { + keys[i] = this.FACE_LIST_KEY + uuid[i]; + } + if (keys.length > 0) { + RedisUtil.del(keys); + } + } + } - /** - * 鍒濆鍖栬〃鍗曞瓧娈电紦瀛� - * - * @param faceUuids 琛ㄥ崟uuid 澶氫釜鐢ㄩ�楀彿鍒嗗壊 浼犲叆null 鍒欏垵濮嬪寲鎵�鏈� - */ - private void initialFieldCache(String faceUuids) { - StringBuilder sql = new StringBuilder(); - sql.append(" SELECT "); - sql.append(" ifnull(d.field_name,a.field_name) field_name,a.field_alias, "); - sql.append(" d.field_reference, "); - sql.append(" d.uuid field_uuid, "); - sql.append(" b.face_name, "); - sql.append(" b.table_uuid, "); - sql.append(" a.face_uuid, "); - sql.append(" column_name, "); - sql.append(" column_width, "); - sql.append(" sequence "); - sql.append(" FROM "); - sql.append(" product_sys_face_list a "); - sql.append(" RIGHT JOIN product_sys_face b ON a.face_uuid = b.uuid "); - sql.append(" LEFT JOIN product_sys_datamodel_field d ON a.field_name = d.field_name and b.table_uuid=d.table_uuid"); - sql.append(" WHERE "); - sql.append(" a.is_used = 1 "); - Object[] objects = {}; - if (!StringUtils.isEmpty(faceUuids)) { - sql.append(" AND ( "); - objects = faceUuids.split(","); - sql.append(BaseUtil.buildQuestionMarkFilter("b.uuid", objects.length, true)); - sql.append(" ) "); - } - sql.append(" ORDER BY face_uuid,sequence "); - DataTableEntity dt = getBaseDao().listTable(sql.toString(), objects); - Map<String, FaceListEntity> faceListEntityMap = Maps.newHashMap(); - if (!BaseUtil.dataTableIsEmpty(dt)) { - for (int i = 0; i < dt.getRows(); i++) { - String face_uuid = dt.getString(i, "face_uuid"); - FaceListEntity faceListEntity = faceListEntityMap.get(face_uuid); - if (faceListEntity == null) { - faceListEntity = new FaceListEntity(); - faceListEntity.setFaceName(face_uuid); - faceListEntity.setTableUuid(dt.getString(i, CmnConst.TABLE_UUID)); - faceListEntity.setUuid(dt.getString(i, "face_uuid")); - faceListEntityMap.put(face_uuid, faceListEntity); - } - faceListEntity.addField(dt.getString(i, CmnConst.FIELD_NAME), dt.getString(i, "field_uuid"), - dt.getString(i, "column_name"), - dt.getString(i, "column_width"), - dt.getInt(i, CmnConst.SEQUENCE), dt.getString(i, "field_reference")); + /** + * 鍒濆鍖栬〃鍗曞瓧娈电紦瀛� + * + * @param faceUuids 琛ㄥ崟uuid 澶氫釜鐢ㄩ�楀彿鍒嗗壊 浼犲叆null 鍒欏垵濮嬪寲鎵�鏈� + */ + private void initialFieldCache(String faceUuids) { + StringBuilder sql = new StringBuilder(); + sql.append(" SELECT "); + sql.append(" ifnull(d.field_name,a.field_name) field_name,a.field_alias, "); + sql.append(" d.field_reference, "); + sql.append(" d.uuid field_uuid, "); + sql.append(" b.face_name, "); + sql.append(" b.table_uuid, "); + sql.append(" a.face_uuid, "); + sql.append(" column_name, "); + sql.append(" column_width, "); + sql.append(" sequence "); + sql.append(" FROM "); + sql.append(" product_sys_face_list a "); + sql.append(" RIGHT JOIN product_sys_face b ON a.face_uuid = b.uuid "); + sql.append(" LEFT JOIN product_sys_datamodel_field d ON a.field_name = d.field_name and b.table_uuid=d.table_uuid"); + sql.append(" WHERE "); + sql.append(" a.is_used = 1 "); + Object[] objects = {}; + if (!StringUtils.isEmpty(faceUuids)) { + sql.append(" AND ( "); + objects = faceUuids.split(","); + sql.append(BaseUtil.buildQuestionMarkFilter("b.uuid", objects.length, true)); + sql.append(" ) "); + } + sql.append(" ORDER BY face_uuid,sequence "); + DataTableEntity dt = getBaseDao().listTable(sql.toString(), objects); + Map<String, FaceListEntity> faceListEntityMap = Maps.newHashMap(); + if (!BaseUtil.dataTableIsEmpty(dt)) { + for (int i = 0; i < dt.getRows(); i++) { + String face_uuid = dt.getString(i, "face_uuid"); + FaceListEntity faceListEntity = faceListEntityMap.get(face_uuid); + if (faceListEntity == null) { + faceListEntity = new FaceListEntity(); + faceListEntity.setFaceName(face_uuid); + faceListEntity.setTableUuid(dt.getString(i, CmnConst.TABLE_UUID)); + faceListEntity.setUuid(dt.getString(i, "face_uuid")); + faceListEntityMap.put(face_uuid, faceListEntity); + } + faceListEntity.addField(dt.getString(i, CmnConst.FIELD_NAME), dt.getString(i, "field_uuid"), + dt.getString(i, "column_name"), + dt.getString(i, "column_width"), + dt.getInt(i, CmnConst.SEQUENCE), dt.getString(i, "field_reference")); - } - if (faceListEntityMap.size() > 0) { - faceListEntityMap.forEach((f, m) -> { - RedisUtil.set(FACE_LIST_KEY + m.getUuid(), m); - }); - } - } - } + } + if (faceListEntityMap.size() > 0) { + faceListEntityMap.forEach((f, m) -> { + RedisUtil.set(FACE_LIST_KEY + m.getUuid(), m); + }); + } + } + } } -- Gitblit v1.9.2