|
|
@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
package com.connor.dfl.plm.dfl043;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.filechooser.FileSystemView;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
|
|
|
import org.jacorb.idl.runtime.int_token;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.connor.dfl.plm.dfl019.ClassPropBean;
|
|
|
|
|
|
|
|
import com.connor.dfl.plm.dfl019.ItemBean;
|
|
|
|
|
|
|
|
import com.connor.dfl.plm.dfl019.ParseXMLUtil;
|
|
|
|
|
|
|
|
import com.connor.dfl.plm.exportBOM.ChangeDbomUtil;
|
|
|
|
|
|
|
|
import com.connor.dfl.plm.util.ClassValueBean;
|
|
|
|
|
|
|
|
import com.connor.dfl.plm.util.ClassValueUtil;
|
|
|
|
|
|
|
|
import com.connor.dfl.plm.util.ProgressBarThread;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.aif.AbstractAIFOperation;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCClassificationService;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponent;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentDataset;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentForm;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentICO;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItem;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentQuery;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentQueryType;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentUser;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCException;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCProperty;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCSession;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCTypeService;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCUserService;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.ics.ICSAdminClass;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.ics.ICSProperty;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.util.MessageBox;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class Dfl043Operation extends AbstractAIFOperation{
|
|
|
|
|
|
|
|
private InterfaceAIFComponent[] comps;
|
|
|
|
|
|
|
|
private TCSession session;
|
|
|
|
|
|
|
|
private List<String> attrList;
|
|
|
|
|
|
|
|
private List<String> errList = new ArrayList<String>();
|
|
|
|
|
|
|
|
private ProgressBarThread wait;
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param app
|
|
|
|
|
|
|
|
* @param lattetTime
|
|
|
|
|
|
|
|
* @param EarlyTime
|
|
|
|
|
|
|
|
* @param pathRoute
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public Dfl043Operation(InterfaceAIFComponent[] comps,TCSession session) {
|
|
|
|
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.comps = comps;
|
|
|
|
|
|
|
|
this.session = session;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void executeOperation() throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
System.out.println("开旁路");
|
|
|
|
|
|
|
|
ChangeDbomUtil.setByPass(true);
|
|
|
|
|
|
|
|
//System.out.println("9.17数量为====="+comps.length);
|
|
|
|
|
|
|
|
for (int i = 0; i < comps.length; i++) {
|
|
|
|
|
|
|
|
InterfaceAIFComponent comp = comps[i];
|
|
|
|
|
|
|
|
wait = new ProgressBarThread("填写作业编号中", "执行中,请稍等...");
|
|
|
|
|
|
|
|
wait.start();// 开启进度条
|
|
|
|
|
|
|
|
if(comp instanceof TCComponentBOMLine) {
|
|
|
|
|
|
|
|
TCComponentBOMLine line = (TCComponentBOMLine) comp;
|
|
|
|
|
|
|
|
setworknum(line);
|
|
|
|
|
|
|
|
wait.setBool(true);// 关闭进度条
|
|
|
|
|
|
|
|
MessageBox.post("已自动填写作业编号!", "WARNING",
|
|
|
|
|
|
|
|
MessageBox.WARNING);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else if(comp instanceof TCComponentItemRevision){
|
|
|
|
|
|
|
|
TCComponentItemRevision revision = (TCComponentItemRevision) comp;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TCComponentItemRevision rev = (TCComponentItemRevision) comp;
|
|
|
|
|
|
|
|
//通过版本获取bomline
|
|
|
|
|
|
|
|
TCTypeService service = session.getTypeService();
|
|
|
|
|
|
|
|
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow");
|
|
|
|
|
|
|
|
TCComponentBOMWindow view = winType.create(null);
|
|
|
|
|
|
|
|
TCComponentItem item = revision.getItem();
|
|
|
|
|
|
|
|
TCComponentBOMLine line1 = view.setWindowTopLine(item,revision, null, null);
|
|
|
|
|
|
|
|
setworknum(line1);
|
|
|
|
|
|
|
|
wait.setBool(true);// 关闭进度条
|
|
|
|
|
|
|
|
MessageBox.post("已自动填写作业编号!", "WARNING",
|
|
|
|
|
|
|
|
MessageBox.WARNING);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
MessageBox.post("选中的对象中有非版本对象或BOM行对象,请检查!", "WARNING",
|
|
|
|
|
|
|
|
MessageBox.WARNING);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ChangeDbomUtil.setByPass(false);
|
|
|
|
|
|
|
|
System.out.println("关旁路");
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
|
|
|
MessageBox.post("自动填写作业编号失败!!!,请检查!", "WARNING",
|
|
|
|
|
|
|
|
MessageBox.WARNING);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//在bom中设置将作业编号发放给结构下面所有的物料
|
|
|
|
|
|
|
|
private void setworknum(TCComponentBOMLine line) {
|
|
|
|
|
|
|
|
//System.out.println("9.17.19.519.17.19.51");
|
|
|
|
|
|
|
|
if(line instanceof TCComponentBOMLine) {
|
|
|
|
|
|
|
|
//System.out.println("9.17.19.479.17.19.47");
|
|
|
|
|
|
|
|
TCComponentItemRevision rev;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
//System.out.println("9.17.19.479.17.19.47");
|
|
|
|
|
|
|
|
//刷新bomline
|
|
|
|
|
|
|
|
line.refresh();
|
|
|
|
|
|
|
|
rev = line.getItemRevision();
|
|
|
|
|
|
|
|
TCProperty tcProperty = rev.getTCProperty("release_status_list");
|
|
|
|
|
|
|
|
TCComponent[] targets = tcProperty.getReferenceValueArray();
|
|
|
|
|
|
|
|
String jobid = line.getStringProperty("T2_JobNumber"); //获取作业编号
|
|
|
|
|
|
|
|
//System.out.println("9.17jobid====="+jobid);
|
|
|
|
|
|
|
|
String itemid = rev.getStringProperty("item_id"); //获取itemid
|
|
|
|
|
|
|
|
//System.out.println("9.17itemid====="+itemid);
|
|
|
|
|
|
|
|
//判断是否发布了
|
|
|
|
|
|
|
|
if(targets.length>=0) {
|
|
|
|
|
|
|
|
//判断是否有作业编号
|
|
|
|
|
|
|
|
if(jobid != null || !"".equals(jobid)) {
|
|
|
|
|
|
|
|
//判断是否有子件
|
|
|
|
|
|
|
|
AIFComponentContext[] childs = line.getChildren();
|
|
|
|
|
|
|
|
//System.out.println("9.17子级个数====="+childs.length);
|
|
|
|
|
|
|
|
if(childs != null && childs.length > 0 ) {
|
|
|
|
|
|
|
|
//循环遍历子级对象
|
|
|
|
|
|
|
|
for (int j = 0;j < childs.length;j++) {
|
|
|
|
|
|
|
|
//获取子级对象
|
|
|
|
|
|
|
|
InterfaceAIFComponent childcomp = childs[j].getComponent();
|
|
|
|
|
|
|
|
//获取子级bomline
|
|
|
|
|
|
|
|
TCComponentBOMLine childline = (TCComponentBOMLine) childcomp;
|
|
|
|
|
|
|
|
//根据自己bomline获取版本
|
|
|
|
|
|
|
|
TCComponentItemRevision childrev = ((TCComponentBOMLine) childline).getItemRevision();
|
|
|
|
|
|
|
|
//获取子级的id
|
|
|
|
|
|
|
|
String childid = childrev.getStringProperty("item_id");
|
|
|
|
|
|
|
|
//System.out.println("9.17子级id====="+childid);
|
|
|
|
|
|
|
|
//获取子级的版本类型
|
|
|
|
|
|
|
|
String childtype = childrev.getStringProperty("object_type");
|
|
|
|
|
|
|
|
//System.out.println("9.17子级版本类型====="+childtype);
|
|
|
|
|
|
|
|
//获取子级的作业编号
|
|
|
|
|
|
|
|
String childjobid = childline.getStringProperty("T2_JobNumber");
|
|
|
|
|
|
|
|
//System.out.println("9.17子级作业编号====="+childjobid);
|
|
|
|
|
|
|
|
if("T2_outsourceRevision".equals(childtype) || "T2_OutBuyPartRevision".equals(childtype) || "T2_VirtualRevision".equals(childtype)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//System.out.println("9.17.19.21");
|
|
|
|
|
|
|
|
//判断有没有作业编号
|
|
|
|
|
|
|
|
if(childjobid == null || "".equals(childjobid) || " ".equals(childjobid)) {
|
|
|
|
|
|
|
|
//没有则设置作业编号
|
|
|
|
|
|
|
|
childline.setStringProperty("T2_JobNumber", jobid);
|
|
|
|
|
|
|
|
if("T2_VirtualRevision".equals(childtype)) {
|
|
|
|
|
|
|
|
//是虚拟件版本则递归
|
|
|
|
|
|
|
|
setworknum(childline);
|
|
|
|
|
|
|
|
//System.out.println("递归方法9.17(1)");
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
//不是则跳出循环,进入下一个循环
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
//有作业编号 则跳出循环,进入下一个循环
|
|
|
|
|
|
|
|
//判断是不是虚拟件版本
|
|
|
|
|
|
|
|
if("T2_VirtualRevision".equals(childtype)) {
|
|
|
|
|
|
|
|
//是虚拟件版本则递归
|
|
|
|
|
|
|
|
setworknum(childline);
|
|
|
|
|
|
|
|
//System.out.println("递归方法9.17(2)");
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
//不是则跳出循环,进入下一个循环
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
//如果父级没有就去找子级的作业编号
|
|
|
|
|
|
|
|
AIFComponentContext[] childs2 = line.getChildren();
|
|
|
|
|
|
|
|
//System.out.println("9.17子级个数2====="+childs2.length);
|
|
|
|
|
|
|
|
if(childs2 != null && childs2.length > 0 ) {
|
|
|
|
|
|
|
|
for (int j = 0;j < childs2.length;j++) {
|
|
|
|
|
|
|
|
//获取子级对象
|
|
|
|
|
|
|
|
InterfaceAIFComponent childcomp2 = childs2[j].getComponent();
|
|
|
|
|
|
|
|
//获取子级bomline
|
|
|
|
|
|
|
|
TCComponentBOMLine childline2 = (TCComponentBOMLine) childcomp2;
|
|
|
|
|
|
|
|
//递归此方法
|
|
|
|
|
|
|
|
setworknum(childline2);
|
|
|
|
|
|
|
|
//System.out.println("递归方法9.17(3)");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
MessageBox.post(itemid+"已发布,不可修改!", "WARNING",
|
|
|
|
|
|
|
|
MessageBox.WARNING);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (TCException e) {
|
|
|
|
|
|
|
|
MessageBox.post("setworknum运行失败!", "WARNING",
|
|
|
|
|
|
|
|
MessageBox.WARNING);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|