| | |
| | | import com.vci.starter.web.annotation.bus.VciChangeDataPlugin; |
| | | import com.vci.starter.web.constant.FrameWorkLcStatusConstant; |
| | | import com.vci.starter.web.constant.QueryOptionConstant; |
| | | import com.vci.starter.web.dto.BaseLinkModelDTO; |
| | | import com.vci.starter.web.dto.BaseLinkModelDTOList; |
| | | import com.vci.starter.web.dto.BaseModelDTO; |
| | | import com.vci.starter.web.dto.BaseModelDTOList; |
| | | import com.vci.starter.web.enumpck.VciChangeDocumentTypeEnum; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.model.BaseModel; |
| | |
| | | import com.vci.web.service.*; |
| | | import com.vci.web.service.impl.WebBoServiceImpl; |
| | | import com.vci.web.service.impl.WebLoServiceImpl; |
| | | import com.vci.web.service.uidataservice.UIDataBaseServiceI; |
| | | import com.vci.web.service.uidataservice.UIDataCommonServiceI; |
| | | import com.vci.web.util.PlatformClientUtil; |
| | | import com.vci.web.util.WebUtil; |
| | |
| | | if(Func.isNotEmpty(dataGridQuery.getSourceData())){ |
| | | dataGridQuery.setSourceData(this.convertMapValueJson2Map(dataGridQuery.getSourceData())); |
| | | } |
| | | //先判断查询模板是否配置了自定义查询类 |
| | | UIComponentVO componentVO = uiEngineService.getComponentByOid(dataGridQuery.getComponentOid(), null); |
| | | UITableDefineVO tableDefineVO = componentVO.getTableDefineVO(); |
| | | String bsCustQueryCLsOrUrl = componentVO.getBsCustQueryCLsOrUrl(); |
| | | //先判断查询模板是否配置了自定义查询类 |
| | | String bsCustQueryCLsOrUrl = componentVO.getBsDataModel() ; |
| | | // TODO: 2024/12/5 Ludc 根据UI配置的进行判断是否使用自定义类进行查询(自定义类查询方式优先级高于查询模板) |
| | | if(Func.isNotBlank(bsCustQueryCLsOrUrl) && isCustomClass(bsCustQueryCLsOrUrl)){ |
| | | //通过反射调用bsCustQueryCLsOrUrl中定义的服务类中的查询方法 |
| | |
| | | } |
| | | //先判断查询模板是否配置了自定义查询类 |
| | | UIComponentVO componentVO = uiEngineService.getComponentByOid(formQuery.getComponentOid(), null); |
| | | UIFormDefineVO formDefineVO = componentVO.getFormDefineVO(); |
| | | //UIFormDefineVO formDefineVO = uiEngineService.getFormById(formQuery.getBtmName(),formQuery.getFormDefineId()); |
| | | String bsCustQueryCLsOrUrl = componentVO.getBsCustQueryCLsOrUrl(); |
| | | String bsCustQueryCLsOrUrl = componentVO.getBsDataModel(); |
| | | if(Func.isNotBlank(bsCustQueryCLsOrUrl) && isCustomClass(bsCustQueryCLsOrUrl)){ |
| | | //通过反射调用bsCustQueryCLsOrUrl中定义的服务类中的查询方法 |
| | | try { |
| | |
| | | // 创建类的实例 |
| | | Object instance = clazz.getDeclaredConstructor().newInstance(); |
| | | // 获取方法getDataForGrid(该方法是接口中统一定义的方法) |
| | | Method method = clazz.getMethod("getDataForForm", UIDataGridQuery.class); |
| | | Method method = clazz.getMethod("getDataForForm", UIFormQuery.class); |
| | | // 调用方法 |
| | | UIFormDataVO uiFormDataVO = (UIFormDataVO) method.invoke(instance, formQuery); |
| | | return uiFormDataVO; |
| | |
| | | throw new VciBaseException("获取表格数据时出现错误,原因:"+e.getMessage()); |
| | | } |
| | | }else{ |
| | | UIFormDefineVO formDefineVO = componentVO.getFormDefineVO(); |
| | | 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()); |
| | | //获取参照 |
| | |
| | | if(componentVO == null || StringUtils.isBlank(componentVO.getOid())){ |
| | | throw new VciBaseException("树的配置信息没有获取到"); |
| | | } |
| | | //树形有两种,一种是业务类型里自参照,一种是链接类型 |
| | | UITreeDefineVO treeDefineVO = componentVO.getTreeDefineVO(); |
| | | if(treeDefineVO == null){ |
| | | throw new VciBaseException("这个组件不是树"); |
| | | } |
| | | if(!treeQuery.isLinkTypeFlag() && StringUtils.isBlank(treeQuery.getParentBtmName())){ |
| | | treeQuery.setParentBtmName(treeQuery.getBtmName()); |
| | | } |
| | | //TODO: 替换树定义上的正反向查询属性,因为正反向查询是由链接类型查询模板上控制的 |
| | | boolean isOrientation = false; //是否反向,使用模板上配置的 |
| | | String qtName = treeDefineVO.getQueryTemplateName(); |
| | | if(Func.isNotBlank(treeDefineVO.getLinkType()) && Func.isNotBlank(qtName)){ |
| | | QTInfo wrapper = platformClientUtil.getQTDService().getQT(qtName); |
| | | QueryTemplate qt = OQTool.getQTByDoc(DocumentHelper.parseText(wrapper.qtText), qtName); |
| | | isOrientation = qt.getDirection().equals("opposite"); |
| | | } |
| | | if(treeQuery.getConditionMap() == null){ |
| | | treeQuery.setConditionMap(new HashMap<>()); |
| | | } |
| | | if(treeQuery.getExtandParamsMap() != null){ |
| | | treeQuery.getConditionMap().putAll(treeQuery.getExtandParamsMap()); |
| | | } |
| | | String parentFieldName = treeQuery.getParentFieldName(); |
| | | if(parentFieldName.contains(",")){ |
| | | parentFieldName = parentFieldName.split(",")[0]; |
| | | } |
| | | if(StringUtils.isNotBlank(parentFieldName)){ |
| | | if(StringUtils.isNotBlank(treeQuery.getParentOid())){ |
| | | treeQuery.getConditionMap().put(parentFieldName,treeQuery.getParentOid()); |
| | | } |
| | | } |
| | | if(StringUtils.isNotBlank(treeQuery.getParentOid()) && treeQuery.getParentOid().contains(TREE_NODE_ID_SEP)){ |
| | | treeQuery.setParentOid(treeQuery.getParentOid().split(TREE_NODE_ID_SEP)[1]); |
| | | } |
| | | String queryTemplate = StringUtils.isNotBlank(treeQuery.getQueryTemplate())?treeQuery.getQueryTemplate():(!CollectionUtils.isEmpty(treeQuery.getSourceData())? (String) treeQuery.getSourceData().getOrDefault("querytemplate",treeDefineVO.getQueryTemplateName()) :treeDefineVO.getQueryTemplateName()); |
| | | String valueField = treeQuery.isLinkTypeFlag()?(!isOrientation?"${oid}" + TREE_NODE_ID_SEP + "${t_oid}":"${oid}" + TREE_NODE_ID_SEP + "${f_oid}"):(StringUtils.isNotBlank(treeQuery.getValueField())?treeQuery.getValueField():"oid"); |
| | | String textField = StringUtils.isNotBlank(treeDefineVO.getTreeNodeExpression())?treeDefineVO.getTreeNodeExpression():(StringUtils.isNotBlank(treeQuery.getTextField())?treeQuery.getTextField():"name"); |
| | | List<UIDataTree> rootTreeList = new ArrayList<>(); |
| | | List<String> queryFieldList = new ArrayList<>(); |
| | | queryFieldList.add("creator_name"); |
| | | queryFieldList.add("lastmodifier_name"); |
| | | String rootExpress = StringUtils.isNotBlank(treeQuery.getRootExpress())?treeQuery.getRootExpress():treeDefineVO.getRootContent(); |
| | | Map<String, Object> replaceMap = wrapperReplaceMap(treeQuery.getSourceData()); |
| | | if(StringUtils.isBlank(treeDefineVO.getLinkType())){ |
| | | //这个是业务类型的自参照 |
| | | //以前的平台没有对自参照这种有全部查询的 |
| | | OsBtmTypeVO btmTypeVO = btmService.getBtmByName(treeDefineVO.getBtmType()); |
| | | queryFieldList.addAll(btmTypeVO.getAttributes().stream().map(OsBtmTypeAttributeVO::getId).collect(Collectors.toList())); |
| | | queryFieldList.addAll(WebBoServiceImpl.BO_BASE_FIELD_MAP.values()); |
| | | |
| | | addQueryField(queryFieldList,valueField); |
| | | addQueryField(queryFieldList,textField); |
| | | |
| | | if(treeQuery.isQueryRoot()){ |
| | | //是查询根节点 |
| | | List<BusinessObject> rootCbos = null; |
| | | if(StringUtils.isNotBlank(queryTemplate)){ |
| | | //说明是菜单里定义了查询模板的 |
| | | rootCbos = boService.queryCBOByScheme(queryTemplate, null, replaceMap); |
| | | }else{ |
| | | //说明没有传递,这需要兼容以前的方式,就是在showLinkAps里设置 |
| | | String parentFieldNameAndValue = treeDefineVO.getShowLinkAbs(); |
| | | if(StringUtils.isBlank(parentFieldNameAndValue) || !parentFieldNameAndValue.contains(",")){ |
| | | throw new VciBaseException("配置的信息有误。在没有在菜单或者来源数据设置根节点的查询模板时,请在树的【参照树】上设置上级字段的名称和根节点的查询的值。比如xxxx,yyy。其中xxxx是上级字段英文名称"); |
| | | } |
| | | parentFieldName = parentFieldNameAndValue.split(",")[0]; |
| | | String rootQueryValue = parentFieldNameAndValue.split(",")[1]; |
| | | treeQuery.getConditionMap().put(parentFieldName,rootQueryValue); |
| | | replaceMap.put(parentFieldName,rootQueryValue); |
| | | replaceMap.put("f_oid",rootQueryValue); |
| | | if(StringUtils.isNotBlank(queryTemplate)){ |
| | | rootCbos = boService.queryCBOByScheme(queryTemplate,treeQuery.getConditionMap(),replaceMap,null,queryFieldList); |
| | | }else{ |
| | | rootCbos = boService.queryCBO(treeDefineVO.getBtmType(),treeQuery.getConditionMap(),null,queryFieldList); |
| | | } |
| | | } |
| | | if(!CollectionUtils.isEmpty(rootCbos)){ |
| | | rootTreeList = cbo2Trees(rootCbos,valueField,StringUtils.isBlank(rootExpress)?textField:rootExpress,parentFieldName,treeQuery.isShowCheckBox(),null); |
| | | TreeQueryObject treeQueryObject = new TreeQueryObject(); |
| | | treeQueryObject.setValueField(valueField); |
| | | treeQueryObject.setTextField(textField); |
| | | treeQueryObject.setParentFieldName(parentFieldName); |
| | | treeQueryObject.setShowCheckBox(treeQuery.isShowCheckBox()); |
| | | if(UITreeLoadTypeEnum.ALL.getValue().equalsIgnoreCase(treeDefineVO.getLoadType())){ |
| | | treeQueryObject.setQueryAllLevel(true); |
| | | } |
| | | queryTreeForBO(rootTreeList,treeDefineVO.getQueryTemplateName(),queryFieldList,treeQueryObject); |
| | | } |
| | | return rootTreeList; |
| | | }else{ |
| | | //这个不是跟节点,但是一般只是增加一个逐级查询,因为全部查询的时候,在根节点已经全部查询完了 |
| | | List<BusinessObject> thisChildren = null; |
| | | if (StringUtils.isNotBlank(queryTemplate)) { |
| | | thisChildren = boService.queryCBOByScheme(queryTemplate, treeQuery.getConditionMap(), replaceMap, null, queryFieldList); |
| | | } else { |
| | | thisChildren = boService.queryCBO(treeQuery.getParentBtmName(), treeQuery.getConditionMap(), null, queryFieldList); |
| | | } |
| | | return cbo2Trees(thisChildren, valueField, textField, parentFieldName, treeQuery.isShowCheckBox(), null); |
| | | String bsCustQueryCLsOrUrl = componentVO.getBsDataModel(); |
| | | 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", UITreeQuery.class); |
| | | // 调用方法 |
| | | List<UIDataTree> uiDataTreeList = (List<UIDataTree>) method.invoke(instance, treeQuery); |
| | | return uiDataTreeList; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | throw new VciBaseException("获取表格数据时出现错误,原因:"+e.getMessage()); |
| | | } |
| | | }else{ |
| | | //OsLinkTypeVO linkTypeVO = linkTypeService.getLinkTypeById(treeDefineVO.getLinkType()); |
| | | LinkType linkType = platformClientUtil.getLinkTypeService().getLinkType(treeDefineVO.getLinkType()); |
| | | //queryFieldList.addAll(linkTypeVO.getAttributes().stream().map(OsLinkTypeAttributeVO::getId).collect(Collectors.toList())); |
| | | queryFieldList.addAll(Arrays.asList(linkType.attributes)); |
| | | queryFieldList.addAll(WebLoServiceImpl.LO_BASE_FIELD_MAP.values()); |
| | | |
| | | addQueryField(queryFieldList,valueField); |
| | | addQueryField(queryFieldList,textField); |
| | | UILinkTypeDataQuery linkTypeDataQuery = new UILinkTypeDataQuery(); |
| | | linkTypeDataQuery.setQueryTemplateName(queryTemplate); |
| | | linkTypeDataQuery.setReplaceMap(replaceMap); |
| | | linkTypeDataQuery.setConditionMap(treeQuery.getConditionMap()); |
| | | linkTypeDataQuery.setParentOid(treeQuery.getParentOid()); |
| | | linkTypeDataQuery.setClauseList(queryFieldList); |
| | | linkTypeDataQuery.setDirection(isOrientation); |
| | | linkTypeDataQuery.setToBtmType(treeDefineVO.getBtmType()); |
| | | linkTypeDataQuery.setLinkType(treeDefineVO.getLinkType()); |
| | | if(UITreeLoadTypeEnum.ALL.getValue().equalsIgnoreCase(treeDefineVO.getLoadType())){ |
| | | linkTypeDataQuery.setQueryAllLevel(true); |
| | | //树形有两种,一种是业务类型里自参照,一种是链接类型 |
| | | UITreeDefineVO treeDefineVO = componentVO.getTreeDefineVO(); |
| | | if(treeDefineVO == null){ |
| | | throw new VciBaseException("这个组件不是树"); |
| | | } |
| | | if(treeQuery.isQueryRoot()){ |
| | | //查询根节点.我们需要判断是否设置了根节点的查询条件 |
| | | List<BOAndLO> rootCbos = null; |
| | | String parentFieldNameAndValue = treeDefineVO.getShowLinkAbs(); |
| | | if(StringUtils.isNotBlank(parentFieldNameAndValue)){ |
| | | if(!treeQuery.isLinkTypeFlag() && StringUtils.isBlank(treeQuery.getParentBtmName())){ |
| | | treeQuery.setParentBtmName(treeQuery.getBtmName()); |
| | | } |
| | | //TODO: 替换树定义上的正反向查询属性,因为正反向查询是由链接类型查询模板上控制的 |
| | | boolean isOrientation = false; //是否反向,使用模板上配置的 |
| | | String qtName = treeDefineVO.getQueryTemplateName(); |
| | | if(Func.isNotBlank(treeDefineVO.getOrientation())){ |
| | | isOrientation = treeDefineVO.getOrientation().equalsIgnoreCase("opposite"); |
| | | }else{ |
| | | if(Func.isNotBlank(treeDefineVO.getLinkType()) && Func.isNotBlank(qtName)){ |
| | | QTInfo wrapper = platformClientUtil.getQTDService().getQT(qtName); |
| | | QueryTemplate qt = OQTool.getQTByDoc(DocumentHelper.parseText(wrapper.qtText), qtName); |
| | | isOrientation = qt.getDirection().equals("opposite"); |
| | | } |
| | | } |
| | | if(treeQuery.getConditionMap() == null){ |
| | | treeQuery.setConditionMap(new HashMap<>()); |
| | | } |
| | | if(treeQuery.getExtandParamsMap() != null){ |
| | | treeQuery.getConditionMap().putAll(treeQuery.getExtandParamsMap()); |
| | | } |
| | | String parentFieldName = treeQuery.getParentFieldName(); |
| | | if(parentFieldName.contains(",")){ |
| | | parentFieldName = parentFieldName.split(",")[0]; |
| | | } |
| | | if(StringUtils.isNotBlank(parentFieldName)){ |
| | | if(StringUtils.isNotBlank(treeQuery.getParentOid())){ |
| | | treeQuery.getConditionMap().put(parentFieldName,treeQuery.getParentOid()); |
| | | } |
| | | } |
| | | if(StringUtils.isNotBlank(treeQuery.getParentOid()) && treeQuery.getParentOid().contains(TREE_NODE_ID_SEP)){ |
| | | treeQuery.setParentOid(treeQuery.getParentOid().split(TREE_NODE_ID_SEP)[1]); |
| | | } |
| | | String queryTemplate = StringUtils.isNotBlank(treeQuery.getQueryTemplate())?treeQuery.getQueryTemplate():(!CollectionUtils.isEmpty(treeQuery.getSourceData())? (String) treeQuery.getSourceData().getOrDefault("querytemplate",treeDefineVO.getQueryTemplateName()) :treeDefineVO.getQueryTemplateName()); |
| | | String valueField = treeQuery.isLinkTypeFlag()?(!isOrientation?"${oid}" + TREE_NODE_ID_SEP + "${t_oid}":"${oid}" + TREE_NODE_ID_SEP + "${f_oid}"):(StringUtils.isNotBlank(treeQuery.getValueField())?treeQuery.getValueField():"oid"); |
| | | String textField = StringUtils.isNotBlank(treeDefineVO.getTreeNodeExpression())?treeDefineVO.getTreeNodeExpression():(StringUtils.isNotBlank(treeQuery.getTextField())?treeQuery.getTextField():"name"); |
| | | List<UIDataTree> rootTreeList = new ArrayList<>(); |
| | | List<String> queryFieldList = new ArrayList<>(); |
| | | queryFieldList.add("creator_name"); |
| | | queryFieldList.add("lastmodifier_name"); |
| | | String rootExpress = StringUtils.isNotBlank(treeQuery.getRootExpress())?treeQuery.getRootExpress():treeDefineVO.getRootContent(); |
| | | Map<String, Object> replaceMap = wrapperReplaceMap(treeQuery.getSourceData()); |
| | | if(StringUtils.isBlank(treeDefineVO.getLinkType())){ |
| | | //这个是业务类型的自参照 |
| | | //以前的平台没有对自参照这种有全部查询的 |
| | | OsBtmTypeVO btmTypeVO = btmService.getBtmByName(treeDefineVO.getBtmType()); |
| | | queryFieldList.addAll(btmTypeVO.getAttributes().stream().map(OsBtmTypeAttributeVO::getId).collect(Collectors.toList())); |
| | | queryFieldList.addAll(WebBoServiceImpl.BO_BASE_FIELD_MAP.values()); |
| | | |
| | | addQueryField(queryFieldList,valueField); |
| | | addQueryField(queryFieldList,textField); |
| | | |
| | | if(treeQuery.isQueryRoot()){ |
| | | //是查询根节点 |
| | | List<BusinessObject> rootCbos = null; |
| | | if(StringUtils.isNotBlank(queryTemplate)){ |
| | | linkTypeDataQuery.setQueryAllLevel(false); |
| | | //根节点只查询一次 |
| | | //使用查询模板本身设置的内容 |
| | | linkTypeDataQuery.setToBtmType(null); |
| | | linkTypeDataQuery.setQueryTemplateName(queryTemplate); |
| | | rootCbos = loService.queryCLOAndBOBySchema(linkTypeDataQuery); |
| | | //说明是菜单里定义了查询模板的 |
| | | rootCbos = boService.queryCBOByScheme(queryTemplate, null, replaceMap); |
| | | }else{ |
| | | String rootQueryValue = ""; |
| | | //说明没有传递,这需要兼容以前的方式,就是在showLinkAps里设置 |
| | | String parentFieldNameAndValue = treeDefineVO.getShowLinkAbs(); |
| | | if(StringUtils.isBlank(parentFieldNameAndValue) || !parentFieldNameAndValue.contains(",")){ |
| | | throw new VciBaseException("配置的信息有误。在没有在菜单或者来源数据设置根节点的查询模板时,请在树的【参照树】上设置上级字段的名称和根节点的查询的值。比如xxxx,yyy。其中xxxx是上级字段英文名称"); |
| | | } |
| | | parentFieldName = parentFieldNameAndValue.split(",")[0]; |
| | | rootQueryValue = parentFieldNameAndValue.split(",")[1]; |
| | | String rootQueryValue = parentFieldNameAndValue.split(",")[1]; |
| | | treeQuery.getConditionMap().put(parentFieldName,rootQueryValue); |
| | | linkTypeDataQuery.setQueryAllLevel(false); |
| | | linkTypeDataQuery.setLinkType(treeDefineVO.getLinkType()); |
| | | linkTypeDataQuery.setParentOid(rootQueryValue); |
| | | rootCbos = loService.queryCLOAndBoByLinkType(linkTypeDataQuery); |
| | | replaceMap.put(parentFieldName,rootQueryValue); |
| | | replaceMap.put("f_oid",rootQueryValue); |
| | | if(StringUtils.isNotBlank(queryTemplate)){ |
| | | rootCbos = boService.queryCBOByScheme(queryTemplate,treeQuery.getConditionMap(),replaceMap,null,queryFieldList); |
| | | }else{ |
| | | rootCbos = boService.queryCBO(treeDefineVO.getBtmType(),treeQuery.getConditionMap(),null,queryFieldList); |
| | | } |
| | | } |
| | | if(!CollectionUtils.isEmpty(rootCbos)){ |
| | | rootTreeList = cbo2Trees(rootCbos,valueField,StringUtils.isBlank(rootExpress)?textField:rootExpress,parentFieldName,treeQuery.isShowCheckBox(),null); |
| | | TreeQueryObject treeQueryObject = new TreeQueryObject(); |
| | | treeQueryObject.setValueField(valueField); |
| | | treeQueryObject.setTextField(textField); |
| | | treeQueryObject.setParentFieldName(parentFieldName); |
| | | treeQueryObject.setShowCheckBox(treeQuery.isShowCheckBox()); |
| | | if(UITreeLoadTypeEnum.ALL.getValue().equalsIgnoreCase(treeDefineVO.getLoadType())){ |
| | | treeQueryObject.setQueryAllLevel(true); |
| | | } |
| | | queryTreeForBO(rootTreeList,treeDefineVO.getQueryTemplateName(),queryFieldList,treeQueryObject); |
| | | } |
| | | return rootTreeList; |
| | | }else{ |
| | | //这个不是跟节点,但是一般只是增加一个逐级查询,因为全部查询的时候,在根节点已经全部查询完了 |
| | | List<BusinessObject> thisChildren = null; |
| | | if (StringUtils.isNotBlank(queryTemplate)) { |
| | | thisChildren = boService.queryCBOByScheme(queryTemplate, treeQuery.getConditionMap(), replaceMap, null, queryFieldList); |
| | | } else { |
| | | thisChildren = boService.queryCBO(treeQuery.getParentBtmName(), treeQuery.getConditionMap(), null, queryFieldList); |
| | | } |
| | | return cbo2Trees(thisChildren, valueField, textField, parentFieldName, treeQuery.isShowCheckBox(), null); |
| | | } |
| | | }else{ |
| | | //OsLinkTypeVO linkTypeVO = linkTypeService.getLinkTypeById(treeDefineVO.getLinkType()); |
| | | LinkType linkType = platformClientUtil.getLinkTypeService().getLinkType(treeDefineVO.getLinkType()); |
| | | //queryFieldList.addAll(linkTypeVO.getAttributes().stream().map(OsLinkTypeAttributeVO::getId).collect(Collectors.toList())); |
| | | queryFieldList.addAll(Arrays.asList(linkType.attributes)); |
| | | queryFieldList.addAll(WebLoServiceImpl.LO_BASE_FIELD_MAP.values()); |
| | | |
| | | addQueryField(queryFieldList,valueField); |
| | | addQueryField(queryFieldList,textField); |
| | | UILinkTypeDataQuery linkTypeDataQuery = new UILinkTypeDataQuery(); |
| | | linkTypeDataQuery.setQueryTemplateName(queryTemplate); |
| | | linkTypeDataQuery.setReplaceMap(replaceMap); |
| | | linkTypeDataQuery.setConditionMap(treeQuery.getConditionMap()); |
| | | linkTypeDataQuery.setParentOid(treeQuery.getParentOid()); |
| | | linkTypeDataQuery.setClauseList(queryFieldList); |
| | | linkTypeDataQuery.setDirection(isOrientation); |
| | | linkTypeDataQuery.setToBtmType(treeDefineVO.getBtmType()); |
| | | linkTypeDataQuery.setLinkType(treeDefineVO.getLinkType()); |
| | | if(UITreeLoadTypeEnum.ALL.getValue().equalsIgnoreCase(treeDefineVO.getLoadType())){ |
| | | linkTypeDataQuery.setQueryAllLevel(true); |
| | | } |
| | | if(treeQuery.isQueryRoot()){ |
| | | //查询根节点.我们需要判断是否设置了根节点的查询条件 |
| | | List<BOAndLO> rootCbos = null; |
| | | String parentFieldNameAndValue = treeDefineVO.getShowLinkAbs(); |
| | | if(StringUtils.isNotBlank(parentFieldNameAndValue)){ |
| | | if(StringUtils.isNotBlank(queryTemplate)){ |
| | | linkTypeDataQuery.setQueryAllLevel(false); |
| | | //根节点只查询一次 |
| | | //使用查询模板本身设置的内容 |
| | | linkTypeDataQuery.setToBtmType(null); |
| | | linkTypeDataQuery.setQueryTemplateName(queryTemplate); |
| | | rootCbos = loService.queryCLOAndBOBySchema(linkTypeDataQuery); |
| | | }else{ |
| | | String rootQueryValue = ""; |
| | | parentFieldName = parentFieldNameAndValue.split(",")[0]; |
| | | rootQueryValue = parentFieldNameAndValue.split(",")[1]; |
| | | treeQuery.getConditionMap().put(parentFieldName,rootQueryValue); |
| | | linkTypeDataQuery.setQueryAllLevel(false); |
| | | linkTypeDataQuery.setLinkType(treeDefineVO.getLinkType()); |
| | | linkTypeDataQuery.setParentOid(rootQueryValue); |
| | | rootCbos = loService.queryCLOAndBoByLinkType(linkTypeDataQuery); |
| | | } |
| | | if(!CollectionUtils.isEmpty(rootCbos)){ |
| | | if(StringUtils.isBlank(parentFieldName)){ |
| | | if(isOrientation){ |
| | | parentFieldName = "t_oid"; |
| | | }else{ |
| | | parentFieldName = "f_oid"; |
| | | } |
| | | } |
| | | rootTreeList = cloAndCbo2Trees(rootCbos,valueField,rootExpress,parentFieldName,treeQuery.isShowCheckBox(),null); |
| | | linkTypeDataQuery.setLinkType(treeDefineVO.getLinkType()); |
| | | linkTypeDataQuery.setQueryTemplateName(queryTemplate); |
| | | if(UITreeLoadTypeEnum.ALL.getValue().equalsIgnoreCase(treeDefineVO.getLoadType())){ |
| | | linkTypeDataQuery.setQueryAllLevel(true); |
| | | } |
| | | queryTreeForLO(rootTreeList,linkTypeDataQuery,parentFieldName,valueField,textField,treeQuery.isShowCheckBox()); |
| | | } |
| | | return rootTreeList; |
| | | }else{ |
| | | //没有设置查询条件。那就是把来源数据作为根节点 |
| | | if(CollectionUtils.isEmpty(replaceMap)){ |
| | | throw new VciBaseException("根节点没有配置查询条件,也没有来源数据"); |
| | | } |
| | | UIDataTree root = new UIDataTree(); |
| | | root.setOid((String) replaceMap.getOrDefault("oid",replaceMap.getOrDefault("t_oid",""))); |
| | | root.setText(getValueByExpressForBOAndLO(new HashMap<>(),replaceMap,rootExpress)); |
| | | root.setAttributes(replaceMap); |
| | | root.setIndex("0"); |
| | | rootTreeList.add(root); |
| | | |
| | | if(StringUtils.isBlank(parentFieldName)){ |
| | | if(isOrientation){ |
| | | parentFieldName = "t_oid"; |
| | |
| | | parentFieldName = "f_oid"; |
| | | } |
| | | } |
| | | rootTreeList = cloAndCbo2Trees(rootCbos,valueField,rootExpress,parentFieldName,treeQuery.isShowCheckBox(),null); |
| | | linkTypeDataQuery.setLinkType(treeDefineVO.getLinkType()); |
| | | linkTypeDataQuery.setQueryTemplateName(queryTemplate); |
| | | if(UITreeLoadTypeEnum.ALL.getValue().equalsIgnoreCase(treeDefineVO.getLoadType())){ |
| | | linkTypeDataQuery.setQueryAllLevel(true); |
| | | } |
| | | queryTreeForLO(rootTreeList,linkTypeDataQuery,parentFieldName,valueField,textField,treeQuery.isShowCheckBox()); |
| | | return rootTreeList; |
| | | } |
| | | return rootTreeList; |
| | | }else{ |
| | | //没有设置查询条件。那就是把来源数据作为根节点 |
| | | if(CollectionUtils.isEmpty(replaceMap)){ |
| | | throw new VciBaseException("根节点没有配置查询条件,也没有来源数据"); |
| | | } |
| | | UIDataTree root = new UIDataTree(); |
| | | root.setOid((String) replaceMap.getOrDefault("oid",replaceMap.getOrDefault("t_oid",""))); |
| | | root.setText(getValueByExpressForBOAndLO(new HashMap<>(),replaceMap,rootExpress)); |
| | | root.setAttributes(replaceMap); |
| | | root.setIndex("0"); |
| | | rootTreeList.add(root); |
| | | |
| | | if(StringUtils.isBlank(parentFieldName)){ |
| | | if(isOrientation){ |
| | | parentFieldName = "t_oid"; |
| | | }else{ |
| | | parentFieldName = "f_oid"; |
| | | if(StringUtils.isNotBlank(treeQuery.getParentOid())){ |
| | | //有上级了。那replace的f_oid就应该设置为上级 |
| | | if(linkTypeDataQuery.getReplaceMap() == null){ |
| | | linkTypeDataQuery.setReplaceMap(new HashMap<>()); |
| | | } |
| | | linkTypeDataQuery.getReplaceMap().put(isOrientation?"t_oid":"f_oid",treeQuery.getParentOid()); |
| | | } |
| | | linkTypeDataQuery.setLinkType(treeDefineVO.getLinkType()); |
| | | linkTypeDataQuery.setQueryTemplateName(queryTemplate); |
| | | if(UITreeLoadTypeEnum.ALL.getValue().equalsIgnoreCase(treeDefineVO.getLoadType())){ |
| | | linkTypeDataQuery.setQueryAllLevel(true); |
| | | } |
| | | queryTreeForLO(rootTreeList,linkTypeDataQuery,parentFieldName,valueField,textField,treeQuery.isShowCheckBox()); |
| | | return rootTreeList; |
| | | return cloAndCbo2Trees(loService.queryCLOAndBoByLinkType(linkTypeDataQuery),valueField,textField,parentFieldName,treeQuery.isShowCheckBox(),treeQuery.getParentOid()); |
| | | } |
| | | }else{ |
| | | if(StringUtils.isNotBlank(treeQuery.getParentOid())){ |
| | | //有上级了。那replace的f_oid就应该设置为上级 |
| | | if(linkTypeDataQuery.getReplaceMap() == null){ |
| | | linkTypeDataQuery.setReplaceMap(new HashMap<>()); |
| | | } |
| | | linkTypeDataQuery.getReplaceMap().put(isOrientation?"t_oid":"f_oid",treeQuery.getParentOid()); |
| | | } |
| | | return cloAndCbo2Trees(loService.queryCLOAndBoByLinkType(linkTypeDataQuery),valueField,textField,parentFieldName,treeQuery.isShowCheckBox(),treeQuery.getParentOid()); |
| | | } |
| | | } |
| | | } |
| | |
| | | UITreeDefineVO treeDefineVO = componentVO.getTreeDefineVO(); |
| | | boolean isOrientation = false; //是否反向,使用模板上配置的 |
| | | String qtName = treeDefineVO.getQueryTemplateName(); |
| | | if(Func.isNotBlank(treeDefineVO.getLinkType()) && Func.isNotBlank(qtName)){ |
| | | QTInfo wrapper = platformClientUtil.getQTDService().getQT(qtName); |
| | | QueryTemplate qt = OQTool.getQTByDoc(DocumentHelper.parseText(wrapper.qtText), qtName); |
| | | isOrientation = qt.getDirection().equals("opposite"); |
| | | if(Func.isNotBlank(treeDefineVO.getOrientation())){ |
| | | isOrientation = treeDefineVO.getOrientation().equalsIgnoreCase("opposite"); |
| | | }else{ |
| | | if(Func.isNotBlank(treeDefineVO.getLinkType()) && Func.isNotBlank(qtName)){ |
| | | QTInfo wrapper = platformClientUtil.getQTDService().getQT(qtName); |
| | | QueryTemplate qt = OQTool.getQTByDoc(DocumentHelper.parseText(wrapper.qtText), qtName); |
| | | isOrientation = qt.getDirection().equals("opposite"); |
| | | } |
| | | } |
| | | |
| | | String queryTemplate = StringUtils.isNotBlank(treeQuery.getQueryTemplate())?treeQuery.getQueryTemplate():(!CollectionUtils.isEmpty(treeQuery.getSourceData())? (String) treeQuery.getSourceData().getOrDefault("querytemplate",treeDefineVO.getQueryTemplateName()) :treeDefineVO.getQueryTemplateName()); |
| | | Map<String, Object> replaceMap = wrapperReplaceMap(treeQuery.getSourceData()); |
| | | List<String> queryFieldList = new ArrayList<>(); |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 封装cbo对象 |
| | | * @param formDataDTO 表单数据 |
| | |
| | | BaseModel baseModel = new BaseModel(); |
| | | baseModel.setOid(cbo.oid); |
| | | baseModel.setNameOid(cbo.nameoid); |
| | | baseModel.setRevisionOid(cbo.revisionid); |
| | | baseModel.setRevisionOid(cbo.revoid); |
| | | baseModel.setBtmName(cbo.btName); |
| | | baseModel.setLastR(String.valueOf(cbo.isLastR)); |
| | | baseModel.setLastV(String.valueOf(cbo.isLastV)); |
| | |
| | | } |
| | | return data; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 链接数据表单对象转换为基础的属性 |
| | |
| | | return BaseResult.success(clo); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 封装to端的数据 |
| | | * @param formLinkDataDTO 链接类型的表单数据 |
| | |
| | | //说明是升版 |
| | | BaseModel baseModel = cbo2BaseModel(cbo); |
| | | RevisionDataInfo revisionValueObject = getNextRevision(btmTypeVO,baseModel); |
| | | cbo.revisionid = VciBaseUtil.getPk(); |
| | | cbo.revoid = VciBaseUtil.getPk(); |
| | | cbo.revisionSeq = revisionValueObject.revisionSeq; |
| | | cbo.revisionValue = revisionValueObject.revisionVal; |
| | | cbo.isLastR = true; |
| | |
| | | if (StringUtils.isBlank(cbo.nameoid)) { |
| | | cbo.nameoid = VciBaseUtil.getPk(); |
| | | } |
| | | if (StringUtils.isBlank(cbo.revisionid)) { |
| | | cbo.revisionid = VciBaseUtil.getPk(); |
| | | if (StringUtils.isBlank(cbo.revoid)) { |
| | | cbo.revoid = VciBaseUtil.getPk(); |
| | | } |
| | | cbo.isFirstR = true; |
| | | cbo.isLastR = true; |
| | |
| | | throw new PLException("500", new String[]{"没有获取到数据的主键"}); |
| | | } |
| | | for (BusinessObject cbo : cbos) { |
| | | if(StringUtils.isBlank(cbo.revisionid)){ |
| | | String revisionoid = Arrays.stream(cbo.hisAttrValList).filter(e -> e.attrName.equals("REVISIONOID")).findFirst().map(e -> e.attrVal).orElse(""); |
| | | cbo.revisionid = revisionoid; |
| | | if(StringUtils.isBlank(cbo.revoid)){ |
| | | String revisionoid = Arrays.stream(cbo.hisAttrValList).filter(e -> e.name.equals("REVISIONOID")).findFirst().map(e -> e.value).orElse(""); |
| | | cbo.revoid = revisionoid; |
| | | } |
| | | boolean b = platformClientUtil.getBOFService().deleteBusinessObject(cbo,type); |
| | | if(!b){ |