武汉代码修改

no-bomasyn
陈翼晖 1 year ago
parent fa86106be6
commit 65c5903c8f

@ -0,0 +1,2 @@
ERROR_NOT_CHANGE=\u8BF7\u9009\u62E9\u66F4\u6539\u901A\u77E5\u5355\u5BF9\u8C61
ERROR_NO_CHANGE=\u672A\u627E\u5230\u53D8\u66F4\u524D\u540E\u5BF9\u8C61,\u65E0\u6CD5\u63D0\u53D6\u5DEE\u5F02\u9879\uFF01

@ -6,6 +6,7 @@
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
@ -78,17 +79,19 @@
<center>
<TableView fx:id="materialsTable" prefHeight="320.0" prefWidth="1302.0" BorderPane.alignment="CENTER">
<columns>
<TableColumn fx:id="no" prefWidth="75.0" />
<TableColumn fx:id="materialNameColumn" prefWidth="126.0" text="材料名称" />
<TableColumn fx:id="relatedMaterialColumn" prefWidth="122.0" text="材料名称" />
<TableColumn fx:id="specificationColumn" prefWidth="250.0" text="规格" />
<TableColumn fx:id="manufacturerColumn" minWidth="0.0" prefWidth="203.0" text="制造厂商" />
<TableColumn fx:id="quantityColumn" prefWidth="91.0" text="数量(净重)" />
<TableColumn fx:id="utilizationRateColumn" prefWidth="69.0" text="利用率" />
<TableColumn fx:id="unitColumn" prefWidth="70.0" text="单位" />
<TableColumn fx:id="unitPriceColumn" prefWidth="86.0" text="单价(元)" />
<TableColumn fx:id="amountColumn" prefWidth="94.0" text="金额(元)" />
<TableColumn fx:id="comparedResultColumn" prefWidth="115.0" text="对比结果(元)" />
<TableColumn fx:id="no" prefWidth="54.0" />
<TableColumn fx:id="materialNameColumn" prefWidth="78.0" text="材料名称" />
<TableColumn fx:id="relatedMaterialColumn" prefWidth="76.0" text="材料名称" />
<TableColumn fx:id="specificationColumn" prefWidth="223.0" text="规格" />
<TableColumn fx:id="manufacturerColumn" minWidth="0.0" prefWidth="215.0" text="制造厂商" />
<TableColumn fx:id="quantityColumn" prefWidth="81.0" text="数量(净重)" />
<TableColumn fx:id="utilizationRateColumn" prefWidth="71.0" text="利用率" />
<TableColumn fx:id="unitColumn" prefWidth="60.0" text="单位" />
<TableColumn fx:id="unitPriceColumn" prefWidth="89.0" text="单价(元)" />
<TableColumn fx:id="amountColumn" prefWidth="85.0" text="金额(元)" />
<TableColumn fx:id="comparedQuantityColumn" prefWidth="74.0" text="对比数量" />
<TableColumn fx:id="comparedUnitPriceColumn" prefWidth="75.0" text="对比单价" />
<TableColumn fx:id="comparedResultColumn" prefWidth="114.0" text="对比结果(元)" />
</columns>
</TableView>
</center>
@ -97,13 +100,42 @@
<center>
<FlowPane alignment="CENTER_RIGHT" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
<FlowPane alignment="CENTER" prefHeight="43.0" prefWidth="447.0">
<children>
<Label alignment="CENTER" contentDisplay="CENTER" nodeOrientation="LEFT_TO_RIGHT" text="颜色备注:">
<FlowPane.margin>
<Insets top="10.0" />
</FlowPane.margin>
</Label>
<TextField editable="false" prefHeight="20.0" prefWidth="37.0" style="-fx-background-color: #FF6600;">
<FlowPane.margin>
<Insets top="10.0" />
</FlowPane.margin>
</TextField>
<Label text=":代表亏损 ">
<FlowPane.margin>
<Insets top="10.0" />
</FlowPane.margin>
</Label>
<TextField editable="false" prefHeight="20.0" prefWidth="37.0" style="-fx-background-color: #A9D08E;">
<FlowPane.margin>
<Insets top="10.0" />
</FlowPane.margin>
</TextField>
<Label text=":代表盈利 ">
<FlowPane.margin>
<Insets top="10.0" />
</FlowPane.margin>
</Label>
</children>
</FlowPane>
<Label prefWidth="86.0" text=" 总价:" />
<TextField fx:id="totalPriceTextField" prefHeight="30.0" prefWidth="131.0" />
</children>
</FlowPane>
</center>
<bottom>
<FlowPane alignment="CENTER_RIGHT" prefHeight="50.0" prefWidth="314.0" BorderPane.alignment="CENTER">
<FlowPane alignment="CENTER_RIGHT" prefHeight="50.0" prefWidth="1237.0" BorderPane.alignment="CENTER">
<children>
<Label text="总价对比结果:" />
<TextField fx:id="totalPriceCompareTextField" prefHeight="30.0" prefWidth="131.0" />
@ -150,6 +182,8 @@
<Insets right="15.0" />
</padding>
</GridPane>
<TextArea fx:id="changeReason" layoutX="106.0" layoutY="794.0" prefHeight="106.0" prefWidth="450.0" AnchorPane.bottomAnchor="1.0" />
<Label layoutX="37.0" layoutY="796.0" text="更改原因:" AnchorPane.bottomAnchor="90.0" />
</children>
<padding>
<Insets bottom="30.0" left="5.0" right="5.0" top="10.0" />

