| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.serializer.SerializerFeature; |
| | | import com.vci.base.common.utility.ObjectUtility; |
| | | import com.vci.corba.common.VCIError; |
| | | import com.vci.client.bof.BOFactoryClient; |
| | | import com.vci.client.bof.ClientBusinessObject; |
| | | import com.vci.client.bof.ClientLinkObject; |
| | | import com.vci.client.bof.ClientLinkObjectOperation; |
| | | import com.vci.client.common.oq.OQTool; |
| | | import com.vci.client.common.providers.ServiceProvider; |
| | | import com.vci.common.qt.object.*; |
| | | import com.vci.common.utility.ObjectUtility; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.omd.data.AttributeValue; |
| | | import com.vci.corba.omd.data.LinkObject; |
| | | import com.vci.corba.query.ObjectQueryService; |
| | | import com.vci.corba.query.data.BOAndLO; |
| | | import com.vci.starter.web.constant.QueryOptionConstant; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.DataGrid; |
| | |
| | | import com.vci.web.util.WebUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.omg.CORBA.IntHolder; |
| | | import org.omg.CORBA.PRIVATE_MEMBER; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import plm.bs.bom.clientobject.BOFactoryClient; |
| | | import plm.bs.bom.clientobject.ClientBusinessObject; |
| | | import plm.bs.bom.clientobject.ClientLinkObject; |
| | | import plm.bs.bom.clientobject.ClientLinkObjectOperation; |
| | | import plm.bs.bom.common.AttributeValue; |
| | | import plm.bs.bom.common.BusinessObject; |
| | | import plm.bs.bom.common.LinkObject; |
| | | import plm.corba.qt.BOAndLO; |
| | | import plm.oq.objectQuery.common.*; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | * 多语言前缀 |
| | | */ |
| | | private final String msgCodePrefix = "com.vci.web.loService."; |
| | | |
| | | |
| | | /** |
| | | * 日志对象 |
| | | */ |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | |
| | | /** |
| | | * LO操作类 |
| | | */ |
| | | private ClientLinkObjectOperation loOperation = new ClientLinkObjectOperation(); |
| | | |
| | | |
| | | @Autowired |
| | | private WebBoServiceI boService; |
| | | |
| | |
| | | LO_BASE_FIELD_MAP.put("ts","ts"); |
| | | LO_BASE_FIELD_MAP.put("linkTypeName","linkTypeName"); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public ClientLinkObjectOperation getLoOption() throws VciBaseException { |
| | | return loOperation; |
| | |
| | | |
| | | @Override |
| | | public List<ClientLinkObject> queryCLO(String linkType, |
| | | Map<String, String> conditionMap) throws VciBaseException { |
| | | Map<String, String> conditionMap) throws VciBaseException { |
| | | return queryCLO(linkType, "", 1, conditionMap); |
| | | } |
| | | |
| | | @Override |
| | | public List<ClientBusinessObject> queryLinkCbo(String linkType, |
| | | String toBtmname, Map<String, String> conditionMap) |
| | | String toBtmname, Map<String, String> conditionMap) |
| | | throws VciBaseException { |
| | | return queryLinkCbo(linkType, toBtmname, 1, conditionMap); |
| | | } |
| | |
| | | int level, Map<String, String> conditionMap) throws VciBaseException { |
| | | return queryCLO(linkType, toBtmName, level, false, conditionMap); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<ClientLinkObject> queryCLO(String linkType, String toBtmName, |
| | | int level, boolean isDirection,Map<String, String> conditionMap) throws VciBaseException { |
| | | return queryCLO(linkType,toBtmName,level,isDirection,conditionMap,new PageHelper(-1)); |
| | | } |
| | | |
| | | |
| | | /*** |
| | | * 链接查询,支持限定某端的业务类型,限定层级,排序,反向,查询条件,但是不支持枚举和参照字段的显示 |
| | | * @param linkType 链接类型名称 |
| | |
| | | Condition condition = boService.getConditionByMap(conditionMap); |
| | | qt.setCondition(condition); |
| | | try { |
| | | LinkObject[] bos = platformClientUtil.getQueryService().findLTObjects(qt.getId(), Tool.qtTOXMl(qt).asXML()); |
| | | LinkObject[] bos = platformClientUtil.getQueryService().findLTObjects(qt.getId(), OQTool.qtTOXMl(qt).asXML()); |
| | | if (bos != null && bos.length > 0) { |
| | | for (LinkObject bo : bos) { |
| | | ClientLinkObject clo = new ClientLinkObject(); |
| | | clo.setLinkObject(bo); |
| | | |
| | | |
| | | rtnOBJs.add(clo); |
| | | } |
| | | return rtnOBJs; |
| | | } |
| | | } catch (VCIError e) { |
| | | // logger.error(e.error_code,e); |
| | | // throw WebUtil.getVciBaseException(e); |
| | | } catch (PLException e) { |
| | | logger.error(e.code,e); |
| | | throw WebUtil.getVciBaseException(e); |
| | | } |
| | | return rtnOBJs; |
| | | } |
| | |
| | | throws VciBaseException { |
| | | return queryLinkCbo(linkType, toBtmname, level, false, conditionMap); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<ClientBusinessObject> queryLinkCbo(String linkType, |
| | | String toBtmName, int level,boolean isDirection, Map<String, String> conditionMap) |
| | |
| | | }else if(!isDirection && conditionMap.containsKey("f_oid")){ |
| | | btmOid = conditionMap.get("f_oid"); |
| | | } |
| | | BOAndLO[] bos = platformClientUtil.getQueryService().getBOAndLOS(qt.getId(), Tool.qtTOXMl(qt).asXML(),btmOid); |
| | | BOAndLO[] bos = platformClientUtil.getQueryService().getBOAndLOS(qt.getId(), OQTool.qtTOXMl(qt).asXML(),btmOid); |
| | | if (bos != null && bos.length > 0) { |
| | | for (BOAndLO blo : bos) { |
| | | ClientBusinessObject cbo = new ClientBusinessObject(); |
| | |
| | | } |
| | | return rtnOBJs; |
| | | } |
| | | } catch (VCIError e) { |
| | | } catch (PLException e) { |
| | | // logger.error(e.error_code,e); |
| | | // throw WebUtil.getVciBaseException(e); |
| | | } |
| | |
| | | boolean isDirection) throws VciBaseException { |
| | | return queryLinkedCbo(los,isDirection,new ArrayList<String>()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Map<String, ClientBusinessObject> queryLinkedCbo(List los, |
| | | boolean isDirection,List<String> queryColumn) throws VciBaseException { |
| | |
| | | return queryLinkedCbo(clol,isDirection,new ArrayList<String>()); |
| | | } |
| | | /***** |
| | | * |
| | | * |
| | | */ |
| | | @Override |
| | | public Map<String, ClientBusinessObject> queryLinkedCbo( |
| | |
| | | btmTypeOidMap.put(btmType, oids); |
| | | } |
| | | } |
| | | Map<String,ClientBusinessObject> linkedCboMap = new HashMap<String, ClientBusinessObject>(); |
| | | Map<String,ClientBusinessObject> linkedCboMap = new HashMap<>(); |
| | | Iterator<String> it = btmTypeOidMap.keySet().iterator(); |
| | | while(it.hasNext()){ |
| | | String btmType = it.next(); |
| | |
| | | if(StringUtils.isBlank(clo.getCreator())){ |
| | | clo.setCreator(WebUtil.getCurrentUserId()); |
| | | } |
| | | if(StringUtils.isBlank(clo.getCreateTime())){ |
| | | clo.setCreateTime(VciDateUtil.getNowString(VciDateUtil.DateTimeMillFormat)); |
| | | if(clo.getCreateTime() == 0){ |
| | | clo.setCreateTime(VciDateUtil.getTime(VciDateUtil.getNow())); |
| | | } |
| | | if(StringUtils.isBlank(clo.getLastModifier())){ |
| | | clo.setLastModifier(clo.getCreator()); |
| | | } |
| | | if(StringUtils.isBlank(clo.getLastModifyTime())){ |
| | | if(clo.getLastModifyTime() == 0){ |
| | | clo.setLastModifyTime(clo.getCreateTime()); |
| | | } |
| | | if(StringUtils.isBlank(clo.getTs())){ |
| | | if(clo.getTs() == 0){ |
| | | clo.setTs(clo.getCreateTime()); |
| | | } |
| | | linkObjects.add(clo.getLinkObject()); |
| | |
| | | } |
| | | } |
| | | return savedClientLinkObject; |
| | | } catch (VCIError vciError) { |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | } |
| | |
| | | WebUtil.alertNotNull(loName,"链接"); |
| | | try { |
| | | return loOperation.createLinkObject(loName,WebUtil.getCurrentUserId()); |
| | | } catch (VCIError vciError) { |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | } |
| | |
| | | newClo.setLinkObject(lo); |
| | | newClo.setOid((new ObjectUtility()).getNewObjectID36()); |
| | | newClo.setCreator(WebUtil.getCurrentUserId()); |
| | | newClo.setCreateTime(VciDateUtil.getNowString(VciDateUtil.DateTimeMillFormat)); |
| | | newClo.setCreateTime(VciDateUtil.getTime(VciDateUtil.getNow())); |
| | | newClo.setLastModifier(newClo.getCreator()); |
| | | newClo.setLastModifyTime(newClo.getCreateTime()); |
| | | newClo.setTs(newClo.getCreateTime()); |
| | |
| | | if(clos!=null){ |
| | | try { |
| | | loOperation.batchdDeleteLinkObject(clos.toArray(new ClientLinkObject[0])); |
| | | } catch (VCIError vciError) { |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | } |
| | |
| | | if(clos!=null){ |
| | | try { |
| | | loOperation.batchUpdateLinkObject(clos.toArray(new ClientLinkObject[0])); |
| | | } catch (VCIError vciError) { |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | } |
| | |
| | | * @return 链接类型和关联的to端 |
| | | */ |
| | | @Override |
| | | public List<BOAndLO> queryCLOAndBOBySchema(UILinkTypeDataQuery linkTypeDataQuery) { |
| | | public List<com.vci.corba.query.data.BOAndLO> queryCLOAndBOBySchema(UILinkTypeDataQuery linkTypeDataQuery) { |
| | | VciBaseUtil.alertNotNull(linkTypeDataQuery,"链接类型查询对象",linkTypeDataQuery.getQueryTemplateName(),"查询模板的名称"); |
| | | QueryTemplate qt =boService.getQtByName(linkTypeDataQuery.getQueryTemplateName(),linkTypeDataQuery.getReplaceMap()); |
| | | return queryCLOAndBOByQueryTemplate(qt,linkTypeDataQuery); |
| | |
| | | * @param linkTypeDataQuery 链接类型的查询对象 |
| | | * @return 链接类型和业务类型 |
| | | */ |
| | | private List<BOAndLO> queryCLOAndBOByQueryTemplate(QueryTemplate qt,UILinkTypeDataQuery linkTypeDataQuery){ |
| | | private List<com.vci.corba.query.data.BOAndLO> queryCLOAndBOByQueryTemplate(QueryTemplate qt,UILinkTypeDataQuery linkTypeDataQuery){ |
| | | if(StringUtils.isNotBlank(linkTypeDataQuery.getToBtmType()) && StringUtils.isBlank(qt.getBtmType())) { |
| | | qt.setBtmType(linkTypeDataQuery.getToBtmType()); |
| | | } |
| | |
| | | } |
| | | Condition condition = boService.getConditionByMap(conditionMap); |
| | | if(qt.getCondition() !=null) { |
| | | qt.setCondition(Tool.mergeCondition(qt.getCondition(), condition, Connector.AND)); |
| | | qt.setCondition(OQTool.mergeCondition(qt.getCondition(), condition, Connector.AND)); |
| | | }else { |
| | | qt.setCondition(condition); |
| | | } |
| | | boService.setPageAndOrderToQT(qt,linkTypeDataQuery.getPageHelper()); |
| | | try { |
| | | BOAndLO[] bos = platformClientUtil.getQueryService().getBOAndLOS(qt.getId(), Tool.qtTOXMl(qt).asXML(),linkTypeDataQuery.getParentOid()==null?"":linkTypeDataQuery.getParentOid()); |
| | | // com.vci.corba.query.data.BOAndLO[] bos = platformClientUtil.getQueryService().getBOAndLOS(qt.getId(), OQTool.qtTOXMl(qt).asXML(),linkTypeDataQuery.getParentOid()==null?"":linkTypeDataQuery.getParentOid()); |
| | | com.vci.corba.query.data.BOAndLO[] bos = ServiceProvider.getOQService().getBOAndLOS(qt.getId(), OQTool.qtTOXMl(qt).asXML(),linkTypeDataQuery.getParentOid()==null?"":linkTypeDataQuery.getParentOid()); |
| | | return Arrays.stream(bos).collect(Collectors.toList()); |
| | | } catch (VCIError e) { |
| | | } catch (PLException e) { |
| | | // logger.error(e.error_code,e); |
| | | throw WebUtil.getVciBaseException(e); |
| | | } |
| | |
| | | * @return 链接对象和to端业务对象 |
| | | */ |
| | | @Override |
| | | public List<BOAndLO> queryCLOAndBoByLinkType(UILinkTypeDataQuery linkTypeDataQuery){ |
| | | public List<com.vci.corba.query.data.BOAndLO> queryCLOAndBoByLinkType(UILinkTypeDataQuery linkTypeDataQuery){ |
| | | VciBaseUtil.alertNotNull(linkTypeDataQuery,"链接类型查询对象",linkTypeDataQuery.getLinkType(),"链接类型的名称"); |
| | | QueryTemplate qt = null; |
| | | if(StringUtils.isBlank(linkTypeDataQuery.getQueryTemplateName())){ |
| | |
| | | } |
| | | Condition condition = boService.getConditionByMap(conditionMap); |
| | | if(qt.getCondition() !=null) { |
| | | qt.setCondition(Tool.mergeCondition(qt.getCondition(), condition, Connector.AND)); |
| | | qt.setCondition(OQTool.mergeCondition(qt.getCondition(), condition, Connector.AND)); |
| | | }else { |
| | | qt.setCondition(condition); |
| | | } |
| | |
| | | Map<String,List<String>> toBtmOidsMap = new HashMap<>(); |
| | | try { |
| | | IntHolder totalHolder = new IntHolder(); |
| | | LinkObject[] linkObjects = platformClientUtil.getQueryService().findLTObjectsV2(qt.getId(), Tool.qtTOXMl(qt).asXML(),totalHolder); |
| | | // com.vci.corba.omd.data.LinkObject[] linkObjects = platformClientUtil.getQueryService().findLTObjectsV2(qt.getId(), OQTool.qtTOXMl(qt).asXML(),totalHolder); |
| | | ObjectQueryService.FindLTObjectsV2Result linkObjects = ServiceProvider.getOQService().findLTObjectsV2(qt.getId(), OQTool.qtTOXMl(qt).asXML()); |
| | | |
| | | |
| | | List<Map<String,String>> data = new ArrayList<>(); |
| | | List<String> finalEnumFields = enumFields; |
| | | final Integer[] total = {totalHolder.value}; |
| | | Arrays.stream(linkObjects).forEach(lo->{ |
| | | Arrays.stream(linkObjects.returnValue).forEach(lo->{ |
| | | ClientLinkObject clo = new ClientLinkObject(); |
| | | clo.setLinkObject(lo); |
| | | Map<String, String> map = new HashMap<>(); |
| | | boService.queryEnumText(null,clo, finalEnumFields); |
| | | WebUtil.copyValueToMapFromClos(clo,map); |
| | | List<String> fromOids = fromBtmOidsMap.getOrDefault(lo.fromBTMName, new ArrayList<>()); |
| | | List<String> fromOids = fromBtmOidsMap.getOrDefault(lo.fromBTName, new ArrayList<>()); |
| | | fromOids.add(lo.fromOid); |
| | | fromBtmOidsMap.put(lo.fromBTMName,fromOids); |
| | | fromBtmOidsMap.put(lo.fromBTName,fromOids); |
| | | |
| | | List<String> toOids = toBtmOidsMap.getOrDefault(lo.toBTMName, new ArrayList<>()); |
| | | List<String> toOids = toBtmOidsMap.getOrDefault(lo.toBTName, new ArrayList<>()); |
| | | toOids.add(lo.toOid); |
| | | toBtmOidsMap.put(lo.toBTMName,toOids); |
| | | toBtmOidsMap.put(lo.toBTName,toOids); |
| | | data.add(map); |
| | | if(total[0] == 0){ |
| | | total[0] = VciBaseUtil.getInt(map.getOrDefault(QTConstants.COUNT_OVER_ALIAS.toLowerCase(),"0")); |
| | |
| | | }); |
| | | dataGrid.setData(data); |
| | | dataGrid.setTotal(total[0]); |
| | | } catch (VCIError e) { |
| | | } catch (PLException e) { |
| | | // logger.error(e.error_code,e); |
| | | throw WebUtil.getVciBaseException(e); |
| | | } |
| | |
| | | Condition condition = boService.getConditionByMap(conditionMap); |
| | | qt.setCondition(condition); |
| | | try { |
| | | return platformClientUtil.getQueryService().findTotalCount(qt.getId(), Tool.qtTOXMl(qt).asXML()); |
| | | } catch (VCIError vciError) { |
| | | return Math.toIntExact(platformClientUtil.getQueryService().findTotalCount(qt.getId(), OQTool.qtTOXMl(qt).asXML())); |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | | } |