parent
e3ee0e25b6
commit
b897f349f2
@ -0,0 +1,69 @@
|
||||
package com.connor.plm.txdp;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.chint.sap2.util.SAPUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class BZGSHandler extends AbstractHandler{
|
||||
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||
TCSession session = (TCSession) app.getSession();
|
||||
try {
|
||||
|
||||
|
||||
//获取首选项判断用户是否可以使用该功能
|
||||
String[] prefs = session.getPreferenceService().getStringValues("CHINT_WORKHOUR_ACL");
|
||||
String userId = session.getUser().getUserId();
|
||||
String groupID = SAPUtil.getGroupID(session);
|
||||
HashMap<String, String> groupNamesMap = new HashMap<String, String>();
|
||||
for (int i = 0; i < prefs.length; i++) {
|
||||
String[] split = prefs[i].split(":");
|
||||
groupNamesMap.put(split[0], split[1]);
|
||||
}
|
||||
System.out.println("groupNamesMap==="+groupNamesMap.toString());
|
||||
String names = groupNamesMap.get(groupID);
|
||||
System.out.println("names==="+names);
|
||||
if(names == null || names.isEmpty()) {
|
||||
MessageBox.post("您无权使用此功能,请联系管理员处理。", "提示", MessageBox.INFORMATION);
|
||||
return null;
|
||||
}else {
|
||||
if(!names.contains(userId)) {
|
||||
MessageBox.post("您无权使用此功能,请联系管理员处理。", "提示", MessageBox.INFORMATION);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
try {
|
||||
new BZGSFram(session);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}.start();
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
package com.connor.plm.txdp;
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.chint.yunpi.command.BomDcSapOp;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
|
||||
public class GXTZHandler extends AbstractHandler{
|
||||
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||
TCSession session = (TCSession) app.getSession();
|
||||
try {
|
||||
|
||||
|
||||
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
try {
|
||||
new GXTZOp(app).executeOperation();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}.start();
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,175 @@
|
||||
package com.connor.plm.txdp;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
|
||||
import com.connor.chint.sap2.util.BomToSapUtil;
|
||||
import com.connor.chint.sap2.util.BomUtilWh;
|
||||
import com.connor.chint.sap2.util.KUtil;
|
||||
import com.connor.chint.sap2.util.MyProgressBarCompent;
|
||||
import com.connor.chint.sap2.util.SAPMessageUtil;
|
||||
import com.connor.chint.sap2.util.SAPUtil;
|
||||
import com.connor.chint.sap2.util.SqlUtil;
|
||||
import com.connor.chint.sap2.util.TXTUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.AbstractAIFOperation;
|
||||
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.TCComponentBOMWindow;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
|
||||
import com.teamcenter.rac.kernel.TCComponentDataset;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCComponentMEProcessRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentUser;
|
||||
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;
|
||||
|
||||
public class GXTZOp extends AbstractAIFOperation {
|
||||
|
||||
private AbstractAIFApplication app;
|
||||
private TCSession session;
|
||||
private String groupName;
|
||||
private String userName;
|
||||
private String[] prefs;
|
||||
|
||||
public GXTZOp(AbstractAIFApplication app) {
|
||||
// Auto-generated constructor stub
|
||||
this.app = app;
|
||||
this.session = (TCSession) app.getSession();
|
||||
|
||||
prefs = session.getPreferenceService().getStringValues("CHINT_SRM_SQL_CONNECT");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOperation() throws Exception {
|
||||
// Auto-generated method stub
|
||||
MyProgressBarCompent comp = null;
|
||||
SqlUtil.SRMGetTCDataConnection(prefs);
|
||||
try {
|
||||
KUtil.setByPass(true);
|
||||
groupName = SAPUtil.getGroupID(session);
|
||||
userName = getUserName(session);
|
||||
System.out.println(groupName + "------------------" + userName);
|
||||
InterfaceAIFComponent target = app.getTargetComponent();
|
||||
TCComponentItemRevision degignRev = null;
|
||||
if (target != null && target.getType().equals("ZT2_Design3DRevision")) {
|
||||
degignRev = (TCComponentItemRevision) target;
|
||||
|
||||
} else {
|
||||
MessageBox.post("请选择图纸版本", "", MessageBox.INFORMATION);
|
||||
return;
|
||||
}
|
||||
|
||||
// sql查询获取对应组的图纸id
|
||||
HashMap<String, String> sqlMap = new HashMap<String, String>();
|
||||
String selectSql = "SELECT \"drawingno\",\"source\" FROM CHINT_DESIGN__SOURCE_RULE WHERE \"factory\" = '"
|
||||
+ groupName + "'";
|
||||
System.out.println("selectSql =========" + selectSql);
|
||||
ResultSet rs = SqlUtil.read(selectSql);
|
||||
while (rs.next()) {
|
||||
sqlMap.put(rs.getString(1), rs.getString(2));
|
||||
}
|
||||
if (sqlMap.size() == 0) {
|
||||
MessageBox.post("该组织未在数据库中获取到图纸", "", MessageBox.INFORMATION);
|
||||
return;
|
||||
}
|
||||
System.out.println("sqlMap====" + sqlMap.toString());
|
||||
|
||||
comp = new MyProgressBarCompent("", "正在进行更新图纸自制外购....");
|
||||
String lineSeparator = System.lineSeparator();// 换行符
|
||||
StringBuffer errMessage = new StringBuffer("");
|
||||
StringBuffer succMessage = new StringBuffer("");
|
||||
succMessage.append("成功修改数据如下:").append(lineSeparator);
|
||||
errMessage.append("无法修改数据如下:").append(lineSeparator);
|
||||
String current_user_name = getUserName(session);
|
||||
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
||||
TCComponentBOMWindow win = bomWinType.create(null);
|
||||
TCComponentBOMLine setWindowTopLine = win.setWindowTopLine(degignRev.getItem(), degignRev, null, null);
|
||||
|
||||
// soa获取bom子
|
||||
List<TCComponentItemRevision> childLines = BomToSapUtil.getBomLineTreeNodeSOA2(setWindowTopLine);
|
||||
System.out.println("childLines.size====" + childLines.size());
|
||||
|
||||
// 遍历逻辑
|
||||
for (int i = 0; i < childLines.size(); i++) {
|
||||
TCComponentItemRevision tcComponentItemRevision = childLines.get(i);
|
||||
String[] properties = tcComponentItemRevision
|
||||
.getProperties(new String[] { "item_id", "item_revision_id" });
|
||||
String zt2_Source = tcComponentItemRevision.getStringProperty("zt2_Source");
|
||||
for (Entry<String, String> map : sqlMap.entrySet()) {
|
||||
String key = map.getKey();
|
||||
if (properties[0].contains(key)) {
|
||||
String value = map.getValue();
|
||||
System.out.println("item_id========" + properties[0]);
|
||||
if (!zt2_Source.equals(value)) {
|
||||
|
||||
// 判断是否发布
|
||||
if (KUtil.isTCM(tcComponentItemRevision)) {
|
||||
errMessage.append(properties[0] + "-" + properties[1] + "因发布无法更改,请手工处理");
|
||||
errMessage.append(lineSeparator);
|
||||
} else {
|
||||
|
||||
// 判断登录人是否owning_user
|
||||
TCComponent owning_user = tcComponentItemRevision.getReferenceProperty("owning_user");
|
||||
String user_name = owning_user.getProperty("user_name");
|
||||
if (current_user_name.equals(user_name)) {
|
||||
// 修改版本的值
|
||||
tcComponentItemRevision.setProperty("zt2_Source", value);
|
||||
succMessage.append(
|
||||
properties[0] + "-" + properties[1] + "已从" + (zt2_Source.equals("S1")?"自制":"外购") + "改成" + (value.equals("S1")?"自制":"外购"));
|
||||
succMessage.append(lineSeparator);
|
||||
} else {
|
||||
errMessage.append(properties[0] + "-" + properties[1] + "所有者为" + user_name
|
||||
+ ",无法更改,请联系" + user_name);
|
||||
errMessage.append(lineSeparator);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
win.close();
|
||||
if (comp != null) {
|
||||
comp.setVisible(false);
|
||||
}
|
||||
|
||||
MessageBox.post(succMessage.toString() + lineSeparator + errMessage.toString(), "项目BOM传递SAP", 2);
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
KUtil.setByPass(false);
|
||||
}
|
||||
}
|
||||
|
||||
public String getUserName(TCSession session) throws TCException {
|
||||
TCComponentUser user = session.getUser();
|
||||
session.getUserName();
|
||||
return user.getTCProperty("user_name").getDisplayValue();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue