在windchill中很多查询都是非常类似的,方法也是非常之多,不过只要会两三种查询方式就可以应付windchill中几乎所有的查询需要,
本次上雪堂将再次提及一种非常方便的查询,不过对于这种查询方式需要对于数据库表有一定的了解。此实例中需要注意的是对于时间的比较查询。
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import wt.fc.PersistenceHelper;
import wt.fc.QueryResult;
import wt.projmgmt.admin.Project2;
import wt.projmgmt.execution.ProjectPlan;
import wt.query.CompositeWhereExpression;
import wt.query.ConstantExpression;
import wt.query.DateExpression;
import wt.query.LogicalOperator;
import wt.query.QuerySpec;
import wt.query.SearchCondition;
import wt.query.TableColumn;
import wt.util.WTException;
public class Demo
{
/**
* @param args
* @throws WTException
* @throws ParseException
*/
public static void main(String[] args) throws WTException, ParseException
{
String string="2009-05-01 00:00:00.000000";
Timestamp time=Timestamp.valueOf(string);
// TODO Auto-generated method stub
QuerySpec qs = new QuerySpec();
int a = qs.appendClassList(Project2.class, true);
int b = qs.appendClassList(ProjectPlan.class, true);
qs.setAdvancedQueryEnabled(true);
String[] aliases = new String[2];
aliases[0] = qs.getFromClause().getAliasAt(a);
aliases[1] = qs.getFromClause().getAliasAt(b);
TableColumn tc1 = new TableColumn(aliases[0], "IDA2A2"); //项目id
TableColumn tc2 = new TableColumn(aliases[0], "STATECONTAINERTEAMMANAGEDINF");//项目状态
TableColumn tc3 = new TableColumn(aliases[1], "IDA3B8"); //项目计划中引用项目id
TableColumn tc4 = new TableColumn(aliases[1], "NAME"); //项目名称
TableColumn tc5 = new TableColumn(aliases[1], "PERCENTCOMPLETE"); //项目完成进度
TableColumn tc6 = new TableColumn(aliases[1], "TIMETOSTART"); //项目实际开始时间
CompositeWhereExpression andExpression = new CompositeWhereExpression(LogicalOperator.AND);
andExpression.append(new SearchCondition(tc1, "=", tc3));
andExpression.append(new SearchCondition(tc2, "=", new ConstantExpression("RUNNING"))); //正在运行
andExpression.append(new SearchCondition(tc4, "=", new ConstantExpression("上雪堂")));
andExpression.append(new SearchCondition(tc5, ">=", new ConstantExpression(new Integer("89"))));
andExpression.append(new SearchCondition(tc6, SearchCondition.GREATER_THAN_OR_EQUAL, new ConstantExpression(time)));
qs.appendWhere(andExpression, null);
QueryResult qr=PersistenceHelper.manager.find(qs);
while (qr.hasMoreElements())
{
Object obj[] = (Object[]) qr.nextElement();
Project2 project2 = (Project2)obj[0];
System.out.println(project2.getName()); //项目名称
System.out.println(project2.getCtmState());//项目状态
ProjectPlan projectPlan = (ProjectPlan)obj[1];
System.out.println(projectPlan.getPercentComplete()); //项目完成进度
System.out.println(projectPlan.getStartTime()); //项目开始时间
}
}
}
分享到:
相关推荐
Windchill中使用JDBC查询 Windchill中使用JDBC查询
Windchill多值 _模糊查询Part.
windchill 中文客制化
windchill资料windchill资料windchill资料windchill资料
NULL 博文链接:https://windchill9.iteye.com/blog/670301
windchill9.0中文教程,适合入门或者深入研究
文件列出了PTC Windchill 9.0开发中使用的Jar文件,以及每个Jar文件中的类名,方便开发人员查询。
Windchille二次开发中用到的查询零件的类,封装好了,可直接用~
查询对象的自定义类型WTTypeDefinition
windchill12.1.0.0 安装
windchill学习windchill学习windchill学习windchill学习windchill学习windchill学习windchill学习windchill学习windchill学习windchill学习
使用linux命令安装windchill教程,教程中详细描述了在linux中执行的命令。因使用的linux版本问题,在安装的过程中可能会遇到其它的问题,请百度自行解决
导出命令需要在windchill shell中执行: windchill wt.load.LoadFromFile -d loadFiles/ext2/ExportType.xml -u wcadmin -p wcadmin
Windchill+spring+mybatis 1、修改codebase/MVCDispatcher-servlet.xml新增如下内容,配置mybatis-spring
windchill 远程调试详细介绍 windchill开发环境搭建 windchill服务端调试模式设置 windchill eclipse开发环境搭建详细介绍
1.load data 命令 把单个xml文件导入: windchill wt.load.LoadFromFile -d testType.xml -u hongdu -p hongdu 把csv文件转化为xml文件: ...windchill wt.load.LoadFileSet -file D:\ptc\Windchill_9.1
windchill系统调优文档windchill
WINDCHILL项目管理模块使用教程 WINDCHILL项目管理模块使用教程
windchill 中文备份恢复文档,支持版本Windchill® 10.0 Windchill PDMLink® Windchill ProjectLink™ Pro/INTRALINK® 10.0
Windchill Data Load for 11.0 M030,Windchill数据装载(导入、导出)参考指南。