@ -40,6 +40,8 @@ public class Util {
public static final String REPRESENTATION_FOR = "representation_for";
public static final String ZT_MATERIAL_NO = "zt2_MaterialNo";
public static final String ITEM_REVIISON_ID = "item_revision_id";
public static final String REVISION_RULE_ANY = "Any Status; Working";
public static final String BL_QTY = "bl_quantity";
public Connection connect(Connection conn, TCSession session) {
String[] database = session.getPreferenceService().getStringValues("database_tc");
String JdbcDriverClass = "oracle.jdbc.driver.OracleDriver";

@ -0,0 +1,126 @@
package com.chint.plm.createbomdifference;
public class BOMCompareBean {
private int index;
private String changeType; // 更改类别
private String zt2_MaterialNo_Parent; // 父件物料编码
private String object_desc_Parent; // 父件物料描述
private String zt2_MaterialNo_Old; // 旧物料编码
private String object_desc_Old; // 旧物料描述
private String num_Old; // 旧物料数量
private String zt2_MaterialNo_new; // 新物料编码
private String object_desc_new; // 新物料描述
private String num_new; // 新物料数量
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public String getZt2_MaterialNo_Parent() {
return zt2_MaterialNo_Parent;
}
public void setZt2_MaterialNo_Parent(String zt2_MaterialNo_Parent) {
this.zt2_MaterialNo_Parent = zt2_MaterialNo_Parent;
}
public String getObject_desc_Parent() {
return object_desc_Parent;
}
public void setObject_desc_Parent(String object_desc_Parent) {
this.object_desc_Parent = object_desc_Parent;
}
public String getZt2_MaterialNo_Old() {
return zt2_MaterialNo_Old;
}
public void setZt2_MaterialNo_Old(String zt2_MaterialNo_Old) {
this.zt2_MaterialNo_Old = zt2_MaterialNo_Old;
}
public String getObject_desc_Old() {
return object_desc_Old;
}
public void setObject_desc_Old(String object_desc_Old) {
this.object_desc_Old = object_desc_Old;
}
public String getNum_Old() {
return num_Old;
}
public void setNum_Old(String num_Old) {
this.num_Old = num_Old;
}
public String getZt2_MaterialNo_new() {
return zt2_MaterialNo_new;
}
public void setZt2_MaterialNo_new(String zt2_MaterialNo_new) {
this.zt2_MaterialNo_new = zt2_MaterialNo_new;
}
public String getObject_desc_new() {
return object_desc_new;
}
public void setObject_desc_new(String object_desc_new) {
this.object_desc_new = object_desc_new;
}
public String getNum_new() {
return num_new;
}
public void setNum_new(String num_new) {
this.num_new = num_new;
}
public String getChangeType() {
return changeType;
}
public void setChangeType(String changeType) {
this.changeType = changeType;
}
public BOMCompareBean(String changeType, String zt2_MaterialNo_Parent, String object_desc_Parent,
String zt2_MaterialNo_Old, String object_desc_Old, String num_Old, String zt2_MaterialNo_new,
String object_desc_new, String num_new) {
super();
this.changeType = changeType;
this.zt2_MaterialNo_Parent = zt2_MaterialNo_Parent;
this.object_desc_Parent = object_desc_Parent;
this.zt2_MaterialNo_Old = zt2_MaterialNo_Old;
this.object_desc_Old = object_desc_Old;
this.num_Old = num_Old;
this.zt2_MaterialNo_new = zt2_MaterialNo_new;
this.object_desc_new = object_desc_new;
this.num_new = num_new;
}
@Override
public String toString() {
return "BOMCompareBean [index=" + index + ", changeType=" + changeType + ", zt2_MaterialNo_Parent="
+ zt2_MaterialNo_Parent + ", object_desc_Parent=" + object_desc_Parent + ", zt2_MaterialNo_Old="
+ zt2_MaterialNo_Old + ", object_desc_Old=" + object_desc_Old + ", num_Old=" + num_Old
+ ", zt2_MaterialNo_new=" + zt2_MaterialNo_new + ", object_desc_new=" + object_desc_new + ", num_new="
+ num_new + "]";
}
public Object[] getRowData(int index) {
this.index = index;
return new Object[] { this.index, changeType, zt2_MaterialNo_Parent, object_desc_Parent, zt2_MaterialNo_Old,
object_desc_Old, num_Old, zt2_MaterialNo_new, object_desc_new, num_new, "", "", "" };
}
}

@ -0,0 +1,169 @@
package com.chint.plm.createbomdifference;
import java.util.HashMap;
import java.util.Map;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
public class BOMCoutBean {
private TCComponentItemRevision part_child_new; // 新物料
private TCComponentItemRevision part_child_old; // 旧物料
private TCComponentBOMLine line_new; // 新BOMLine
private TCComponentBOMLine line_old; // 旧BOMLine
private double num_new = 0; // 新BOM物料数量
private double num_old = 0; // 旧BOM物料数量
private int index_num; // 排序
private String zt2_DesignWeight_old;
private String zt2_DesignWeight_new;
private Map<TCComponentItem, TCComponentBOMLine> map_line_new = new HashMap<>();
private Map<TCComponentItem, TCComponentBOMLine> map_line_old = new HashMap<>();
private TCComponentItemRevision rev; // 对象
private TCComponentItemRevision part_parent; // 父项物料
public TCComponentItemRevision getPart_parent() {
return part_parent;
}
public void setPart_parent(TCComponentItemRevision part_parent) {
this.part_parent = part_parent;
}
public void addItemLineNew(TCComponentItem item, TCComponentBOMLine line) {
map_line_new.put(item, line);
}
public void addItemLineOld(TCComponentItem item, TCComponentBOMLine line) {
map_line_old.put(item, line);
}
public Map<TCComponentItem, TCComponentBOMLine> getMap_line_new() {
return map_line_new;
}
public void setMap_line_new(Map<TCComponentItem, TCComponentBOMLine> map_line_new) {
this.map_line_new = map_line_new;
}
public Map<TCComponentItem, TCComponentBOMLine> getMap_line_old() {
return map_line_old;
}
public void setMap_line_old(Map<TCComponentItem, TCComponentBOMLine> map_line_old) {
this.map_line_old = map_line_old;
}
public TCComponentItemRevision getRev() {
return rev;
}
public void setRev(TCComponentItemRevision rev) {
this.rev = rev;
}
public int getIndex_num() {
return index_num;
}
public void setIndex_num(int index_num) {
if (this.index_num == 0)
this.index_num = index_num;
}
public TCComponentItemRevision getPart_child_new() {
return part_child_new;
}
public void setPart_child_new(TCComponentItemRevision part_child_new) {
this.part_child_new = part_child_new;
}
public TCComponentItemRevision getPart_child_old() {
return part_child_old;
}
public void setPart_child_old(TCComponentItemRevision part_child_old) {
this.part_child_old = part_child_old;
}
public TCComponentBOMLine getLine_new() {
return line_new;
}
public void setLine_new(TCComponentBOMLine line_new) {
this.line_new = line_new;
}
public TCComponentBOMLine getLine_old() {
return line_old;
}
public void setLine_old(TCComponentBOMLine line_old) {
this.line_old = line_old;
}
public double getNum_new() {
return num_new;
}
public void setNum_new(double num_new) {
this.num_new = num_new;
}
public double getNum_old() {
return num_old;
}
public void setNum_old(double num_old) {
this.num_old = num_old;
}
public void addNum_new(double num) {
this.num_new += num;
}
public void addNum_old(double num) {
this.num_old += num;
}
public String getZt2_DesignWeight_old() {
return zt2_DesignWeight_old;
}
public void setZt2_DesignWeight_old(String zt2_DesignWeight_old) {
this.zt2_DesignWeight_old = zt2_DesignWeight_old;
}
public String getZt2_DesignWeight_new() {
return zt2_DesignWeight_new;
}
public void setZt2_DesignWeight_new(String zt2_DesignWeight_new) {
this.zt2_DesignWeight_new = zt2_DesignWeight_new;
}
/*
* @Override public String toString() { return "BOMCoutBean [part_child_new=" +
* part_child_new + ", part_child_old=" + part_child_old + ", line_new=" +
* line_new + ", line_old=" + line_old + ", num_new=" + num_new + ", num_old=" +
* num_old + ", index_num=" + index_num + ", zt2_DesignWeight_old=" +
* zt2_DesignWeight_old + ", zt2_DesignWeight_new=" + zt2_DesignWeight_new +
* ", map_line_new=" + map_line_new + ", map_line_old=" + map_line_old +
* ", rev=" + rev + "]"; }
*/
public static void main(String[] args) {
BOMCoutBean bean = new BOMCoutBean();
System.out.println(bean.getIndex_num());
}
@Override
public String toString() {
return "BOMCoutBean [part_child_new=" + part_child_new + ", part_child_old=" + part_child_old + ", num_new="
+ num_new + ", num_old=" + num_old + ", index_num=" + index_num + ", part_parent=" + part_parent + "]";
}
}

@ -0,0 +1,137 @@
package com.chint.plm.createbomdifference;
import java.awt.Component;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.swing.AbstractCellEditor;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.TableCellEditor;
import com.connor.chint.sap2.util.KUtil;
public class BOMDifCellEditor extends AbstractCellEditor implements TableCellEditor {
private static final long serialVersionUID = -6384535937264729978L;
private Map<String, Map<String, String>> class_subclass = new HashMap<>();// 大小类
private List<JComboBox<String>> jcom_subclass = new ArrayList<>(32); // 小类下拉框
private List<JTextField> jtf_subclass = new ArrayList<>(32); // 小类文本框
private int size = 0;
private int row;
// private int col;
private JTable table;
private Map<String, String> map_class;
private Map<String, String[]> map_values;
public BOMDifCellEditor(Map<String, Map<String, String>> class_subclass, Map<String, String> map_class, int size) {
this.class_subclass = class_subclass;
this.map_class = map_class;
this.size = size;
initUI();
}
private void initUI() {
JTextField jtf = null;
List<Entry<String, String>> list = new ArrayList<>(map_class.entrySet());
String[] keys = new String[list.size() + 1];
Collections.sort(list, new Comparator<Entry<String, String>>() {
@Override
public int compare(Entry<String, String> o1, Entry<String, String> o2) {
return o1.getValue().compareTo(o2.getValue());
}
});
keys[0] = "";
map_values = new HashMap<>(8);
List<Entry<String, String>> list2 = null;
Map<String, String> map = null;
String[] subclass = null;
for (Entry<String, Map<String, String>> entry : class_subclass.entrySet()) {
map = entry.getValue();
list2 = new ArrayList<>(map.entrySet());
Collections.sort(list2, new Comparator<Entry<String, String>>() {
@Override
public int compare(Entry<String, String> o1, Entry<String, String> o2) {
return o1.getValue().compareTo(o2.getValue());
}
});
subclass = new String[list2.size() + 1];
subclass[0] = "";
for (int i = 0, len = list2.size(); i < len; i++) {
subclass[i + 1] = list2.get(i).getKey();
}
map_values.put(entry.getKey(), subclass);
}
for (int i = 0, len = list.size(); i < len; i++) {
keys[i + 1] = list.get(i).getKey();
}
JComboBox<String> jcom = null;
for (int i = 0; i < size; i++) {
jcom = new JComboBox<String>();
jtf = new JTextField();
jcom_subclass.add(jcom);
jtf_subclass.add(jtf);
}
}
@Override
public Object getCellEditorValue() {
String class_value = String.valueOf(table.getValueAt(row, 10));
Component comp = null;
if (!KUtil.isEmpty(class_value) && class_subclass.containsKey(class_value)) {
comp = jcom_subclass.get(row);
return ((JComboBox<?>) comp).getSelectedItem();
} else {
comp = jtf_subclass.get(row);
return ((JTextField) comp).getText();
}
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
this.table = table;
this.row = row;
// this.col = column;
Map<String, String> map = null;
if (row > -1) {
String class_value = String.valueOf(table.getValueAt(row, 10));
String subclass_value = String.valueOf(table.getValueAt(row, 11));
JComboBox<String> jcom = jcom_subclass.get(row);
jcom.removeAllItems();
if (column == 11) {
if (!KUtil.isEmpty(class_value) && class_subclass.containsKey(class_value)) {
String[] values = map_values.get(class_value);
map = class_subclass.get(class_value);
for (int i = 0, len = values.length; i < len; i++) {
jcom.addItem(values[i]);
}
if (map.containsKey(subclass_value))
jcom.setSelectedItem(subclass_value);
return jcom;
}
JTextField jtf = jtf_subclass.get(row);
jtf.setText(subclass_value);
return jtf;
}
}
return null;
}
}

@ -0,0 +1,279 @@
package com.chint.plm.createbomdifference;
import java.util.ArrayList;
import java.util.List;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
public class BOMDifferenceBean {
/**
*
*/
public TCComponentItemRevision oldRev;
/**
*
*/
public TCComponentItemRevision newRev;
/**
*
*/
public TCComponentItemRevision oldPartRev;
/**
*
*/
public TCComponentItemRevision newPartRev;
/**
*
*/
public TCComponentItemRevision parentPartRev;
/**
*
*/
public String zt2_MaterialNo_Parent;
/**
*
*/
public String object_desc_Parent;
/**
*
*/
public String object_name_Parent;
public String getObject_name_Parent() {
return object_name_Parent;
}
public void setObject_name_Parent(String object_name_Parent) {
this.object_name_Parent = object_name_Parent;
}
/**
*
*/
public TCComponentItem item;
/**
* BOMLine
*/
TCComponentBOMLine oldBOMLine;
/**
* BOMLine
*/
TCComponentBOMLine newBOMLine;
/**
*
*/
private String rev_object_type;
private TCComponentItemRevision rev;
public TCComponentItem getItem() {
return item;
}
public void setItem(TCComponentItem item) {
this.item = item;
}
public TCComponentBOMLine getOldBOMLine() {
return oldBOMLine;
}
public void setOldBOMLine(TCComponentBOMLine oldBOMLine) {
this.oldBOMLine = oldBOMLine;
}
public TCComponentBOMLine getNewBOMLine() {
return newBOMLine;
}
public void setNewBOMLine(TCComponentBOMLine newBOMLine) {
this.newBOMLine = newBOMLine;
}
public String getRev_object_type() {
return rev_object_type;
}
public void setRev_object_type(String rev_object_type) {
this.rev_object_type = rev_object_type;
}
public TCComponentItemRevision getOldRev() {
return oldRev;
}
public void setOldRev(TCComponentItemRevision oldRev) {
this.oldRev = oldRev;
}
public TCComponentItemRevision getNewRev() {
return newRev;
}
public void setNewRev(TCComponentItemRevision newRev) {
this.newRev = newRev;
}
@Override
public String toString() {
return "BOMDifferenceBean [oldRev=" + oldRev + ", newRev=" + newRev + ", oldPartRev=" + oldPartRev
+ ", newPartRev=" + newPartRev + ", parentPartRev=" + parentPartRev + ", zt2_MaterialNo_Parent="
+ zt2_MaterialNo_Parent + ", object_desc_Parent=" + object_desc_Parent + ", item=" + item
+ ", oldBOMLine=" + oldBOMLine + ", newBOMLine=" + newBOMLine + ", rev_object_type=" + rev_object_type
+ ", level=" + level + ", Quantity=" + Quantity + ", oldQuantity=" + oldQuantity + ", newQuantity="
+ newQuantity + ", m_virtualNode=" + m_virtualNode + ", current_rev=" + current_rev + ", childs="
+ childs + "]";
}
/**
*
*/
private int level;
/**
*
*/
private double Quantity = 0;
/**
*
*/
private double oldQuantity = 0;
/**
*
*/
private double newQuantity = 0;
/**
*
*/
protected boolean m_virtualNode;
private TCComponentItemRevision current_rev;
private List<BOMDifferenceBean> childs = new ArrayList<>();
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public double getQuantity() {
return Quantity;
}
public void setQuantity(double quantity) {
Quantity = quantity;
}
public boolean isM_virtualNode() {
return m_virtualNode;
}
public void setM_virtualNode(boolean m_virtualNode) {
this.m_virtualNode = m_virtualNode;
}
public TCComponentItemRevision getCurrent_rev() {
return current_rev;
}
public void setCurrent_rev(TCComponentItemRevision current_rev) {
this.current_rev = current_rev;
}
public List<BOMDifferenceBean> getChilds() {
return childs;
}
public void setChilds(List<BOMDifferenceBean> childs) {
this.childs = childs;
}
public void addChilds(List<BOMDifferenceBean> list) {
BOMDifferenceBean bean;
for (int i = 0, len = list.size(); i < len; i++) {
bean = list.get(i);
if (childs.indexOf(bean) == -1) {
childs.add(bean);
}
}
}
public TCComponentItemRevision getOldPartRev() {
return oldPartRev;
}
public void setOldPartRev(TCComponentItemRevision oldPartRev) {
this.oldPartRev = oldPartRev;
}
public TCComponentItemRevision getNewPartRev() {
return newPartRev;
}
public void setNewPartRev(TCComponentItemRevision newPartRev) {
this.newPartRev = newPartRev;
}
public double getOldQuantity() {
return oldQuantity;
}
public void setOldQuantity(double oldQuantity) {
this.oldQuantity = oldQuantity;
}
public double getNewQuantity() {
return newQuantity;
}
public void setNewQuantity(double newQuantity) {
this.newQuantity = newQuantity;
}
public void addOldQuantity(double num) {
this.oldQuantity += num;
}
public void addNewQuantity(double num) {
this.newQuantity += num;
}
public TCComponentItemRevision getParentPartRev() {
return parentPartRev;
}
public void setParentPartRev(TCComponentItemRevision parentPartRev) {
this.parentPartRev = parentPartRev;
}
public String getZt2_MaterialNo_Parent() {
return zt2_MaterialNo_Parent;
}
public void setZt2_MaterialNo_Parent(String zt2_MaterialNo_Parent) {
this.zt2_MaterialNo_Parent = zt2_MaterialNo_Parent;
}
public String getObject_desc_Parent() {
return object_desc_Parent;
}
public void setObject_desc_Parent(String object_desc_Parent) {
this.object_desc_Parent = object_desc_Parent;
}
public TCComponentItemRevision getRev() {
return rev;
}
public void setRev(TCComponentItemRevision rev) {
this.rev = rev;
}
}

@ -0,0 +1,46 @@
/**
* Copyright 2024 eSunny Info. Tech Ltd. All rights reserved.
*
* @Package: com.chint.plm.createbomdifference
* @author: cyh
* @date: 2024110 3:39:18
*/
package com.chint.plm.createbomdifference;
import java.util.List;
import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.yunpi.KCommand;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
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.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
/**
* @author cyh
*
* PE
*
*/
public class BomCompareComd extends KCommand {
/**
* @param app
* @param commandId
* @param actionInfo
* @function
*/
public BomCompareComd(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
this.setRunnable(new CreateBOMDifferenceDialog(app));
}
}

@ -0,0 +1,40 @@
/**
* Copyright 2024 eSunny Info. Tech Ltd. All rights reserved.
*
* @Package: com.chint.plm.createbomdifference
* @author: cyh
* @date: 2024112 4:04:10
*/
package com.chint.plm.createbomdifference;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
/**
* @author cyh
*
*
*/
public class ChangeDesignBean {
private TCComponentItemRevision oldDesgin;
private TCComponentItemRevision newDesgin;
@Override
public String toString() {
return "ChangeDesignBean [oldDesgin=" + oldDesgin + ", newDesgin=" + newDesgin + "]";
}
public TCComponentItemRevision getOldDesgin() {
return oldDesgin;
}
public void setOldDesgin(TCComponentItemRevision oldDesgin) {
this.oldDesgin = oldDesgin;
}
public TCComponentItemRevision getNewDesgin() {
return newDesgin;
}
public void setNewDesgin(TCComponentItemRevision newDesgin) {
this.newDesgin = newDesgin;
}
}

@ -0,0 +1,708 @@
package com.chint.plm.createbomdifference;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableColumnModel;
import com.chint.plm.createEcn.Util;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.POIUtil;
import com.connor.chint.sap2.util.ProgressBar;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.ListOfValuesInfo;
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.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentFormType;
import com.teamcenter.rac.kernel.TCComponentGroup;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
/*
* BOM
*
*/
public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
private static final long serialVersionUID = 1190944518442503011L;
public static final String[] HEADER = { "序号", "更改类别", "父件物料编码", "父件物料描述", "旧物料编码", "旧物料描述", "旧物料数量", "新物料编码",
"新物料描述", "新物料数量", "原因大类", "原因小类", "处理类型" };
public static final int[] HEADERWIDTH = new int[] { 50, 80, 120, 220, 120, 180, 80, 120, 180, 80, 100, 100, 100 };
private AbstractAIFApplication app;
private TCSession session;
private final JButton btn_ok = new JButton("确定");
private final JButton btn_cel = new JButton("取消");
private JTable t_part;
private DefaultTableModel tm_part;
// private JComboBox<String> jcom_Subclass = null; //小类
private TCComponent tar = null;
// 差异集合
private List<BOMCompareBean> compares = new ArrayList<>();
private ProgressBar pb = null;
// private Map<String, String> map_material = new HashMap<>(6); // 原材料库
// private Map<String, TCComponentItemRevision> map_Materials = null; // 原材料
private Map<String, String> processType = new HashMap<>(32); // 更改类别
private Map<String, String> map_indexs = new HashMap<>(8); // 序号
private Map<String, Map<String, String>> class_subclass = new HashMap<>(8);
private Map<String, String> map_class = new HashMap<>(8); // 大类
private Map<String, String> map_subclass = new HashMap<>(64); // 小类
// 多选编辑
JPanel selectPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
private JComboBox<String> box_class = new JComboBox<String>();
private JComboBox<String> box_subClass = new JComboBox<String>();
private JComboBox<String> box_processType = new JComboBox<String>();
private JTextField field_subClass = new JTextField();
private String selectClassItemString = new String();
private String selectSubClassItemString = new String();
private String selectProcessTypeItemString = new String();
public CreateBOMDifferenceDialog(AbstractAIFApplication app) {
super(false);
this.app = app;
this.session = (TCSession) app.getSession();
}
private void initUI() {
this.setTitle("BOM差异表");
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(1400, 400));
this.setMinimumSize(new Dimension(1300, 300));
this.add(BorderLayout.NORTH, getSelectPanel());
this.add(BorderLayout.CENTER, getTablePanel());
this.add(BorderLayout.SOUTH, getButtonPanel());
addListener();
}
private Component getSelectPanel() {
box_class.setPreferredSize(new Dimension(85, 25));
box_subClass.setPreferredSize(new Dimension(85, 25));
box_processType.setPreferredSize(new Dimension(85, 25));
field_subClass.setPreferredSize(new Dimension(85, 25));
selectPanel.add(box_class);
selectPanel.add(box_subClass);
selectPanel.add(field_subClass);
selectPanel.add(box_processType);
box_subClass.setVisible(false);
selectPanel.setVisible(false);
return selectPanel;
}
private void initMap(TCSession session) throws Exception {
// 序号
// map_indexs.put("1-物料新增", "1"); //变压器
// map_indexs.put("2-物料删除", "2"); //高压开关
// map_indexs.put("3-物料数量变更", "3"); //中压设备
// map_indexs.put("4-物料变更", "4");
// map_indexs.put("5-其他", "5");
map_indexs = KUtil.getLOVDisplay_value(session, "ZT2_ChangeCategory");
System.out.println("map_indexs:" + map_indexs);
// 原材料分类库
// map_material.put("M005", "ICM0802"); // 变压器
// map_material.put("M006", "ICM0104"); // 高压开关
// map_material.put("M007", "ICM1202"); // 箱变
// map_material.put("M034", "ICM0801"); // 中压设备
// map_material.put("M030", "ICM1102");
// 处理类型
processType = KUtil.getLOVDisplay_value(session, "ZT2_ProcessType");
System.out.println("processType:" + processType);
TCComponentListOfValues lov = KUtil.getLov(session, "ZT2_ReasonCategories");
Map<String, String> map = null;
String disval = "";
String disval2 = "";
if (lov != null) {
TCComponentListOfValues[] ff = lov.getListOfFilters();
ListOfValuesInfo listOfValues = lov.getListOfValues();
String[] realval = listOfValues.getStringListOfValues();
for (int i = 0, len = realval.length; i < len; i++) {
disval = listOfValues.getDisplayableValue(realval[i]);
ListOfValuesInfo listOfValues2 = ff[i].getListOfValues();
String[] realval2 = listOfValues2.getStringListOfValues();
map = new HashMap<>(realval2.length);
for (int j = 0, len2 = realval2.length; j < len2; j++) {
disval2 = listOfValues2.getDisplayableValue(realval2[j]);
map.put(disval2, realval2[j]);
map_subclass.put(disval2, realval2[j]);
}
class_subclass.put(disval, map);
map_class.put(disval, realval[i]);
}
}
System.out.println("class_subclass:" + class_subclass);
}
@Override
public void run() {
try {
InterfaceAIFComponent target = app.getTargetComponent();
if (target == null || !target.getType().equals("ZT2_Change")) {
MessageBox.post("请选择更改通知单对象", "", 2);
return;
}
tar = (TCComponent) target;
TCComponent[] oldComponents = tar.getRelatedComponents("ZT2_ChangeBefore");
TCComponent[] newComponents = tar.getRelatedComponents("ZT2_ChangeAfter");
if (oldComponents.length == 0 && newComponents.length == 0) {
MessageBox.post("未找到变更前后对象,无法生成BOM差异表!", "", 2);
return;
}
String str = "";
for (int i = 0, len = oldComponents.length; i < len; i++) {
if (!(oldComponents[i] instanceof TCComponentItemRevision)) {
str += "更改前";
break;
}
}
for (int i = 0, len = newComponents.length; i < len; i++) {
if (!(newComponents[i] instanceof TCComponentItemRevision)) {
if (str.length() > 0) {
str += "、";
}
str += "更改后";
break;
}
}
if (!KUtil.isEmpty(str)) {
System.out.println("警告:" + str);
MessageBox.post("对象" + tar + "[" + str + "]存在非版本对象", "警告", 2);
return;
}
initMap(session);
// int icsId = -1;
TCComponentGroup group = (TCComponentGroup) tar.getRelatedComponent("owning_group");
String groupID = group.getTCProperty("name").getStringValue();
System.out.println("groupID:" + groupID);
String codeRemark = "";
System.out.println("codeRemark:" + codeRemark);
// if (map_material.containsKey(groupID)) {
// codeRemark = map_material.get(groupID);
//// icsId = SAPUtil.getIcsId(codeRemark, "材料标记", session);
// map_Materials = new HashMap<>();
// }
initUI();
pb = new ProgressBar(new Dimension(250, 50));
pb.startProgress();
pb.setText("正在进行BOM比较...");
showDialog();
// 获取低压设备的逻辑
if ("M060".equals(groupID)) {
KUtil.setByPass(true);
// 更改前的图纸对象获取物料,更改后的图纸获取物料
TCComponent[] oldMaterialComps = getPMaterial(oldComponents);
for(TCComponent oldMaterialComp:oldMaterialComps) {
System.out.println(oldMaterialComp);
}
for(TCComponent oldMaterialComp:oldMaterialComps) {
System.out.println("new=====>"+oldMaterialComp);
}
TCComponent[] newMaterialComps = getPMaterial(newComponents);
CreateBOMDifference_DYController.getRevMap(session, oldMaterialComps, newMaterialComps, compares,
groupID);
}
if (pb != null)
pb.disposeDialog();
int size = compares.size();
if (size == 0) {
disposeDialog();
MessageBox.post("更改前后没有BOM差异", "", 2);
return;
}
BOMDifCellEditor cellEditor = new BOMDifCellEditor(class_subclass, map_class, size);
t_part.getColumnModel().getColumn(11).setCellEditor(cellEditor);
new Thread(new Runnable() {
@Override
public void run() {
try {
pb = new ProgressBar(CreateBOMDifferenceDialog.this, new Dimension(250, 50));
pb.startProgress();
pb.setText("正在生成BOM差异数据...");
pb.showDialog();
for (int i = 0, len = compares.size(); i < len; i++) {
System.out.println(i + "--" + compares.get(i));
tm_part.addRow(compares.get(i).getRowData(i + 1));
}
pb.disposeDialog();
} catch (Exception e) {
pb.disposeDialog();
e.printStackTrace();
}
}
}).start();
System.out.println("差异个数:" + compares.size());
} catch (Exception e) {
if (pb != null) {
pb.disposeDialog();
}
MessageBox.post("界面初始化失败:" + e.getMessage(), "", 2);
e.printStackTrace();
disposeDialog();
} finally {
KUtil.setByPass(false);
if (pb != null) {
pb.disposeDialog();
}
}
}
/**
* P
*
* @param oldComponents
* @throws TCException
* @function
*/
private TCComponent[] getPMaterial(TCComponent[] oldComponents) throws TCException {
// TODO Auto-generated method stub
// Util.ZT_PROP_PBOM;
// 物料编码 - E和P物料
Map<String, PBomBean> pbomMap = new HashMap<>();
for (TCComponent oldComponent : oldComponents) {
if (!oldComponent.getType().equals(Util.ZT_DESIGN_TYPE)) {
String[] matnrProps = oldComponent.getProperties(
new String[] { Util.ZT_MATERIAL_NO, Util.ZT_PROP_PBOM, Util.ITEM_REVIISON_ID });
String materialNo = matnrProps[0];// material.getProperty(Util.ZT_MATERIAL_NO);
if (pbomMap.containsKey(materialNo)) {
PBomBean pBomBean = pbomMap.get(materialNo);
if (matnrProps[1].equals(Util.ZT_VAL_PBOM) && matnrProps[2].compareTo(pBomBean.getpRevision()) > 0) {
pBomBean.setpMaterial(oldComponent);
} else if (matnrProps[2].compareTo(pBomBean.geteRevision()) > 0) {
pBomBean.seteMaterial(oldComponent);
}
} else {
PBomBean pBomBean = new PBomBean();
if (matnrProps[1].equals(Util.ZT_VAL_PBOM)) {
pBomBean.setpMaterial(oldComponent);
pBomBean.setpRevision(matnrProps[2]);
} else {
pBomBean.seteMaterial(oldComponent);
pBomBean.seteRevision(matnrProps[2]);
}
pbomMap.put(materialNo, pBomBean);
}
// TCComponent[] materials = oldComponent.getRelatedComponents(Util.REPRESENTATION_FOR);
// for (TCComponent material : materials) {
// 获取物料编码
// }
}
}
TCComponent[] comps = new TCComponent[pbomMap.keySet().size()];
int ind = 0;
for (String materialNo : pbomMap.keySet()) {
PBomBean pBomBean = pbomMap.get(materialNo);
if (pBomBean.getpMaterial() == null) {
comps[ind] = pBomBean.geteMaterial();
} else {
comps[ind] = pBomBean.getpMaterial();
}
ind++;
}
return comps;
}
// 页面初始化的
private JPanel getTablePanel() {
JPanel panel = new JPanel(new BorderLayout());
tm_part = new DefaultTableModel();
t_part = new JTable(tm_part) {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public boolean isCellEditable(int row, int column) {
// TODO Auto-generated method stub
if (column > 9) {
return true;
}
return false;
}
};
tm_part.setDataVector(null, HEADER);
t_part.getTableHeader().setReorderingAllowed(false); // 设置列不可移动,否则会发生类型转换错误(第三列)
this.t_part.setRowHeight(23);
TableColumnModel colModel = this.t_part.getColumnModel();
int colCnt = HEADERWIDTH.length;
for (int i = 0; i < colCnt; i++) {
colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]);
}
List<Entry<String, String>> list = new ArrayList<>(map_class.entrySet());
JComboBox<String> jcm_reason = new JComboBox<String>();
jcm_reason.addItem("");
box_class.addItem("");
Collections.sort(list, new Comparator<Entry<String, String>>() {
@Override
public int compare(Entry<String, String> o1, Entry<String, String> o2) {
// TODO Auto-generated method stub
return o1.getValue().compareTo(o2.getValue());
}
});
for (int i = 0, len = list.size(); i < len; i++) {
jcm_reason.addItem(list.get(i).getKey());
box_class.addItem(list.get(i).getKey());
}
t_part.getColumnModel().getColumn(10).setCellEditor(new DefaultCellEditor(jcm_reason));
t_part.getModel().addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
int col = e.getColumn();
int row = e.getFirstRow();
if (col == 10 && row > -1) {
String value = String.valueOf(t_part.getValueAt(row, col));
if (KUtil.isEmpty(value)) {
t_part.setValueAt("", row, 11);
return;
}
}
}
});
System.out.println("processType:" + processType);
if (processType.size() > 0) {
int size = processType.size() + 1;
List<String> list2 = new ArrayList<>(size);
list2.add("");
List<String> keys = new ArrayList<>(processType.keySet());
for (int i = 0; i < size - 1; i++) {
list2.add(keys.get(i));
}
Collections.sort(list2);
JComboBox<String> jcom_Type = new JComboBox<String>(list2.toArray(new String[size]));
t_part.getColumnModel().getColumn(12).setCellEditor(new DefaultCellEditor(jcom_Type));
for (String processType : list2) {
box_processType.addItem(processType);
}
}
JScrollPane scroll = new JScrollPane(t_part);
panel.add(BorderLayout.CENTER, scroll);
return panel;
}
private JPanel getButtonPanel() {
JPanel panel = new JPanel(new FlowLayout());
panel.add(btn_ok);
for (int i = 0; i < 4; i++) {
panel.add(new JLabel(" "));
}
panel.add(btn_cel);
return panel;
}
private void addListener() {
btn_cel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
disposeDialog();
}
});
// 点击OK 则将界面显示数据写入zt2_BOMEC,并挂载到更改通知单对象下
btn_ok.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Thread(new Runnable() {
@Override
public void run() {
// 停止表格编辑状态
KUtil.stopTableEditing(t_part);
// 组织数据
try {
createBOMEC(t_part.getRowCount());
btn_ok.setEnabled(false);
MessageBox.post("BOM差异表生成成功", "", 2);
disposeDialog();
} catch (Exception e) {
e.printStackTrace();
MessageBox.post("BOM差异表生成失败:" + e.getMessage(), "", 2);
}
}
}).start();
}
});
t_part.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (t_part.getSelectedRowCount() >= 2) {
selectPanel.setVisible(true);
} else {
selectPanel.setVisible(false);
}
}
});
box_class.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
// 使Table编辑失去焦点
TableCellEditor tableCellEditor = t_part.getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.stopCellEditing();
}
if (selectClassItemString == null) {
selectClassItemString = (String) e.getItem();
} else if (!selectClassItemString.equals((String) e.getItem())) {
selectClassItemString = (String) e.getItem();
setSubClassBoxValue();
}
}
private void setSubClassBoxValue() {
if (selectClassItemString != "") {
field_subClass.setVisible(false);
box_subClass.setVisible(true);
box_subClass.removeAllItems();
Map<String, String> subClassMap = class_subclass.get(selectClassItemString);
box_subClass.addItem("");
for (String item : subClassMap.keySet()) {
box_subClass.addItem(item);
}
} else {
field_subClass.setVisible(true);
box_subClass.setVisible(false);
box_subClass.removeAllItems();
}
setTableClassCellValue();
selectClassItemString = null;
}
private void setTableClassCellValue() {
int[] selectRowsIndex = t_part.getSelectedRows();
for (int index : selectRowsIndex) {
t_part.setValueAt(selectClassItemString, index, 10);
}
}
});
box_subClass.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
// 使Table编辑失去焦点
TableCellEditor tableCellEditor = t_part.getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.stopCellEditing();
}
if (selectSubClassItemString == null) {
selectSubClassItemString = (String) e.getItem();
} else if (!selectSubClassItemString.equals((String) e.getItem())) {
selectSubClassItemString = (String) e.getItem();
setTableSubClassCellValue();
selectSubClassItemString = null;
}
}
private void setTableSubClassCellValue() {
int[] selectRowsIndex = t_part.getSelectedRows();
for (int index : selectRowsIndex) {
t_part.setValueAt(selectSubClassItemString, index, 11);
}
}
});
box_processType.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
// 使Table编辑失去焦点
TableCellEditor tableCellEditor = t_part.getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.stopCellEditing();
}
if (selectProcessTypeItemString == null) {
selectProcessTypeItemString = (String) e.getItem();
} else if (!selectProcessTypeItemString.equals((String) e.getItem())) {
selectProcessTypeItemString = (String) e.getItem();
setTableSubClassCellValue();
selectProcessTypeItemString = null;
}
}
private void setTableSubClassCellValue() {
int[] selectRowsIndex = t_part.getSelectedRows();
for (int index : selectRowsIndex) {
t_part.setValueAt(selectProcessTypeItemString, index, 12);
}
}
});
}
public TCComponentForm createBOMEC(int rowCout) throws Exception {
TCComponentForm form = null;
TCComponent[] comps = tar.getRelatedComponents("IMAN_reference");
for (int i = 0, len = comps.length; i < len; i++) {
if ("ZT2_BOMEC".equals(comps[i].getType())) {
form = (TCComponentForm) comps[i];
break;
}
}
if (form == null) {
TCComponentFormType formTyep = (TCComponentFormType) session.getTypeComponent("ZT2_BOMEC");
form = formTyep.create("BOM差异表", "", "ZT2_BOMEC");
tar.add("IMAN_reference", form);
}
System.out.println("form uid:" + form.getUid());
List<String> list = new ArrayList<>(rowCout);
for (int i = 0; i < 13; i++) {
String[] values = KUtil.getColumnValues(rowCout, i, list, t_part).toArray(new String[rowCout]);
System.out.println("设置值:" + "zt2_property" + (i + 1) + ";" + Arrays.toString(values));
switch (i) {
case 1:
for (int j = 0; j < values.length; j++) {
if (map_indexs.containsKey(values[j]))
values[j] = map_indexs.get(values[j]);
}
break;
case 10:
for (int j = 0; j < values.length; j++) {
if (map_class.containsKey(values[j]))
values[j] = map_class.get(values[j]);
}
form.getTCProperty("zt2_property12").setStringValueArray(new String[] {});
break;
case 11:
for (int j = 0; j < values.length; j++) {
if (map_subclass.containsKey(values[j]))
values[j] = map_subclass.get(values[j]);
}
break;
case 12:
for (int j = 0; j < values.length; j++) {
if (processType.containsKey(values[j]))
values[j] = processType.get(values[j]);
}
break;
default:
break;
}
System.out.println("设置值:" + "zt2_property" + (i + 1) + ";" + Arrays.toString(values));
KUtil.setProperty(form, "zt2_property" + (i + 1), values);
form.unlock();
}
tar.unlock();
return form;
}
/**
* ,,BOM ,
*
* @param rev
* @return
* @throws Exception
*/
// public List<TCComponentItemRevision> getAssembly(TCComponentItemRevision rev) throws Exception {
// List<TCComponentItemRevision> revs = new ArrayList<>();
// List<TCComponentItem> items = new ArrayList<>();
// if (rev.getType().equals("ZT2_Design3DRevision")) {
// TCComponent[] factoryNos = rev.getRelatedComponents("ZT2_FactoryNumber");
// TCComponentItem item;
// TCComponentItemRevision ccp;
// if (factoryNos.length > 0) {
// AIFComponentContext[] refs;
// for (int i = 0, len = factoryNos.length; i < len; i++) {
// refs = factoryNos[i].whereReferencedByTypeRelation(new String[] { "Part Revision" },
// new String[] { "ZT2_FactoryNumber" });
// for (int j = 0, len2 = refs.length; j < len2; j++) {
// if (!KUtil.isEmpty(refs[j].getComponent().getProperty("zt2_WBSNo"))) {
// ccp = (TCComponentItemRevision) refs[j].getComponent();
// item = ccp.getItem();
// if (items.indexOf(item) == -1) {
// revs.add(ccp);
// items.add(item);
// }
// }
// }
// }
// if (revs.size() == 0)
// throw new Exception("总装图[" + rev + "]未能找到关联的产成品对象!");
// }
// }
//
// return revs;
// }
}

