创建更改通知单问题修改

pull/10/head
李冬阳 1 year ago
parent 3f2c541044
commit ca895bb822

@ -238,7 +238,7 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TitledPane fx:id="referencePane" animated="false" text="影响分析:">
<TitledPane fx:id="referencePane" animated="false" text="影响分析(会签)">
<GridPane.margin>
<Insets top="5.0" />
</GridPane.margin>

@ -60,6 +60,7 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
@ -72,6 +73,7 @@ import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.TitledPane;
import javafx.scene.control.ToggleGroup;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
@ -92,6 +94,8 @@ public class CreateEcnController extends KFXPanelController {
@FXML
private TableView<EcnBean> tableView;
@FXML
public TableView<RefTableBean> refTable;
@FXML
private StackPane stackPane;
@FXML
private DatePicker changeDate;
@ -166,7 +170,7 @@ public class CreateEcnController extends KFXPanelController {
rb_formalChange.setToggleGroup(group);
rb_tempChange.setToggleGroup(group);
rb_formalChange.setSelected(true);
referencePane.setExpanded(false);
referencePane.setExpanded(true);
ToggleGroup groupGc = new ToggleGroup(); // 变更类型组
rb_product.setToggleGroup(groupGc);
@ -338,8 +342,14 @@ public class CreateEcnController extends KFXPanelController {
refTableBean.getMessage(), result, refTableBean.getUserVal() + ";" + refTableBean.getUserUUid(),
refTableBean.getCompDate().getText(), refTableBean.getMark().getText() }, insertSql);
}
frame.dispose();
} catch (Exception e) {
e.printStackTrace();
Alert alert = new Alert(AlertType.ERROR);
//alert.setTitle("信息");
//alert.setHeaderText("这是一个信息对话框");
alert.setContentText("" + e.getMessage());
alert.showAndWait();
} finally {
SqlUtil.freeAll();
}
@ -775,9 +785,9 @@ public class CreateEcnController extends KFXPanelController {
rowNum++;
EcnBean ecnBean = new EcnBean(rowNum, reasons, wips, ChangeDrawingNo[j], sign[j], placesNo[j],
ChangeBefore1[j], ChangeAfter1[j], ChangeReason[j], ProcessType1[j], szVersionBef[j],
szVersionAft[j]);
szVersionAft[j], products, szProduct[j]);
ecnBeans.add(ecnBean);
ecnBean.setProductSz(szProduct[j]);
// ecnBean.setProductSz(szProduct[j]);
}
}
tableView.getItems().addAll(ecnBeans);
@ -856,7 +866,7 @@ public class CreateEcnController extends KFXPanelController {
try {
dataset = (TCComponentDataset) session.stringToComponent(DatasetUid);
newDataset = dataset.saveAs(null);
} catch (TCException e) {
} catch (Exception e) {
e.printStackTrace();
}
@ -956,15 +966,12 @@ public class CreateEcnController extends KFXPanelController {
tc_beforChange.prefWidthProperty().bind(tableView.widthProperty().multiply(0.10));
tc_beforVer.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06));
tc_afterChange.prefWidthProperty().bind(tableView.widthProperty().multiply(0.10));
productSz.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06));
productSz.prefWidthProperty().bind(tableView.widthProperty().multiply(0.08));
tc_afterVer.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06));
tc_reason.prefWidthProperty().bind(tableView.widthProperty().multiply(0.14)); // 0.4
tc_wipTreat.prefWidthProperty().bind(tableView.widthProperty().multiply(0.10));
}
@FXML
public TableView<RefTableBean> refTable;
/**
*
* @function

@ -1,10 +1,8 @@
package com.chint.plm.createEcn;
import java.util.ArrayList;
import java.util.List;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextArea;
@ -30,7 +28,7 @@ public class EcnBean {
this.productSz.getSelectionModel().select(productSz);
}
EcnBean(int ind, List<String> reasons, List<String> wips, List<String> products) {
public EcnBean(int ind, List<String> reasons, List<String> wips, List<String> products) {
num = new SimpleIntegerProperty(ind);
drawNo = new TextArea(); // ComboBoxTextArea
drawNo.setPrefSize(200, 40);
@ -58,9 +56,9 @@ public class EcnBean {
changeReason.getItems().addAll(reasons);
}
EcnBean(int ind, List<String> reasons, List<String> wips, String drawNoVal, String markVal, String placesNo,
public EcnBean(int ind, List<String> reasons, List<String> wips, String drawNoVal, String markVal, String placesNo,
String changeBefore, String changeAfter, String reasonVal, String processType, String szRevisionBef,
String szRevisionAft) {
String szRevisionAft, List<String> products, String product) {
num = new SimpleIntegerProperty(ind);
drawNo = new TextArea(); // ComboBoxTextArea
drawNo.setPrefSize(200, 40);
@ -94,6 +92,9 @@ public class EcnBean {
wipTreat.getSelectionModel().select(processType);
changeReason.getItems().addAll(reasons);
changeReason.getSelectionModel().select(reasonVal);
//lidy20240517
productSz.getItems().addAll(products);
productSz.getSelectionModel().select(product);
}
public Integer getNum() {

@ -4,12 +4,11 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.SqlUtil;
import com.teamcenter.rac.util.MessageBox;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.ObservableList;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.control.TableView;
@ -76,12 +75,12 @@ public class RelateEcnBean {
String customPal = read.getString("CUSTOMNOTICEPRINCIPAL");// FINAPRICEPRINCIPAL
String finaPal = read.getString("FINAPRICEPRINCIPAL");
String docuName = read.getString("DOCUNAME"); // 文件代号及名称
String designFile = read.getString("DESIGNFILE");// 获取行动内容
// String designFile = read.getString("DESIGNFILE");// 获取行动内容
linkBtn.setOnAction(e -> {
try {
BomToSapUtil.browse2(link);
} catch (Exception e1) {
// TODO Auto-generated catch block
// Auto-generated catch block
e1.printStackTrace();
}
});
@ -118,9 +117,14 @@ public class RelateEcnBean {
// 更新数据库信息
SqlUtil.update(controller.UPDATE_OA, new String[] { applyNo });
tableView.refresh();
MessageBox.post("导入完成", "", MessageBox.INFORMATION);
//MessageBox.post("导入完成", "", MessageBox.INFORMATION);
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("提示");
alert.setHeaderText("导入完成");
//alert.setContentText("导入完成");
alert.showAndWait();
} catch (Exception e1) {
// TODO Auto-generated catch block
// Auto-generated catch block
e1.printStackTrace();
} finally {
SqlUtil.freeAll();

@ -2,19 +2,16 @@ package com.chint.plm.createEcn;
import java.io.IOException;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCSession;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
public class RelateEcnDialog extends Application {
private String groupID;
// private String groupID;
private TCSession session;
private CreateEcnController controller;

@ -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;

Loading…
Cancel
Save