|
|
|
@ -11,12 +11,9 @@ import org.apache.axiom.om.OMAbstractFactory;
|
|
|
|
|
import org.apache.axiom.om.OMElement;
|
|
|
|
|
import org.apache.axiom.om.OMFactory;
|
|
|
|
|
import org.apache.axiom.om.OMNamespace;
|
|
|
|
|
import org.apache.axis2.AxisFault;
|
|
|
|
|
import org.apache.axis2.addressing.EndpointReference;
|
|
|
|
|
import org.apache.axis2.client.Options;
|
|
|
|
|
import org.apache.axis2.client.ServiceClient;
|
|
|
|
|
import org.apache.axis2.transport.http.HTTPConstants;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
@ -24,12 +21,8 @@ import com.connor.chint.sap2.util.BomToSapUtil;
|
|
|
|
|
import com.connor.chint.sap2.util.ChintPreferenceUtil;
|
|
|
|
|
import com.connor.chint.sap2.util.KUtil;
|
|
|
|
|
import com.connor.chint.sap2.util.MyProgressBarCompent;
|
|
|
|
|
import com.connor.chint.sap2.util.SAPUtil;
|
|
|
|
|
//import com.connor.ml.tcm.outfile.util.ClassProperty;
|
|
|
|
|
import com.squareup.okhttp.MediaType;
|
|
|
|
|
import com.squareup.okhttp.OkHttpClient;
|
|
|
|
|
import com.squareup.okhttp.Request;
|
|
|
|
|
import com.squareup.okhttp.RequestBody;
|
|
|
|
|
import com.squareup.okhttp.Response;
|
|
|
|
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
|
|
|
|
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
|
|
|
@ -47,11 +40,9 @@ import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItemType;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentRevisionRule;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentUser;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCException;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCPreferenceService;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCSession;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCTypeService;
|
|
|
|
|
import com.teamcenter.rac.util.MessageBox;
|
|
|
|
|
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
|
|
|
|
|
import com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureInputInfo;
|
|
|
|
|
import com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureResponse;
|
|
|
|
@ -65,11 +56,11 @@ public class KjController {
|
|
|
|
|
private String projectDh = "";
|
|
|
|
|
private String projectId = "";
|
|
|
|
|
public KjController(AbstractAIFApplication app) {
|
|
|
|
|
// TODO Auto-generated constructor stub
|
|
|
|
|
// Auto-generated constructor stub
|
|
|
|
|
this.app = app;
|
|
|
|
|
this.session = (TCSession) app.getSession();
|
|
|
|
|
}
|
|
|
|
|
public boolean checkProject() throws TCException {
|
|
|
|
|
public boolean checkProject() throws Exception {
|
|
|
|
|
InterfaceAIFComponent target = app.getTargetComponent();
|
|
|
|
|
if (target == null || !(target instanceof TCComponent)) {
|
|
|
|
|
return false;
|
|
|
|
@ -85,19 +76,19 @@ public class KjController {
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
Map<String,String> idName = new HashMap<String,String>();
|
|
|
|
|
Map<String, String> idName = new HashMap<String, String>();
|
|
|
|
|
//存放 ID-文件夹
|
|
|
|
|
private Map<String,TCComponentFolder> fMap = new HashMap<>();
|
|
|
|
|
private Map<String,TCComponentUser> nameUser = new HashMap<>();
|
|
|
|
|
private Map<String, TCComponentFolder> fMap = new HashMap<>();
|
|
|
|
|
private Map<String, TCComponentUser> nameUser = new HashMap<>();
|
|
|
|
|
private TCComponentItem tqqgdItem;
|
|
|
|
|
public List<TCComponentItemRevision> byqCCPFromProject;
|
|
|
|
|
public boolean checkFolder(String kjBomId,KjBean kjBean,StringBuilder errBuff) throws TCException {
|
|
|
|
|
protected List<TCComponentItemRevision> byqCCPFromProject;
|
|
|
|
|
protected boolean checkFolder(String kjBomId, KjBean kjBean, StringBuilder errBuff) throws Exception {
|
|
|
|
|
|
|
|
|
|
boolean flag = true;
|
|
|
|
|
try {
|
|
|
|
|
//获取首选项里的文件夹名称、判断当前项目是否存在
|
|
|
|
|
fMap.clear();
|
|
|
|
|
Map<String,TCComponentFolder> fodlers = new HashMap<>();
|
|
|
|
|
Map<String, TCComponentFolder> fodlers = new HashMap<>();
|
|
|
|
|
TCComponentFolder xmzxFolder = KUtil.getXMZXFolderFromProject(project);
|
|
|
|
|
byqCCPFromProject = KUtil.getByqCCPFromProject(project,session);
|
|
|
|
|
AIFComponentContext[] childFolders = xmzxFolder.getChildren();
|
|
|
|
@ -112,12 +103,12 @@ public class KjController {
|
|
|
|
|
}else if(cName.equals("1-电磁设计")) {
|
|
|
|
|
dcsjFolder = (TCComponentFolder)c;
|
|
|
|
|
}
|
|
|
|
|
fodlers.put(cName,(TCComponentFolder)c);
|
|
|
|
|
fodlers.put(cName, (TCComponentFolder)c);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(bztFolder!=null) {
|
|
|
|
|
AIFComponentContext[] children = bztFolder.getChildren();
|
|
|
|
|
for(AIFComponentContext cont:children) {
|
|
|
|
|
for(AIFComponentContext cont : children) {
|
|
|
|
|
InterfaceAIFComponent component = cont.getComponent();
|
|
|
|
|
String type = component.getType();
|
|
|
|
|
if(type.equals("ZT2_Requisition")) {
|
|
|
|
@ -128,7 +119,7 @@ public class KjController {
|
|
|
|
|
TCComponentItem dcsjItem = null;;
|
|
|
|
|
if(dcsjFolder!=null) {
|
|
|
|
|
AIFComponentContext[] children = dcsjFolder.getChildren();
|
|
|
|
|
for(AIFComponentContext cont:children) {
|
|
|
|
|
for(AIFComponentContext cont : children) {
|
|
|
|
|
InterfaceAIFComponent component = cont.getComponent();
|
|
|
|
|
String type = component.getType();
|
|
|
|
|
if(type.equals("ZT2_MainMat")) {
|
|
|
|
@ -180,7 +171,6 @@ public class KjController {
|
|
|
|
|
idName.put(jsonObject.getString("taskname"),string2);
|
|
|
|
|
}
|
|
|
|
|
System.out.println(jsonObject.getString("taskname")+"====="+string2);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -206,12 +196,12 @@ public class KjController {
|
|
|
|
|
}
|
|
|
|
|
System.out.println(nameUser.toString());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
// Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
public static TCComponent getUserName(String userID, TCSession session) throws Exception {
|
|
|
|
|
private static TCComponent getUserName(String userID, TCSession session) throws Exception {
|
|
|
|
|
Map<String, String> fields = new HashMap<>();
|
|
|
|
|
fields.put("用户 ID", userID);
|
|
|
|
|
TCComponentContextList quertList = KUtil.query(session, "__WEB_find_user", fields);
|
|
|
|
@ -221,7 +211,7 @@ public class KjController {
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
public String objectToJson(List<ClassProperty> props) {
|
|
|
|
|
private String objectToJson(List<ClassProperty> props) {
|
|
|
|
|
String str = null;
|
|
|
|
|
try {
|
|
|
|
|
net.sf.json.JSONArray json = net.sf.json.JSONArray.fromObject(props);// 将java对象转换为json对象
|
|
|
|
@ -240,7 +230,8 @@ public class KjController {
|
|
|
|
|
private String kjBs;
|
|
|
|
|
// public
|
|
|
|
|
// private TCComponentItemType ccomponentitemtype;
|
|
|
|
|
public boolean createKjBom(KjBean bean,MyProgressBarCompent comp) throws TCException {
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
|
protected boolean createKjBom(KjBean bean,MyProgressBarCompent comp) throws Exception {
|
|
|
|
|
StringBuilder builder = new StringBuilder("");
|
|
|
|
|
TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("ZT2_Design3D");
|
|
|
|
|
TCComponentItem newItem = ccomponentitemtype.find(bean.getKjbomId());
|
|
|
|
@ -258,21 +249,20 @@ public class KjController {
|
|
|
|
|
String item_id = kjBomRev.getProperty("item_id");
|
|
|
|
|
String replaceAll = item_id.replaceAll(kjBs, projectDh);
|
|
|
|
|
kjIdMap.put(kjBomRev, replaceAll);
|
|
|
|
|
Map<String, TCComponentItem> findMap = new HashMap<String,TCComponentItem>();
|
|
|
|
|
Map<String, TCComponentItem> findMap = new HashMap<String, TCComponentItem>();
|
|
|
|
|
//遍历获取BOM新ID
|
|
|
|
|
List<TCComponentBOMLine> useLines = new ArrayList<TCComponentBOMLine>();
|
|
|
|
|
createId(kjBomLine,bomLineTreeNodeSOA,builder,ccomponentitemtype,findMap,useLines,1);
|
|
|
|
|
createId(kjBomLine, bomLineTreeNodeSOA, builder, ccomponentitemtype, findMap, useLines, 1);
|
|
|
|
|
System.out.println(kjIdMap.toString());
|
|
|
|
|
|
|
|
|
|
if(builder.length()>0) {
|
|
|
|
|
if(builder.length() > 0) {
|
|
|
|
|
// MessageBox.post(builder.toString(), "提示",2);
|
|
|
|
|
Object[] options = {"ÊÇ","·ñ"};
|
|
|
|
|
Object[] options = { "ÊÇ", "·ñ" };
|
|
|
|
|
comp.setVisible(false);
|
|
|
|
|
builder.append("是否要继续生成.");
|
|
|
|
|
int response = JOptionPane.showOptionDialog(null, builder.toString(), "Ñ¡Ôñ",JOptionPane.YES_OPTION,
|
|
|
|
|
int response = JOptionPane.showOptionDialog(null, builder.toString(), "Ñ¡Ôñ", JOptionPane.YES_OPTION,
|
|
|
|
|
JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
|
|
|
|
|
if(response == -1 || response==1)
|
|
|
|
|
{
|
|
|
|
|
if(response == -1 || response == 1) {
|
|
|
|
|
window.close();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -280,13 +270,13 @@ public class KjController {
|
|
|
|
|
{
|
|
|
|
|
comp = new MyProgressBarCompent("", "正在创建框架BOM......");
|
|
|
|
|
//开始克隆BOM
|
|
|
|
|
cloneOrUpdate(session,kjBomLine,copyLines,useLines);
|
|
|
|
|
cloneOrUpdate(session, kjBomLine, copyLines, useLines);
|
|
|
|
|
//添加到文件夹
|
|
|
|
|
for(TCComponentItemRevision rev:oldkjIdMap.keySet()) {
|
|
|
|
|
for(TCComponentItemRevision rev : oldkjIdMap.keySet()) {
|
|
|
|
|
TCComponentItem find = oldkjIdMap.get(rev);
|
|
|
|
|
String id = find.getProperty("item_id");
|
|
|
|
|
String[] split = id.split("-");
|
|
|
|
|
System.out.println("id==>"+id);
|
|
|
|
|
System.out.println("id==>" + id);
|
|
|
|
|
if(fMap.containsKey(split[0])) {
|
|
|
|
|
TCComponentFolder tcComponentFolder = fMap.get(split[0]);
|
|
|
|
|
try {
|
|
|
|
@ -300,7 +290,7 @@ public class KjController {
|
|
|
|
|
System.out.println("fMap==>"+nameUser.toString());
|
|
|
|
|
for(TCComponentItemRevision rev:kjIdMap.keySet()) {
|
|
|
|
|
String id = kjIdMap.get(rev);
|
|
|
|
|
TCComponentItem find = ccomponentitemtype.find(id);
|
|
|
|
|
TCComponentItem find = ccomponentitemtype.findItems(id)[0];
|
|
|
|
|
String[] split = id.split("-");
|
|
|
|
|
System.out.println("id==>"+split[0]);
|
|
|
|
|
if(fMap.containsKey(split[0])) {
|
|
|
|
@ -316,12 +306,12 @@ public class KjController {
|
|
|
|
|
try {
|
|
|
|
|
changeOwners(find,tcComponentUser);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
// Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
TCComponentItem find = ccomponentitemtype.find(replaceAll);
|
|
|
|
|
TCComponentItem find = ccomponentitemtype.findItems(replaceAll)[0];
|
|
|
|
|
if(findMap.size()>0) {
|
|
|
|
|
// window.lock();
|
|
|
|
|
TCComponentBOMLine newTopline = window.setWindowTopLine(find, find.getLatestItemRevision(),null, null);
|
|
|
|
@ -340,23 +330,23 @@ public class KjController {
|
|
|
|
|
find.getLatestItemRevision().add("representation_for", byqCCPFromProject);
|
|
|
|
|
}
|
|
|
|
|
List<ClassProperty> propList = new ArrayList<ClassProperty>();
|
|
|
|
|
sendToClass(find.getUid(),"ICM230101",objectToJson(propList));
|
|
|
|
|
sendToClass(find.getUid(), "ICM230101", objectToJson(propList));
|
|
|
|
|
List<TCComponentBOMLine> listBoms = BomToSapUtil.listBoms(newTopline);
|
|
|
|
|
//存放名称对应的BOM行
|
|
|
|
|
List<BomBean> bomBeans = new ArrayList<>();
|
|
|
|
|
for(TCComponentBOMLine listBom:listBoms) {
|
|
|
|
|
for(TCComponentBOMLine listBom : listBoms) {
|
|
|
|
|
String name = listBom.getItemRevision().getProperty("object_name");
|
|
|
|
|
bomBeans.add(new BomBean(name,listBom));
|
|
|
|
|
bomBeans.add(new BomBean(name, listBom));
|
|
|
|
|
}
|
|
|
|
|
System.out.println("bomBeans==>"+bomBeans.toString());
|
|
|
|
|
System.out.println("bomBeans==>" + bomBeans.toString());
|
|
|
|
|
// Map<String,List<TCComponentBOMLine>> remarkMap = new HashMap<String,List<TCComponentBOMLine>>();
|
|
|
|
|
//拆分BOM逻辑获取物料提前请购单的BOM
|
|
|
|
|
if(tqqgdItem!=null) {
|
|
|
|
|
if(tqqgdItem != null) {
|
|
|
|
|
TCComponentBOMWindow window2 = winType.create(null);
|
|
|
|
|
TCComponentBOMLine qgdBomline = window2.setWindowTopLine(tqqgdItem, tqqgdItem.getLatestItemRevision(), null, null);
|
|
|
|
|
AIFComponentContext[] children = qgdBomline.getChildren();
|
|
|
|
|
//遍历物料提前请购单 根据备注添加BOM到对应位置
|
|
|
|
|
for(int i=0;i<children.length;i++) {
|
|
|
|
|
for(int i = 0; i < children.length; i++) {
|
|
|
|
|
TCComponentBOMLine wlLine = (TCComponentBOMLine) children[i].getComponent();
|
|
|
|
|
TCComponentItem item = wlLine.getItem();
|
|
|
|
|
if(item.getType().equals("ZT2_MainMat")) {
|
|
|
|
@ -366,8 +356,8 @@ public class KjController {
|
|
|
|
|
String object_name = wlLine2.getProperty("ZT2_Remark");
|
|
|
|
|
String objName = wlLine2.getItem().getProperty("object_name");
|
|
|
|
|
System.out.println(object_name);
|
|
|
|
|
System.out.println(objName+"gg");
|
|
|
|
|
if(!object_name.equals("")&&bomBeans.contains(new BomBean(object_name))) {
|
|
|
|
|
System.out.println(objName + "gg");
|
|
|
|
|
if(!object_name.equals("") && bomBeans.contains(new BomBean(object_name))) {
|
|
|
|
|
BomBean bomBean = bomBeans.get(bomBeans.indexOf(new BomBean(object_name)));
|
|
|
|
|
bomBean.bomLine.add(wlLine2, false);
|
|
|
|
|
bomBean.bomLine.save();
|
|
|
|
@ -387,7 +377,7 @@ public class KjController {
|
|
|
|
|
String object_name = wlLine.getProperty("ZT2_Remark");
|
|
|
|
|
System.out.println(object_name);
|
|
|
|
|
String objName = wlLine.getItem().getProperty("object_name");
|
|
|
|
|
if(!object_name.equals("")&&bomBeans.contains(new BomBean(object_name))) {
|
|
|
|
|
if(!object_name.equals("") && bomBeans.contains(new BomBean(object_name))) {
|
|
|
|
|
BomBean bomBean = bomBeans.get(bomBeans.indexOf(new BomBean(object_name)));
|
|
|
|
|
bomBean.bomLine.add(wlLine, false);
|
|
|
|
|
bomBean.bomLine.save();
|
|
|
|
@ -413,36 +403,39 @@ public class KjController {
|
|
|
|
|
window.close();
|
|
|
|
|
comp.setVisible(false);
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public static void changePrivilege(TCSession session,TCComponent dataset) throws TCException {
|
|
|
|
|
|
|
|
|
|
private static void changePrivilege(TCSession session, TCComponent dataset) throws Exception {
|
|
|
|
|
KUtil.setByPass(true);
|
|
|
|
|
TCAccessControlService accessControlService = session.getTCAccessControlService();
|
|
|
|
|
TCComponentUser user = session.getUser();
|
|
|
|
|
accessControlService.grantPrivilege(dataset, user, new String[]{"WRITE","READ"});
|
|
|
|
|
KUtil.setByPass(false);
|
|
|
|
|
}
|
|
|
|
|
private void updateKjBom(Map<String, TCComponentItem> findMap,Map<String, ExpandPSData[]> bomLineTreeNodeSOA,String uid) throws TCException {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
|
private void updateKjBom(Map<String, TCComponentItem> findMap, Map<String, ExpandPSData[]> bomLineTreeNodeSOA, String uid) throws Exception {
|
|
|
|
|
// Auto-generated method stub
|
|
|
|
|
ExpandPSData[] expandPSDatas = bomLineTreeNodeSOA.get(uid);
|
|
|
|
|
for(ExpandPSData expandPSData:expandPSDatas) {
|
|
|
|
|
TCComponentBOMLine bomLine = expandPSData.bomLine;
|
|
|
|
|
TCComponentItemRevision itemRevOfBOMLine = expandPSData.itemRevOfBOMLine;
|
|
|
|
|
String itemId = itemRevOfBOMLine.getProperty("item_id");
|
|
|
|
|
System.out.println("findMap===>"+findMap.toString());
|
|
|
|
|
System.out.println("itemId===>"+itemId.toString());
|
|
|
|
|
System.out.println("findMap===>" + findMap.toString());
|
|
|
|
|
System.out.println("itemId===>" + itemId.toString());
|
|
|
|
|
if(findMap.containsKey(itemId)) {
|
|
|
|
|
TCComponentItem tcItem = findMap.get(itemId);
|
|
|
|
|
System.out.println("tcItem===>"+tcItem.toString());
|
|
|
|
|
System.out.println("tcItem===>" + tcItem.toString());
|
|
|
|
|
TCComponentItemRevision lastRev = tcItem.getLatestItemRevision();
|
|
|
|
|
bomLine.replace(tcItem, lastRev, null);
|
|
|
|
|
bomLine.save();
|
|
|
|
|
bomLine.unlock();
|
|
|
|
|
// bomLine.unlock();
|
|
|
|
|
}
|
|
|
|
|
updateKjBom(findMap,bomLineTreeNodeSOA,bomLine.getUid());//ExpandPSData[] expandPSDatas2 = bomLineTreeNodeSOA.get(bomLine.getUid());
|
|
|
|
|
updateKjBom(findMap, bomLineTreeNodeSOA, bomLine.getUid());//ExpandPSData[] expandPSDatas2 = bomLineTreeNodeSOA.get(bomLine.getUid());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public static void changeOwners(TCComponentItem item, TCComponentUser user) throws Exception {
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
|
private static void changeOwners(TCComponentItem item, TCComponentUser user) throws Exception {
|
|
|
|
|
TCComponent[] revs = item.getRelatedComponents("revision_list");
|
|
|
|
|
TCComponentItemRevision rev;
|
|
|
|
|
TCComponentGroup group = (TCComponentGroup) user.getRelatedComponent("default_group");
|
|
|
|
@ -481,19 +474,17 @@ public class KjController {
|
|
|
|
|
item.changeOwner(user, group);
|
|
|
|
|
item.save();
|
|
|
|
|
item.unlock();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public void sendToClass(String wsoPUID, String classID, String json ) {
|
|
|
|
|
|
|
|
|
|
private void sendToClass(String wsoPUID, String classID, String json) {
|
|
|
|
|
// AbstractAIFApplication app;
|
|
|
|
|
// app=AIFUtility.getCurrentApplication();
|
|
|
|
|
// TCSession session;
|
|
|
|
|
// session=(TCSession) app.getSession();
|
|
|
|
|
TCPreferenceService preferenceService;
|
|
|
|
|
preferenceService=session.getPreferenceService();
|
|
|
|
|
// String account=preferenceService.getStringValue("Autocode_PriverUser_ID");
|
|
|
|
|
String url;
|
|
|
|
|
url = preferenceService.getStringValue("Autocode_SendClassServer_URL");
|
|
|
|
|
try {
|
|
|
|
|
TCPreferenceService preferenceService = session.getPreferenceService();
|
|
|
|
|
// String account=preferenceService.getStringValue("Autocode_PriverUser_ID");
|
|
|
|
|
String url = preferenceService.getStringValue("Autocode_SendClassServer_URL");
|
|
|
|
|
ServiceClient sc = new ServiceClient();
|
|
|
|
|
Options opts = new Options();
|
|
|
|
|
// url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL";
|
|
|
|
@ -520,17 +511,16 @@ public class KjController {
|
|
|
|
|
OMElement res = sc.sendReceive(method);
|
|
|
|
|
res.getFirstElement().getText();
|
|
|
|
|
System.out.println(res.getFirstElement().getText());
|
|
|
|
|
} catch (AxisFault e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public void createId(TCComponentBOMLine pLine,Map<String, ExpandPSData[]> bomLineTreeNodeSOA,
|
|
|
|
|
StringBuilder builder,TCComponentItemType ccomponentitemtype,
|
|
|
|
|
Map<String, TCComponentItem> findMap,List<TCComponentBOMLine> useLines,int type) throws TCException {
|
|
|
|
|
private void createId(TCComponentBOMLine pLine, Map<String, ExpandPSData[]> bomLineTreeNodeSOA,
|
|
|
|
|
StringBuilder builder, TCComponentItemType ccomponentitemtype,
|
|
|
|
|
Map<String, TCComponentItem> findMap, List<TCComponentBOMLine> useLines, int type) throws Exception {
|
|
|
|
|
|
|
|
|
|
ExpandPSData[] expandPSDatas = bomLineTreeNodeSOA.get(pLine.getUid());
|
|
|
|
|
if(type != 0){
|
|
|
|
|
if(type != 0) {
|
|
|
|
|
copyLines.add(pLine);
|
|
|
|
|
}
|
|
|
|
|
for(ExpandPSData expandPSData : expandPSDatas) {
|
|
|
|
@ -539,24 +529,22 @@ public class KjController {
|
|
|
|
|
if(cRev.getType().contains("ZT2_Design3D")) {
|
|
|
|
|
String item_id = cRev.getProperty("item_id");
|
|
|
|
|
String replaceAll = item_id.replaceAll(kjBs, projectDh);
|
|
|
|
|
if(type==0) {
|
|
|
|
|
if(type == 0) {
|
|
|
|
|
useLines.add(cLine);
|
|
|
|
|
createId(cLine,bomLineTreeNodeSOA,builder,ccomponentitemtype,findMap,useLines,0);
|
|
|
|
|
createId(cLine, bomLineTreeNodeSOA, builder, ccomponentitemtype, findMap, useLines, 0);
|
|
|
|
|
}else {
|
|
|
|
|
TCComponentItem find = ccomponentitemtype.find(replaceAll);
|
|
|
|
|
if(find!=null) {
|
|
|
|
|
TCComponentItem find = ccomponentitemtype.findItems(replaceAll)[0];
|
|
|
|
|
if(find != null) {
|
|
|
|
|
builder.append("当前ID已经存在:").append(replaceAll).append("\n");
|
|
|
|
|
findMap.put(item_id, find);
|
|
|
|
|
useLines.add(cLine);
|
|
|
|
|
oldkjIdMap.put(cRev, find);
|
|
|
|
|
createId(cLine,bomLineTreeNodeSOA,builder,ccomponentitemtype,findMap,useLines,0);
|
|
|
|
|
createId(cLine, bomLineTreeNodeSOA, builder, ccomponentitemtype, findMap, useLines, 0);
|
|
|
|
|
}else {
|
|
|
|
|
kjIdMap.put(cRev, replaceAll);
|
|
|
|
|
createId(cLine,bomLineTreeNodeSOA,builder,ccomponentitemtype,findMap,useLines,1);
|
|
|
|
|
createId(cLine, bomLineTreeNodeSOA, builder, ccomponentitemtype, findMap, useLines, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
copyLines.add(cLine);
|
|
|
|
|
}
|
|
|
|
@ -564,8 +552,8 @@ public class KjController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//批量复制
|
|
|
|
|
public void cloneOrUpdate(TCSession session,TCComponentBOMLine puid,
|
|
|
|
|
List<TCComponentBOMLine> bomLines,List<TCComponentBOMLine> useLines) {
|
|
|
|
|
private void cloneOrUpdate(TCSession session, TCComponentBOMLine puid,
|
|
|
|
|
List<TCComponentBOMLine> bomLines, List<TCComponentBOMLine> useLines) {
|
|
|
|
|
com.teamcenter.services.rac.structuremanagement.StructureService service =
|
|
|
|
|
com.teamcenter.services.rac.structuremanagement.StructureService.getService(session);
|
|
|
|
|
// idMapAdd.clear();
|
|
|
|
@ -574,12 +562,12 @@ public class KjController {
|
|
|
|
|
infos[0] = new CloneStructureInputInfo();
|
|
|
|
|
|
|
|
|
|
// infos[0].bomline = puid;
|
|
|
|
|
infos[0].cadOptions = new String[] {"PartFamilyMaster"};
|
|
|
|
|
infos[0].cadOptions = new String[] { "PartFamilyMaster" };
|
|
|
|
|
try {
|
|
|
|
|
infos[0].defaultFolder = session.getUser().getNewStuffFolder();
|
|
|
|
|
infos[0].cloneFlags = 2;
|
|
|
|
|
com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureProjectInfo projectInfo
|
|
|
|
|
= new com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureProjectInfo();
|
|
|
|
|
= new com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureProjectInfo();
|
|
|
|
|
projectInfo.assign = false;
|
|
|
|
|
projectInfo.validate = false;
|
|
|
|
|
infos[0].projects = projectInfo;
|
|
|
|
@ -588,22 +576,22 @@ public class KjController {
|
|
|
|
|
TCComponentItemRevision[] revs = new TCComponentItemRevision[] { puid.getItemRevision() };
|
|
|
|
|
infos[0].topItemRevs = revs;
|
|
|
|
|
|
|
|
|
|
System.out.println("Save class Partial bomLine -- "+bomLines.size());
|
|
|
|
|
System.out.println("Save class Partial bomLine -- " + bomLines.size());
|
|
|
|
|
|
|
|
|
|
List<CloneStructureSaveAsIn> saveList = new ArrayList<CloneStructureSaveAsIn>();
|
|
|
|
|
for(TCComponentBOMLine subLine: bomLines) {
|
|
|
|
|
for(TCComponentBOMLine subLine : bomLines) {
|
|
|
|
|
CloneStructureSaveAsIn dataMap = null;
|
|
|
|
|
TCComponentItem item = subLine.getItem();
|
|
|
|
|
if(item.getType().equals("ZT2_Design3D")) {
|
|
|
|
|
// subLine.replace
|
|
|
|
|
dataMap = getDataMap(subLine,0, session);
|
|
|
|
|
dataMap = getDataMap(subLine, 0, session);
|
|
|
|
|
}else {
|
|
|
|
|
dataMap = getDataMap(subLine,1, session);
|
|
|
|
|
dataMap = getDataMap(subLine, 1, session);
|
|
|
|
|
}
|
|
|
|
|
saveList.add(dataMap);
|
|
|
|
|
}
|
|
|
|
|
for(TCComponentBOMLine subLine: useLines) {
|
|
|
|
|
CloneStructureSaveAsIn dataMap = getDataMap(subLine,1, session);
|
|
|
|
|
for(TCComponentBOMLine subLine : useLines) {
|
|
|
|
|
CloneStructureSaveAsIn dataMap = getDataMap(subLine, 1, session);
|
|
|
|
|
saveList.add(dataMap);
|
|
|
|
|
}
|
|
|
|
|
com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureDefaultNaming naming =
|
|
|
|
@ -612,61 +600,56 @@ public class KjController {
|
|
|
|
|
infos[0].dataMap = array;
|
|
|
|
|
naming.autogen = true;
|
|
|
|
|
infos[0].defaultName = naming;
|
|
|
|
|
infos[0].topLines = new TCComponentBOMLine[] { puid};
|
|
|
|
|
infos[0].topLines = new TCComponentBOMLine[] { puid };
|
|
|
|
|
// TCComponentBOMLine.get
|
|
|
|
|
// puid.getr
|
|
|
|
|
} catch (TCException e1) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
|
// Auto-generated catch block
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
CloneStructureResponse cloneStructure = service.cloneStructure(infos);
|
|
|
|
|
// infos[0].
|
|
|
|
|
// cloneStructureExpandOrUpdate.serviceData;
|
|
|
|
|
if (cloneStructure.serviceData.sizeOfPartialErrors() > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < cloneStructure.serviceData
|
|
|
|
|
.sizeOfPartialErrors(); i++)
|
|
|
|
|
{
|
|
|
|
|
System.out.println("Save class Partial Error -- "+cloneStructure.serviceData
|
|
|
|
|
if (cloneStructure.serviceData.sizeOfPartialErrors() > 0) {
|
|
|
|
|
for (int i = 0; i < cloneStructure.serviceData.sizeOfPartialErrors(); i++) {
|
|
|
|
|
System.out.println("Save class Partial Error -- " + cloneStructure.serviceData
|
|
|
|
|
.getPartialError(i).getMessages()[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
System.out.println("Save class Partial Error -- "+cloneStructure.serviceData.sizeOfUpdatedObjects());
|
|
|
|
|
System.out.println("Save class Partial Error -- " + cloneStructure.serviceData.sizeOfUpdatedObjects());
|
|
|
|
|
if(cloneStructure.serviceData.sizeOfUpdatedObjects()>0) {
|
|
|
|
|
TCComponent updatedObject = cloneStructure.serviceData.getUpdatedObject(0);
|
|
|
|
|
System.out.println(session.componentToString(updatedObject));
|
|
|
|
|
}
|
|
|
|
|
for(int i = 0 ;i<cloneStructure.serviceData.sizeOfCreatedObjects();i++) {
|
|
|
|
|
for(int i = 0; i < cloneStructure.serviceData.sizeOfCreatedObjects(); i++) {
|
|
|
|
|
TCComponent plainObject = cloneStructure.serviceData.getCreatedObject(i);
|
|
|
|
|
System.out.println(session.componentToString(plainObject));
|
|
|
|
|
}
|
|
|
|
|
for(int i = 0 ;i<cloneStructure.serviceData.sizeOfPlainObjects();i++) {
|
|
|
|
|
for(int i = 0; i < cloneStructure.serviceData.sizeOfPlainObjects(); i++) {
|
|
|
|
|
TCComponent plainObject = cloneStructure.serviceData.getPlainObject(i);
|
|
|
|
|
System.out.println(session.componentToString(plainObject));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (TCException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private CloneStructureSaveAsIn getDataMap(TCComponentBOMLine child,int type
|
|
|
|
|
,TCSession session) throws TCException {
|
|
|
|
|
private CloneStructureSaveAsIn getDataMap(TCComponentBOMLine child, int type, TCSession session) throws Exception {
|
|
|
|
|
TCComponentItemRevision rev = child.getItemRevision();
|
|
|
|
|
com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureSaveAsIn dataMap =
|
|
|
|
|
new com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureSaveAsIn();
|
|
|
|
|
Map<String, String[]> newItemRevinfo = new HashMap();
|
|
|
|
|
Map<String, String[]> newItemRevinfo = new HashMap<>();
|
|
|
|
|
dataMap.cloneOperationType = type;
|
|
|
|
|
// dataMap.newItemRevinfo =
|
|
|
|
|
dataMap.origItemRevComp = rev;
|
|
|
|
|
|
|
|
|
|
newItemRevinfo.put("sequence_limit", new String[] {"3"});
|
|
|
|
|
newItemRevinfo.put("fnd0CheckoutOnSaveAs", new String[] {"false"});
|
|
|
|
|
newItemRevinfo.put("item_revision_id", new String[] {""});
|
|
|
|
|
newItemRevinfo.put("sequence_id", new String[] {"1"});
|
|
|
|
|
newItemRevinfo.put("object_name", new String[] {rev.getStringProperty("object_name")});
|
|
|
|
|
newItemRevinfo.put("sequence_limit", new String[] { "3" });
|
|
|
|
|
newItemRevinfo.put("fnd0CheckoutOnSaveAs", new String[] { "false" });
|
|
|
|
|
newItemRevinfo.put("item_revision_id", new String[] { "" });
|
|
|
|
|
newItemRevinfo.put("sequence_id", new String[] { "1" });
|
|
|
|
|
newItemRevinfo.put("object_name", new String[] { rev.getStringProperty("object_name") });
|
|
|
|
|
if(type == 0) {
|
|
|
|
|
com.teamcenter.services.rac.structuremanagement._2014_10.Structure.DeepCopyData[] copys =
|
|
|
|
|
new com.teamcenter.services.rac.structuremanagement._2014_10.Structure.DeepCopyData[1];
|
|
|
|
@ -680,13 +663,13 @@ public class KjController {
|
|
|
|
|
copy.operationInputTypeName = "";
|
|
|
|
|
copy.propertyName = "items_tag";
|
|
|
|
|
copy.propertyType = "Reference";
|
|
|
|
|
Map<String, String[]> operationInputs = new HashMap();
|
|
|
|
|
Map<String, String[]> operationInputs = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
operationInputs.put("fnd0CheckoutOnSaveAs", new String[] {"false"});
|
|
|
|
|
operationInputs.put("is_configuration_item", new String[] {"false"});
|
|
|
|
|
operationInputs.put("fnd0CheckoutOnSaveAs", new String[] { "false" });
|
|
|
|
|
operationInputs.put("is_configuration_item", new String[] { "false" });
|
|
|
|
|
String zt2Unit = rev.getItem().getTCProperty("zt2_unit").getStringValue();
|
|
|
|
|
// rev.getItem().get("zt2_unit");
|
|
|
|
|
operationInputs.put("zt2_unit", new String[] {zt2Unit});
|
|
|
|
|
operationInputs.put("zt2_unit", new String[] { zt2Unit });
|
|
|
|
|
String newId = "";
|
|
|
|
|
try {
|
|
|
|
|
newId = kjIdMap.get(rev);
|
|
|
|
@ -695,7 +678,7 @@ public class KjController {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
operationInputs.put("item_id", new String[] {newId}); // »ñÈ¡¹æÔò
|
|
|
|
|
operationInputs.put("item_id", new String[] { newId }); // »ñÈ¡¹æÔò
|
|
|
|
|
copy.operationInputs = operationInputs;
|
|
|
|
|
copys[0] = copy;
|
|
|
|
|
|
|
|
|
|