|
|
|
@ -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;
|
|
|
|
@ -90,8 +81,8 @@ public class KjController {
|
|
|
|
|
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 {
|
|
|
|
@ -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());
|
|
|
|
@ -271,8 +262,7 @@ public class KjController {
|
|
|
|
|
builder.append("是否要继续生成.");
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
@ -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);
|
|
|
|
@ -413,17 +403,19 @@ 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;
|
|
|
|
@ -437,12 +429,13 @@ public class KjController {
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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,14 +511,13 @@ 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,
|
|
|
|
|
private void createId(TCComponentBOMLine pLine, Map<String, ExpandPSData[]> bomLineTreeNodeSOA,
|
|
|
|
|
StringBuilder builder, TCComponentItemType ccomponentitemtype,
|
|
|
|
|
Map<String, TCComponentItem> findMap,List<TCComponentBOMLine> useLines,int type) throws TCException {
|
|
|
|
|
Map<String, TCComponentItem> findMap, List<TCComponentBOMLine> useLines, int type) throws Exception {
|
|
|
|
|
|
|
|
|
|
ExpandPSData[] expandPSDatas = bomLineTreeNodeSOA.get(pLine.getUid());
|
|
|
|
|
if(type != 0) {
|
|
|
|
@ -543,7 +533,7 @@ public class KjController {
|
|
|
|
|
useLines.add(cLine);
|
|
|
|
|
createId(cLine, bomLineTreeNodeSOA, builder, ccomponentitemtype, findMap, useLines, 0);
|
|
|
|
|
}else {
|
|
|
|
|
TCComponentItem find = ccomponentitemtype.find(replaceAll);
|
|
|
|
|
TCComponentItem find = ccomponentitemtype.findItems(replaceAll)[0];
|
|
|
|
|
if(find != null) {
|
|
|
|
|
builder.append("当前ID已经存在:").append(replaceAll).append("\n");
|
|
|
|
|
findMap.put(item_id, find);
|
|
|
|
@ -555,8 +545,6 @@ public class KjController {
|
|
|
|
|
createId(cLine, bomLineTreeNodeSOA, builder, ccomponentitemtype, findMap, useLines, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
copyLines.add(cLine);
|
|
|
|
|
}
|
|
|
|
@ -564,7 +552,7 @@ public class KjController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//批量复制
|
|
|
|
|
public void cloneOrUpdate(TCSession session,TCComponentBOMLine puid,
|
|
|
|
|
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);
|
|
|
|
@ -615,22 +603,18 @@ public class KjController {
|
|
|
|
|
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++)
|
|
|
|
|
{
|
|
|
|
|
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());
|
|
|
|
@ -647,17 +631,16 @@ public class KjController {
|
|
|
|
|
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;
|
|
|
|
@ -680,7 +663,7 @@ 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" });
|
|
|
|
|