Part/BOM的导出
程序员文章站
2022-07-14 20:05:43
...
private static ReferenceFactory rf=new ReferenceFactory();
private static final boolean serverFlag=RemoteMethodServer.getDefault().ServerFlag;
/**
* @param args
* @throws WTException
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
OutputStream os=new FileOutputStream(new File("E:/test.xls"));
bomexport(os,"VR:wt.part.WTPart:311117");
//bomexport(os, "VR:wt.part.WTPart:311189");
}
public static Object getObjectByOid(String oid) throws WTException{
return rf.getReference(oid).getObject();
}
public static void bomexport(OutputStream os,String oid) throws Exception{
RemoteMethodServer methodServer = RemoteMethodServer.getDefault();
methodServer.setUserName("wcadmin");
methodServer.setPassword("wcadmin");
if(oid!=null && oid.length()>0){
ArrayList list=new ArrayList();
WTPart part=(WTPart) getObjectByOid(oid);
list=getBOM(part,list);
createBOMExcel(os, list, part);
}
}
public static ArrayList getBOM(WTPart part,ArrayList list) throws Exception{
System.out.println("whodd");
//if(serverFlag){
if(part==null){
return list;
}
WTPrincipal currentUser=null;
try {
currentUser=SessionHelper.getPrincipal();
SessionHelper.manager.setAdministrator();
if(part.isEndItem()){
addAttrToList(list, part);
}
QueryResult qr=WTPartHelper.service.getUsesWTPartMasters(part);
if(qr.size()!=0){
while(qr.hasMoreElements()){
WTPartUsageLink link=(WTPartUsageLink) qr.nextElement();
if(link!=null){
WTPartMaster partmaster=(WTPartMaster) link.getRoleBObject();
WTPart subpart=getLastPart(partmaster);
if(subpart!=null){
addAttrToList(list, subpart);
}
getBOM(subpart,list);
}
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
SessionHelper.manager.setPrincipal(currentUser.getName());
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
return list;
private static final boolean serverFlag=RemoteMethodServer.getDefault().ServerFlag;
/**
* @param args
* @throws WTException
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
OutputStream os=new FileOutputStream(new File("E:/test.xls"));
bomexport(os,"VR:wt.part.WTPart:311117");
//bomexport(os, "VR:wt.part.WTPart:311189");
}
public static Object getObjectByOid(String oid) throws WTException{
return rf.getReference(oid).getObject();
}
public static void bomexport(OutputStream os,String oid) throws Exception{
RemoteMethodServer methodServer = RemoteMethodServer.getDefault();
methodServer.setUserName("wcadmin");
methodServer.setPassword("wcadmin");
if(oid!=null && oid.length()>0){
ArrayList list=new ArrayList();
WTPart part=(WTPart) getObjectByOid(oid);
list=getBOM(part,list);
createBOMExcel(os, list, part);
}
}
public static ArrayList getBOM(WTPart part,ArrayList list) throws Exception{
System.out.println("whodd");
//if(serverFlag){
if(part==null){
return list;
}
WTPrincipal currentUser=null;
try {
currentUser=SessionHelper.getPrincipal();
SessionHelper.manager.setAdministrator();
if(part.isEndItem()){
addAttrToList(list, part);
}
QueryResult qr=WTPartHelper.service.getUsesWTPartMasters(part);
if(qr.size()!=0){
while(qr.hasMoreElements()){
WTPartUsageLink link=(WTPartUsageLink) qr.nextElement();
if(link!=null){
WTPartMaster partmaster=(WTPartMaster) link.getRoleBObject();
WTPart subpart=getLastPart(partmaster);
if(subpart!=null){
addAttrToList(list, subpart);
}
getBOM(subpart,list);
}
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
SessionHelper.manager.setPrincipal(currentUser.getName());
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
return list;
推荐阅读
-
深入学习JavaScript中的bom
-
使用canvas对多图片拼合并导出图片的方法
-
Excel-Boot(一款Excel导入导出解决方案组成的轻量级开源组件)
-
【C#常用方法】2.DataTable(或DataSet)与Excel文件之间的导出与导入(使用NPOI)
-
ASP导出Excel数据的四种方法
-
3dmax怎么导出obj格式的文件?
-
VideoScribe怎么做视频?VideoScribe导出视频的详细教程
-
oracle 11g导出数据时报ORA 1455错误的处理方法
-
PHP+MySQL实现海量数据导入导出的总结:is_numbric函数的坑
-
神剪辑如何导出视频?神剪辑导出视频的方法