博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PTC FlexPLM rfa 常用功能api
阅读量:7224 次
发布时间:2019-06-29

本文共 9930 字,大约阅读时间需要 33 分钟。

1.根据款号查询产品
public LCSProduct GetProductByName(String SKC) throws WTException {        //声明查询        PreparedQueryStatement statement = new PreparedQueryStatement();        statement.appendFromTable("LCSPRODUCT");        //获取FlexType类型,也就是系列        String flextypePath = "Product";         FlexType flextype = FlexTypeCache.getFlexTypeFromPath(flextypePath);// the flextype of product flextype        //设置SQL语句的列名        String columnFtaName = null;                columnFtaName = flextype.getAttribute("productName").getVariableName();        statement.appendSelectColumn("LCSPRODUCT", columnFtaName);                statement.appendSelectColumn("LCSPRODUCT", "BRANCHIDITERATIONINFO");                //设置SQL中的Where条件        //款号条件        if(SKC.trim().length()>0){            statement.appendAndIfNeeded();            statement.appendCriteria(new Criteria("LCSPRODUCT",flextype.getAttribute("EPAstyleNumber").getVariableName(),SKC,Criteria.EQUALS));        }                statement.appendAndIfNeeded(); //版本号为A        statement.appendCriteria(new Criteria("LCSPRODUCT", "VERSIONIDA2VERSIONINFO", "A", Criteria.EQUALS));                statement.appendAndIfNeeded();//并且为最大版本号        statement.appendCriteria(new Criteria("LCSPRODUCT", "LATESTITERATIONINFO", "1", Criteria.EQUALS));                SearchResults results = LCSQuery.runDirectQuery(statement);//执行查询        Vector vRlt = results.getResults(); //获取所有行的信息        int iRecNum = vRlt.size();                if (iRecNum == 0 || iRecNum > 1) {            System.out.println("1-无法定位产品");            return null;        }        FlexObject obj = (FlexObject) vRlt.get(0);//获取产品        String oid="VR:com.lcs.wc.product.LCSProduct:"+obj.getString("LCSPRODUCT.BRANCHIDITERATIONINFO");//取出该产品的oid        //通过接口查询处产品实体        return (LCSProduct)(new LCSProductQuery()).findObjectById(oid);    }
2.根据产品获取所属季节对象
public LCSSeason GetSeasonByProduct(LCSProduct product)throws Exception{        SeasonProductLocator seasonProductLocator = new SeasonProductLocator();        LCSSeasonProductLink seasonProductLink = seasonProductLocator.getSeasonProductLink(product);        LCSSeason season = (LCSSeason)seasonProductLocator.getSeasonRev(seasonProductLink);        return season;    }
3.获取季节和产品的关联对象
SeasonProductLocator seasonProductLocator = new SeasonProductLocator();LCSSeasonProductLink seasonProductLink = seasonProductLocator.getSeasonProductLink(product);
4.获取产品的采购来源(1:m)
   Collection sourcing = LCSSourcingConfigQuery.getSourcingConfigsForProduct(product);    Iterator it = sourcing.iterator();    LCSSourcingConfig configSource=null;    while (it.hasNext()) {        configSource = (LCSSourcingConfig)it.next();    }
5.获取产品采购来源下的所有规格
SearchResults gg = FlexSpecQuery.findSpecsByOwner((WTPartMaster)product.getMaster(), (WTPartMaster)season.getMaster(), null, null);Collection coll = LCSQuery.getObjectsFromResults(gg, "VR:com.lcs.wc.specification.FlexSpecification:", "FLEXSPECIFICATION.BRANCHIDITERATIONINFO");    for(int n=0;n
6.获取产品下的所有图像文档集合
LCSProductQuery prodQuery = new LCSProductQuery();    Collection prodImagePages = prodQuery.findImagePages(product, null, null, true);    prodImagePages = CollectionUtil.distinctResults(prodImagePages, "LCSDOCUMENT.BRANCHIDITERATIONINFO");    Iterator imagePageIter = prodImagePages.iterator();    while(imagePageIter.hasNext()){       FlexObject obj = (FlexObject) imagePageIter.next();       ...    }
7.获取产品下的所有工艺包
Collection construction = LCSQuery.runDirectQuery(LCSConstructionQuery.findConstructionForProductQuery(product, null, true)).getResults();    Iterator constIter = construction.iterator();    while(constIter.hasNext()){        FlexObject obj = (FlexObject) constIter.next();    }
8.获取产品下的所有版型集合
Collection measurements = LCSQuery.runDirectQuery(LCSMeasurementsQuery.findMeasurmentsForProductQuery(product, null, true)).getResults();    Iterator measIter = measurements.iterator();    while(measIter.hasNext()){        FlexObject obj = (FlexObject) measIter.next();    }
9.获取产品下的所有BOM
LCSFlexBOMQuery bomQuery = new LCSFlexBOMQuery();    QueryStatement bomQueryStatement = bomQuery.findBOMPartsForOwnerQuery((WTPartMaster)product.getMaster(), "", true);    Collection bomResults = LCSQuery.runDirectQuery(bomQueryStatement).getResults();    Iterator bomIter = bomResults.iterator();    while(bomIter.hasNext()){         FlexObject obj = (FlexObject) bomIter.next();    }
10.给FlexModel批量赋值,Collection操作
Map specMap=new HashMap();    specMap.put("specOwnerId",specOwnerId);    specMap.put("sourceIds",sourceIds);    specMap.put("specSourceId",specSourceId);    specMap.put("specSeason",specSeason);    specMap.put("typeId",typeId);    specMap.put(att1Name,"颁行");    //操作Collection    Collection c_sourceIds = new HashSet();    c_sourceIds.add(sourceIds);        AttributeValueSetter.setAllAttributes(flexSpecModel, specMap);
11.获取产品的颜色
public String GetProductColor(LCSProduct product){        try{             String str="";             LCSSKUQuery query = new LCSSKUQuery();             Collection skuList = query.findSKUs(product);             for (Iterator iter = skuList.iterator(); iter.hasNext();) {                LCSSKU sku=(LCSSKU)iter.next();                str+=sku.getName().replace(" ("+product.getValue("productName")+")","\\");            }            if(str=="") return "无";            return str.substring(0,str.length()-1);        }        catch(Exception e){            return "ERROR";        }    }
12.根据用户名,获取用户对象
public WTUser getUser(String name) throws WTException {           Enumeration enumUser = OrganizationServicesHelper.manager.findUser(WTUser.NAME, name);           WTUser user = null;           if (enumUser.hasMoreElements())               user = (WTUser) enumUser.nextElement();             if (user == null) {               enumUser = OrganizationServicesHelper.manager.findUser(WTUser.FULL_NAME, name);               if (enumUser.hasMoreElements())                   user = (WTUser) enumUser.nextElement();           }        if (user == null) {               throw new WTException("系统中不存在用户名为'" + name + "'的用户!");           }           return user;       }
13.FlexPLM键值对查找
public String GetBusinessObjDispKey(String Key,String Disp,String path,String Att){        try{            //准备关键字和值的转换            FlexTypeAttribute LoadAtt=FlexTypeCache.getFlexTypeFromPath(path).getAttribute(Att);            Collection pathData = LoadAtt.getAttValueList().getDataSet();                        for(Iterator iter=pathData.iterator();iter.hasNext();){                FlexObject fo=(FlexObject)iter.next();                String key=fo.getString("KEY");                String disp=fo.getString("VALUE_ZH_CN");                if(!Key.equals("") && key.equals(Key))                    return disp;                else if(!Disp.equals("") && disp.equals(Disp))                    return key;            }            return Key;        }        catch(Exception e){            System.out.println("GetValueByKey====Error:"+e);            return "";                }    }
14.获取打样品颜色列表
FlexTypeAttribute LoadAtt=FlexTypeCache.getFlexTypeFromPath("Business Object\\PTCOListOfValue\\PTCOCommonLov\\PTCOCommon1Lov").getAttribute("LovSampleColor");        Collection pathData = LoadAtt.getAttValueList().getDataSet();        for(Iterator iter=pathData.iterator();iter.hasNext();){            FlexObject fo=(FlexObject)iter.next();            String key=fo.getString("KEY");            String disp=fo.getString("VALUE_ZH_CN");        }
15.根据产品和用户获取用户下的所有工作流,并驱动执行
String OjbectID="VR:com.lcs.wc.product.LCSProduct:"+(int)spl.getProductSeasonRevId();        //获取用户实体        WTUser user = getUserFromName(UserName);        //根据用户和ObjectID定位项目        SearchResults res = (new LCSWorkitemQuery()).getUserWorkList(user,OjbectID);        Collection coll = res.getResults();        System.out.println("根据用户和ObjectID获取" + coll.size());        if(coll.size()<=0) {            out.println("1-没有找到该工作项!");            return;        }        String WorkName="",WorkItemID="";        for (int i = 0; i < coll.size(); i++) {            FlexObject item=(FlexObject)coll.toArray()[i];                        System.out.println(item);            WorkName=item.getString("WFASSIGNEDACTIVITY.NAME");            WorkItemID="OR:wt.workflow.work.WorkItem:"+item.getString("WORKITEM.IDA2A2");        }        if(!WorkName.equals("商品部主导初样评审"))        {            out.println("1-状态错误");            return;        }        //执行工作流        String workIds = "|~*~|"+WorkItemID;        Collection workIdsCollection = MOAHelper.getMOACollection(workIds);        WFHelper.getService().processWFTasks(workIdsCollection, workEvent);
16.获取产品下的尺码
Collection productSizeCats = new SizingQuery().findProductSizeCategoriesForProduct(product).getResults();    Iterator itor=productSizeCats.iterator();    String productSizeCategory="";    while(itor.hasNext()){        FlexObject obj = (FlexObject)itor.next();        if(obj.getString("SIZECATEGORY.NAME").equals(brand)){            productSizeCategory="OR:com.lcs.wc.measurements.ProductSizeCategory:"+obj.getString("PRODUCTSIZECATEGORY.IDA2A2");            break;        }    }
17.jsp页面接收xml流,格式化为字符串,打印
InputStream input = request.getInputStream();        ByteArrayOutputStream output = new ByteArrayOutputStream();        byte buffer[] = new byte[1024];        int len = -1;        try {            while ((len = input.read(buffer, 0, buffer.length)) > 0) {                output.write(buffer, 0, len);            }        } finally {            if (output != null)                output.close();        }        buffer = output.toByteArray();        if (buffer == null || buffer.length == 0) {            throw new LCSException(RB.XML, "noDataForProduct_ERR", RB.objA);        }        if (DEBUG) {            String message = new String(buffer, DEFAULT_ENCODING);            System.out.println("-----------------");            System.out.println("XML message="+message);        }

 

转载地址:http://eyzfm.baihongyu.com/

你可能感兴趣的文章
电子病历,到底是用BS还是CS
查看>>
Visual Studio (VSIX,项目模板 )制作
查看>>
两个人的荒岛
查看>>
机器学习经典书籍
查看>>
[nginx] nginx安装
查看>>
[转].NET 绘制 EAN13 (商品条码)
查看>>
【转】越狱的 iPhone、iPad 通过网站实现一键安装 ipa 格式的 APP 应用
查看>>
开发者的利器:Docker 理解与使用
查看>>
mybatis调用视图和存储过程
查看>>
Nested loops、Hash join、Sort merge join(三种连接类型原理、使用要点)
查看>>
RT-Thread的线程(任务)处理 rt_thread_create/rt_thread_init区别
查看>>
为什么需要单元测试
查看>>
[原]shell中的三个零碎知识
查看>>
piix4_smbus 0000:00:07.0: SMBus base address uninitialized - upgrade BIOS or use force_addr=0xaddr
查看>>
操作MSSQL服务还有测试是否连接
查看>>
vim命令拾遗[zz]
查看>>
简单PHP留言板之七 —— 附加上css样式表
查看>>
数据库开发篇(一)——转换日期类型
查看>>
php 燕十八 观察者模式代码例子
查看>>
利用Android Lost通过互联网或短信远程控制安卓设备
查看>>