| | |
| | | |
| | | import static com.vci.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST; |
| | | |
| | | |
| | | /** |
| | | * UI上的数据查询(通用查询服务) |
| | | * @author Ludc |
| | |
| | | if(Func.isNotEmpty(dataGridQuery.getSourceData())){ |
| | | dataGridQuery.setSourceData(this.convertMapValueJson2Map(dataGridQuery.getSourceData())); |
| | | } |
| | | //先判断查询模板 |
| | | UITableDefineVO tableDefineVO = uiEngineService.getComponentByOid(dataGridQuery.getComponentOid(),null).getTableDefineVO(); |
| | | //先判断查询模板是否配置了自定义查询类 |
| | | UIComponentVO componentVO = uiEngineService.getComponentByOid(dataGridQuery.getComponentOid(), null); |
| | | UITableDefineVO tableDefineVO = componentVO.getTableDefineVO(); |
| | | String bsCustQueryCLsOrUrl = componentVO.getBsCustQueryCLsOrUrl(); |
| | | // TODO: 2024/12/5 Ludc 根据UI配置的进行判断是否使用自定义类进行查询(自定义类查询方式优先级高于查询模板) |
| | | if(Func.isNotBlank(bsCustQueryCLsOrUrl) && isCustomClass(bsCustQueryCLsOrUrl)){ |
| | | //通过反射调用bsCustQueryCLsOrUrl中定义的服务类中的查询方法 |
| | | try { |
| | | // 获取类的 Class 对象 |
| | | Class<?> clazz = Class.forName(bsCustQueryCLsOrUrl.replace("@","")); |
| | | // 创建类的实例 |
| | | Object instance = clazz.getDeclaredConstructor().newInstance(); |
| | | // 获取方法getDataForGrid(该方法是接口中统一定义的方法) |
| | | Method method = clazz.getMethod("getDataForGrid", UIDataGridQuery.class); |
| | | // 调用方法 |
| | | DataGrid dataGrid = (DataGrid) method.invoke(instance, dataGridQuery); |
| | | return dataGrid; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | throw new VciBaseException("获取表格数据时出现错误,原因:"+e.getMessage()); |
| | | } |
| | | }else{ |
| | | String queryTemplate = Func.isNotEmpty(dataGridQuery.getSourceData())? (String) dataGridQuery.getSourceData().getOrDefault("querytemplate",tableDefineVO.getQueryTemplateName()) :tableDefineVO.getQueryTemplateName(); |
| | | if(StringUtils.isBlank(queryTemplate)){ |
| | | //说明没有设置查询模板,需要看看在这个表格所在的组件有没有设置 |
| | |
| | | dataGridQuery.getConditionMap(), replaceMap, dataGridQuery.getPageHelper(), queryFieldList.stream().collect(Collectors.toList())); |
| | | return dataGrid; |
| | | } |
| | | //生命周期在其中查询后就会处理 |
| | | //枚举也会被处理了 |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | if(Func.isNotEmpty(formQuery.getSourceData())){ |
| | | formQuery.setSourceData(this.convertMapValueJson2Map(formQuery.getSourceData())); |
| | | } |
| | | UIFormDefineVO formDefineVO = uiEngineService.getFormById(formQuery.getBtmName(),formQuery.getFormDefineId()); |
| | | //先判断查询模板是否配置了自定义查询类 |
| | | UIComponentVO componentVO = uiEngineService.getComponentByOid(formQuery.getComponentOid(), null); |
| | | UIFormDefineVO formDefineVO = componentVO.getFormDefineVO(); |
| | | //UIFormDefineVO formDefineVO = uiEngineService.getFormById(formQuery.getBtmName(),formQuery.getFormDefineId()); |
| | | String bsCustQueryCLsOrUrl = componentVO.getBsCustQueryCLsOrUrl(); |
| | | if(Func.isNotBlank(bsCustQueryCLsOrUrl) && isCustomClass(bsCustQueryCLsOrUrl)){ |
| | | //通过反射调用bsCustQueryCLsOrUrl中定义的服务类中的查询方法 |
| | | try { |
| | | // 获取类的 Class 对象 |
| | | Class<?> clazz = Class.forName(bsCustQueryCLsOrUrl.replace("@","")); |
| | | // 创建类的实例 |
| | | Object instance = clazz.getDeclaredConstructor().newInstance(); |
| | | // 获取方法getDataForGrid(该方法是接口中统一定义的方法) |
| | | Method method = clazz.getMethod("getDataForForm", UIDataGridQuery.class); |
| | | // 调用方法 |
| | | UIFormDataVO uiFormDataVO = (UIFormDataVO) method.invoke(instance, formQuery); |
| | | return uiFormDataVO; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | throw new VciBaseException("获取表格数据时出现错误,原因:"+e.getMessage()); |
| | | } |
| | | }else{ |
| | | String queryTemplate = !CollectionUtils.isEmpty(formQuery.getSourceData())? (String) formQuery.getSourceData().getOrDefault("querytemplate",formDefineVO.getQueryTemplateName()) :formDefineVO.getQueryTemplateName(); |
| | | Set<String> queryFieldList = formDefineVO.getItems().stream().filter(s->!UIFieldTypeEnum.CUSTOM.getValue().equalsIgnoreCase(s.getType())).map(UIFormItemVO::getField).collect(Collectors.toSet()); |
| | | //获取参照 |
| | |
| | | } |
| | | return formDataVO; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 封装replaceMap |