11.23阶段性代码保存

master
郭宇航 4 years ago
parent 8a5a879792
commit 66926b393c

@ -0,0 +1,734 @@
package com.connor.dfl.plm.dfl044;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import com.connor.dfl.plm.dfl027.ChangeOwnerbean;
import com.connor.dfl.plm.dfl038.ChangeBean;
import com.connor.dfl.plm.forms.ChangeOrderBean;
import com.connor.dfl.plm.util.CodeBean;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class DataBaseControl2 {
/** ************************数据库类调用:声明部分*********************************** */
/**
* kelsen ....
*/
Connection conn;
ResultSet rs;
PreparedStatement pstmt;
Statement stmt;
String strSQLQuery;
public String str_Information = "";
private String strDriver = "oracle.jdbc.driver.OracleDriver";
private String strUrl = "";
private String strUserName = "";
private String strPassword = "";
/**
*
*/
public DataBaseControl2(String strDriver, String strUrl, String strUserName,
String strPassword) {
// this.strDriver ="oracle.jdbc.driver.OracleDriver";//驱动
// this.strUrl = "jdbc:oracle:thin:@127.0.0.1:1521:tc";//连接路径
// this.strUserName = "infodba";//数据库用户
// this.strPassword = "infodba";//数据库密码
this.strDriver = strDriver; // "oracle.jdbc.driver.OracleDriver";//驱动
this.strUrl = strUrl; // "jdbc:oracle:thin:@127.0.0.1:1521:tceng";//连接路径
this.strUserName = strUserName; // "infodba";//数据库用户
this.strPassword = strPassword; // "infodba";//数据库密码
// 加载驱动
try {
Class.forName(strDriver);// 通过反射加载驱动到内存
} catch (ClassNotFoundException cnfe) {
cnfe.printStackTrace();
}
// try {
// Class.forName("org.objectweb.rmijdbc.Driver").newInstance();
// } catch (InstantiationException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
}
/**
*
*/
public DataBaseControl2(TCSession session) {
String[] stringArray = session.getPreferenceService().getStringArray(4,
"DFL2_ERP_SQL_Connect2");
if (stringArray != null && stringArray.length == 3) {
strUrl = "jdbc:oracle:thin:@" + stringArray[0];
strUserName = stringArray[1];
strPassword = stringArray[2];
} else {
MessageBox.post("未配置DFL2_ERP_SQL_Connect2首选项无法获得连接信息!", "错误",
MessageBox.ERROR);
}
// 加载驱动
try {
Class.forName(strDriver);// 通过反射加载驱动到内存
} catch (ClassNotFoundException cnfe) {
cnfe.printStackTrace();
}
}
/**
*
*/
public DataBaseControl2(TCSession session,String connect) {
String[] stringArray = session.getPreferenceService().getStringArray(4,
connect);
if (stringArray != null && stringArray.length == 3) {
strUrl = "jdbc:oracle:thin:@" + stringArray[0];
strUserName = stringArray[1];
strPassword = stringArray[2];
} else {
MessageBox.post("未配置"+connect+"首选项,无法获得连接信息!", "错误",
MessageBox.ERROR);
}
// 加载驱动
try {
Class.forName(strDriver);// 通过反射加载驱动到内存
} catch (ClassNotFoundException cnfe) {
cnfe.printStackTrace();
}
}
/**
*
*
* @param strSQLQuery
*/
public void dbModify(String strSQLQuery) {
openDataBase();
try {
stmt = conn.createStatement();
stmt.executeUpdate(strSQLQuery);
} catch (SQLException sqle2) {
sqle2.printStackTrace();
}
closeDataBase();
}
/**
*
*
* @param strSQLQuery
* @return
*/
public ResultSet dbQuery(String strSQLQuery) {
ResultSet rs_result = null;
if (conn == null)
openDataBase();
try {
stmt = conn.createStatement();
rs_result = stmt.executeQuery(strSQLQuery);
} catch (SQLException sqle2) {
sqle2.printStackTrace();
}
return rs_result;
}
/**
* 2
*
* @param strSQLQuery
* @return
*/
public ResultSet dbQuery2(String strSQLQuery, Object[] strs) {
ResultSet rs_result = null;
if (conn == null)
openDataBase();
try {
// stmt = conn.createStatement();
PreparedStatement ps = conn.prepareStatement(strSQLQuery);
for (int i = 0; i < strs.length; i++) {
ps.setObject(i + 1, strs[i]);
}
rs_result = ps.executeQuery();
} catch (SQLException sqle2) {
sqle2.printStackTrace();
}
return rs_result;
}
/**
* 3
*
* @param strSQLQuery
* @return
*/
public ResultSet dbQuery3(String strSQLQuery) {
ResultSet rs_result = null;
if (conn == null)
openDataBase();
try {
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs_result = stmt.executeQuery(strSQLQuery);
} catch (SQLException sqle2) {
sqle2.printStackTrace();
}
return rs_result;
}
/**
* 2
*
* @param strSQLQuery
*/
public void dbModify2(String strSQLQuery, Object[] strs) {
openDataBase();
try {
// stmt = conn.createStatement();
PreparedStatement ps = conn.prepareStatement(strSQLQuery);
for (int i = 0; i < strs.length; i++) {
ps.setObject(i + 1, strs[i]);
}
ps.executeUpdate();
} catch (SQLException sqle2) {
sqle2.printStackTrace();
}
closeDataBase();
}
/**
*
*
*/
public void openDataBase() {
try {
// this.strUrl="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.29)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=tcprod)))";
if (conn == null || conn.isClosed())
conn = DriverManager.getConnection(strUrl, strUserName,
strPassword);
} catch (SQLException sqle) {
sqle.printStackTrace();
MessageBox.post("数据库连接错误" + sqle.getMessage(), "错误", 1);
}
}
/**
*
*
*/
public void closeDataBase() {
try {
if (rs != null) {
try {
rs.close();
} catch (SQLException sqlec) {
sqlec.printStackTrace();
}
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException sqlec) {
sqlec.printStackTrace();
}
}
if (conn != null && !conn.isClosed()) {
try {
conn.close();
} catch (SQLException sqlecon) {
sqlecon.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* HashMap,key
* VectorHasnMap
*
* @param strSQLQuery
* @return
* @author xuk
*/
public Vector orgQuery(String strSQLQuery) {
openDataBase();
Vector v_result = new Vector();
try {
ResultSet rs_get = dbQuery(strSQLQuery);
// System.out.println("RS_GET:"+rs_get);
if (rs_get != null) {
ResultSetMetaData metaData = rs_get.getMetaData();
int i_ColumnCount = metaData.getColumnCount();
// System.out.println("i_ColumnCount:"+i_ColumnCount);
while (rs_get.next()) {
// System.out.println("【BJZJ2】"+rs_get.getString("BJZJ2"));;
HashMap<String, String> hm_unit = new HashMap<String, String>();
for (int i = 1; i <= i_ColumnCount; i++) {
hm_unit.put(metaData.getColumnName(i),
rs_get.getString(i));
// System.out.println("metaData.getColumnName(i):"+metaData.getColumnName(i));
// System.out.println("rs_get.getString(i):"+rs_get.getString(i));
}
v_result.add(hm_unit);
}
} else {
str_Information = "【" + strSQLQuery + "】" + "查询的结果集为空\n";
}
} catch (Exception e) {
e.printStackTrace();
}
return v_result;
}
public String getTaskIdea(String uid)
throws Exception {
openDataBase();
String query = "select IDEA from PLM_Perform_Task where PUID= ?";
// 查询该id在数据库中的内容
ResultSet rs = dbQuery2(query, new Object[] { uid});
String taskIdea = "";
if (rs.next()) {
taskIdea = rs.getString(1);
System.out.println("taskIdea=" + taskIdea);
}
closeDataBase();
return taskIdea;
}
public void setTaskIdea(String uid,String idea)
throws Exception {
openDataBase();
String query = "select IDEA from PLM_Perform_Task where PUID= ?";
// 查询该id在数据库中的内容
ResultSet rs = dbQuery2(query, new Object[] { uid});
if(rs.next()) {
String upin = "update PLM_Perform_Task set IDEA= ? where PUID= ?";
dbModify2(upin, new Object[] { idea, uid });
}else {
String upin = "insert into PLM_Perform_Task(PUID,IDEA) values ( ? , ? )";
dbModify2(upin, new Object[] { uid, idea });
}
closeDataBase();
}
/**
*
*
* @param type
*
* @param prefix
*
* @param col
* 4"0000"
* @return
* @throws Exception
*/
public String getNewCode(String type, String prefix, String col)
throws Exception {
openDataBase();
String query = "select PREFIX,LSH from PLM_LSH where PLMTYPE= ? and PREFIX= ?";
// 查询该id在数据库中的内容
ResultSet rs = dbQuery2(query, new Object[] { type, prefix });
String lshstr = col;
String pre = "";
String lsh = "";
if (rs.next()) {
pre = rs.getString(1);
lsh = rs.getString(2);
System.out.println("sspre=" + pre);
System.out.println("sslsh=" + lsh);
if ("".equals(lsh)) {
throw new Exception("流水码为空!");
}
int ls = Integer.parseInt(lsh) + 1;// 新的流水码数
lshstr = ls + "";
if (col != null) {
DecimalFormat df = new DecimalFormat(col);
lshstr = df.format(ls);
}
String upin = "update PLM_LSH set LSH= ? where PLMTYPE= ? and PREFIX= ? ";
dbModify2(upin, new Object[] { lshstr, type, prefix });
} else {
String upin = "insert into PLM_LSH(PLMTYPE,PREFIX,LSH) values ( ? , ? , ? )";
dbModify2(upin, new Object[] { type, prefix, lshstr });
}
closeDataBase();
String newId = prefix + lshstr;
return newId;
}
//获取变更单信息
public List<ChangeBean> getChangeMesg(String product,String time1,String time2) throws SQLException {
List<ChangeBean> list = new ArrayList<ChangeBean>();
if("全部".equals(product)) {
product = "";
}
String sql = "select * from DFL_CHANGEFORM where PRODUCTDEPARTMENT like '%"+product+"%'";//
SimpleDateFormat df = new SimpleDateFormat("yyyy-M-d HH:mm");
openDataBase();
System.out.println("sql============"+sql);
ResultSet rs = dbQuery(sql);
while(rs.next()){
try {
String dateStr = rs.getString(3);
System.out.println("date========"+rs.getString(3));
if(dateStr == null) {
continue;
}
Date date = df.parse(rs.getString(3));
Date date1 = df.parse(time1);
Date date2 = df.parse(time2);
if(date.after(date2) && date.before(date1)) {
System.out.println("date2========"+rs.getString(3));
}
if(date.after(date1) && date.before(date2)) {
ChangeBean bn = new ChangeBean();
bn.setApplyName(rs.getString(2));
bn.setApplyDate(rs.getString(3));
bn.setProjectCode(rs.getString(4));
bn.setClientNae(rs.getString(5));
bn.setProductName(rs.getString(7));
bn.setProjectModel(rs.getString(8));
bn.setChangeType(rs.getString(10));
bn.setProductType(rs.getString(11));
bn.setErrorType(rs.getString(12));
bn.setDutyDepartment(rs.getString(13));
bn.setDutyMan(rs.getString(14));
bn.setChangeReason(rs.getString(15));
bn.setSalseClassify(rs.getString(16));
bn.setPriceBooking(rs.getString(17));
bn.setIsNotProductLoss(rs.getString(18));
bn.setReceiveClassify(rs.getString(19));
bn.setWarehouseCode(rs.getString(20));
bn.setAccountSet(rs.getString(21));
bn.setNotifyEmergencyProcedures(rs.getString(22));
bn.setDrawingTo(rs.getString(23));
bn.setChangeListCode(rs.getString(24));
bn.setTZChangeType(rs.getString(25));
bn.setSUOSU_ProductDepartment(rs.getString(26));
bn.setProjectState(rs.getString(27));
list.add(bn);
}
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
closeDataBase();
return list;
}
/**
*
*
* @param type
*
* @param prefix
*
* @param col
* 4"0000"
* @return
* @throws Exception
*/
public String getNewCode(String type,CodeBean selCodeBean)
throws Exception {
String prefix = selCodeBean.getCode();
String col = selCodeBean.getNum();
String min = selCodeBean.getMin();
String max = selCodeBean.getMax();
openDataBase();
String query = "select PREFIX,LSH from PLM_LSH where PLMTYPE= ? and PREFIX= ?";
// 查询该id在数据库中的内容
ResultSet rs = dbQuery2(query, new Object[] { type, prefix });
String lshstr = col;
String pre = "";
String lsh = "";
if (rs.next()) {
pre = rs.getString(1);
lsh = rs.getString(2);
System.out.println("sspre=" + pre);
System.out.println("sslsh=" + lsh);
if ("".equals(lsh)) {
throw new Exception("流水码为空!");
}
int ls = Integer.parseInt(lsh) + 1;// 新的流水码数
int minls = Integer.parseInt(min);
int maxls = Integer.parseInt(max);
if (minls>ls) {
ls=minls;
}
if (ls>maxls) {
System.out.println("错误:流水码最已超过最大值");
return "MAXERR";
}
lshstr = ls + "";
if (col != null) {
DecimalFormat df = new DecimalFormat(col);
lshstr = df.format(ls);
}
String upin = "update PLM_LSH set LSH= ? where PLMTYPE= ? and PREFIX= ? ";
dbModify2(upin, new Object[] { lshstr, type, prefix });
} else {
if (col != null) {
int minls = Integer.parseInt(min);
DecimalFormat df = new DecimalFormat(col);
lshstr = df.format(minls);
}
String upin = "insert into PLM_LSH(PLMTYPE,PREFIX,LSH) values ( ? , ? , ? )";
dbModify2(upin, new Object[] { type, prefix, lshstr });
}
closeDataBase();
String newId = prefix + lshstr;
return newId;
}
/**
*
*
*/
public String getMaxCode(String type,CodeBean selCodeBean)throws Exception {
String prefix = selCodeBean.getCode();
String col = selCodeBean.getNum();
String min = selCodeBean.getMin();
String max = selCodeBean.getMax();
openDataBase();
String query = "select * from (select * from pitem where pitem_id like '"+prefix+"%' order by pitem_id desc) where rownum<=1";
// 查询该id在数据库中的内容
ResultSet rs = dbQuery(query);
String lshstr = col;
String lsh = "";
if (rs.next()) {
lsh = rs.getString(2);
System.out.println("sslsh=" + lsh);
if ("".equals(lsh)) {
throw new Exception("流水码为空!");
}
lsh = lsh.substring(6);
int ls = Integer.parseInt(lsh) + 1;// 新的流水码数
lshstr = ls + "";
System.out.println("lshstr=" + lshstr);
if (col != null) {
DecimalFormat df = new DecimalFormat(col);
lshstr = df.format(ls);
}
}
String upin = "update PLM_LSH set LSH= ? where PLMTYPE= ? and PREFIX= ? ";
dbModify2(upin, new Object[] { lshstr, type, prefix });
closeDataBase();
String newId = prefix + lshstr;
return newId;
}
/**
*
* @param v3
* @param v16
* @param time
* @param user
* @throws Exception
*/
public void setSqlConn(String v3, String v16, String time, String user)
throws Exception {
openDataBase();
// WF_MJID varchar2(200),--编码
// WF_YXJ varchar2(200),--已下机数
// WF_DATE varchar2(200),--上传日期
// WF_USER varchar2(200),--上传人员
String query = "select WF_MJID from WF_MJ_XJ_T where WF_MJID = ? ";
// 查询该id在数据库中的内容
ResultSet rs = dbQuery2(query, new Object[] {v3});
String wfmjid = "";
if (rs.next()) {
System.out.println("更新");
wfmjid = rs.getString(1);
System.out.println("wfmjid=" + wfmjid);
String upup = "UPDATE WF_MJ_XJ_T set WF_YXJ = ? ,WF_DATE= ?, WF_USER = ? WHERE WF_MJID = ? ";
dbModify2(upup, new Object[] {v16, time, user ,v3});
} else {
System.out.println("插入");
System.out.println("wfmjid=" + v3);
String upin = "insert into WF_MJ_XJ_T(WF_MJID,WF_YXJ,WF_DATE,WF_USER) values ( ?,? , ? , ? )";
dbModify2(upin, new Object[] {v3, v16, time, user});
}
closeDataBase();
return ;
}
/**
* ERP
*
* @param value
*
* @param sql
*
* @return
* @throws Exception
*/
public String getRecord(String sql)
throws Exception {
String result=null;
openDataBase();
// 查询该id在数据库中的内容
ResultSet rs = dbQuery(sql);
while (rs.next()) {
// ERPStockandPrice bean = new ERPStockandPrice();
// bean.setID(rs.getInt(1));
// bean.setfun(rs.getString(2));
// bean.setitem_id(rs.getString(3));
// bean.setzhangtao(rs.getString(4));
// bean.setUser_id(rs.getString(5));
// list.add(bean);
result = rs.getString(1);
}
closeDataBase();
return result;
}
// public List<ChangeOwnerbean> getRecord2(String value,String zhangT,String cangK,String sql)
// throws Exception {
// List<ChangeOwnerbean> list=new ArrayList<>();
// openDataBase();
// // 查询该id在数据库中的内容
// ResultSet rs = dbQuery2(sql, new Object[] {value,zhangT,cangK});
// while (rs.next()) {
// ChangeOwnerbean bean = new ChangeOwnerbean();
// bean.setId(rs.getString(1));
// bean.setCustomerName(rs.getString(2));
// bean.setSpec(rs.getString(3));
// bean.setZhangt(rs.getString(4));
// bean.setCangk(rs.getString(5));
// bean.setNum(rs.getString(6));
// bean.setUnit(rs.getString(7));
// list.add(bean);
// }
// closeDataBase();
// return list;
// }
public String getNum(Object[] values)
throws Exception {
openDataBase();
// 查询该id在数据库中的内容
String sql = "select NUM from DFL_OLD_ITEM where ITEM_ID= ? and ZHANGTAO= ? and WAREHOUSE= ?";
String num = "";
ResultSet rs = dbQuery2(sql, values);
if (rs.next()) {
num = rs.getString(1);
}
closeDataBase();
return num;
}
public double getNums(String sql)
throws Exception {
openDataBase();
// 查询该id在数据库中的内容
double nums = 0;
ResultSet rs = dbQuery(sql);
if (rs.next()) {
nums = rs.getInt(1);
}
closeDataBase();
return nums;
}
/**
*
*
* @param args
*/
public static void main(String args[]) {
try {
String str_DataBaseDriver = "oracle.jdbc.driver.OracleDriver";
String str_URL = "jdbc:oracle:thin:@localhost:1521:tc12";
String str_UserName = "infodba";
String str_Password = "infodba";
DataBaseControl2 dbc = new DataBaseControl2(str_DataBaseDriver,
str_URL, str_UserName, str_Password);
// dbc.openDataBase();
System.out.println("连接成功");
// dbc.stmt = dbc.conn.createStatement();
// String sql = "select * from PLM_LSH";
// Vector rs_result = dbc.orgQuery(sql);
// for (int i = 0; i < rs_result.size(); i++) {
// HashMap<String, String> map = (HashMap<String, String>)
// rs_result.get(i);
//
// for (Map.Entry<String, String> entry: map.entrySet()) {
// System.out.println(entry.getKey()+"---"+entry.getValue());
// }
// }
String newid = dbc.getNewCode("PLMITEMID", "pz", "0000");
System.out.println(newid);
// dbc.closeDataBase();
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,24 @@
package com.connor.dfl.plm.dfl044;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
public class Dfl044Action extends AbstractAIFAction {
private AbstractAIFUIApplication app;
public Dfl044Action(AbstractAIFUIApplication app, String string) {
super(app,string);
this.app=app;
}
@Override
public void run() {
try {
new Dfl044Command(app).executeModal();
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,20 @@
package com.connor.dfl.plm.dfl044;
import com.teamcenter.rac.aif.AbstractAIFCommand;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.kernel.TCSession;
public class Dfl044Command extends AbstractAIFCommand {
private TCSession session;
public Dfl044Command(AbstractAIFUIApplication app) {
this.session=(TCSession)app.getSession();
}
@Override
public void executeModal() throws Exception {
new Thread(new Dfl044Dialog(session)).start();
}
}

@ -0,0 +1,296 @@
package com.connor.dfl.plm.dfl044;
import java.awt.Color;
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.MouseAdapter;
import java.awt.event.MouseEvent;
import java.lang.reflect.InvocationTargetException;
import java.time.Year;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.MissingResourceException;
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.JTextArea;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableRowSorter;
import org.jacorb.idl.runtime.int_token;
import com.connor.dfl.plm.dfl042.ERPTransferStatusbean;
import com.connor.dfl.plm.util.DataBaseControl;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aif.commands.open.OpenCommand;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentGroup;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.ButtonLayout;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout;
import com.teamcenter.rac.util.Registry;
import com.teamcenter.soaictstubs.stringSeq_tHolder;
import sun.awt.www.content.audio.x_aiff;
public class Dfl044Dialog extends AbstractAIFDialog {
private static final long serialVersionUID = 6130114042631785757L;
private static final int width=800;
DefaultTableModel model;
private TCSession session;
private JButton qryBtn2;
private JTextField idField;
private JTextField useridField;
private JComboBox<String> zt_combobox; //账套选择下拉框
private JLabel StockwriteLabel=new JLabel("");//库存显示文本框
private JLabel PricewriteLabel=new JLabel("");//价格显示文本框
private HashMap<String, String> account_set = new HashMap();
private StringBuilder sb = new StringBuilder("select sum(img10) from ");
private StringBuilder numsSb = new StringBuilder("select ccc23a from ");
private String sql2 = "";
private String zhangtao = ""; //SQL语句中的账套
private String zhangtao1 = ""; //SQL语句中的账套
private String cangku = "";//SQL语句中的仓库号
private String cangku1 = "";
private String group = "";
private JComboBox<String> zhangTBox;
private DataBaseControl2 data;
public Dfl044Dialog(TCSession session) {
super(false);
this.session=session;
//this.service = session.getPreferenceService();
this.data = new DataBaseControl2(session,"DFL2_ERP_SQL_Connect");
String[] BOMZT = session.getPreferenceService().getStringValues("DFL2_ZHANGTAO_WAREHOUSE");
if (BOMZT == null || BOMZT.length <= 0 ) {
MessageBox.post("首选项DFL2_ZHANGTAO_WAREHOUSE未配置,请联系管理员!!",
"错误", MessageBox.ERROR);
return;
}
TCComponentGroup group = session.getCurrentGroup();
try {
String group_name = group.getStringProperty("display_name");
System.out.println("11.04group_name=============="+group_name);
if(group_name.contains(".")) {
String[] names = group_name.split("\\.");
if(names != null && names.length >=2) {
for (int i = 0; i < BOMZT.length; i++) {
if(BOMZT[i].contains(";")) {
String[] zts = BOMZT[i].split(";");
if(names[names.length-2].equals(zts[0])) {
this.zhangtao = zts[1];
System.out.println("11.04账套======"+zhangtao);
this.cangku = zts[2];
System.out.println("11.04仓库======"+cangku);
break;
}
}
}
}
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void run() {
//显示窗口
initUI();
}
@SuppressWarnings("serial")
private void initUI() {
this.setTitle("仓库库存和价格查询");
this.setLayout(new FlowLayout(FlowLayout.CENTER,2,3));
this.setPreferredSize(new Dimension(width, 150));
this.setLocation(2, 5);
model = new DefaultTableModel() {
private static final long serialVersionUID = 6905817304437097181L;
public boolean isCellEditable(int row, int column) {
return true;
}
};
JPanel qryPanel=new JPanel(new PropertyLayout());
JLabel idLabel=new JLabel("请在右边框中输入零件号");
JLabel ztLabel=new JLabel("选择账套");
zhangTBox = new JComboBox<String>();
JLabel useridLabel=new JLabel(" 零件号:");
JLabel StockLabel=new JLabel("库存量:");
JLabel PriceLabel=new JLabel(" 单 价:");
useridField = new JTextField(10);
//new下拉框对象
zt_combobox = new JComboBox();
zt_combobox.addItem(" ");
String[] BOMZT = session.getPreferenceService().getStringValues("DFL2_ZHANGTAO_WAREHOUSE");
for(int i = 0 ;i<BOMZT.length;i++) {
String s2 = BOMZT[i].split(";")[2];
String s1 = BOMZT[i].split(";")[1];
String s0 = BOMZT[i].split(";")[0];
account_set.put(s1, s0);
zt_combobox.addItem(s0+":"+s1);
}
//获取下拉框的值
qryBtn2=new JButton("查询");
qryPanel.add("1.1.center.top",idLabel);//添加零件id文本
qryPanel.add("1.2.center.top",useridLabel);//添加品名文本
qryPanel.add("1.3.center.top",useridField);//添加品名写入框
qryPanel.add("1.4.center.top",ztLabel);//查询按钮
qryPanel.add("1.5.center.top",zt_combobox);//查询按钮
qryPanel.add("1.6.center.top",qryBtn2);//查询按钮
qryPanel.add("2.1.center.top",StockLabel);//添加库存文本框
qryPanel.add("2.2.center.top",StockwriteLabel);//添加库存写入框
qryPanel.add("2.3.center.top",PriceLabel);//添加价格文本框
qryPanel.add("2.4.center.top",PricewriteLabel);//添加品名写入框
JPanel southPanel = new JPanel(new FlowLayout());
JButton celBtn = new JButton("取消");
celBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
disposeDialog();
}
});
southPanel.add(celBtn);
JPanel rootPanel=new JPanel(new ButtonLayout());
qryBtn2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
//下拉值对比
getdropdown();
StockwriteLabel.setText(StockResult());
PricewriteLabel.setText(PriceResult(useridField.getText()));
}
});
this.add(qryPanel);
this.add(rootPanel);
this.setResizable(false);
this.setAlwaysOnTop(false);
this.showDialog();
}
//返回库存数量
public String StockResult() {
String Stock = null;
String Select = null; //选择下拉的值
String userid = useridField.getText();//获取零件号
Select = (String) zt_combobox.getSelectedItem();//获取账套文本框的值
System.out.println("11.05选择的下拉值库存======="+Select);
//sql语句拼接账套
if("".equals(Select) || " ".equals(Select) || "null".equals(Select)) {
sb.append(zhangtao+".img_file where img01='");
//如果零件号不为空,则拼接
if(!("".equals(userid.trim()))) {
sb.append(userid+"' and img02='"+cangku+"' and img02<>'Z1'");
}
}else {
sb.append(zhangtao1+".img_file where img01='");
//如果零件号不为空,则拼接
if(!("".equals(userid.trim()))) {
sb.append(userid+"' and img02='"+cangku1+"' and img02<>'Z1'");
}
}
sql2 = sb.toString();
System.out.println("sql===================="+sql2);
Stock = getRecords(sql2);
System.out.println("11.04Stock==================="+Stock);
return Stock;
}
//返回单价
public String PriceResult(String userid) {
String Price = null;
String Select = null; //选择下拉的值
//如果零件号不为空,则拼接
Select = (String) zt_combobox.getSelectedItem();
System.out.println("11.05选择的下拉值单价======="+Select);
if(!("".equals(userid.trim()))) {
if("".equals(Select) || " ".equals(Select) || "null".equals(Select)) {
numsSb.append(zhangtao + ".ccc_file inner join "+zhangtao+".ccz_file on ccz01=ccc02 and ccz02=ccc03 where ccc01='"+userid+"'");
}else {
numsSb.append(zhangtao1 + ".ccc_file inner join "+zhangtao1+".ccz_file on ccz01=ccc02 and ccz02=ccc03 where ccc01='"+userid+"'");
}
}
String numsSql = numsSb.toString();
System.out.println("numsSql===================="+numsSql);
Price = getRecords(numsSql);
System.out.println("11.04Price==================="+Price);
return Price;
}
/**
*
* @return tabledataVector
*/
private String getRecords(String sql){
String result =null;
try {
result = data.getRecord(sql);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("11.04获得的结果======"+result);
if(result == null ) {
MessageBox.post("数据库中未查找到相应的数据!! 该零件没有库存或单价!!",
"错误", MessageBox.ERROR);
}
return result;
}
private void getdropdown () {
String[] BOMZT = session.getPreferenceService().getStringValues("DFL2_ZHANGTAO_WAREHOUSE");
String combobox = (String) zt_combobox.getSelectedItem();
boolean flag = true;
for (int i = 0; i < BOMZT.length; i++) {
String s2 = BOMZT[i].split(";")[2];
String s1 = BOMZT[i].split(";")[1];
String s0 = BOMZT[i].split(";")[0];
cangku1 = s2;
System.out.println("11.05-cangku1====="+cangku1);
zhangtao1 = s1;
System.out.println("11.05-zhangtao1====="+zhangtao1);
group = s0;
System.out.println("11.05-group====="+group);
//判断选中的是否和首选项中的一致,是就跳出循环,不再赋值
if(combobox.equals(s0+":"+s1)) {
flag = false;
break;
}
}
}
}

@ -0,0 +1,19 @@
package com.connor.dfl.plm.dfl044;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class Dfl044Handler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
new Thread(new Dfl044Action(app,"")).start();
return null;
}
}

@ -0,0 +1,46 @@
package com.connor.dfl.plm.dfl044;
import javax.swing.JTextField;
public class ERPStockandPrice {
private Integer ID; //ID
private String fun; //Àà±ð
private String item_id;//Æ·ºÅ
private String zhangtao;//ÕËÌ×
private String User_id;//Óû§id
public Integer getID() {
return ID;
}
public void setID(Integer ID) {
this.ID = ID;
}
public String getfun() {
return fun;
}
public void setfun(String fun) {
this.fun = fun;
}
public String getitem_id() {
return item_id;
}
public void setitem_id(String item_id) {
this.item_id = item_id;
}
public String getzhangtao() {
return zhangtao;
}
public void setzhangtao(String zhangtao) {
this.zhangtao = zhangtao;
}
public String getUser_id() {
return User_id;
}
public void setUser_id(String User_id) {
this.User_id = User_id;
}
}

@ -0,0 +1,24 @@
package com.connor.dfl.plm.dfl045;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
public class Dfl045Action extends AbstractAIFAction {
private AbstractAIFUIApplication app;
public Dfl045Action(AbstractAIFUIApplication app, String string) {
super(app,string);
this.app=app;
}
@Override
public void run() {
try {
new Dfl045Command(app).executeModal();
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,20 @@
package com.connor.dfl.plm.dfl045;
import com.teamcenter.rac.aif.AbstractAIFCommand;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.kernel.TCSession;
public class Dfl045Command extends AbstractAIFCommand {
private TCSession session;
public Dfl045Command(AbstractAIFUIApplication app) {
this.session=(TCSession)app.getSession();
}
@Override
public void executeModal() throws Exception {
new Thread(new Dfl045Dialog(session)).start();
}
}

@ -0,0 +1,229 @@
package com.connor.dfl.plm.dfl045;
import java.awt.Color;
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.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.text.SimpleDateFormat;
import java.time.Year;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.MissingResourceException;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.filechooser.FileSystemView;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableRowSorter;
import org.jacorb.idl.runtime.int_token;
import com.connor.dfl.plm.dfl025.Dfl025Operation;
import com.connor.dfl.plm.dfl028.Dfl028AIFDialog;
import com.connor.dfl.plm.dfl040.DateChooser;
import com.connor.dfl.plm.dfl042.ERPTransferStatusbean;
import com.connor.dfl.plm.util.DataBaseControl;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.commands.open.OpenCommand;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentGroup;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.ButtonLayout;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout;
import com.teamcenter.rac.util.Registry;
import com.teamcenter.soaictstubs.stringSeq_tHolder;
import sun.awt.www.content.audio.x_aiff;
public class Dfl045Dialog extends AbstractAIFDialog {
private static final long serialVersionUID = 6130114042631785757L;
private static final int width=800;
DefaultTableModel model;
private AbstractAIFUIApplication app;
private TCSession session;
private JFileChooser jFileChooser;
private JButton bowBtn = new JButton("浏览");
private JButton qryBtn = new JButton("导出");
private JButton celBtn = new JButton("取消");
private JLabel StarttimeLabel = new JLabel("流程统计开始时间:");//文本
private JLabel endtimeLabel=new JLabel("流程统计结束时间:"); //文本
private JLabel exportLabel=new JLabel("导出目录:"); //文本
private JTextField starttimeField; //开始时间框
private JTextField endtimeField; //结束时间框
private JTextField jtf = new JTextField(15); //浏览文件路径
private HashMap<String, String> account_set = new HashMap();
private String starttime = ""; //SQL语句中的账套
private String endtime = "";//SQL语句中的仓库号
//private DataBaseControl2 data;
public Dfl045Dialog(TCSession session) {
super(false);
this.app = app;
this.session=session;
//this.service = session.getPreferenceService();
//this.data = new DataBaseControl2(session,"DFL2_ERP_SQL_Connect");
String[] BOMZT = session.getPreferenceService().getStringValues("DFL2_ZHANGTAO_WAREHOUSE");
}
@Override
public void run() {
//显示窗口
initUI();
}
@SuppressWarnings("serial")
private void initUI() {
//设置整体界面
this.setTitle("导出流程报表");
this.setLayout(new FlowLayout(FlowLayout.CENTER,2,3));
this.setPreferredSize(new Dimension(width, 150));
this.setLocation(2, 5);
model = new DefaultTableModel() {
private static final long serialVersionUID = 6905817304437097181L;
public boolean isCellEditable(int row, int column) {
return true;
}
};
//定义容器
JPanel qryPanel=new JPanel(new PropertyLayout());
//设置控件
FileSystemView fsv = FileSystemView.getFileSystemView();
String deskPath = fsv.getHomeDirectory().getPath();
this.jtf.setText(deskPath);
// 初始化日期控件
Date date = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String time = df.format(date);
//设置时间选择框
starttimeField = new JTextField(15);
starttimeField.setText(time);
endtimeField = new JTextField(15);
endtimeField.setText(time);
//初始化赋值
jFileChooser = new JFileChooser();
this.jFileChooser.setCurrentDirectory(new File(deskPath));// 文件选择器的初始目录定为当前用户桌面
this.jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
// 注册日期面板
DateChooser dateChooser1 = DateChooser.getInstance("yyyy-M-d");
DateChooser dateChooser2 = DateChooser.getInstance("yyyy-M-d");
dateChooser1.register(starttimeField);
dateChooser2.register(endtimeField);
qryPanel.add("1.1.center.top",StarttimeLabel);//添加开始时间文本框
qryPanel.add("1.2.center.top",starttimeField);//添加开始时间框
qryPanel.add("2.1.center.top",endtimeLabel);//添加结束时间文本框
qryPanel.add("2.2.center.top",endtimeField);//添加结束时间框
qryPanel.add("3.1.center.top",exportLabel);//导出目录文本框
qryPanel.add("3.2.center.top",jtf);//导出目录选择框
qryPanel.add("3.3.center.top",bowBtn);//浏览按钮
qryPanel.add("3.4.center.top",qryBtn);//导出按钮
qryPanel.add("3.5.center.top",celBtn);//取消按钮
//JPanel southPanel = new JPanel(new FlowLayout());
//浏览按钮监听事件
bowBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
selectFileButtonEvent();
}
});
//导出按钮监听事件
qryBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
//下拉值对比
okEvent();
}
});
//取消按钮监听事件
celBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
disposeDialog();
}
});
//southPanel.add(celBtn);
JPanel rootPanel=new JPanel(new ButtonLayout());
this.add(qryPanel);
this.add(rootPanel);
this.setResizable(false);
this.setAlwaysOnTop(false);
this.showDialog();
}
public void okEvent() {
try {
String path = jtf.getText();
if("".equals(path) || " ".equals(path)) {
MessageBox.post("请选择要导出的路径!!",
"提示", MessageBox.INFORMATION);
return;
}
System.out.println("ok");
starttime = starttimeField.getText()+" 00:00";
endtime = endtimeField.getText()+" 00:00";
Dfl045Operation operation = new Dfl045Operation(session,starttime,endtime,path);
session.queueOperation(operation);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.disposeDialog();
this.dispose();
}
//获取文件选择路径
public void selectFileButtonEvent() {
int state = jFileChooser.showOpenDialog(null);// 此句是打开文件选择器界面的触发语句
if (state == 1) {
return;
} else {
File f = jFileChooser.getSelectedFile();// f为选择到的目录
jtf.setText(f.getAbsolutePath());
}
}
/**
*
* @return tabledataVector
*/
}

@ -0,0 +1,19 @@
package com.connor.dfl.plm.dfl045;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class Dfl045Handler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
new Thread(new Dfl045Action(app,"")).start();
return null;
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,77 @@
package com.connor.dfl.plm.dfl046;
public class AutoCreateBean {
private String item_id;//品号
private String name;//名称
private String spec;//规格
private String unit;//单位
private String design_num;//设计用量
private String brand;//品牌
private String weihao;//编号
private String importance;//重要度
private String num;//序号
private int level;//等级
public String getItem_id() {
return item_id;
}
public void setItem_id(String item_id) {
this.item_id = item_id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSpec() {
return spec;
}
public void setSpec(String spec) {
this.spec = spec;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getDesign_num() {
return design_num;
}
public void setDesign_num(String design_num) {
this.design_num = design_num;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public String getWeihao() {
return weihao;
}
public void setWeihao(String weihao) {
this.weihao = weihao;
}
public String getImportance() {
return importance;
}
public void setImportance(String importance) {
this.importance = importance;
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
}

@ -0,0 +1,52 @@
package com.connor.dfl.plm.dfl046;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.pse.common.BOMLineNode;
import com.teamcenter.rac.pse.common.BOMTreeTableModel;
import com.teamcenter.rac.pse.operations.ExpandBelowOperation;
import com.teamcenter.rac.psebase.AbstractBOMLineViewerApplication;
import com.teamcenter.rac.psebase.common.AbstractViewableTreeTable;
import com.teamcenter.rac.util.AdapterUtil;
import com.teamcenter.rac.util.MessageBox;
/**
* Our sample handler extends AbstractHandler, an IHandler base class.
* @see org.eclipse.core.commands.IHandler
* @see org.eclipse.core.commands.AbstractHandler
*/
public class BOMExportHandler extends AbstractHandler {
/**
* The constructor.
*/
public BOMExportHandler() {
}
/**
* the command has been executed, so extract extract the needed information
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
AbstractAIFApplication app=AIFUtility.getCurrentApplication();
//DL2_VehicleRevision DL2_EBOM
if(app.getTargetComponent() instanceof TCComponentBOMLine){
TCSession session=(TCSession) app.getSession();
test operation=new test(app, session);
session.queueOperation(operation);
}else{
MessageBox.post("ÇëÑ¡ÔñBOMLine","",2);
}
return null;
}
}

@ -0,0 +1,56 @@
package com.connor.dfl.plm.dfl046;
import java.util.List;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMViewRevision;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentContextList;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentQuery;
import com.teamcenter.rac.kernel.TCComponentQueryType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCQueryClause;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCTextService;
import com.teamcenter.rac.kernel.TCTypeService;
import com.teamcenter.rac.kernel.TCUserService;
import com.teamcenter.rac.util.MessageBox;
public class ChangeDbomUtil {
public static TCPreferenceService service;
public static TCSession session;
public static TCUserService userservice;;
static {
if (session == null) {
session = (TCSession) (AIFUtility.getCurrentApplication()
.getSession());
}
if (service == null)
service = session.getPreferenceService();
}
public static void setByPass(boolean val) throws TCException {
if (userservice == null) {
userservice = session.getUserService();
}
Object[] obj = new Object[1];
obj[0] = "origin";
if (val) {
// userservice.call("ORIGIN_set_bypass", obj);
userservice.call("Connor_set_bypass", obj);
} else {
// userservice.call("ORIGIN_close_bypass", obj);
userservice.call("Connor_close_bypass", obj);
}
}
}

File diff suppressed because it is too large Load Diff

@ -24,6 +24,7 @@ import org.jacorb.idl.runtime.int_token;
import com.connor.dfl.plm.dfl019.ClassPropBean; import com.connor.dfl.plm.dfl019.ClassPropBean;
import com.connor.dfl.plm.dfl019.ItemBean; import com.connor.dfl.plm.dfl019.ItemBean;
import com.connor.dfl.plm.dfl019.ParseXMLUtil; import com.connor.dfl.plm.dfl019.ParseXMLUtil;
import com.connor.dfl.plm.dfl044.DataBaseControl2;
import com.connor.dfl.plm.util.ClassValueBean; import com.connor.dfl.plm.util.ClassValueBean;
import com.connor.dfl.plm.util.ClassValueUtil; import com.connor.dfl.plm.util.ClassValueUtil;
import com.connor.dfl.plm.util.ProgressBarThread; import com.connor.dfl.plm.util.ProgressBarThread;
@ -44,7 +45,7 @@ import com.teamcenter.rac.treetable.TreeTableNode;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.soaictstubs.stringSeq_tHolder; import com.teamcenter.soaictstubs.stringSeq_tHolder;
public class BOMExportOperation extends AbstractAIFOperation { public class test extends AbstractAIFOperation {
private AbstractAIFApplication app; private AbstractAIFApplication app;
private TCSession session; private TCSession session;
private ProgressBarThread wait; private ProgressBarThread wait;
@ -55,10 +56,11 @@ public class BOMExportOperation extends AbstractAIFOperation {
private String xuninum = "1"; private String xuninum = "1";
private String xuanzhongid = null; private String xuanzhongid = null;
private DataBaseControl2 data;
private String item_id1 = "";//品号 item_id private String item_id1 = "";//品号 item_id
private String rev_id1 = ""; //版本 item_revision_id private String rev_id1 = ""; //版本 item_revision_id
private String name1 = "";//名称 object_name private String name1 = "";//名称 object_name
private String oldid1 = "";//旧品号
private String spec1 = "";//规格 private String spec1 = "";//规格
private String unit1 = "";//单位 t2_unit private String unit1 = "";//单位 t2_unit
private String design_num1;//设计用量 bl_quantity private String design_num1;//设计用量 bl_quantity
@ -67,11 +69,45 @@ public class BOMExportOperation extends AbstractAIFOperation {
private String source1 = "";//来源码 private String source1 = "";//来源码
private String weihao1 = "";//编号 T2_weihao private String weihao1 = "";//编号 T2_weihao
private String importance1 = "";//重要度 t2_BOMImportance private String importance1 = "";//重要度 t2_BOMImportance
private String price1 = "";//单价
private String total1 = "";//总价
private int xuhao1 ; private int xuhao1 ;
private String lev1 = ""; private String zhangtao = "";
public BOMExportOperation(AbstractAIFApplication app, TCSession session) { public test(AbstractAIFApplication app, TCSession session) {
this.app = app; this.app = app;
this.session = session; this.session = session;
this.data = new DataBaseControl2(session,"DFL2_ERP_SQL_Connect");
String[] BOMZT = session.getPreferenceService().getStringValues("DFL2_ZHANGTAO_WAREHOUSE");
if (BOMZT == null || BOMZT.length <= 0 ) {
MessageBox.post("首选项DFL2_ZHANGTAO_WAREHOUSE未配置,请联系管理员!!",
"错误", MessageBox.ERROR);
return;
}
TCComponentGroup group = session.getCurrentGroup();
try {
String group_name = group.getStringProperty("display_name");
System.out.println("11.04group_name=============="+group_name);
if(group_name.contains(".")) {
String[] names = group_name.split("\\.");
if(names != null && names.length >=2) {
for (int i = 0; i < BOMZT.length; i++) {
if(BOMZT[i].contains(";")) {
String[] zts = BOMZT[i].split(";");
if(names[names.length-2].equals(zts[0])) {
this.zhangtao = zts[1];
System.out.println("11.04账套======"+zhangtao);
break;
}
}
}
}
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
@Override @Override
public void executeOperation() throws Exception { public void executeOperation() throws Exception {
@ -87,10 +123,10 @@ public class BOMExportOperation extends AbstractAIFOperation {
} }
try { try {
System.out.println("开始获取BOM模板"); System.out.println("开始获取BOM模板");
String puid = session.getPreferenceService().getStringValue("DFL_BOM_UID"); String puid = session.getPreferenceService().getStringValue("DFL3_BOM_UID");
System.out.println("puid======================"+puid); System.out.println("puid======================"+puid);
if (puid == null||"".equals(puid)) { if (puid == null||"".equals(puid)) {
MessageBox.post("首选项DFL_BOM_UID未配置,请联系管理员!!", MessageBox.post("首选项DFL3_BOM_UID未配置,请联系管理员!!",
"错误", MessageBox.ERROR); "错误", MessageBox.ERROR);
return; return;
} }
@ -144,6 +180,11 @@ public class BOMExportOperation extends AbstractAIFOperation {
//对照表的获取方法 //对照表的获取方法
private void getAndSetValue1(TCComponentBOMLine bomLine,int level,int num) { private void getAndSetValue1(TCComponentBOMLine bomLine,int level,int num) {
//定义一个集合,将外购、外协存在一个集合内
List<TCComponentBOMLine> wai = new ArrayList<TCComponentBOMLine>();
//定义一个集合,将虚拟存在一个集合内
List<TCComponentBOMLine> xu = new ArrayList<TCComponentBOMLine>();
// TODO Auto-generated method stub // TODO Auto-generated method stub
try { try {
//通过解包方法来解包 //通过解包方法来解包
@ -186,13 +227,26 @@ public class BOMExportOperation extends AbstractAIFOperation {
{ {
//如果版本类型是外购件版本或者外协件版本则获取属性 //如果版本类型是外购件版本或者外协件版本则获取属性
if("T2_outsourceRevision".equals(type) || "T2_OutBuyPartRevision".equals(type)) { if("T2_outsourceRevision".equals(type) || "T2_OutBuyPartRevision".equals(type)) {
//序号+1
num++;
//将遍历的对象强转类型为bomline //将遍历的对象强转类型为bomline
TCComponentBOMLine ziLine = (TCComponentBOMLine) comp; TCComponentBOMLine ziLine = (TCComponentBOMLine) comp;
wai.add(ziLine);
}
//如果不是外购外协件
else {
TCComponentBOMLine ziLine = (TCComponentBOMLine) comp;
xu.add(ziLine);
}
}
}
}
//处理外购外协的数据
if(wai.size()>0) {
getItemValue1(ziLine,level,num); for (int i = 0;i<wai.size();i++) {
num++;
TCComponentBOMLine waiLine = wai.get(i);
getItemValue1(waiLine,level,num);
List<String> beanList1 = new ArrayList<String>(); List<String> beanList1 = new ArrayList<String>();
@ -211,6 +265,7 @@ public class BOMExportOperation extends AbstractAIFOperation {
beanList1.add(item_id1); beanList1.add(item_id1);
beanList1.add(rev_id1); beanList1.add(rev_id1);
beanList1.add(name1); beanList1.add(name1);
beanList1.add(oldid1);
//beanList1.add(lev1); //不要层级 //beanList1.add(lev1); //不要层级
beanList1.add(spec1); beanList1.add(spec1);
beanList1.add(unit1); beanList1.add(unit1);
@ -220,6 +275,8 @@ public class BOMExportOperation extends AbstractAIFOperation {
beanList1.add(source1); beanList1.add(source1);
beanList1.add(weihao1); beanList1.add(weihao1);
beanList1.add(importance1); beanList1.add(importance1);
// beanList1.add(price1);
// beanList1.add(total1);
System.out.println("beanList19.15====="+beanList1); System.out.println("beanList19.15====="+beanList1);
//先做布尔逻辑判断 //先做布尔逻辑判断
boolean include=idlist.contains(item_id1);//true boolean include=idlist.contains(item_id1);//true
@ -243,7 +300,7 @@ public class BOMExportOperation extends AbstractAIFOperation {
if(include1 == panduan) { if(include1 == panduan) {
String numString = null; String numString = null;
for(int k = 0 ; k<=beanList2.size() ; k++) { for(int k = 0 ; k<=beanList2.size() ; k++) {
numString = beanList2.get(6); numString = beanList2.get(7);
System.out.println("数量9.18====="+numString); System.out.println("数量9.18====="+numString);
} }
double before = Double.valueOf(numString).doubleValue(); double before = Double.valueOf(numString).doubleValue();
@ -251,7 +308,7 @@ public class BOMExportOperation extends AbstractAIFOperation {
double sum = before+add; double sum = before+add;
//String sum = ""+before+add; //String sum = ""+before+add;
System.out.println("9.18sum====="+sum); System.out.println("9.18sum====="+sum);
beanList2.set(6, ""+sum); beanList2.set(7, ""+sum);
list.set(j, beanList2); list.set(j, beanList2);
} }
} }
@ -260,14 +317,17 @@ public class BOMExportOperation extends AbstractAIFOperation {
System.out.println("list9.15====="+list); System.out.println("list9.15====="+list);
} }
} }
}
//处理虚拟件的数据
if(xu.size()>0) {
//如果不是外购外协件则递归此方法
else { for (int i = 0;i<xu.size();i++) {
TCComponentBOMLine ziLine = (TCComponentBOMLine) comp; TCComponentBOMLine xuLine = xu.get(i);
String xuniid = ziLine.getStringProperty("awb0BomLineItemId"); String xuniid = xuLine.getStringProperty("awb0BomLineItemId");
//判断如果没有该虚拟件下没有物料,则跳出此循环 //判断如果没有该虚拟件下没有物料,则跳出此循环
AIFComponentContext[] childs23 = ziLine.getChildren(); AIFComponentContext[] childs23 = xuLine.getChildren();
int geshu = childs23.length; int geshu = childs23.length;
System.out.println("个数为9.22====="+geshu+"====="+xuniid); System.out.println("个数为9.22====="+geshu+"====="+xuniid);
if (childs23.length <= 0 ) { if (childs23.length <= 0 ) {
@ -283,7 +343,7 @@ public class BOMExportOperation extends AbstractAIFOperation {
//设置虚拟件数量为double类型a //设置虚拟件数量为double类型a
double a = Double.valueOf(xuninum).doubleValue(); double a = Double.valueOf(xuninum).doubleValue();
System.out.println("8.12虚拟件的double数量a"+a+"===9.22虚拟件id==="+xuniid); System.out.println("8.12虚拟件的double数量a"+a+"===9.22虚拟件id==="+xuniid);
getItemValue1(ziLine,level,xuhao1); getItemValue1(xuLine,level,xuhao1);
//设置获取的数量为double类型b //设置获取的数量为double类型b
System.out.println("9.22运行方法后获得design_num1的值====="+design_num1); System.out.println("9.22运行方法后获得design_num1的值====="+design_num1);
double b = Double.valueOf(design_num1).doubleValue(); double b = Double.valueOf(design_num1).doubleValue();
@ -301,12 +361,9 @@ public class BOMExportOperation extends AbstractAIFOperation {
System.out.println("8.12第一个虚拟件"+xuninum+"===9.22虚拟件id==="+xuniid); System.out.println("8.12第一个虚拟件"+xuninum+"===9.22虚拟件id==="+xuniid);
//递归 //递归
getAndSetValue1(ziLine,level,xuhao1); getAndSetValue1(xuLine,level,xuhao1);
} }
} }
}
}
//level--; //level--;
} }
} catch (TCException e) { } catch (TCException e) {
@ -708,10 +765,13 @@ public class BOMExportOperation extends AbstractAIFOperation {
item_id1 = rev.getStringProperty("item_id"); item_id1 = rev.getStringProperty("item_id");
rev_id1 = rev.getStringProperty("item_revision_id"); rev_id1 = rev.getStringProperty("item_revision_id");
name1 = rev.getStringProperty("object_name"); name1 = rev.getStringProperty("object_name");
price1 = getPrice();
total1 = getTotal(design_num1,price1);
if("T2_outsourceRevision".equals(type)) { if("T2_outsourceRevision".equals(type)) {
xuhao1 = num ; xuhao1 = num ;
String classID = item_id1.substring(0, 2); String classID = item_id1.substring(0, 2);
item_id1 = item_id1+rev_id1; item_id1 = item_id1+rev_id1;
oldid1 = rev.getStringProperty("t2_OldId");
System.out.println("classID==============="+classID); System.out.println("classID==============="+classID);
if("51".equals(classID) || "72".equals(classID) || "76".equals(classID)) { if("51".equals(classID) || "72".equals(classID) || "76".equals(classID)) {
@ -725,10 +785,13 @@ public class BOMExportOperation extends AbstractAIFOperation {
spec1 = getOutsourceValue(rev); spec1 = getOutsourceValue(rev);
} }
unit1 = rev.getStringProperty("t2_unit"); unit1 = rev.getStringProperty("t2_unit");
brand1 = "";
}else if("T2_OutBuyPartRevision".equals(type)) { }else if("T2_OutBuyPartRevision".equals(type)) {
xuhao1 = num; xuhao1 = num;
ClassValueBean valueBean = ClassValueUtil.getOutBuyPartValue(rev,errList); ClassValueBean valueBean = ClassValueUtil.getOutBuyPartValue(rev,errList);
oldid1 = rev.getStringProperty("t2_OldID");
if(valueBean != null) { if(valueBean != null) {
spec1 = valueBean.getSpecs(); spec1 = valueBean.getSpecs();
unit1 = valueBean.getUnit(); unit1 = valueBean.getUnit();
@ -800,6 +863,39 @@ public class BOMExportOperation extends AbstractAIFOperation {
e.printStackTrace(); e.printStackTrace();
} }
} }
private String getPrice () {
String price = null;
String sql = null;
sql = "select ccc23a from " +zhangtao + ".ccc_file inner join "+zhangtao+".ccz_file on ccz01=ccc02 and ccz02=ccc03 where ccc01='"+item_id1+"'";
System.out.println("sql======"+sql);
try {
price = data.getRecord(sql);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("11.08==price=="+price);
if(price == null ) {
price ="";
}
return price;
}
private String getTotal(String quantity,String price) {
// TODO Auto-generated method stub
if("".equals(price)||" ".equals(price)||"null".equals(price)) {
price = "0";
}
String total;
double amount = Double.valueOf(quantity).doubleValue();
double tariff = Double.valueOf(price).doubleValue();
double product = amount * tariff ;
total = ""+product;
System.out.println("11.08==总价====="+total);
return total;
}
//匹配分群码 //匹配分群码
private void getgroup() { private void getgroup() {
if("F10".equals(group1)) { if("F10".equals(group1)) {
Loading…
Cancel
Save