@ -0,0 +1,512 @@
package com.chint.plm.createbomdifference;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
//import com.connor.chint.sap2.assignfactoryno.FactoryController;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
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.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
/**
*
*
* @author xiaol
*
*/
public class CreateBOMDifference_DYController {
/**
*
* @param oldComponents
* @param newComponents
* @throws TCException
*/
public static void getRevMap(TCSession session, TCComponent[] oldComponents, TCComponent[] newComponents,
List<BOMCompareBean> beans, String groupID) throws TCException {
// Map<String, String> map_types = new HashMap<>();
// Map<String, Integer> map_num = new HashMap<>();
// FactoryController.getFactoryType(session, map_types, map_num, groupID);
TCComponentItem item = null;
TCComponentItemRevision rev = null;
BOMDifferenceBean bean;
/**
* -
*/
Map<TCComponentItem, BOMDifferenceBean> map_item_beans = new HashMap<>();
/**
* -
*/
Map<TCComponent, List<BOMDifferenceBean>> map_factoryNo_beans = new HashMap<>();
/**
* -
*/
Map<TCComponent, List<TCComponent>> map_ccp_factoryNo = new HashMap<>();
TCComponent factoryNo = null;
TCComponent comps[] = null;
List<BOMDifferenceBean> list_beans;
List<TCComponent> list_comps;
for (TCComponent comp : oldComponents) {
if (comp instanceof TCComponentItemRevision) {
rev = (TCComponentItemRevision) comp;
item = rev.getItem();
bean = map_item_beans.get(item);
if (bean == null) {
bean = new BOMDifferenceBean();
bean.setOldRev(rev);
}
bean.setItem(item);
map_item_beans.put(item, bean);
if (("Part Revision").equals(rev.getType())) {
comps = rev.getRelatedComponents("ZT2_FactoryNumber");
if (comps.length > 0) {
factoryNo = comps[0];
// 非产成品对象才放入比较
list_beans = map_factoryNo_beans.get(factoryNo);
if (list_beans == null) {
list_beans = new ArrayList<>();
}
if (list_beans.indexOf(bean) == -1) {
list_beans.add(bean);
}
map_factoryNo_beans.put(factoryNo, list_beans);
// if (isCCP(rev, map_types)) {
// bean.setRev(rev);
// list_comps = map_ccp_factoryNo.get(item);
// if (list_comps == null) {
// list_comps = new ArrayList<>();
// }
// if (list_comps.indexOf(factoryNo) == -1) {
// list_comps.add(factoryNo);
// }
// map_ccp_factoryNo.put(item, list_comps);
// } else {
//
// }
}
}
}
}
for (TCComponent comp : newComponents) {
if (comp instanceof TCComponentItemRevision) {
rev = (TCComponentItemRevision) comp;
item = rev.getItem();
bean = map_item_beans.get(item);
if (bean == null) {
bean = new BOMDifferenceBean();
}
bean.setItem(item);
bean.setNewRev(rev);
map_item_beans.put(item, bean);
if (("Part Revision").equals(rev.getType())) {
comps = rev.getRelatedComponents("ZT2_FactoryNumber");
if (comps.length > 0) {
factoryNo = comps[0];
// if (isCCP(rev, map_types)) {
// bean.setRev(rev);
// list_comps = map_ccp_factoryNo.get(item);
// if (list_comps == null) {
// list_comps = new ArrayList<>();
// }
// if (list_comps.indexOf(factoryNo) == -1) {
// list_comps.add(factoryNo);
// }
// map_ccp_factoryNo.put(item, list_comps);
// } else {
list_beans = map_factoryNo_beans.get(factoryNo);
if (list_beans == null) {
list_beans = new ArrayList<>();
}
if (list_beans.indexOf(bean) == -1) {
list_beans.add(bean);
}
map_factoryNo_beans.put(factoryNo, list_beans);
// }
}
}
}
}
System.out.println("出厂编号遍历-------开始");
for (Entry<TCComponent, List<BOMDifferenceBean>> entry : map_factoryNo_beans.entrySet()) {
factoryNo = entry.getKey();
System.out.println("出厂编号--------" + factoryNo);
list_beans = entry.getValue();
for (int i = 0, len = list_beans.size(); i < len; i++) {
System.out.println(i + "--" + list_beans.get(i));
}
}
System.out.println("出厂编号遍历-------结束");
// 找到产成品
List<BOMDifferenceBean> list_ccps = new ArrayList<>();
if (map_ccp_factoryNo.size() > 0) {
List<TCComponentItem> childs = new ArrayList<>();
for (Entry<TCComponent, List<TCComponent>> entry : map_ccp_factoryNo.entrySet()) {
item = (TCComponentItem) entry.getKey();
list_comps = entry.getValue();
bean = map_item_beans.get(item);
// 确保产成品 变更前变更后都放进去了
if (bean.getOldRev() == null || bean.getNewRev() == null)
continue;
for (int i = 0, len = list_comps.size(); i < len; i++) {
factoryNo = list_comps.get(i);
// System.out.println("父项:"+item+";出厂编号:"+factoryNo);
list_beans = map_factoryNo_beans.get(factoryNo);
// System.out.println("------"+list_beans);
if (list_beans != null && list_beans.size() > 0) {
// 添加子项
bean.addChilds(list_beans);
for (int j = 0, len2 = list_beans.size(); j < len2; j++) {
childs.add(list_beans.get(j).getItem());
}
}
}
// 产成品比较
if (bean.getChilds().size() > 0) {
childs.add(item);
list_ccps.add(bean);
}
}
for (int i = 0, len = childs.size(); i < len; i++) {
item = childs.get(i);
map_item_beans.remove(item);
}
}
// 无产成品 一对一比较
TCComponentItemRevision oldRev = null;
TCComponentItemRevision newRev = null;
BOMDifferenceBean childBean;
List<TCComponentItem> list_items = new ArrayList<>();
String zt2_MaterialNo_Parent;
String object_desc_Parent;
String zt2_MaterialNo;
String object_desc;
BOMCompareBean compareBean;
TCComponentBOMWindowType bomWinType;
// BOMDifferenceBean parentBean;
bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null);
win.lock();
TCComponentBOMWindow win2 = bomWinType.create(null);
win2.lock();
TCComponentItemRevision parentRev;
try {
for (int i = 0, len = list_ccps.size(); i < len; i++) {
bean = list_ccps.get(i);
item = bean.getItem();
System.out.println("产成品:" + item);
if (list_items.indexOf(item) != -1) {
continue;
}
list_items.add(item);
rev = bean.getRev();
zt2_MaterialNo_Parent = rev.getProperty("zt2_MaterialNo");
object_desc_Parent = rev.getProperty("object_desc");
list_beans = bean.getChilds();
for (int j = 0, len2 = list_beans.size(); j < len2; j++) {
childBean = list_beans.get(j);
System.out.println("子项:" + childBean);
if (item == childBean.getItem())
continue;
item = childBean.getItem();
// System.out.println("子项:"+item);
if (list_items.indexOf(item) != -1) {
continue;
}
list_items.add(item);
oldRev = childBean.getOldRev();
newRev = childBean.getNewRev();
// 单元新增
if (oldRev == null && newRev != null) {
zt2_MaterialNo = newRev.getProperty("zt2_MaterialNo");
object_desc = newRev.getProperty("object_desc");
compareBean = new BOMCompareBean("物料新增", zt2_MaterialNo_Parent, object_desc_Parent, "", "", "",
zt2_MaterialNo, object_desc, "1");
beans.add(compareBean);
}
// 单元删除
if (oldRev != null && newRev == null) {
zt2_MaterialNo = oldRev.getProperty("zt2_MaterialNo");
object_desc = oldRev.getProperty("object_desc");
compareBean = new BOMCompareBean("物料删除", zt2_MaterialNo_Parent, object_desc_Parent,
zt2_MaterialNo, object_desc, "1", "", "", "");
beans.add(compareBean);
}
// BOM展开比较
if (oldRev != null && newRev != null) {
// 比较
win.setWindowTopLine(item, bean.getOldRev(), null, null);
win2.setWindowTopLine(item, bean.getNewRev(), null, null);
win.refresh();
win2.refresh();
childBean.setNewBOMLine(win2.getTopBOMLine());
childBean.setOldBOMLine(win.getTopBOMLine());
zt2_MaterialNo = newRev.getProperty("zt2_MaterialNo");
object_desc = newRev.getProperty("object_desc");
childBean.setZt2_MaterialNo_Parent(zt2_MaterialNo);
childBean.setObject_desc_Parent(object_desc);
childBean.setParentPartRev(newRev);
bomCompare_M030(childBean, session, 1, 1, beans, list_items);
}
}
}
for (Entry<TCComponentItem, BOMDifferenceBean> entry : map_item_beans.entrySet()) {
bean = entry.getValue();
oldRev = bean.getOldRev();
newRev = bean.getNewRev();
if (oldRev != null && newRev != null && oldRev != newRev) {
win.setWindowTopLine(item, bean.getOldRev(), null, null);
win2.setWindowTopLine(item, bean.getNewRev(), null, null);
win.refresh();
win2.refresh();
bean.setNewBOMLine(win2.getTopBOMLine());
bean.setOldBOMLine(win.getTopBOMLine());
zt2_MaterialNo = "";
object_desc = "";
parentRev = null;
parentRev = SAPUtil.getSAPPart(bean.getNewBOMLine(), session);
if (parentRev != null) {
zt2_MaterialNo = parentRev.getProperty("zt2_MaterialNo");
object_desc = parentRev.getProperty("object_desc");
}
bean.setZt2_MaterialNo_Parent(zt2_MaterialNo);
bean.setObject_desc_Parent(object_desc);
bean.setParentPartRev(newRev);
bomCompare_M030(bean, session, 1, 1, beans, list_items);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
*
*
* @param rev
* @param map_types
* @return
* @throws TCException
*/
public static boolean isCCP(TCComponentItemRevision rev, Map<String, String> map_types) throws TCException {
String object_name = rev.getProperty("object_name");
System.out.println("检查对象:" + rev + ";map_types:" + map_types);
for (Entry<String, String> entry : map_types.entrySet()) {
if (object_name.indexOf(entry.getKey()) != -1) {
return true;
}
}
return false;
}
public static void bomCompare_M030(BOMDifferenceBean parentBean, TCSession session, double parent_quantity_old,
double parent_quantity_new, List<BOMCompareBean> beans, List<TCComponentItem> item_compares)
throws TCException, SQLException {
if (item_compares.indexOf(parentBean.getItem()) != -1) {
System.out.println("已添加过" + parentBean.getItem());
return;
}
System.out.println("未添加过:" + parentBean.getItem());
item_compares.add(parentBean.getItem());
TCComponentBOMLine parentLine_new = parentBean.getNewBOMLine();
TCComponentBOMLine parentLine_old = parentBean.getOldBOMLine();
System.out.println("比较:" + parentLine_old + "--" + parent_quantity_old + "||" + parentLine_new + "--"
+ parent_quantity_new);
BOMDifferenceBean bean;
Map<TCComponentItem, BOMDifferenceBean> map_child_beans = new HashMap<>();
TCComponentItem item = null;
TCComponentItemRevision rev = null;
TCComponentBOMLine line;
TCComponentItemRevision oldPartRev = null;
TCComponentItemRevision newPartRev = null;
// 物料数量
String bl_quantity;
double quantity;
String rev_object_type;
if (parentLine_new != null) {
AIFComponentContext[] childs_new = parentLine_new.getChildren();
for (int i = 0, len = childs_new.length; i < len; i++) {
line = (TCComponentBOMLine) childs_new[i].getComponent();
rev = line.getItemRevision();
item = rev.getItem();
bean = map_child_beans.get(item);
newPartRev = SAPUtil.getSAPPart(line, session);
// System.out.println("子项:" + rev + ";物料:" + newPartRev);
if (newPartRev == null) {
continue;
}
bl_quantity = line.getProperty("bl_quantity");
System.out.println(rev + "-bl_quantity:" + bl_quantity);
if (bl_quantity == null || bl_quantity.trim().length() == 0) {
bl_quantity = "1";
}
quantity = Double.parseDouble(bl_quantity) * parent_quantity_new;
if (bean == null) {
bean = new BOMDifferenceBean();
bean.setItem(item);
bean.setNewRev(rev);
bean.setNewBOMLine(line);
rev_object_type = rev.getType();
bean.setRev_object_type(rev_object_type);
bean.setNewPartRev(newPartRev);
}
bean.addNewQuantity(quantity);
map_child_beans.put(item, bean);
}
}
if (parentLine_old != null) {
AIFComponentContext[] childs_old = parentLine_old.getChildren();
for (int i = 0, len = childs_old.length; i < len; i++) {
line = (TCComponentBOMLine) childs_old[i].getComponent();
rev = line.getItemRevision();
item = rev.getItem();
bean = map_child_beans.get(item);
oldPartRev = SAPUtil.getSAPPart(line, session);
// System.out.println("子项:" + rev + ";物料:" + oldPartRev);
if (oldPartRev == null) {
continue;
}
bl_quantity = line.getProperty("bl_quantity");
System.out.println(rev + "-bl_quantity:" + bl_quantity);
if (bl_quantity == null || bl_quantity.trim().length() == 0) {
bl_quantity = "1";
}
quantity = Double.parseDouble(bl_quantity) * parent_quantity_old;
if (bean == null) {
bean = new BOMDifferenceBean();
bean.setItem(item);
rev_object_type = rev.getType();
bean.setRev_object_type(rev_object_type);
}
bean.setOldRev(rev);
bean.setOldBOMLine(line);
bean.setOldPartRev(oldPartRev);
bean.addOldQuantity(quantity);
map_child_beans.put(item, bean);
}
}
BOMCompareBean compareBean;
// 父项物料编码
String zt2_MaterialNo_Parent;
// 父项版本描述
String object_desc_Parent = "";
// 旧物料号
String zt2_MaterialNo_Old;
String object_desc_Old;
String num_Old;
// 新物料号
String zt2_MaterialNo_New;
String object_desc_New;
String num_New;
zt2_MaterialNo_Parent = parentBean.getZt2_MaterialNo_Parent();
object_desc_Parent = parentBean.getObject_desc_Parent();
for (Entry<TCComponentItem, BOMDifferenceBean> entry : map_child_beans.entrySet()) {
bean = entry.getValue();
newPartRev = bean.getNewPartRev();
oldPartRev = bean.getOldPartRev();
System.out.println(bean.getItem() + "BOMDifferenceBean:" + bean);
if (newPartRev == null && oldPartRev != null) {
zt2_MaterialNo_Old = oldPartRev.getProperty("zt2_MaterialNo");
object_desc_Old = oldPartRev.getProperty("object_desc");
num_Old = String.format("%.1f", bean.getOldQuantity());
bean.setParentPartRev(oldPartRev);
bean.setZt2_MaterialNo_Parent(zt2_MaterialNo_Old);
bean.setObject_desc_Parent(object_desc_Old);
rev = bean.getOldRev();
compareBean = new BOMCompareBean("物料删除", zt2_MaterialNo_Parent, object_desc_Parent, zt2_MaterialNo_Old,
object_desc_Old, num_Old, "", "", "");
beans.add(compareBean);
// 物料删除遍历
bomCompare_M030(bean, session, 1, 1, beans, item_compares);
}
if (newPartRev != null && oldPartRev == null) {
// 物料新增 若变更项不为虚拟项则记录
zt2_MaterialNo_New = newPartRev.getProperty("zt2_MaterialNo");
object_desc_New = newPartRev.getProperty("object_desc");
num_New = String.format("%.1f", bean.getNewQuantity());
bean.setParentPartRev(newPartRev);
bean.setZt2_MaterialNo_Parent(zt2_MaterialNo_New);
bean.setObject_desc_Parent(object_desc_New);
compareBean = new BOMCompareBean("物料新增", zt2_MaterialNo_Parent, object_desc_Parent, "", "", "",
zt2_MaterialNo_New, object_desc_New, num_New);
beans.add(compareBean);
// 物料新增遍历
bomCompare_M030(bean, session, 1, 1, beans, item_compares);
}
if (newPartRev != null && oldPartRev != null) {
zt2_MaterialNo_New = newPartRev.getProperty("zt2_MaterialNo");
object_desc_New = newPartRev.getProperty("object_desc");
zt2_MaterialNo_Old = oldPartRev.getProperty("zt2_MaterialNo");
object_desc_Old = oldPartRev.getProperty("object_desc");
if (newPartRev != oldPartRev) {
// 物料变更
num_New = String.format("%.1f", bean.getNewQuantity());
num_Old = String.format("%.1f", bean.getOldQuantity());
compareBean = new BOMCompareBean("物料数量变更", zt2_MaterialNo_Parent, object_desc_Parent,
zt2_MaterialNo_Old, object_desc_Old, num_Old, zt2_MaterialNo_New, object_desc_New, num_New);
beans.add(compareBean);
// 物料新增遍历
bomCompare_M030(bean, session, 1, 1, beans, item_compares);
} else {
if (bean.getOldQuantity() > bean.getNewQuantity()) {
System.out.println("物料数量变更-删除-" + bean.getItem());
num_New = String.format("%.1f", bean.getNewQuantity());
num_Old = String.format("%.1f", bean.getOldQuantity());
compareBean = new BOMCompareBean("物料数量变更", zt2_MaterialNo_Parent, object_desc_Parent,
zt2_MaterialNo_Old, object_desc_Old, num_Old, zt2_MaterialNo_New, object_desc_New,
num_New);
beans.add(compareBean);
}
// 物料数量变更->新增
if (bean.getOldQuantity() < bean.getNewQuantity()) {
System.out.println("物料数量变更-新增" + bean.getItem());
num_New = String.format("%.1f", bean.getNewQuantity() - bean.getOldQuantity());
num_Old = String.format("%.1f", bean.getOldQuantity());
compareBean = new BOMCompareBean("物料新增", zt2_MaterialNo_Parent, object_desc_Parent,
zt2_MaterialNo_Old, object_desc_New, num_Old, zt2_MaterialNo_New, object_desc_New,
num_New);
beans.add(compareBean);
}
bomCompare_M030(bean, session, 1, 1, beans, item_compares);
}
}
}
}
}

@ -0,0 +1,342 @@
/**
* Copyright 2024 eSunny Info. Tech Ltd. All rights reserved.
*
* @Package: com.chint.plm.createbomdifference
* @author: cyh
* @date: 2024112 3:34:11
*/
package com.chint.plm.createbomdifference;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
import com.chint.plm.createEcn.Util;
import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.yunpi.KCommand;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
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.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentRevisionRule;
import com.teamcenter.rac.kernel.TCComponentRevisionRuleType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
/**
* @author cyh BOM
*/
public class ExtractDiffComd extends KCommand {
// 更改单的类型
public static final String ZT_CHANGE = "ZT2_Change";
// 更改前关系文件夹
public static final String ZT_CHANGE_BEF = "ZT2_ChangeBefore";
// 更改后关系文件夹
public static final String ZT_CHANGE_AFT = "ZT2_ChangeAfter";
public static final String ZT_DESIGN3D = "ZT2_Design3DRevision";
public static final String ITEM_REV_ID = "item_revision_id";
public static final String REF_LIST = "ref_list";
public static final String REPRESENTATION_FOR = "representation_for";
private TCSession session;
/**
* @param app
* @param commandId
* @param actionInfo
* @function
*/
public ExtractDiffComd(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
try {
InterfaceAIFComponent target = app.getTargetComponent();
this.session = (TCSession) app.getSession();
ResourceBundle resource = ResourceBundle.getBundle("com.chint.plm.createbomdifference.Message",
Locale.getDefault());
if (target == null || !target.getType().equals(ZT_CHANGE)) {
MessageBox.post(resource.getString("ERROR_NOT_CHANGE"), "", 2);
return;
}
TCComponent tar = (TCComponent) target;
TCComponent[] oldComponents = tar.getRelatedComponents(ZT_CHANGE_BEF);
TCComponent[] newComponents = tar.getRelatedComponents(ZT_CHANGE_AFT);
if (oldComponents.length == 0 && newComponents.length == 0) {
MessageBox.post(resource.getString("ERROR_NO_CHANGE"), "", 2);
return;
}
readChangeDesign(oldComponents, newComponents, tar);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
*
*
* @param oldComponents
* @param newComponents
* @param tar
* @throws TCException
* @function
*/
private void readChangeDesign(TCComponent[] oldComponents, TCComponent[] newComponents, TCComponent tar)
throws TCException {
// TODO Auto-generated method stub
Map<TCComponentItem, ChangeDesignBean> itemChangeMap = new HashMap<>();
for (TCComponent oldComponent : oldComponents) {
if (oldComponent.getType().equals(ZT_DESIGN3D)) {
TCComponentItemRevision rev = (TCComponentItemRevision) oldComponent;
TCComponentItem item = rev.getItem();
if (itemChangeMap.containsKey(item)) {
itemChangeMap.get(item).setOldDesgin(rev);
} else {
ChangeDesignBean changeDesignBean = new ChangeDesignBean();
changeDesignBean.setOldDesgin(rev);
itemChangeMap.put(item, changeDesignBean);
}
}
}
for (TCComponent newComponent : newComponents) {
if (newComponent.getType().equals(ZT_DESIGN3D)) {
TCComponentItemRevision rev = (TCComponentItemRevision) newComponent;
TCComponentItem item = rev.getItem();
if (itemChangeMap.containsKey(item)) {
itemChangeMap.get(item).setNewDesgin(rev);
} else {
ChangeDesignBean changeDesignBean = new ChangeDesignBean();
changeDesignBean.setNewDesgin(rev);
itemChangeMap.put(item, changeDesignBean);
}
}
}
// 遍历检查变更前后图纸版本数量是否对应,不对应添加到变更前、后
for (TCComponentItem keyItem : itemChangeMap.keySet()) {
ChangeDesignBean changeDesignBean = itemChangeMap.get(keyItem);
TCComponentItemRevision newDesgin = changeDesignBean.getNewDesgin();
if (newDesgin == null) {
TCComponentItemRevision latestItemRevision = keyItem.getLatestItemRevision();
changeDesignBean.setNewDesgin(latestItemRevision);
tar.add(ZT_CHANGE_AFT, latestItemRevision);
}
if (changeDesignBean.getOldDesgin() == null) {
String revId = newDesgin.getProperty(ITEM_REV_ID);
TCComponent[] refs = keyItem.getReferenceListProperty("revision_list");
for (TCComponent ref : refs) {
String property = ref.getProperty(ITEM_REV_ID);
System.out.println("property===>" + property);
if (revId.equals(property)) {
break;
}
changeDesignBean.setOldDesgin((TCComponentItemRevision) ref);
}
System.out.println("changeDesignBean.getOldDesgin()===>" + changeDesignBean.getOldDesgin());
tar.add(ZT_CHANGE_BEF, changeDesignBean.getOldDesgin());
}
}
// 获取图纸下的物料比较BOM视图信息
for (TCComponentItem keyItem : itemChangeMap.keySet()) {
ChangeDesignBean changeDesignBean = itemChangeMap.get(keyItem);
TCComponentItemRevision oldDesgin = changeDesignBean.getOldDesgin();
Map<String, PBomBean> materialOld = getMaterialByDesign(oldDesgin);
TCComponentItemRevision newDesgin = changeDesignBean.getNewDesgin();
Map<String, PBomBean> materialNew = getMaterialByDesign(newDesgin);
System.out.println("materialOld===>" + materialOld.toString());
System.out.println("materialNew===>" + materialNew.toString());
// 比较变更前后物料BOM
for (String materialNo : materialOld.keySet()) {
if (!materialNew.containsKey(materialNo))
continue;
PBomBean pBomBeanOld = materialOld.get(materialNo);
PBomBean pBomBeanNew = materialNew.get(materialNo);
// 有P物料获取P没有遍历EBOM
TCComponent oldMaterial = pBomBeanOld.getpMaterial() == null ? pBomBeanOld.geteMaterial()
: pBomBeanOld.getpMaterial();
TCComponent newMaterial = pBomBeanNew.getpMaterial() == null ? pBomBeanNew.geteMaterial()
: pBomBeanNew.getpMaterial();
// 全展开之后比较单层物料编码的数量
// 旧的bom修改版本规则
TCComponentBOMLine oldBomLine = sendToStructureManager((TCComponentItemRevision) oldMaterial,
Util.REVISION_RULE_ANY);
TCComponentBOMLine newBomLine = sendToStructureManager((TCComponentItemRevision) newMaterial, null);
// BOM全展开
Map<String, ExpandPSData[]> oldBomMap = BomToSapUtil.getBomLineTreeNodeSOA(oldBomLine);
Map<String, ExpandPSData[]> newBomMap = BomToSapUtil.getBomLineTreeNodeSOA(newBomLine);
addChangeBom(oldBomMap, oldBomLine, newBomMap, newBomLine, tar);
System.out.println("oldBomMap===>" + oldBomMap.toString());
System.out.println("newBomMap===>" + newBomMap.toString());
}
}
System.out.println("itemChangeMap===>" + itemChangeMap.toString());
}
/**
* BOM
*
* @param oldBomMap
* @param oldBomLine
* @param newBomMap
* @param newBomLine BOM
* @param changeTag
* @throws TCException
* @function
*/
private void addChangeBom(Map<String, ExpandPSData[]> oldBomMap, TCComponentBOMLine oldBomLine,
Map<String, ExpandPSData[]> newBomMap, TCComponentBOMLine newBomLine, TCComponent changeTag)
throws TCException {
// TODO Auto-generated method stub
String oldUid = oldBomLine.getUid();
ExpandPSData[] expandPSDatasOld = oldBomMap.get(oldUid);
ExpandPSData[] expandPSDatasNew = newBomMap.get(newBomLine.getUid());
if (expandPSDatasNew.length == 0 && expandPSDatasOld.length == 0) {
return;
}
Map<String, Double> oldMaterialMap = new HashMap<>();
Map<String, Double> newMaterialMap = new HashMap<>();
// 记录变更前的物料编码和对应的BOM
Map<String, TCComponentBOMLine> oldBomLineMap = new HashMap<>();
for (ExpandPSData expandPSData : expandPSDatasOld) {
TCComponentBOMLine bomLine = expandPSData.bomLine;
TCComponentItemRevision itemRevOfBOMLine = expandPSData.itemRevOfBOMLine;
// 记录变更前物料编码和数量
String materialNo = itemRevOfBOMLine.getProperty(Util.ZT_MATERIAL_NO);
String blQty = bomLine.getProperty(Util.BL_QTY);
if (blQty.isEmpty()) {
blQty = "0";
}
oldBomLineMap.put(materialNo, bomLine);
if (oldMaterialMap.containsKey(materialNo)) {
oldMaterialMap.put(materialNo, oldMaterialMap.get(materialNo) + Double.parseDouble(blQty));
} else {
oldMaterialMap.put(materialNo, Double.parseDouble(blQty));
}
}
for (ExpandPSData expandPSData : expandPSDatasNew) {
TCComponentBOMLine bomLine = expandPSData.bomLine;
TCComponentItemRevision itemRevOfBOMLine = expandPSData.itemRevOfBOMLine;
// 记录变更后物料编码和数量
String materialNo = itemRevOfBOMLine.getProperty(Util.ZT_MATERIAL_NO);
String blQty = bomLine.getProperty(Util.BL_QTY);
if (blQty.isEmpty()) {
blQty = "0";
}
if (newMaterialMap.containsKey(materialNo)) {
newMaterialMap.put(materialNo, newMaterialMap.get(materialNo) + Double.parseDouble(blQty));
} else {
newMaterialMap.put(materialNo, Double.parseDouble(blQty));
}
if (oldBomLineMap.containsKey(materialNo)) {
System.out.println("oldBom===>" + oldBomLineMap.get(materialNo));
System.out.println("bomLine===>" + bomLine);
addChangeBom(oldBomMap, oldBomLineMap.get(materialNo), newBomMap, bomLine, changeTag);
}
}
// 对比前后物料编码对应的数量是不是一样
if (oldMaterialMap.size() != newMaterialMap.size()) {
try {
// 添加到变更单中
System.out.println("oldMaterialMap1===>" + oldMaterialMap.toString());
System.out.println("newMaterialMap1===>" + newMaterialMap.toString());
changeTag.add(ZT_CHANGE_BEF, oldBomLine.getItemRevision());
changeTag.add(ZT_CHANGE_AFT, newBomLine.getItemRevision());
} catch (Exception e) {
}
} else {
for (String materNo : oldMaterialMap.keySet()) {
Double double1 = oldMaterialMap.get(materNo);
if (!newMaterialMap.containsKey(materNo) || newMaterialMap.get(materNo).doubleValue() != double1.doubleValue()) {
try {
System.out.println("oldMaterialMap2===>" + oldMaterialMap.toString());
System.out.println("newMaterialMap2===>" + newMaterialMap.toString());
changeTag.add(ZT_CHANGE_BEF, oldBomLine.getItemRevision());
changeTag.add(ZT_CHANGE_AFT, newBomLine.getItemRevision());
} catch (Exception e) {
}
}
}
}
}
/**
*
*
* @param tcComponentItem
* @param revisionRuleName
* @return
*/
public TCComponentBOMLine sendToStructureManager(TCComponentItemRevision tcComponentItemRev,
String revisionRuleName) {
try {
TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow bomWindow = bomWindowType.create(null);
if (revisionRuleName != null) {
TCComponentRevisionRule[] listAllRules = TCComponentRevisionRule.listAllRules(session);
for (TCComponentRevisionRule rule : listAllRules) {
if (rule.toString().equals(revisionRuleName)) {
bomWindow.setRevisionRule(rule);
}
}
}
return bomWindow.setWindowTopLine(null, tcComponentItemRev, null, null);
} catch (TCException e) {
e.printStackTrace();
return null;
}
}
/**
* , PP
*
* @param designRev
* @throws TCException
* @function
*/
private Map<String, PBomBean> getMaterialByDesign(TCComponentItemRevision designRev) throws TCException {
// TODO Auto-generated method stub
Map<String, PBomBean> pbomMap = new HashMap<>();
// 图纸下物料
TCComponent[] represents = designRev.getReferenceListProperty(REPRESENTATION_FOR);
for (TCComponent represent : represents) {
String[] matnrProps = represent
.getProperties(new String[] { Util.ZT_MATERIAL_NO, Util.ZT_PROP_PBOM, Util.ITEM_REVIISON_ID });
String materialNo = matnrProps[0];// material.getProperty(Util.ZT_MATERIAL_NO);
if (pbomMap.containsKey(materialNo)) {
PBomBean pBomBean = pbomMap.get(materialNo);
// 是否PBOM
if (matnrProps[1].equals(Util.ZT_VAL_PBOM) && matnrProps[2].compareTo(pBomBean.getpRevision()) > 0) {
pBomBean.setpMaterial(represent);
pBomBean.setpRevision(matnrProps[2]);
} else if (!matnrProps[1].equals(Util.ZT_VAL_PBOM)
&& matnrProps[2].compareTo(pBomBean.geteRevision()) > 0) {
pBomBean.seteMaterial(represent);
pBomBean.seteRevision(matnrProps[2]);
}
} else {
PBomBean pBomBean = new PBomBean();
if (matnrProps[1].equals(Util.ZT_VAL_PBOM)) {
pBomBean.setpMaterial(represent);
pBomBean.setpRevision(matnrProps[2]);
} else {
pBomBean.seteMaterial(represent);
pBomBean.seteRevision(matnrProps[2]);
}
pbomMap.put(materialNo, pBomBean);
}
}
return pbomMap;
}
}

@ -0,0 +1,2 @@
ERROR_NOT_CHANGE=\u8BF7\u9009\u62E9\u66F4\u6539\u901A\u77E5\u5355\u5BF9\u8C61
ERROR_NO_CHANGE=\u672A\u627E\u5230\u53D8\u66F4\u524D\u540E\u5BF9\u8C61,\u65E0\u6CD5\u63D0\u53D6\u5DEE\u5F02\u9879\uFF01

@ -0,0 +1,53 @@
/**
* Copyright 2024 eSunny Info. Tech Ltd. All rights reserved.
*
* @Package: com.chint.plm.createbomdifference
* @author: cyh
* @date: 2024110 2:21:11
*/
package com.chint.plm.createbomdifference;
import com.teamcenter.rac.kernel.TCComponent;
/**
* @author cyh
*
*/
public class PBomBean {
//记录 E物料 和 P物料 相同物料编码
private TCComponent eMaterial;
private String eRevision = "";
private TCComponent pMaterial;
private String pRevision = "";
@Override
public String toString() {
return "PBomBean [eMaterial=" + eMaterial + ", eRevision=" + eRevision + ", pMaterial=" + pMaterial
+ ", pRevision=" + pRevision + "]";
}
public String geteRevision() {
return eRevision;
}
public void seteRevision(String eRevision) {
this.eRevision = eRevision;
}
public String getpRevision() {
return pRevision;
}
public void setpRevision(String pRevision) {
this.pRevision = pRevision;
}
public TCComponent geteMaterial() {
return eMaterial;
}
public void seteMaterial(TCComponent eMaterial) {
this.eMaterial = eMaterial;
}
public TCComponent getpMaterial() {
return pMaterial;
}
public void setpMaterial(TCComponent pMaterial) {
this.pMaterial = pMaterial;
}
}

@ -0,0 +1,49 @@
package com.chint.plm.createbomdifference;
public class YCLMaterialBean {
private String materialNo; // 昜蹋晤鎢
private String materialutilization; // 第蹋瞳蚚薹
private String materialunit; // 埻第蹋等弇
private String materialmark; // 第蹋梓暮
public String getMaterialNo() {
return materialNo;
}
public void setMaterialNo(String materialNo) {
this.materialNo = materialNo;
}
public String getMaterialutilization() {
return materialutilization;
}
public void setMaterialutilization(String materialutilization) {
this.materialutilization = materialutilization;
}
public String getMaterialunit() {
return materialunit;
}
public void setMaterialunit(String materialunit) {
this.materialunit = materialunit;
}
public String getMaterialmark() {
return materialmark;
}
public void setMaterialmark(String materialmark) {
this.materialmark = materialmark;
}
public YCLMaterialBean(String materialNo, String materialutilization, String materialunit, String materialmark) {
super();
this.materialNo = materialNo;
this.materialutilization = materialutilization;
this.materialunit = materialunit;
this.materialmark = materialmark;
}
}

@ -0,0 +1,120 @@
/**
* Copyright 2023 eSunny Info. Tech Ltd. All rights reserved.
*
* @Package: com.chint.plm.extractDraw
* @author: cyh
* @date: 20231225 4:38:03
*/
package com.chint.plm.extractdraw;
import java.util.List;
import com.chint.plm.createEcn.CreateEcnFrame;
import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.SAPMessageUtilFram;
import com.connor.chint.yunpi.KCommand;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
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.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCUserService;
import com.teamcenter.rac.util.MessageBox;
/**
* @author cyh
*/
public class ExtractDrawComd extends KCommand {
/**
* @param app
* @param commandId
* @param actionInfo
* @function
*/
public ExtractDrawComd(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
try {
TCSession session = (TCSession) app.getSession();
InterfaceAIFComponent targetComponent = app.getTargetComponent();
if (targetComponent.getType().equals("ZT2_Design3DRevision")) {
new Thread() {
@Override
public void run() {
MyProgressBarCompent my = new MyProgressBarCompent("", "一键提取图纸中......");
try {
// 版本获取所在的文件夹
TCComponentItemRevision itemRev = (TCComponentItemRevision) targetComponent;
TCComponentItem item = itemRev.getItem();
AIFComponentContext[] projectFolders = item.whereReferenced();
TCComponent projectFolder = null;
for (AIFComponentContext context : projectFolders) {
if (context.getComponent().getType().equals("ZT2_ProjectFolder")) {
projectFolder = (TCComponent) context.getComponent();
}
}
System.out.println("projectFolders====>" + projectFolders.length);
System.out.println("projectFolder====>" + projectFolder);
if (projectFolder != null) {
// 根据对象获取BOM
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session
.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null);
TCComponentItemRevision rev = (TCComponentItemRevision) itemRev;
win.setWindowTopLine(rev.getItem(), rev, null, null);
TCComponentBOMLine bomline = win.getTopBOMLine();
// 遍历BOM
List<TCComponentItemRevision> childLines = BomToSapUtil.getBomLineTreeNodeSOA2(bomline);
childLines.add(rev);
System.out.println("childLines====>" + childLines);
// 过滤2ZDB开头的数据 获取PDF文件 提取到projectFolder下
for (TCComponentItemRevision childLine : childLines) {
if (childLine.getProperty("item_id").startsWith("2ZD")) {
continue;
}
TCComponent[] datasets = childLine.getRelatedComponents("IMAN_specification");
for (TCComponent dataset : datasets) {
String dsType = dataset.getProperty("object_type");
if (dsType.equals("PDF")) {
try {
projectFolder.add("contents", dataset);
} catch (Exception e) {
// 文件夹已经存在就跳过
}
}
}
}
win.close();
}
my.setVisible(false);
MessageBox.post("一键提取完成....", "", MessageBox.INFORMATION);
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (my != null) {
my.setVisible(false);
}
}
}.start();
// new CreateEcnFrame();
} else {
MessageBox.post("请选中图纸版本执行功能..", "", MessageBox.ERROR);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -151,29 +151,19 @@ public class MySceneController extends KFXPanelController {
private String updMsgString = "UPDATE CHINT_CHECK_DETAILS SET designresult = ?,proofreadresult = ?,design = ?,proofread = ?,\"AUDIT\" = ? where checkno = ? and no = ? and modelversion = ? and numberofchecks = ? ";
private String getTempString = "SELECT no,imcheckproject,ipcheckdetials,designresultrule,proofreadresultrule,designrule,proofreadrule,auditrule"
+ " FROM CHINT_CHECK_DETAILS_TEMPLATE where code = ? and modelversion = ? order by no asc";
// @FXML
// public void tableClick(MouseEvent event) {
//
// }
// @FXML
// void queryBtnClick(ActionEvent event) {
//// table.get
// System.out.println("clickBtn1");
// //有个变量判断是否第一次插入
// }
// private String updMsgString = "UPDATE CHINT_CHECK_DETAILS SET designresult = ?,proofreadresult = ?,design = ?,proofread = ?,audit = ? where checkno = ? and no = ? and modelversion = ? ";
// private String addMsgString = "INSERT INTO CHINT_CHECK_DETAILS (no,imcheckproject,ipcheckdetials,designresult,proofreadresult,design,proofread,"
// + "audit,checkno,modelversion) VALUES (?,?,?,?,?,?,?,?,?,?)";
//更新校对、审核、设计
private String upRowStrin2 = "UPDATE CHINT_CHECK_TITLE set datastatus = ?,PROOFREADISSUE = ?,AUDITISSUE = ?,DESIGNISSUE = ? ,"
+ " PROOFREADDATE = to_date(?,'yyyy-mm-ddhh24:mi:ss') where checkno = ? and modelversion = ? and numberofchecks = ? ";
private String upRowStrin1 = "UPDATE CHINT_CHECK_TITLE set datastatus = ?,PROOFREADISSUE = ?,AUDITISSUE = ?,DESIGNISSUE = ? ,"
+ " DESIGNDATE = to_date(?,'yyyy-mm-ddhh24:mi:ss') where checkno = ? and modelversion = ? and numberofchecks = ? ";
private String upRowStrin3 = "UPDATE CHINT_CHECK_TITLE set datastatus = ?,PROOFREADISSUE = ?,AUDITISSUE = ?,DESIGNISSUE = ? ,"
+ " AUDITDATE = to_date(?,'yyyy-mm-ddhh24:mi:ss') where checkno = ? and modelversion = ? and numberofchecks = ? ";
//新增
private String insertRow = "INSERT into CHINT_CHECK_TITLE (checkno,code,modelversion,name,"
+ "drawingno,spec,datastatus,createdate,owninguser,modedate,designdate,numberofchecks,PROOFREADISSUE,AUDITISSUE,DESIGNISSUE,drawingversion)"
+ " VALUES (?,?,?,?,?,?,?,to_date(?,'yyyy-mm-ddhh24:mi:ss'),?,to_date(?,'yyyy-mm-ddhh24:mi:ss'),to_date(?,'yyyy-mm-ddhh24:mi:ss'),'1',?,?,?,?) ";
//查询模板
private String selectTitle = "select * from CHINT_CHECK_TITLE where checkno = ? and modelversion=? and numberofchecks = ? ";
void saveRows(String checkno,String modelversion,String type,String str_jclx,String str_thqd) {
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
@ -467,7 +457,7 @@ public class MySceneController extends KFXPanelController {
}
@FXML
private TabPane TestPane;
private String bhSql = "select CODE,DRAWINGNO,name,modelversion from CHINT_CHECK_TITLE_TEMPLATE";
private String bhSql = "select CODE,DRAWINGNO,name,modelversion from CHINT_CHECK_TITLE_TEMPLATE order by modelversion desc";
private JDBFrame dialog;
protected AbstractAIFApplication app;
protected TCSession session;
@ -522,18 +512,7 @@ public class MySceneController extends KFXPanelController {
}
});
// frame.addComponentListener(new ComponentAdapter() {//让窗口响应大小改变事件
// @Override
// public void componentResized(ComponentEvent e) {
// double width = scene.getWidth();;//获取面板宽度
//// double width = primaryStage.getWidth();
// System.out.println("==============");
// System.out.println("width==>"+width+"dialog"+dialog.getPreferredSize().getWidth());
// double width2 = scene.getWindow().getWidth();
// System.out.println("width2"+width2+"scollPane"+scollPane.getWidth()+"stackPane"+stackPane.getWidth());
//
// }
// });
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
@ -596,14 +575,26 @@ public class MySceneController extends KFXPanelController {
SqlUtil.getTCDataConnection(prefs);
ResultSet read = SqlUtil.read(bhSql);
//记录模板号和对应的图号
Map<String,String[]> drawCode = new HashMap<>();
//记录最新版本
Map<String,String> titleCodeMap = new HashMap<>();
while(read.next()) {
String code = read.getString(1);
String drawNo = read.getString(2);
String name = read.getString(3);
String modelversion = read.getString(4);
//模板升版之后 读取新的
if(titleCodeMap.containsKey(code)) {
continue;
}
titleCodeMap.put(code, modelversion);
if(!drawCode.containsKey(drawNo)) {
System.out.println("drawNo==>"+drawNo);
System.out.println("modelversion==>"+modelversion);
drawCode.put(drawNo, new String[] { code,name,modelversion});
}
}
SqlUtil.free();
System.out.println("drawCode==>"+drawCode.toString());
TCComponent[] attachments = task.getReferenceListProperty("root_target_attachments");

@ -66,7 +66,7 @@ public class BomToSapUtil {
List<TCComponentBOMLine> listBoms = new ArrayList<>();
try {
TCComponentItemRevision object = bomLine.getItemRevision();
String object_type = object.getType();
// String object_type = object.getType();
com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService
.getService(RACUIUtil.getTCSession());
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo levelInfo = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo();

@ -33,11 +33,50 @@ import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData
//import plm.xi.com.chintelectric.DT_PROCESSROUTE_S4_REQLISTITEMSITEMSUBITEMSSUBITEM;
public class BomUtilWh {
public static final String DATABASE_TC = "database_tc";
public static final String logSql = "insert into CHINT_BOM_TO_SAP_DETIALS (code,batchnumber,plmsendstatus,plmsendstarttime,factory,productmaterialno,pitemid,puid,materialno,wbsno,plmstatus) VALUES (?,?,'PLM开始传递',SYSDATE,?,?,?,?,?,?,'未处理') ";
public static final String WLLIST = "WLLIST";
public static final String WLCONTENTS = "WLCONTENTS";
public static final String WH_FACOTRY = "M060";
public static final String PARENTTCID = "PARENTTCID";
public static final String PARENTWLBM = "PARENTWLBM";
public static final String SPLIT_MSG = "/";
public static final String UID = "UID";
/**
* BOMDETAILS
*
* @param document XML Element INTERGRATIONLIST WLLIST WLCONTENTS BOM
* @param code CODE
* @param productNos
* @function
*/
public static void logXmlMsg(Document interGrationList, String code, String productNos, String batchNo,
String wbsNo, TCSession session) {
String strs[] = session.getPreferenceService().getStringValues(DATABASE_TC);
SqlUtil.getTCDataConnection(strs);
try {
Element rootElement = interGrationList.getRootElement();
// 物料信息
Element element = rootElement.element(WLLIST);
List<Element> elements = element.elements(WLCONTENTS);
for (Element content : elements) {
// 记录TCid UID 物料编码
String tcId = content.elementText(PARENTTCID);
String[] split = tcId.split(SPLIT_MSG);
String parentMantrNo = content.elementText(PARENTWLBM);
String uid = content.elementText(UID);
SqlUtil.write(logSql,
new String[] { code, batchNo, WH_FACOTRY, productNos, split[0], uid, parentMantrNo, wbsNo });
}
} catch (Exception e) {
e.printStackTrace();
} finally {
SqlUtil.freeAll();
}
}
private static ArrayList<String> lists2 = new ArrayList<String>(){{
add("PDF");
add("MS WordX");add("MS ExcelX");add("MS Excel");add("MS Word");
}};
private static ArrayList<String> lists2=new ArrayList<String>(){{add("PDF");add("MS WordX");add("MS ExcelX");add("MS Excel");add("MS Word");}};
// public static String getXML(String parameters){
// String soapXML = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" "
// + "xmlns:web=\"http://webservice.core.intf.mes.xinhua.com/\"> "
@ -105,10 +144,12 @@ public class BomUtilWh {
ls.add(dsList2);
return ls;
}
// 获取二级工序 BOPLIST BOPCONTENTS
public static void getProcess(TCComponentMEProcessRevision rev, TCComponentItemRevision partRev,
TCSession session, String now, String txtPath, String groupName,
Map<String, TCComponent> gy_meops, List<TCComponentMEProcessRevision> needTCM_meops,Element BOPLIST,Element SONLIST,Integer valueOf) throws Exception {
public static void getProcess(TCComponentMEProcessRevision rev, TCComponentItemRevision partRev, TCSession session,
String now, String txtPath, String groupName, Map<String, TCComponent> gy_meops,
List<TCComponentMEProcessRevision> needTCM_meops, Element BOPLIST, Element SONLIST, Integer valueOf)
throws Exception {
String zt2_MaterialNo = partRev.getProperty("zt2_MaterialNo");
if (KUtil.isTCM(rev))
@ -124,7 +165,8 @@ public class BomUtilWh {
TCComponentBOPWindowType bopWindowType = (TCComponentBOPWindowType) session.getTypeComponent("BOPWindow");
TCComponentBOPWindow window = (TCComponentBOPWindow) bopWindowType.create(null);
TCComponentBOMLine topLine = window.setWindowTopLine(rev.getItem(), rev, null, null);
String[] properties = rev.getProperties(new String[] {"item_id","item_revision_id","object_name","zt2_Source"} );
String[] properties = rev
.getProperties(new String[] { "item_id", "item_revision_id", "object_name", "zt2_Source" });
Element BOPCONTENTS = BOPLIST.addElement("BOPCONTENTS");
String boptcId = properties[0] + "/" + properties[1];
String bopName = properties[2];
@ -154,7 +196,8 @@ public class BomUtilWh {
String fileName = ds.getProperty("object_name");
String fileType = "文件";
String fileUid = ds.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId);
FILECONTENTS.addElement("FILENAME").setText(fileName);
FILECONTENTS.addElement("FILETYPE").setText(fileType);
@ -169,14 +212,15 @@ public class BomUtilWh {
Element KJJDLIST = BOPCONTENTS.addElement("KJJDLIST");
readOneGx(expandPSDatas, partRev, now, bomLineTree, KJJDLIST, SONLIST, valueOf);
window.closeBOPWindow();
}
public static void readOneGx(ExpandPSData[] expandPSDatas,TCComponentItemRevision partRev,
String now,Map<String, ExpandPSData[]> bomLineTree,Element KJJDLIST,Element SONLIST,Integer valueOf) throws Exception {
public static void readOneGx(ExpandPSData[] expandPSDatas, TCComponentItemRevision partRev, String now,
Map<String, ExpandPSData[]> bomLineTree, Element KJJDLIST, Element SONLIST, Integer valueOf)
throws Exception {
List<FlowBean> flowBeans = new ArrayList<>();
List<TCComponentBOMLine> startLines = SAPUtil.getFlowStarts(expandPSDatas);
String p_uom = partRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase();
@ -221,11 +265,14 @@ public class BomUtilWh {
getGXInfo(bean, i, partRev, p_uom, now, bomLineTree, KJJDLIST, SONLIST, valueOf);
// ind = ind+1;
// }
//getGXInfo(bean, i, partRev, p_uom, now,bomLineTree,KJJDLIST,SONLIST, valueOf);
// getGXInfo(bean, i, partRev, p_uom, now,bomLineTree,KJJDLIST,SONLIST,
// valueOf);
}
}
public static void readTowGx(ExpandPSData[] expandPSDatas, TCComponentItemRevision partRev, String now,
Map<String, ExpandPSData[]> bomLineTree,Element OPLIST,Element SONLIST,Integer valueOf) throws Exception {
Map<String, ExpandPSData[]> bomLineTree, Element OPLIST, Element SONLIST, Integer valueOf)
throws Exception {
List<FlowBean> flowBeans = new ArrayList<>();
List<TCComponentBOMLine> startLines = SAPUtil.getFlowStarts(expandPSDatas);
String p_uom = partRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase();
@ -275,10 +322,11 @@ public class BomUtilWh {
}
}
}
// 读取二级工序 并行工序无后续
public static void getGXInfo2Comb(FlowBean bean, int index,
TCComponentItemRevision partRev, String p_uom, String now,Map<String, ExpandPSData[]> bomLineTree,
Element OPLIST,Element SONLIST,Integer valueOf,TCComponentBOMLine gxLine) throws Exception {
public static void getGXInfo2Comb(FlowBean bean, int index, TCComponentItemRevision partRev, String p_uom,
String now, Map<String, ExpandPSData[]> bomLineTree, Element OPLIST, Element SONLIST, Integer valueOf,
TCComponentBOMLine gxLine) throws Exception {
// DT_PROCESSROUTE_S4_REQLISTITEMSITEM item = new DT_PROCESSROUTE_S4_REQLISTITEMSITEM();
String plnal = "1";
String plnfl = String.format("%06d", index);
@ -333,9 +381,11 @@ public class BomUtilWh {
// }
// }
TCComponentItemRevision gxRev = gxLine.getItemRevision();
String[] properties2 = gxLine.getProperties(new String[] {"zt2_ControlCode","bl_ZT2_FirstOPRevision_zt2_ArtificialTime"
,"bl_ZT2_FirstOPRevision_zt2_MachineTime","bl_ZT2_FirstOPRevision_zt2_ReadinessTime","bl_ZT2_FirstOPRevision_zt2_ProCycle"});
String[] properties = gxRev.getProperties(new String[] {"item_id","item_revision_id","zt2_WorkCenter","object_name","zt2_ClassificationCode"});
String[] properties2 = gxLine.getProperties(new String[] { "zt2_ControlCode",
"bl_ZT2_FirstOPRevision_zt2_ArtificialTime", "bl_ZT2_FirstOPRevision_zt2_MachineTime",
"bl_ZT2_FirstOPRevision_zt2_ReadinessTime", "bl_ZT2_FirstOPRevision_zt2_ProCycle" });
String[] properties = gxRev.getProperties(new String[] { "item_id", "item_revision_id", "zt2_WorkCenter",
"object_name", "zt2_ClassificationCode" });
// DT_PROCESSROUTE_S4_REQLISTITEMSITEMSUBITEMSSUBITEM sub = new DT_PROCESSROUTE_S4_REQLISTITEMSITEMSUBITEMSSUBITEM();
// subItems.add(sub);
String kjjdId = properties[0] + "/" + properties[1];
@ -385,14 +435,15 @@ public class BomUtilWh {
if (remark.equals("ZT2_FuLiao") || remark.equals("辅料")) {
type = "2";
Element SONCONTENTS = SONLIST.addElement("SONCONTENTS");
String[] properties3 = itemRevOfBOMLine.getProperties(new String[] {"item_id","item_revision_id",
"zt2_MaterialNo","zt2_Quantity"});
String[] properties3 = itemRevOfBOMLine.getProperties(
new String[] { "item_id", "item_revision_id", "zt2_MaterialNo", "zt2_Quantity" });
SONCONTENTS.addElement("TCID").setText(properties3[0] + "/" + properties3[1]);
SONCONTENTS.addElement("WLBM").setText(properties3[2]);
SONCONTENTS.addElement("DATUV").setText(now);
String zysapmenge = getZYSAPMENGE(itemRevOfBOMLine, null, bomLine, false, "1", new StringBuffer());
SONCONTENTS.addElement("QUE").setText(zysapmenge);
SONCONTENTS.addElement("QUIT").setText(itemRevOfBOMLine.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
SONCONTENTS.addElement("QUIT")
.setText(itemRevOfBOMLine.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
SONCONTENTS.addElement("SORTF");
valueOf = valueOf + 10;
SONCONTENTS.addElement("SEQID").setText(valueOf.toString());
@ -416,7 +467,8 @@ public class BomUtilWh {
String fileName = ds.getProperty("object_name");
String fileType = "文件";
String fileUid = ds.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId);
FILECONTENTS.addElement("FILENAME").setText(fileName);
FILECONTENTS.addElement("FILETYPE").setText(fileType);
@ -449,7 +501,8 @@ public class BomUtilWh {
fileType = "xlsx";
}
String fileUid = dataset.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId + "/" + fileRevId);
FILECONTENTS.addElement("FILENAME").setText(fileName);
FILECONTENTS.addElement("FILETYPE").setText(fileType);
@ -461,7 +514,6 @@ public class BomUtilWh {
}
}
Element OPGXZYZDSFILELIST = OPCONTENTS.addElement("OPGXZYZDSFILELIST");
TCComponentItem procGuidBook = (TCComponentItem) gxRev.getRelatedComponent("ZT2_ProcGuidBookRelation");
System.out.println("gxRev===========>" + gxRev + "procGuidBook======>" + procGuidBook);
@ -488,7 +540,8 @@ public class BomUtilWh {
fileType = "xlsx";
}
String fileUid = dataset.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId + "/" + fileRevId);
FILECONTENTS.addElement("FILENAME").setText(fileName);
FILECONTENTS.addElement("FILETYPE").setText(fileType);
@ -511,13 +564,15 @@ public class BomUtilWh {
// item.setSUBITEMS(subItems.toArray(new DT_PROCESSROUTE_S4_REQLISTITEMSITEMSUBITEMSSUBITEM[] {}));
// return item;
}
// 读取质量检验项
public static void getZljyxInfo2(Element OPCHECKCONTENTS, TCComponentItemRevision gxRev) {
// 质量检验项关系文件夹
try {
TCComponent[] quantityChecks = gxRev.getRelatedComponents("ZT2_QualityCheckRelation");
if (quantityChecks.length > 0) {
String[] properties3 = gxRev.getProperties(new String[] {"item_id","item_revision_id","object_name"});
String[] properties3 = gxRev
.getProperties(new String[] { "item_id", "item_revision_id", "object_name" });
OPCHECKCONTENTS.addElement("PARENTTCID").setText(properties3[0] + "/" + properties3[1]);
OPCHECKCONTENTS.addElement("PARENTNAME").setText(properties3[2]);
OPCHECKCONTENTS.addElement("OTHER1").setText("OTHER1");
@ -529,10 +584,10 @@ public class BomUtilWh {
List<QCheckBean> beans = new ArrayList<QCheckBean>();
for (TCComponent zt2_QCheck : zt2_QChecks) {
// 质量检验项信息
String[] properties = zt2_QCheck.getProperties(new String[] {"zt2_code","zt2_jjxbh","zt2_jyxmc","zt2_jyxsjjg"
,"zt2_bzgcsxbh","zt2_bzgcsx","zt2_bzgcxxbh","zt2_bzgczxx"});
beans.add(new QCheckBean(properties[0],properties[1],
properties[2],properties[3],properties[4],properties[5],properties[6],properties[7]));
String[] properties = zt2_QCheck.getProperties(new String[] { "zt2_code", "zt2_jjxbh", "zt2_jyxmc",
"zt2_jyxsjjg", "zt2_bzgcsxbh", "zt2_bzgcsx", "zt2_bzgcxxbh", "zt2_bzgczxx" });
beans.add(new QCheckBean(properties[0], properties[1], properties[2], properties[3], properties[4],
properties[5], properties[6], properties[7]));
}
Collections.sort(beans, new Comparator<QCheckBean>() {
@ -560,10 +615,11 @@ public class BomUtilWh {
}
}
// 读取二级工序
public static void getGXInfo2(FlowBean bean, int index,
TCComponentItemRevision partRev, String p_uom, String now,Map<String, ExpandPSData[]> bomLineTree,
Element OPLIST,Element SONLIST,Integer valueOf) throws Exception {
public static void getGXInfo2(FlowBean bean, int index, TCComponentItemRevision partRev, String p_uom, String now,
Map<String, ExpandPSData[]> bomLineTree, Element OPLIST, Element SONLIST, Integer valueOf)
throws Exception {
// DT_PROCESSROUTE_S4_REQLISTITEMSITEM item = new DT_PROCESSROUTE_S4_REQLISTITEMSITEM();
String plnal = "1";
String plnfl = String.format("%06d", index);
@ -618,9 +674,11 @@ public class BomUtilWh {
}
}
TCComponentItemRevision gxRev = gxLine.getItemRevision();
String[] properties2 = gxLine.getProperties(new String[] {"zt2_ControlCode","bl_ZT2_FirstOPRevision_zt2_ArtificialTime"
,"bl_ZT2_FirstOPRevision_zt2_MachineTime","bl_ZT2_FirstOPRevision_zt2_ReadinessTime","bl_ZT2_FirstOPRevision_zt2_ProCycle"});
String[] properties = gxRev.getProperties(new String[] {"item_id","item_revision_id","zt2_WorkCenter","object_name","zt2_ClassificationCode"});
String[] properties2 = gxLine.getProperties(new String[] { "zt2_ControlCode",
"bl_ZT2_FirstOPRevision_zt2_ArtificialTime", "bl_ZT2_FirstOPRevision_zt2_MachineTime",
"bl_ZT2_FirstOPRevision_zt2_ReadinessTime", "bl_ZT2_FirstOPRevision_zt2_ProCycle" });
String[] properties = gxRev.getProperties(new String[] { "item_id", "item_revision_id", "zt2_WorkCenter",
"object_name", "zt2_ClassificationCode" });
// DT_PROCESSROUTE_S4_REQLISTITEMSITEMSUBITEMSSUBITEM sub = new DT_PROCESSROUTE_S4_REQLISTITEMSITEMSUBITEMSSUBITEM();
// subItems.add(sub);
String kjjdId = properties[0] + "/" + properties[1];
@ -670,14 +728,15 @@ public class BomUtilWh {
if (remark.equals("ZT2_FuLiao") || remark.equals("辅料")) {
type = "2";
Element SONCONTENTS = SONLIST.addElement("SONCONTENTS");
String[] properties3 = itemRevOfBOMLine.getProperties(new String[] {"item_id","item_revision_id",
"zt2_MaterialNo","zt2_Quantity"});
String[] properties3 = itemRevOfBOMLine.getProperties(
new String[] { "item_id", "item_revision_id", "zt2_MaterialNo", "zt2_Quantity" });
SONCONTENTS.addElement("TCID").setText(properties3[0] + "/" + properties3[1]);
SONCONTENTS.addElement("WLBM").setText(properties3[2]);
SONCONTENTS.addElement("DATUV").setText(now);
String zysapmenge = getZYSAPMENGE(itemRevOfBOMLine, null, bomLine, false, "1", new StringBuffer());
SONCONTENTS.addElement("QUE").setText(zysapmenge);
SONCONTENTS.addElement("QUIT").setText(itemRevOfBOMLine.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
SONCONTENTS.addElement("QUIT").setText(
itemRevOfBOMLine.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
SONCONTENTS.addElement("SORTF");
valueOf = valueOf + 10;
SONCONTENTS.addElement("SEQID").setText(valueOf.toString());
@ -701,7 +760,8 @@ public class BomUtilWh {
String fileName = ds.getProperty("object_name");
String fileType = "文件";
String fileUid = ds.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId);
FILECONTENTS.addElement("FILENAME").setText(fileName);
FILECONTENTS.addElement("FILETYPE").setText(fileType);
@ -734,7 +794,8 @@ public class BomUtilWh {
fileType = "xlsx";
}
String fileUid = dataset.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId + "/" + fileRevId);
FILECONTENTS.addElement("FILENAME").setText(fileName);
FILECONTENTS.addElement("FILETYPE").setText(fileType);
@ -746,7 +807,6 @@ public class BomUtilWh {
}
}
Element OPGXZYZDSFILELIST = OPCONTENTS.addElement("OPGXZYZDSFILELIST");
TCComponentItem procGuidBook = (TCComponentItem) gxRev.getRelatedComponent("ZT2_ProcGuidBookRelation");
System.out.println("gxRev===========>" + gxRev + "procGuidBook======>" + procGuidBook);
@ -773,7 +833,8 @@ public class BomUtilWh {
fileType = "xlsx";
}
String fileUid = dataset.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId + "/" + fileRevId);
FILECONTENTS.addElement("FILENAME").setText(fileName);
FILECONTENTS.addElement("FILETYPE").setText(fileType);
@ -796,10 +857,11 @@ public class BomUtilWh {
// item.setSUBITEMS(subItems.toArray(new DT_PROCESSROUTE_S4_REQLISTITEMSITEMSUBITEMSSUBITEM[] {}));
// return item;
}
// 读取一级工序
public static void getGXInfoComb(FlowBean bean, int index,
TCComponentItemRevision partRev, String p_uom, String now,Map<String, ExpandPSData[]> bomLineTree,
Element KJJDLIST,Element SONLIST,Integer valueOf,TCComponentBOMLine gxLine) throws Exception {
public static void getGXInfoComb(FlowBean bean, int index, TCComponentItemRevision partRev, String p_uom,
String now, Map<String, ExpandPSData[]> bomLineTree, Element KJJDLIST, Element SONLIST, Integer valueOf,
TCComponentBOMLine gxLine) throws Exception {
// DT_PROCESSROUTE_S4_REQLISTITEMSITEM item = new DT_PROCESSROUTE_S4_REQLISTITEMSITEM();
String plnal = "1";
String plnfl = String.format("%06d", index);
@ -841,9 +903,11 @@ public class BomUtilWh {
boolean inBx = bean.flow_split == null;
TCComponentItemRevision gxRev = gxLine.getItemRevision();
String[] properties2 = gxLine.getProperties(new String[] {"zt2_ControlCode","bl_ZT2_FirstOPRevision_zt2_ArtificialTime",
"bl_ZT2_FirstOPRevision_zt2_MachineTime","bl_ZT2_FirstOPRevision_zt2_ReadinessTime","bl_ZT2_FirstOPRevision_zt2_ProCycle"});
String[] properties = gxRev.getProperties(new String[] {"item_id","item_revision_id","zt2_WorkCenter","object_name","zt2_ClassificationCode"});
String[] properties2 = gxLine.getProperties(new String[] { "zt2_ControlCode",
"bl_ZT2_FirstOPRevision_zt2_ArtificialTime", "bl_ZT2_FirstOPRevision_zt2_MachineTime",
"bl_ZT2_FirstOPRevision_zt2_ReadinessTime", "bl_ZT2_FirstOPRevision_zt2_ProCycle" });
String[] properties = gxRev.getProperties(new String[] { "item_id", "item_revision_id", "zt2_WorkCenter",
"object_name", "zt2_ClassificationCode" });
// DT_PROCESSROUTE_S4_REQLISTITEMSITEMSUBITEMSSUBITEM sub = new DT_PROCESSROUTE_S4_REQLISTITEMSITEMSUBITEMSSUBITEM();
// subItems.add(sub);
String kjjdId = properties[0] + "/" + properties[1];
@ -886,7 +950,8 @@ public class BomUtilWh {
String fileName = ds.getProperty("object_name");
String fileType = "文件";
String fileUid = ds.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId);
FILECONTENTS.addElement("FILENAME").setText(fileName);
FILECONTENTS.addElement("FILETYPE").setText(fileType);
@ -900,10 +965,11 @@ public class BomUtilWh {
readTowGx(bomLineTree.get(gxLine.getUid()), gxRev, now, bomLineTree, OPLIST, SONLIST, valueOf);
// }
}
// 读取一级工序
public static void getGXInfo(FlowBean bean, int index,
TCComponentItemRevision partRev, String p_uom, String now,Map<String, ExpandPSData[]> bomLineTree,
Element KJJDLIST,Element SONLIST,Integer valueOf) throws Exception {
public static void getGXInfo(FlowBean bean, int index, TCComponentItemRevision partRev, String p_uom, String now,
Map<String, ExpandPSData[]> bomLineTree, Element KJJDLIST, Element SONLIST, Integer valueOf)
throws Exception {
// DT_PROCESSROUTE_S4_REQLISTITEMSITEM item = new DT_PROCESSROUTE_S4_REQLISTITEMSITEM();
String plnal = "1";
String plnfl = String.format("%06d", index);
@ -958,9 +1024,11 @@ public class BomUtilWh {
}
}
TCComponentItemRevision gxRev = gxLine.getItemRevision();
String[] properties2 = gxLine.getProperties(new String[] {"zt2_ControlCode","bl_ZT2_FirstOPRevision_zt2_ArtificialTime",
"bl_ZT2_FirstOPRevision_zt2_MachineTime","bl_ZT2_FirstOPRevision_zt2_ReadinessTime","bl_ZT2_FirstOPRevision_zt2_ProCycle"});
String[] properties = gxRev.getProperties(new String[] {"item_id","item_revision_id","zt2_WorkCenter","object_name","zt2_ClassificationCode"});
String[] properties2 = gxLine.getProperties(new String[] { "zt2_ControlCode",
"bl_ZT2_FirstOPRevision_zt2_ArtificialTime", "bl_ZT2_FirstOPRevision_zt2_MachineTime",
"bl_ZT2_FirstOPRevision_zt2_ReadinessTime", "bl_ZT2_FirstOPRevision_zt2_ProCycle" });
String[] properties = gxRev.getProperties(new String[] { "item_id", "item_revision_id", "zt2_WorkCenter",
"object_name", "zt2_ClassificationCode" });
// DT_PROCESSROUTE_S4_REQLISTITEMSITEMSUBITEMSSUBITEM sub = new DT_PROCESSROUTE_S4_REQLISTITEMSITEMSUBITEMSSUBITEM();
// subItems.add(sub);
String kjjdId = properties[0] + "/" + properties[1];
@ -1003,7 +1071,8 @@ public class BomUtilWh {
String fileName = ds.getProperty("object_name");
String fileType = "文件";
String fileUid = ds.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId);
FILECONTENTS.addElement("FILENAME").setText(fileName);
FILECONTENTS.addElement("FILETYPE").setText(fileType);
@ -1017,6 +1086,7 @@ public class BomUtilWh {
readTowGx(bomLineTree.get(gxLine.getUid()), gxRev, now, bomLineTree, OPLIST, SONLIST, valueOf);
}
}
public static void readGXFlow(TCComponentBOMLine gxLine, List<FlowBean> flowBeans, FlowBean currentFlow,
boolean isMainFlow) throws Exception {
TCComponent[] suc = gxLine.getReferenceListProperty("Mfg0successors");
@ -1046,6 +1116,7 @@ public class BomUtilWh {
}
readGXFlow((TCComponentBOMLine) suc[0], flowBeans, currentFlow, false);
}
// WBSList
public static void getWbsMsg2(TCComponentItemRevision pRev, String groupId, List<String> wbsList, Element WBSLIST) {
@ -1072,6 +1143,7 @@ public class BomUtilWh {
}
}
// WBSList
public static void getWbsMsg(TCComponentItemRevision pRev, String groupId, List<String> wbsList, Element WBSLIST) {
@ -1098,11 +1170,13 @@ public class BomUtilWh {
}
}
// 遍历产成品BOM 单层 没有BOM 和 文件跳过
public static void expandAllBomPartBj(Map<String, ExpandPSData[]> expands, TCComponentBOMLine pBomLine,
TCComponentItemRevision pRev,String groupName,List<String> wbsList,TCSession session,String now
,List<TCComponentMEProcessRevision> needTCM_meops,Map<String, TCComponent> gy_meops,
Element INTERGRATIONLIST,StringBuffer errMessage,List<TCComponentItem> cppRevision,String txtPath,Map<String, TCComponentItemRevision> material_revs) {
TCComponentItemRevision pRev, String groupName, List<String> wbsList, TCSession session, String now,
List<TCComponentMEProcessRevision> needTCM_meops, Map<String, TCComponent> gy_meops,
Element INTERGRATIONLIST, StringBuffer errMessage, List<TCComponentItem> cppRevision, String txtPath,
Map<String, TCComponentItemRevision> material_revs) {
try {
String uid = pBomLine.getUid();
@ -1133,7 +1207,8 @@ public class BomUtilWh {
}
Element WLCONTENTS = WLLIST.addElement("WLCONTENTS"); // 文件信息
Element TCID = WLCONTENTS.addElement("TCID");
String[] properties = pRev.getProperties(new String[] {"item_id","item_revision_id","zt2_MaterialNo","zt2_Quantity","zt2_State"});
String[] properties = pRev.getProperties(
new String[] { "item_id", "item_revision_id", "zt2_MaterialNo", "zt2_Quantity", "zt2_State" });
TCID.setText(properties[0] + "/" + properties[1]);
@ -1152,7 +1227,8 @@ public class BomUtilWh {
String fileName = ds.getProperty("object_name");
String fileType = "文件";
String fileUid = ds.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId + "/" + fileRevId);
// <ID>图号</ID>(文件载体item_id)
// <NAME>图纸名称</NAME>(文件载体object_name
@ -1173,7 +1249,8 @@ public class BomUtilWh {
String fileName = ds.getProperty("object_name");
String fileType = "文件";
String fileUid = ds.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId + "/" + fileRevId);
// <ID>图号</ID>(文件载体item_id)
// <NAME>图纸名称</NAME>(文件载体object_name
@ -1195,10 +1272,11 @@ public class BomUtilWh {
BOMCONTENTS.addElement("STLAN").setText("1");
BOMCONTENTS.addElement("STLAL").setText("1"); // <QUANTITY>基本数量</QUANTITY>
BOMCONTENTS.addElement("QUANTITY").setText(properties[3]);
BOMCONTENTS.addElement("QUIT").setText(pRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
BOMCONTENTS.addElement("QUIT")
.setText(pRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
Element SONLIST = BOMCONTENTS.addElement("SONLIST");
// 获取工艺信息 BOPLIST BOPCONTENTS ()二级工序下的辅料放到子件
String maxSeq = "";
String maxSeq = "10";
System.out.println("=========getProcess over========" + pRev);
for (int i = 0; i < expandPSDatas.length; i++) {
Element SONCONTENTS = SONLIST.addElement("SONCONTENTS");
@ -1215,7 +1293,8 @@ public class BomUtilWh {
String zysapmenge = getZYSAPMENGE(rev2, null, line2, false, "1", errMessage);
SONCONTENTS.addElement("QUE").setText(zysapmenge);
SONCONTENTS.addElement("QUIT").setText(rev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
SONCONTENTS.addElement("QUIT")
.setText(rev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
SONCONTENTS.addElement("SORTF").setText("");
SONCONTENTS.addElement("SEQID").setText(line2.getProperty("bl_sequence_no"));
SONCONTENTS.addElement("POSTP").setText("L");
@ -1230,8 +1309,8 @@ public class BomUtilWh {
if (!KUtil.isEmpty(properties2[2])) {
material_revs.put(properties2[2], rev2);
}
expandAllBomPart(expands,line2,rev2,groupName,wbsList,
session,now,needTCM_meops,gy_meops,INTERGRATIONLIST,errMessage, txtPath,material_revs);
expandAllBomPart(expands, line2, rev2, groupName, wbsList, session, now, needTCM_meops, gy_meops,
INTERGRATIONLIST, errMessage, txtPath, material_revs);
// if (!KUtil.isEmpty(zt2_materialNo)) {
// material_revs.put(zt2_materialNo, part2Rev);
@ -1242,8 +1321,8 @@ public class BomUtilWh {
Integer valueOf = Integer.valueOf(maxSeq);
if (pRev != null && meops.length > 0) {
TXTUtil.writeTXT(txtPath, "物料[" + pRev + "]工艺信息:" + meops[0].getComponent());
getProcess((TCComponentMEProcessRevision) meops[0].getComponent(), pRev, session, now,
"", groupName, gy_meops, needTCM_meops,BOPLIST,SONLIST,valueOf);
getProcess((TCComponentMEProcessRevision) meops[0].getComponent(), pRev, session, now, "",
groupName, gy_meops, needTCM_meops, BOPLIST, SONLIST, valueOf);
}
}
@ -1253,12 +1332,12 @@ public class BomUtilWh {
}
}
// 遍历产成品BOM 单层 没有BOM 和 文件跳过
public static void expandAllBomPartBjOne(Map<String, ExpandPSData[]> expands, TCComponentBOMLine pBomLine,
TCComponentItemRevision pRev,String groupName,List<String> wbsList,TCSession session,String now
,List<TCComponentMEProcessRevision> needTCM_meops,Map<String, TCComponent> gy_meops,
Element INTERGRATIONLIST,StringBuffer errMessage,List<TCComponentItem> cppRevision,String txtPath,Map<String, TCComponentItemRevision> material_revs) {
TCComponentItemRevision pRev, String groupName, List<String> wbsList, TCSession session, String now,
List<TCComponentMEProcessRevision> needTCM_meops, Map<String, TCComponent> gy_meops,
Element INTERGRATIONLIST, StringBuffer errMessage, List<TCComponentItem> cppRevision, String txtPath,
Map<String, TCComponentItemRevision> material_revs) {
try {
String uid = pBomLine.getUid();
@ -1289,7 +1368,8 @@ public class BomUtilWh {
}
Element WLCONTENTS = WLLIST.addElement("WLCONTENTS"); // 文件信息
Element TCID = WLCONTENTS.addElement("TCID");
String[] properties = pRev.getProperties(new String[] {"item_id","item_revision_id","zt2_MaterialNo","zt2_Quantity","zt2_State"});
String[] properties = pRev.getProperties(
new String[] { "item_id", "item_revision_id", "zt2_MaterialNo", "zt2_Quantity", "zt2_State" });
TCID.setText(properties[0] + "/" + properties[1]);
@ -1308,7 +1388,8 @@ public class BomUtilWh {
String fileName = ds.getProperty("object_name");
String fileType = "文件";
String fileUid = ds.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId + "/" + fileRevId);
// <ID>图号</ID>(文件载体item_id)
// <NAME>图纸名称</NAME>(文件载体object_name
@ -1329,7 +1410,8 @@ public class BomUtilWh {
String fileName = ds.getProperty("object_name");
String fileType = "文件";
String fileUid = ds.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId + "/" + fileRevId);
// <ID>图号</ID>(文件载体item_id)
// <NAME>图纸名称</NAME>(文件载体object_name
@ -1351,10 +1433,11 @@ public class BomUtilWh {
BOMCONTENTS.addElement("STLAN").setText("1");
BOMCONTENTS.addElement("STLAL").setText("1"); // <QUANTITY>基本数量</QUANTITY>
BOMCONTENTS.addElement("QUANTITY").setText(properties[3]);
BOMCONTENTS.addElement("QUIT").setText(pRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
BOMCONTENTS.addElement("QUIT")
.setText(pRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
Element SONLIST = BOMCONTENTS.addElement("SONLIST");
// 获取工艺信息 BOPLIST BOPCONTENTS ()二级工序下的辅料放到子件
String maxSeq = "";
String maxSeq = "10";
System.out.println("=========getProcess over========" + pRev);
for (int i = 0; i < expandPSDatas.length; i++) {
Element SONCONTENTS = SONLIST.addElement("SONCONTENTS");
@ -1371,7 +1454,8 @@ public class BomUtilWh {
String zysapmenge = getZYSAPMENGE(rev2, null, line2, false, "1", errMessage);
SONCONTENTS.addElement("QUE").setText(zysapmenge);
SONCONTENTS.addElement("QUIT").setText(rev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
SONCONTENTS.addElement("QUIT")
.setText(rev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
SONCONTENTS.addElement("SORTF").setText("");
SONCONTENTS.addElement("SEQID").setText(line2.getProperty("bl_sequence_no"));
SONCONTENTS.addElement("POSTP").setText("L");
@ -1390,8 +1474,8 @@ public class BomUtilWh {
Integer valueOf = Integer.valueOf(maxSeq);
if (pRev != null && meops.length > 0) {
TXTUtil.writeTXT(txtPath, "物料[" + pRev + "]工艺信息:" + meops[0].getComponent());
getProcess((TCComponentMEProcessRevision) meops[0].getComponent(), pRev, session, now,
"", groupName, gy_meops, needTCM_meops,BOPLIST,SONLIST,valueOf);
getProcess((TCComponentMEProcessRevision) meops[0].getComponent(), pRev, session, now, "",
groupName, gy_meops, needTCM_meops, BOPLIST, SONLIST, valueOf);
}
}
@ -1403,14 +1487,14 @@ public class BomUtilWh {
public static boolean checkMatnr(StringBuffer errMessage, TCComponentItemRevision matnrRev) throws TCException {
TCProperty[] tcProperties = matnrRev.getTCProperties(new String[] {"zt2_SZFactory","zt2_SZProcuretype","zt2_SZSealedornot"});
TCProperty[] tcProperties = matnrRev
.getTCProperties(new String[] { "zt2_SZFactory", "zt2_SZProcuretype", "zt2_SZSealedornot" });
try {
String[] properties = matnrRev.getProperties(new String[] { "item_id", "zt2_State", "object_name" });
String zt2_State = properties[1];// matnrRev.getStringProperty("zt2_State");
// System.out.println("properties[4]===>"+zt2_State);
if (zt2_State.equals("封存") || zt2_State.equals("D1")) {
errMessage.append("物料:").append(properties[0]).append("/")
.append(properties[2]).append("已封存,无法传递SAP");
errMessage.append("物料:").append(properties[0]).append("/").append(properties[2]).append("已封存,无法传递SAP");
}
Boolean flag = false;
String[] zt2_SZFactory = tcProperties[0].getStringArrayValue();
@ -1420,18 +1504,18 @@ public class BomUtilWh {
if (zt2_SZFactory[num].equals("M060")) {
flag = true;
if (zt2_SZProcuretype.length > num && zt2_SZProcuretype[num].equals("/")) {
errMessage.append("物料:").append(properties[0]).append("/")
.append(properties[2]).append("物料不可用,无法传递SAP\n");
errMessage.append("物料:").append(properties[0]).append("/").append(properties[2])
.append("物料不可用,无法传递SAP\n");
}
if (zt2_SZSealedornot.length > num && zt2_SZSealedornot[num].equals("Y")) {
errMessage.append("物料:").append(properties[0]).append("/")
.append(properties[2]).append("已封存,无法传递SAP\n");
errMessage.append("物料:").append(properties[0]).append("/").append(properties[2])
.append("已封存,无法传递SAP\n");
}
}
}
if (!flag) {
errMessage.append("物料:").append(properties[0]).append("/")
.append(properties[2]).append("没有维护物料视图,无法传递SAP\n");
errMessage.append("物料:").append(properties[0]).append("/").append(properties[2])
.append("没有维护物料视图,无法传递SAP\n");
}
return false;
} catch (Exception e) {
@ -1443,9 +1527,10 @@ public class BomUtilWh {
// 遍历产成品BOM 单层 没有BOM 和 文件跳过
public static void expandAllBomPart(Map<String, ExpandPSData[]> expands, TCComponentBOMLine pBomLine,
TCComponentItemRevision pRev,String groupName,List<String> wbsList,TCSession session,String now
,List<TCComponentMEProcessRevision> needTCM_meops,Map<String, TCComponent> gy_meops,
Element INTERGRATIONLIST,StringBuffer errMessage,String txtPath,Map<String, TCComponentItemRevision> material_revs) {
TCComponentItemRevision pRev, String groupName, List<String> wbsList, TCSession session, String now,
List<TCComponentMEProcessRevision> needTCM_meops, Map<String, TCComponent> gy_meops,
Element INTERGRATIONLIST, StringBuffer errMessage, String txtPath,
Map<String, TCComponentItemRevision> material_revs) {
try {
String uid = pBomLine.getUid();
@ -1469,7 +1554,8 @@ public class BomUtilWh {
}
Element WLCONTENTS = WLLIST.addElement("WLCONTENTS"); // 文件信息
Element TCID = WLCONTENTS.addElement("TCID");
String[] properties = pRev.getProperties(new String[] {"item_id","item_revision_id","zt2_MaterialNo","zt2_Quantity","zt2_State"});
String[] properties = pRev.getProperties(
new String[] { "item_id", "item_revision_id", "zt2_MaterialNo", "zt2_Quantity", "zt2_State" });
TCID.setText(properties[0] + "/" + properties[1]);
@ -1488,7 +1574,8 @@ public class BomUtilWh {
String fileName = ds.getProperty("object_name");
String fileType = "文件";
String fileUid = ds.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId + "/" + fileRevId);
// <ID>图号</ID>(文件载体item_id)
// <NAME>图纸名称</NAME>(文件载体object_name
@ -1509,7 +1596,8 @@ public class BomUtilWh {
String fileName = ds.getProperty("object_name");
String fileType = "文件";
String fileUid = ds.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId + "/" + fileRevId);
// <ID>图号</ID>(文件载体item_id)
// <NAME>图纸名称</NAME>(文件载体object_name
@ -1531,11 +1619,13 @@ public class BomUtilWh {
BOMCONTENTS.addElement("STLAN").setText("1");
BOMCONTENTS.addElement("STLAL").setText("1"); // <QUANTITY>基本数量</QUANTITY>
BOMCONTENTS.addElement("QUANTITY").setText(properties[3]);
BOMCONTENTS.addElement("QUIT").setText(pRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
BOMCONTENTS.addElement("QUIT")
.setText(pRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
Element SONLIST = BOMCONTENTS.addElement("SONLIST");
// 获取工艺信息 BOPLIST BOPCONTENTS ()二级工序下的辅料放到子件
String maxSeq = "";
System.out.println("=========getProcess over========"+pRev+"expandPSDatas==>"+expandPSDatas.length);
String maxSeq = "10";
System.out
.println("=========getProcess over========" + pRev + "expandPSDatas==>" + expandPSDatas.length);
for (int i = 0; i < expandPSDatas.length; i++) {
Element SONCONTENTS = SONLIST.addElement("SONCONTENTS");
ExpandPSData exPsData = expandPSDatas[i];
@ -1558,7 +1648,8 @@ public class BomUtilWh {
String zysapmenge = getZYSAPMENGE(rev2, null, line2, false, "1", errMessage);
SONCONTENTS.addElement("QUE").setText(zysapmenge);
SONCONTENTS.addElement("QUIT").setText(rev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
SONCONTENTS.addElement("QUIT")
.setText(rev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
SONCONTENTS.addElement("SORTF").setText("");
SONCONTENTS.addElement("SEQID").setText(line2.getProperty("bl_sequence_no"));
SONCONTENTS.addElement("POSTP").setText("L");
@ -1573,8 +1664,8 @@ public class BomUtilWh {
if (!KUtil.isEmpty(properties2[2])) {
material_revs.put(properties2[2], rev2);
}
expandAllBomPart(expands,line2,rev2,groupName,wbsList,session,now,
needTCM_meops,gy_meops,INTERGRATIONLIST,errMessage,txtPath,material_revs);
expandAllBomPart(expands, line2, rev2, groupName, wbsList, session, now, needTCM_meops, gy_meops,
INTERGRATIONLIST, errMessage, txtPath, material_revs);
}
AIFComponentContext[] meops = pRev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
@ -1582,8 +1673,8 @@ public class BomUtilWh {
Integer valueOf = Integer.valueOf(maxSeq);
if (pRev != null && meops.length > 0) {
TXTUtil.writeTXT(txtPath, "物料[" + pRev + "]工艺信息:" + meops[0].getComponent());
getProcess((TCComponentMEProcessRevision) meops[0].getComponent(), pRev, session, now,
"", groupName, gy_meops, needTCM_meops,BOPLIST,SONLIST,valueOf);
getProcess((TCComponentMEProcessRevision) meops[0].getComponent(), pRev, session, now, "",
groupName, gy_meops, needTCM_meops, BOPLIST, SONLIST, valueOf);
}
}
@ -1611,8 +1702,8 @@ public class BomUtilWh {
Element SONCONTENTS = SONLIST.addElement("SONCONTENTS");
TCComponentItemRevision rev2 = SAPUtil.getSAPPart(line2, session, groupName, errMessage);
String[] properties2 = rev2.getProperties(new String[] {"item_id","item_revision_id",
"zt2_MaterialNo","zt2_Quantity","zt2_State"});
String[] properties2 = rev2.getProperties(
new String[] { "item_id", "item_revision_id", "zt2_MaterialNo", "zt2_Quantity", "zt2_State" });
checkMatnr(errMessage, rev2);
// System.out.println("properties[4]===>"+properties2[4]);
// if(properties2[4].equals("封存")||properties2[4].equals("D1")) {
@ -1624,7 +1715,8 @@ public class BomUtilWh {
String zysapmenge = getZYSAPMENGE(rev2, null, line2, false, "1", errMessage);
SONCONTENTS.addElement("QUE").setText(zysapmenge);
SONCONTENTS.addElement("QUIT").setText(rev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
SONCONTENTS.addElement("QUIT")
.setText(rev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
SONCONTENTS.addElement("SORTF").setText("");
SONCONTENTS.addElement("SEQID").setText(line2.getProperty("bl_sequence_no"));
SONCONTENTS.addElement("POSTP").setText("L");
@ -1634,7 +1726,8 @@ public class BomUtilWh {
// if(i==expandPSDatas.length-1) {
// maxSeq = line2.getProperty("bl_sequence_no");
// }
// if(!designRev.getType().contains("ZT2_Design3D") || !thList.contains(itemId.split("-")[0])) {
// if(!designRev.getType().contains("ZT2_Design3D") ||
// !thList.contains(itemId.split("-")[0])) {
// continue;
// }
// if (rev2.getProperty("zt2_SapState").equals("已传"))
@ -1654,9 +1747,10 @@ public class BomUtilWh {
// 遍历产成品BOM 单层 没有BOM 和 文件跳过
public static void expandAllBomPartKj(Map<String, ExpandPSData[]> expands, TCComponentBOMLine tzBomLine,
TCComponentItemRevision pRev,String groupName,List<String> wbsList,TCSession session,String now
,List<TCComponentMEProcessRevision> needTCM_meops,Map<String, TCComponent> gy_meops,
Element INTERGRATIONLIST,StringBuffer errMessage,String txtPath,Map<String, TCComponentItemRevision> material_revs,List<String> thList) {
TCComponentItemRevision pRev, String groupName, List<String> wbsList, TCSession session, String now,
List<TCComponentMEProcessRevision> needTCM_meops, Map<String, TCComponent> gy_meops,
Element INTERGRATIONLIST, StringBuffer errMessage, String txtPath,
Map<String, TCComponentItemRevision> material_revs, List<String> thList) {
try {
String uid = tzBomLine.getUid();
@ -1680,7 +1774,8 @@ public class BomUtilWh {
}
Element WLCONTENTS = WLLIST.addElement("WLCONTENTS"); // 文件信息
Element TCID = WLCONTENTS.addElement("TCID");
String[] properties = pRev.getProperties(new String[] {"item_id","item_revision_id","zt2_MaterialNo","zt2_Quantity","zt2_State"});
String[] properties = pRev.getProperties(
new String[] { "item_id", "item_revision_id", "zt2_MaterialNo", "zt2_Quantity", "zt2_State" });
TCID.setText(properties[0] + "/" + properties[1]);
@ -1699,7 +1794,8 @@ public class BomUtilWh {
String fileName = ds.getProperty("object_name");
String fileType = "文件";
String fileUid = ds.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId + "/" + fileRevId);
// <ID>图号</ID>(文件载体item_id)
// <NAME>图纸名称</NAME>(文件载体object_name
@ -1720,7 +1816,8 @@ public class BomUtilWh {
String fileName = ds.getProperty("object_name");
String fileType = "文件";
String fileUid = ds.getUid();
System.out.println("fileId==>"+fileId+"fileName==>"+fileName+"fileType==>"+fileType+"fileUid==>"+fileUid);
System.out.println("fileId==>" + fileId + "fileName==>" + fileName + "fileType==>" + fileType
+ "fileUid==>" + fileUid);
FILECONTENTS.addElement("FILEID").setText(fileId + "/" + fileRevId);
// <ID>图号</ID>(文件载体item_id)
// <NAME>图纸名称</NAME>(文件载体object_name
@ -1742,7 +1839,8 @@ public class BomUtilWh {
BOMCONTENTS.addElement("STLAN").setText("1");
BOMCONTENTS.addElement("STLAL").setText("1"); // <QUANTITY>基本数量</QUANTITY>
BOMCONTENTS.addElement("QUANTITY").setText(properties[3]);
BOMCONTENTS.addElement("QUIT").setText(pRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
BOMCONTENTS.addElement("QUIT")
.setText(pRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
Element SONLIST = BOMCONTENTS.addElement("SONLIST");
// 获取工艺信息 BOPLIST BOPCONTENTS ()二级工序下的辅料放到子件
// String maxSeq = "";
@ -1753,7 +1851,8 @@ public class BomUtilWh {
TCComponentBOMLine line2 = exPsData.bomLine;
TCComponentItemRevision designRev = exPsData.itemRevOfBOMLine;
if (designRev.getType().equals("ZT2_XNZJBRevision")) {
//虚拟组件包削层逻辑String now,StringBuffer errMessage,Element SONLIST,TCSession session,String groupName
// 虚拟组件包削层逻辑String now,StringBuffer errMessage,Element SONLIST,TCSession
// session,String groupName
ExpandPSData[] expandPSDatas2 = expands.get(line2.getUid());
xnzjbXcMsg(expandPSDatas2, now, errMessage, SONLIST, session, groupName, expands);
continue;
@ -1775,7 +1874,8 @@ public class BomUtilWh {
String zysapmenge = getZYSAPMENGE(rev2, null, line2, false, "1", errMessage);
SONCONTENTS.addElement("QUE").setText(zysapmenge);
SONCONTENTS.addElement("QUIT").setText(rev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
SONCONTENTS.addElement("QUIT")
.setText(rev2.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
SONCONTENTS.addElement("SORTF").setText("");
SONCONTENTS.addElement("SEQID").setText(line2.getProperty("bl_sequence_no"));
SONCONTENTS.addElement("POSTP").setText("L");
@ -1799,8 +1899,8 @@ public class BomUtilWh {
if (!KUtil.isEmpty(properties2[2])) {
material_revs.put(properties2[2], rev2);
}
expandAllBomPartKj(expands,line2,rev2,groupName,wbsList,session,now,
needTCM_meops,gy_meops,INTERGRATIONLIST,errMessage,txtPath,material_revs,thList);
expandAllBomPartKj(expands, line2, rev2, groupName, wbsList, session, now, needTCM_meops, gy_meops,
INTERGRATIONLIST, errMessage, txtPath, material_revs, thList);
}

@ -83,7 +83,7 @@ public class AssignProcess extends KCommand {
}
for(TCComponentItemRevision revP:revPs) {
if(whereUsed.length>1) {
if(revPs.size()>1) {
// TCComponentItemRevision revP = (TCComponentItemRevision)whereUsed[i];
String property = revP.getProperty("zt2_ifpbom");
if(property==null||!property.equals("P")) {

@ -192,6 +192,10 @@ public class BomSendSapController {
comp = new MyProgressBarCompent("", "正在进行项目BOM传递......");
StringBuffer errMessageAll = new StringBuffer("");
StringBuffer sendMessageAll = new StringBuffer("");
//2024 1 22新增逻辑往CHINT_BOM_TO_SAP_SUM
project.getProperty("zt2_WBSNo");
//产成品BOM组织时除了产成品不同其他相同 BOM结构是一样的
for(PartBean bean : selectedParts) {
Document document = DocumentHelper.parseText(getXML());
@ -230,7 +234,9 @@ public class BomSendSapController {
win.close();
}else {
// new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation();
sendMessageAll.append(name(txtPath,document.asXML()));
//记录XML信息到CHINT_BOM_TO_SAP_DETIALS
sendMessageAll.append(SendToSap(txtPath,document.asXML()));
win.close();
}
TCComponentDataset dataset = TXTUtil.createDataset(txtPath, txtName, session);
@ -276,7 +282,7 @@ public class BomSendSapController {
return selectedParts;
}
public StringBuffer name(String txtPath,String wsdlString) throws IOException {
public StringBuffer SendToSap(String txtPath,String wsdlString) throws IOException {
// new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation();
TXTUtil.writeTXT(txtPath, "----------------BOM传递数据--------------");
TXTUtil.writeTXT(txtPath, wsdlString);

Loading…
Cancel
Save