20240802分发包代码上传

master
李冬阳 11 months ago
parent 96eac805ed
commit f4b5b5cb20

@ -18,24 +18,41 @@ public class WorkhourService {
* @return * @return
*/ */
public static EasyResponse<List<String>> getProducttype(String companycode) { public static EasyResponse<List<String>> getProducttype(String companycode) {
String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhourType/getProducttype"; String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhour/getProducttype";
Map<String, Object> paramMap = new LinkedHashMap<String, Object>(); Map<String, Object> paramMap = new LinkedHashMap<String, Object>();
paramMap.put("companycode", companycode); paramMap.put("companycode", companycode);
String result = HttpUtils.get(url, paramMap); String result = HttpUtils.get(url, paramMap);
return JSONObject.parseObject(result, new TypeReference<EasyResponse<List<String>>>(EasyResponse.class){}); return JSONObject.parseObject(result, new TypeReference<EasyResponse<List<String>>>(EasyResponse.class){});
} }
/**
* »ñÈ¡µçѹµÈ¼
* @param companycode
* @param producttype
* @return
*/
public static EasyResponse<List<String>> getVoltagelevel(String companycode, String producttype) {
String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhour/getVoltagelevel";
Map<String, Object> paramMap = new LinkedHashMap<String, Object>();
paramMap.put("companycode", companycode);
paramMap.put("producttype", producttype);
String result = HttpUtils.get(url, paramMap);
return JSONObject.parseObject(result, new TypeReference<EasyResponse<List<String>>>(EasyResponse.class){});
}
/** /**
* »ñÈ¡²úÆ·ÐͺŠ* »ñÈ¡²úÆ·ÐͺÅ
* @param companycode * @param companycode
* @param producttype * @param producttype
* @param voltagelevel
* @return * @return
*/ */
public static EasyResponse<List<String>> getProductxh(String companycode, String producttype) { public static EasyResponse<List<String>> getProductxh(String companycode, String producttype, String voltagelevel) {
String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhourXh/getProductxh"; String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhour/getProductxh";
Map<String, Object> paramMap = new LinkedHashMap<String, Object>(); Map<String, Object> paramMap = new LinkedHashMap<String, Object>();
paramMap.put("companycode", companycode); paramMap.put("companycode", companycode);
paramMap.put("producttype", producttype); paramMap.put("producttype", producttype);
paramMap.put("voltagelevel", voltagelevel);
String result = HttpUtils.get(url, paramMap); String result = HttpUtils.get(url, paramMap);
return JSONObject.parseObject(result, new TypeReference<EasyResponse<List<String>>>(EasyResponse.class){}); return JSONObject.parseObject(result, new TypeReference<EasyResponse<List<String>>>(EasyResponse.class){});
} }
@ -46,7 +63,7 @@ public class WorkhourService {
* @return * @return
*/ */
public static EasyResponse<List<String>> getJsask(String companycode) { public static EasyResponse<List<String>> getJsask(String companycode) {
String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhourAsk/getJsask"; String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhour/getJsask";
Map<String, Object> paramMap = new LinkedHashMap<String, Object>(); Map<String, Object> paramMap = new LinkedHashMap<String, Object>();
paramMap.put("companycode", companycode); paramMap.put("companycode", companycode);
String result = HttpUtils.get(url, paramMap); String result = HttpUtils.get(url, paramMap);

@ -11,37 +11,37 @@ public class BOMDifferenceBean {
/** /**
* *
*/ */
public TCComponentItemRevision oldRev; private TCComponentItemRevision oldRev;
/** /**
* *
*/ */
public TCComponentItemRevision newRev; private TCComponentItemRevision newRev;
/** /**
* *
*/ */
public TCComponentItemRevision oldPartRev; private TCComponentItemRevision oldPartRev;
/** /**
* *
*/ */
public TCComponentItemRevision newPartRev; private TCComponentItemRevision newPartRev;
/** /**
* *
*/ */
public TCComponentItemRevision parentPartRev; private TCComponentItemRevision parentPartRev;
/** /**
* *
*/ */
public String zt2_MaterialNo_Parent; private String zt2_MaterialNo_Parent;
/** /**
* *
*/ */
public String object_desc_Parent; private String object_desc_Parent;
/** /**
* *
*/ */
public String object_name_Parent; private String object_name_Parent;
public String getObject_name_Parent() { public String getObject_name_Parent() {
return object_name_Parent; return object_name_Parent;
@ -58,17 +58,21 @@ public class BOMDifferenceBean {
/** /**
* BOMLine * BOMLine
*/ */
TCComponentBOMLine oldBOMLine; private TCComponentBOMLine oldBOMLine;
/** /**
* BOMLine * BOMLine
*/ */
TCComponentBOMLine newBOMLine; private TCComponentBOMLine newBOMLine;
/** /**
* *
*/ */
private String rev_object_type; private String rev_object_type;
private TCComponentItemRevision rev; private TCComponentItemRevision rev;
/**
* ÊÇ·ñ¿ò¼Ü²ã
*/
private boolean isKj;
public TCComponentItem getItem() { public TCComponentItem getItem() {
return item; return item;
@ -276,6 +280,14 @@ public class BOMDifferenceBean {
this.rev = rev; this.rev = rev;
} }
public boolean isKj() {
return isKj;
}
public void setKj(boolean isKj) {
this.isKj = isKj;
}
public String getId() { public String getId() {
return (zt2_MaterialNo_Parent == null ? "" : zt2_MaterialNo_Parent) + "@" + (item == null ? "" : item); return (zt2_MaterialNo_Parent == null ? "" : zt2_MaterialNo_Parent) + "@" + (item == null ? "" : item);
} }

@ -323,8 +323,8 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
if (pb != null) { if (pb != null) {
pb.disposeDialog(); pb.disposeDialog();
} }
MessageBox.post("½çÃæ³õʼ»¯Ê§°Ü:" + e.getMessage(), "", 2);
e.printStackTrace(); e.printStackTrace();
MessageBox.post("½çÃæ³õʼ»¯Ê§°Ü:" + e.getMessage(), "", 2);
disposeDialog(); disposeDialog();
} finally { } finally {
KUtil.setByPass(false); KUtil.setByPass(false);

@ -1,9 +1,7 @@
package com.connor.chint.sap2.lijc; package com.connor.chint.sap2.lijc;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -14,28 +12,15 @@ import com.connor.chint.sap2.dy.createElectricalBOM.WebApiUtil;
import com.connor.chint.sap2.util.ChintPreferenceUtil; import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.SqlUtil; import com.connor.chint.sap2.util.SqlUtil;
import com.connor.chint.sap2.util.ZYFactoryUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext; import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent; 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.TCComponentFolder; import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentGroup;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentSchedule; import com.teamcenter.rac.kernel.TCComponentSchedule;
import com.teamcenter.rac.kernel.TCPreferenceService; import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCTypeService;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.bom._2008_06.StructureManagement.RemoveChildrenFromParentLineResponse;
import com.teamcenter.services.rac.core.DataManagementService;
import com.teamcenter.services.rac.core._2006_03.DataManagement.ReviseResponse;
import com.teamcenter.soa.client.model.ErrorStack;
public class GetDesignDsCommand extends KCommand{ public class GetDesignDsCommand extends KCommand{
@ -168,7 +153,7 @@ public class GetDesignDsCommand extends KCommand{
if (SqlUtil.getTCDataConnection(database_tc) == null) { if (SqlUtil.getTCDataConnection(database_tc) == null) {
throw new Exception("TC数据库连接失败"); throw new Exception("TC数据库连接失败");
} }
Map esbMap=new HashMap(); Map<String, Object> esbMap=new HashMap<>();
try { try {
System.out.println("selectSql==>"+selectSql); System.out.println("selectSql==>"+selectSql);
ResultSet rs = SqlUtil.read(selectSql); ResultSet rs = SqlUtil.read(selectSql);
@ -199,10 +184,15 @@ public class GetDesignDsCommand extends KCommand{
if (pathList.size()>0) { if (pathList.size()>0) {
TCComponent[] relatedComponents = xmzx_folder.getRelatedComponents("contents"); TCComponent[] relatedComponents = xmzx_folder.getRelatedComponents("contents");
TCComponentFolder tptz = null; TCComponentFolder tptz = null;
String folderName = "Í­ÅÅͼֽ";
if(actionInfo.equals("BOM")) {
//TODO lidy20240725
folderName = "Í­ÅÅÉè¼Æ";
}
for(TCComponent relatedComponent:relatedComponents) { for(TCComponent relatedComponent:relatedComponents) {
String cName = relatedComponent.getProperty("object_name"); String cName = relatedComponent.getProperty("object_name");
System.out.println(">> 找到子对象:" + cName); System.out.println(">> 找到子对象:" + cName);
if ((relatedComponent instanceof TCComponentFolder) && "Í­ÅÅͼֽ".contains(cName)) { if ((relatedComponent instanceof TCComponentFolder) && folderName.contains(cName)) {
tptz = (TCComponentFolder) relatedComponent; tptz = (TCComponentFolder) relatedComponent;
} }
} }

@ -10,10 +10,11 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.connor.chint.sap2.KCommand; import com.connor.chint.sap2.KCommand;
import com.connor.chint.sap2.bean.ApplyCodeFactoryBean;
import com.connor.chint.sap2.sap_zy.CodeBean; import com.connor.chint.sap2.sap_zy.CodeBean;
import com.connor.chint.sap2.util.ChintPreferenceUtil; import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.KUtil;
@ -31,7 +32,6 @@ import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType; import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentSchedule; import com.teamcenter.rac.kernel.TCComponentSchedule;
import com.teamcenter.rac.kernel.TCComponentUser;
import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
@ -133,7 +133,7 @@ public class SendProjectLcCommand extends KCommand {
} }
TCComponent[] allTasks = schedule.getAllTasks(); TCComponent[] allTasks = schedule.getAllTasks();
if(allTasks== null ||allTasks.length<2) { if(allTasks == null || allTasks.length < 2) {
MessageBox.post(schedule+"时间表下未找到任务,请检查数据","",MessageBox.INFORMATION); MessageBox.post(schedule+"时间表下未找到任务,请检查数据","",MessageBox.INFORMATION);
return; return;
} }
@ -144,7 +144,7 @@ public class SendProjectLcCommand extends KCommand {
tpsjTask = allTask; tpsjTask = allTask;
} }
} }
if(tpsjTask==null) { if(tpsjTask == null) {
MessageBox.post("时间表中没有找到名称为铜排设计的任务","提示",2); MessageBox.post("时间表中没有找到名称为铜排设计的任务","提示",2);
return; return;
} }
@ -153,18 +153,76 @@ public class SendProjectLcCommand extends KCommand {
String userId = user == null ? "" : user.getProperty("user_id"); String userId = user == null ? "" : user.getProperty("user_id");
String userName = user == null ? "" : user.getProperty("user_name"); String userName = user == null ? "" : user.getProperty("user_name");
Map<String,String> lcApplyMap = new HashMap<>(); Map<String, String> lcApplyMap = new HashMap<>();
//获取编码申请的规则 //获取编码申请的规则
String[] preferences = ChintPreferenceUtil.getPreferences("Chint_lcApplyCode", session); String[] preferences = ChintPreferenceUtil.getPreferences("Chint_lcApplyCode", session);
for(String preference:preferences) { for(String preference : preferences) {
String[] split = preference.split(":"); String[] split = preference.split(":");
String[] split2 = split[1].split(";"); String[] split2 = split[1].split(";");
for(String fac:split2) { for(String fac : split2) {
lcApplyMap.put(fac, split[0]); lcApplyMap.put(fac, split[0]);
} }
} }
//出厂编号的前缀进行匹配,得到方案号
Map<String, String> fahMap = new HashMap<>();
String prefs = ChintPreferenceUtil.getPreference("CHINT_FactoryNoTPBOM", session);
for(String pref : prefs.split(";")) {
String split = pref.substring(0, pref.indexOf(":"));
String fah = pref.substring(pref.indexOf("|") + 1);
String[] split2 = split.split("、");
for(String fac : split2) {
fahMap.put(fac, fah);
}
}
StringBuilder err = new StringBuilder("");
AIFComponentContext[] children = ccbh_folder.getChildren();
for(AIFComponentContext c : children) {//TODO ccbh
TCComponent ccbh = (TCComponent) c.getComponent();
System.out.println("ccbh:" + ccbh);
//出厂编号的前缀前缀取ID号第一个数字前的值与首选项CHINT_FactoryNoTPBOM里的值进行匹配得到方案号
String id = ccbh.getProperty("item_id");
Pattern pattern = Pattern.compile("[0-9]");
Matcher matcher = pattern.matcher(id);
int index = 0;
while (matcher.find()) {
index = matcher.start();
break;
}
String key = id.substring(0, index);
if(!fahMap.containsKey(key)) {
err.append(id).append("在首选项中未找到匹配的前缀\n");
continue;
}
//根据获取到的方案号去项目对象下“项目执行”下“铜排设计”文件夹获取所有的方案编码
//检查方案编码版本属性“zt2_MaterialNo”属性值截取“-”前面的值)进行匹配,匹配的上代表方案编码已创建
key = fahMap.get(key) + "-";
boolean check = true;
for(AIFComponentContext t : tpsj.getChildren()) {
TCComponentItemRevision fabm = ((TCComponentItem) t.getComponent()).getLatestItemRevision();
System.out.println("fabm:" + fabm);
String zt2_MaterialNo = fabm.getProperty("zt2_MaterialNo");
if(zt2_MaterialNo.startsWith(key)) {
check = false;
//检查方案编码对象版本下的关系文件夹中是否有“出厂编号”对象
if(KUtil.getPseudoFolder(fabm, "ZT2_FactoryNumber").getChildren().length == 0) {
System.out.println("未关联出厂编号");
if(!err.toString().contains(zt2_MaterialNo))
err.append("当前项目中铜排方案编码").append(zt2_MaterialNo).append("未关联出厂编号\n");
}
break;
}
}
if(check) {
err.append("当前项目").append(id).append("未创建铜排方案编码\n");
continue;
}
}
if(err.length() > 0) {
MessageBox.post(err.toString(), "提示", MessageBox.ERROR);
return;
}
Map esbMap=new HashMap(); Map<String, Object> esbMap = new HashMap<>();
String task_id = tpsjTask.getProperty("item_id"); String task_id = tpsjTask.getProperty("item_id");
esbMap.put("taskid",task_id); esbMap.put("taskid",task_id);
sql1[0] = task_id; sql1[0] = task_id;
@ -207,18 +265,17 @@ public class SendProjectLcCommand extends KCommand {
}else { }else {
esbMap.put("startdate",""); esbMap.put("startdate","");
} }
List<String[]> strsList = new ArrayList<>(); // List<String[]> strsList = new ArrayList<>();
List<Map> factoryNos = new ArrayList<Map>(); List<Map<String, String>> factoryNos = new ArrayList<>();
List<String> factorys_list = new ArrayList<>(); List<String> factorys_list = new ArrayList<>();
List<String> cpbm_list = new ArrayList<>(); List<String> cpbm_list = new ArrayList<>();
AIFComponentContext[] children = ccbh_folder.getChildren();
int lsh = 0; int lsh = 0;
int cno = 1; int cno = 1;
apply_lists.clear(); apply_lists.clear();
// Map<String,Integer> codeNum = new HashMap<>(); // Map<String,Integer> codeNum = new HashMap<>();
for(AIFComponentContext child : children) { for(AIFComponentContext child : children) {
Map facCpMap = new HashMap<>(); Map<String, String> facCpMap = new HashMap<>();
TCComponent ccbhTarget = (TCComponent) child.getComponent(); TCComponent ccbhTarget = (TCComponent) child.getComponent();
//查询出厂编号的引用,判断是否有铜排单元 //查询出厂编号的引用,判断是否有铜排单元
AIFComponentContext[] contexts22 = ccbhTarget.whereReferencedByTypeRelation( AIFComponentContext[] contexts22 = ccbhTarget.whereReferencedByTypeRelation(
@ -227,7 +284,7 @@ public class SendProjectLcCommand extends KCommand {
Boolean hasFabm = false; Boolean hasFabm = false;
List<TCComponentItemRevision> components = new ArrayList<>(); List<TCComponentItemRevision> components = new ArrayList<>();
String id = ""; String id = "";
for(int t=0;t<contexts22.length;t++) { for(int t = 0; t < contexts22.length; t++) {
TCComponentItemRevision component = (TCComponentItemRevision) contexts22[t].getComponent(); TCComponentItemRevision component = (TCComponentItemRevision) contexts22[t].getComponent();
if(tpsjList.contains(component)) { if(tpsjList.contains(component)) {
hasFabm = true; hasFabm = true;
@ -237,22 +294,22 @@ public class SendProjectLcCommand extends KCommand {
} }
if(!hasFabm) { if(!hasFabm) {
Boolean flag = false; Boolean flag = false;
System.out.println("lcApplyMap===>"+lcApplyMap.toString()+"ccbhId==>"+ccbhId); System.out.println("lcApplyMap===>" + lcApplyMap.toString() + "ccbhId==>" + ccbhId);
//编码申请铜排单元 //编码申请铜排单元
for(String fac : lcApplyMap.keySet()) { for(String fac : lcApplyMap.keySet()) {
if(ccbhId.contains(fac)) { if(ccbhId.contains(fac)) {
flag = true; flag = true;
if(apply_lists.size()==0) { if(apply_lists.size() == 0) {
checkTargets(lcApplyMap.get(fac),zt2_WBSNo,session); checkTargets(lcApplyMap.get(fac), zt2_WBSNo, session);
} }
if(apply_lists.size()>0) { if(apply_lists.size( )> 0) {
id = applyPart(apply_lists.get(lsh),session,zt2_WBSNo,tpsj,ccbhTarget); id = applyPart(apply_lists.get(lsh), session, zt2_WBSNo, tpsj, ccbhTarget);
} }
lsh = lsh+1; lsh = lsh + 1;
} }
} }
if(!flag) { if(!flag) {
MessageBox.post("出厂编号"+ccbhId+"在首选项Chint_lcApplyCode中未配置请检查","提示",2); MessageBox.post("出厂编号" + ccbhId + "在首选项Chint_lcApplyCode中未配置请检查","提示",2);
return; return;
} }
} }
@ -410,6 +467,7 @@ public class SendProjectLcCommand extends KCommand {
} }
} }
// 新的方案编码申请 // 新的方案编码申请
@SuppressWarnings("deprecation")
public String applyPart(CodeBean bean,TCSession session,String wbsNo,TCComponentFolder tpsj,TCComponent ccbhTarget) public String applyPart(CodeBean bean,TCSession session,String wbsNo,TCComponentFolder tpsj,TCComponent ccbhTarget)
throws TCException { throws TCException {
@ -442,10 +500,10 @@ public class SendProjectLcCommand extends KCommand {
rev.unlock(); rev.unlock();
item.unlock(); item.unlock();
bean.setRev(rev); bean.setRev(rev);
TCComponentUser user = session.getUser(); // TCComponentUser user = session.getUser();
tpsj.add("contents", item); tpsj.add("contents", item);
//addChildToCcp(rev,bean); //addChildToCcp(rev,bean);
TCComponent target = (TCComponent) app.getTargetComponent(); // TCComponent target = (TCComponent) app.getTargetComponent();
rev.add("ZT2_FactoryNumber", ccbhTarget); rev.add("ZT2_FactoryNumber", ccbhTarget);
// //
return zt2_MaterialNo; return zt2_MaterialNo;

@ -134,6 +134,9 @@ public class SearchMaterialDialog extends AbstractAIFDialog {
stopEd(); stopEd();
controller.doSearch(); controller.doSearch();
pb.disposeDialog(); pb.disposeDialog();
if(table.getRowCount() == 0) {
MessageBox.post(SearchMaterialDialog.this, "查询不到数据", "", MessageBox.INFORMATION);
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
pb.disposeDialog(); pb.disposeDialog();

@ -505,7 +505,7 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
SelfMPartBean bean = self_lists.get(i); SelfMPartBean bean = self_lists.get(i);
String spec = bean.getSpec(); String spec = bean.getSpec();
System.out.println("===============开始新建物料==============="); System.out.println("===============开始新建物料===============");
CreateIn createMaterialYH = createMaterialYH(bean, groupID, spec, m_code); //groupID bean.getSpec(); m_code CreateIn createMaterialYH = createMaterialYH(bean, groupID, spec, m_code); //groupID bean.getSpec(); m_code TODO
if(createMaterialYH!=null) { if(createMaterialYH!=null) {
cIList.add(createMaterialYH); cIList.add(createMaterialYH);
} }

@ -19,7 +19,7 @@ public class BYProcBean {
private int index; private int index;
private TCComponentItemRevision cpgy; private TCComponentItemRevision cpgy;
private TCComponentItemRevision tlgx; private TCComponentItemRevision tlgx;
private String class_Code; // private String class_Code;
private TCComponentItemRevision cptlgx; private TCComponentItemRevision cptlgx;
private boolean isFeeding; private boolean isFeeding;
private List<TCComponentItemRevision> meLists = new ArrayList<TCComponentItemRevision>(); private List<TCComponentItemRevision> meLists = new ArrayList<TCComponentItemRevision>();

@ -670,6 +670,7 @@ public class CreateProcBYQDialog extends AbstractAIFDialog {
@Override @Override
public void run() { public void run() {
System.out.println("btn_expandAll start");
ProgressBar pb = new ProgressBar(CreateProcBYQDialog.this, new Dimension(350, 50)); ProgressBar pb = new ProgressBar(CreateProcBYQDialog.this, new Dimension(350, 50));
try { try {
if (SqlUtil2.getTCConnection() == null) { if (SqlUtil2.getTCConnection() == null) {

@ -65,6 +65,9 @@ public class CreateProcBYQGSDialog extends AbstractAIFDialog implements ActionLi
// 产品类型 // 产品类型
private JLabel labelProducttype; private JLabel labelProducttype;
private JComboBox<ComboItem> cbbProducttype; private JComboBox<ComboItem> cbbProducttype;
// µçѹµÈ¼¶
private JLabel labelVoltageClasses;
private JComboBox<ComboItem> cbbVoltageClasses;
// 产品型号 // 产品型号
private JLabel labelProductxh; private JLabel labelProductxh;
private JComboBox<ComboItem> cbbProductxh; private JComboBox<ComboItem> cbbProductxh;
@ -85,7 +88,7 @@ public class CreateProcBYQGSDialog extends AbstractAIFDialog implements ActionLi
protected void initGUI() { protected void initGUI() {
this.setTitle("工时计算"); this.setTitle("工时计算");
// 设置显示大小 // 设置显示大小
Dimension dimension = new Dimension(400, 330); Dimension dimension = new Dimension(400, 380);
this.setPreferredSize(dimension); this.setPreferredSize(dimension);
this.setMinimumSize(dimension); this.setMinimumSize(dimension);
this.setMaximumSize(dimension); this.setMaximumSize(dimension);
@ -97,6 +100,9 @@ public class CreateProcBYQGSDialog extends AbstractAIFDialog implements ActionLi
this.add(labelProducttype = ComponentUtils.createLabel(labelProducttype, "labelProducttype", "产品类型", 20, y, 80, 20)); this.add(labelProducttype = ComponentUtils.createLabel(labelProducttype, "labelProducttype", "产品类型", 20, y, 80, 20));
this.add(cbbProducttype = ComponentUtils.createComboBox(cbbProducttype, "cbbProducttype", 120, y, 260, 20)); this.add(cbbProducttype = ComponentUtils.createComboBox(cbbProducttype, "cbbProducttype", 120, y, 260, 20));
y+= 40; y+= 40;
this.add(labelVoltageClasses = ComponentUtils.createLabel(labelVoltageClasses, "labelVoltageClasses", "µçѹµÈ¼¶", 20, y, 80, 20));
this.add(cbbVoltageClasses = ComponentUtils.createComboBox(cbbVoltageClasses, "cbbVoltageClasses", 120, y, 260, 20));
y+= 40;
this.add(labelProductxh = ComponentUtils.createLabel(labelProductxh, "labelProductxh", "产品型号", 20, y, 80, 20)); this.add(labelProductxh = ComponentUtils.createLabel(labelProductxh, "labelProductxh", "产品型号", 20, y, 80, 20));
this.add(cbbProductxh = ComponentUtils.createComboBox(cbbProductxh, "cbbProductxh", 120, y, 260, 20)); this.add(cbbProductxh = ComponentUtils.createComboBox(cbbProductxh, "cbbProductxh", 120, y, 260, 20));
y+= 40; y+= 40;
@ -113,6 +119,7 @@ public class CreateProcBYQGSDialog extends AbstractAIFDialog implements ActionLi
this.add(btnCancel = ComponentUtils.createButton(btnCancel, "btnCancel", "取消", 290, y, 80, 25, this)); this.add(btnCancel = ComponentUtils.createButton(btnCancel, "btnCancel", "取消", 290, y, 80, 25, this));
// 事件监听 // 事件监听
cbbProducttype.addItemListener(this); cbbProducttype.addItemListener(this);
cbbVoltageClasses.addItemListener(this);
cbbProductxh.addItemListener(this); cbbProductxh.addItemListener(this);
// 加载数据 // 加载数据
this.loadData(); this.loadData();
@ -236,17 +243,45 @@ public class CreateProcBYQGSDialog extends AbstractAIFDialog implements ActionLi
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
if (e.getSource() == cbbProducttype) { if (e.getSource() == cbbProducttype) {
ComboItem producttypeItem = (ComboItem) cbbProducttype.getSelectedItem(); ComboItem producttypeItem = (ComboItem) cbbProducttype.getSelectedItem();
ComboItem voltageClassesItem = (ComboItem) cbbVoltageClasses.getSelectedItem();
if (producttypeItem!=null) { if (producttypeItem!=null) {
EasyResponse<List<String>> productxhResult = WorkhourService.getProductxh(groupId, producttypeItem.getName()); EasyResponse<List<String>> voltagelevelResult = WorkhourService.getVoltagelevel(groupId, producttypeItem.getName());
if (voltagelevelResult.isSuccess()) {
List<String> list = voltagelevelResult.getData();
if (CollectionUtils.isNotEmpty(list)) {
cbbVoltageClasses.removeAllItems();
cbbVoltageClasses.addItem(new ComboItem(""));
for (String str : list) {
cbbVoltageClasses.addItem(new ComboItem(str));
}
}
}
EasyResponse<List<String>> productxhResult = WorkhourService.getProductxh(groupId, producttypeItem.getName(), voltageClassesItem!=null?voltageClassesItem.getName():"");
if (productxhResult.isSuccess()) { if (productxhResult.isSuccess()) {
List<String> list = productxhResult.getData(); List<String> list = productxhResult.getData();
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
cbbProductxh.removeAllItems();
cbbProductxh.addItem(new ComboItem(""));
for (String str : list) { for (String str : list) {
cbbProductxh.addItem(new ComboItem(str)); cbbProductxh.addItem(new ComboItem(str));
} }
} }
} }
} }
} else if (e.getSource() == cbbVoltageClasses) {
ComboItem producttypeItem = (ComboItem) cbbProducttype.getSelectedItem();
ComboItem voltageClassesItem = (ComboItem) cbbVoltageClasses.getSelectedItem();
EasyResponse<List<String>> productxhResult = WorkhourService.getProductxh(groupId, producttypeItem.getName(), voltageClassesItem!=null?voltageClassesItem.getName():"");
if (productxhResult.isSuccess()) {
List<String> list = productxhResult.getData();
if (CollectionUtils.isNotEmpty(list)) {
cbbProductxh.removeAllItems();
cbbProductxh.addItem(new ComboItem(""));
for (String str : list) {
cbbProductxh.addItem(new ComboItem(str));
}
}
}
} }
} }

@ -245,25 +245,24 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(250, 50)); ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(400, 50));
setCompEnabled(false); setCompEnabled(false);
try { try {
long startTime = System.currentTimeMillis();
value_strings = KUtil.getLOVDisplay_value(session, "zt2_ControlCode"); value_strings = KUtil.getLOVDisplay_value(session, "zt2_ControlCode");
KUtil.setByPass(true); KUtil.setByPass(true);
if (revs.size() == 1) { if (revs.size() == 1) {
tree.setRootVisible(false); tree.setRootVisible(false);
controller.readData(pb, revs); controller.readData(pb, revs);
long startTime = System.currentTimeMillis(); System.out.println("usedTime1:" + (System.currentTimeMillis() - startTime) / 1000);
controller.readData(pb, rev_nodes.get(revs.get(0))); controller.readData(pb, rev_nodes.get(revs.get(0)));
long endTime = System.currentTimeMillis(); System.out.println("usedTime2:" + (System.currentTimeMillis() - startTime) / 1000);
long usedTime = (endTime - startTime) / 1000;
System.out.println("usedTime:" + usedTime);
clickNode = rev_nodes.get(revs.get(0)); clickNode = rev_nodes.get(revs.get(0));
KUtil.expandTree(tree, new TreePath(topNode)); KUtil.expandTree(tree, new TreePath(topNode));
System.out.println("usedTime3:" + (System.currentTimeMillis() - startTime) / 1000);
} else { } else {
controller.readData(pb, revs); controller.readData(pb, revs);
} }
addListeners();
isAllowExpand = true; isAllowExpand = true;
pb.disposeDialog(); pb.disposeDialog();
} catch (Exception e) { } catch (Exception e) {
@ -276,9 +275,10 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
setCompEnabled(true); setCompEnabled(true);
} }
}).start(); }).start();
addListeners();
showDialog(); showDialog();
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
pb2.disposeDialog(); pb2.disposeDialog();
MessageBox.post(CreateProcZYDialog.this, "初始化异常:" + e.getMessage(), "", 2); MessageBox.post(CreateProcZYDialog.this, "初始化异常:" + e.getMessage(), "", 2);
@ -287,7 +287,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
@Override @Override
protected void processWindowEvent(WindowEvent e) { protected void processWindowEvent(WindowEvent e) {
// TODO Auto-generated method stub // Auto-generated method stub
if (e.getID() == WindowEvent.WINDOW_CLOSING && isSecSpec) { if (e.getID() == WindowEvent.WINDOW_CLOSING && isSecSpec) {
try { try {
AIFComponentContext meops[] = bomrev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" }, AIFComponentContext meops[] = bomrev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
@ -299,7 +299,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
} }
} catch (TCException e1) { } catch (TCException e1) {
// TODO Auto-generated catch block // Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
} }
} }
@ -371,25 +371,21 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
if (min != -1) { if (min != -1) {
t_part.scrollRectToVisible(t_part.getCellRect(min, 0, true)); t_part.scrollRectToVisible(t_part.getCellRect(min, 0, true));
} }
} }
} }
}); });
tree.addTreeExpansionListener(new TreeExpansionListener() { tree.addTreeExpansionListener(new TreeExpansionListener() {
@Override @Override
public void treeExpanded(TreeExpansionEvent event) { public void treeExpanded(TreeExpansionEvent event) {
// TODO Auto-generated method stub // Auto-generated method stub
final TreePath path = event.getPath(); final TreePath path = event.getPath();
if (path != null) { if (path != null) {
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
System.out.println("isAllowExpand:" + isAllowExpand); System.out.println("isAllowExpand:" + isAllowExpand);
if (isAllowExpand && node != null && map_nodes.containsKey(node) if (isAllowExpand && node != null && map_nodes.containsKey(node)) {
&& map_nodes.get(node).size() == 0) { if(map_nodes.get(node).size() == 0) {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(250, 50)); ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(250, 50));
@ -408,36 +404,38 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
setCompEnabled(true); setCompEnabled(true);
} }
}).start(); }).start();
} else { }else {
if (map_nodes.containsKey(node)) {
try { try {
controller.refushTable2(map_nodes.get(node)); controller.refushTable2(map_nodes.get(node));
clickNode = node; clickNode = node;
} catch (Exception e1) { } catch (Exception e1) {
// TODO Auto-generated catch block // Auto-generated catch block
MessageBox.post(CreateProcZYDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "", MessageBox.post(CreateProcZYDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "",
MessageBox.ERROR); MessageBox.ERROR);
e1.printStackTrace(); e1.printStackTrace();
} }
} }
} }
if (isAllowExpand && node != null && map_nodes.containsKey(node)
&& map_nodes.get(node).size() == 0) {
} } else {
if (map_nodes.containsKey(node)) {
} }
}
}
}
@Override @Override
public void treeCollapsed(TreeExpansionEvent event) { public void treeCollapsed(TreeExpansionEvent event) {
// TODO Auto-generated method stub // Auto-generated method stub
DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getPath().getLastPathComponent(); DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getPath().getLastPathComponent();
JTree tree = (JTree) event.getSource(); JTree tree = (JTree) event.getSource();
DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
tree.clearSelection(); tree.clearSelection();
KUtil.recurRemove(model, node, tm_part); KUtil.recurRemove(model, node, tm_part);
} }
}); });
@ -670,7 +668,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
@Override @Override
public int compare(String o1, String o2) { public int compare(String o1, String o2) {
// TODO Auto-generated method stub // Auto-generated method stub
return o2.compareTo(o1); return o2.compareTo(o1);
} }
}); });
@ -815,7 +813,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
* MessageBox.post(CreateProcZYDialog.this, "投料异常,ERROR:"+e1.getMessage() , "", * MessageBox.post(CreateProcZYDialog.this, "投料异常,ERROR:"+e1.getMessage() , "",
* MessageBox.ERROR); e1.printStackTrace(); * MessageBox.ERROR); e1.printStackTrace();
* }//如果不关闭会导致BOM被占用乃至包含BOM的版本不能删除除非重启TC System.out.println(sb.toString()); * }//如果不关闭会导致BOM被占用乃至包含BOM的版本不能删除除非重启TC System.out.println(sb.toString());
* //TODO 设置最后一列 setTable(bomMap); * // 设置最后一列 setTable(bomMap);
* *
* if(sb.length()>0) { MessageBox.post(CreateProcZYDialog.this, * if(sb.length()>0) { MessageBox.post(CreateProcZYDialog.this,
* "自动投料完成,请进行手工投料", "", MessageBox.WARNING); }else { * "自动投料完成,请进行手工投料", "", MessageBox.WARNING); }else {
@ -901,7 +899,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
} catch (Exception e) { } catch (Exception e) {
pb.disposeDialog(); pb.disposeDialog();
// TODO: handle exception // : handle exception
e.printStackTrace(); e.printStackTrace();
MessageBox.post(CreateProcZYDialog.this, "异常:" + e.getMessage(), "提示", 2); MessageBox.post(CreateProcZYDialog.this, "异常:" + e.getMessage(), "提示", 2);
} }
@ -1022,9 +1020,10 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
if (pb == null) { if (pb == null) {
pb = new MyProgressBarCompent("工艺修改", "工艺路线修改中......"); pb = new MyProgressBarCompent("工艺修改", "工艺路线修改中......");
} else {
pb.setShowLabel("工艺路线修改中......");
} }
// else {
// pb.setShowLabel("工艺路线修改中......");
// }
pb.setVisible(true); pb.setVisible(true);
if (procs == null || procs.size() == 0) { if (procs == null || procs.size() == 0) {
@ -1091,7 +1090,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
new ZYUpdateProcDialog(CreateProcZYDialog.this, revs, rev_Beans, value_strings, new ZYUpdateProcDialog(CreateProcZYDialog.this, revs, rev_Beans, value_strings,
session); session);
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
MessageBox.post("工艺修改异常:" + e.getMessage(), "", 2); MessageBox.post("工艺修改异常:" + e.getMessage(), "", 2);
} }
@ -1111,7 +1110,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
new ZYUpdateProcDialog(CreateProcZYDialog.this, revs, rev_Beans, value_strings, new ZYUpdateProcDialog(CreateProcZYDialog.this, revs, rev_Beans, value_strings,
session); session);
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
MessageBox.post("工艺修改异常:" + e.getMessage(), "", 2); MessageBox.post("工艺修改异常:" + e.getMessage(), "", 2);
} }
@ -1119,7 +1118,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
} }
}); });
} catch (Exception e1) { } catch (Exception e1) {
// TODO Auto-generated catch block // Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
} }
@ -1197,7 +1196,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
} }
} catch (Exception e1) { } catch (Exception e1) {
// TODO Auto-generated catch block // Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
MessageBox.post("PDF打开异常:" + e1.getMessage(), "", 2); MessageBox.post("PDF打开异常:" + e1.getMessage(), "", 2);
} }
@ -1209,7 +1208,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub // Auto-generated method stub
// 清除Table // 清除Table
for (int i = tm_part.getRowCount() - 1; i > -1; i--) { for (int i = tm_part.getRowCount() - 1; i > -1; i--) {
tm_part.removeRow(i); tm_part.removeRow(i);
@ -1668,7 +1667,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
* tm_part.addRow(new Object[] * tm_part.addRow(new Object[]
* {index,item_id,rev.getProperty("object_name"),"","",gy_name}); index++; * {index,item_id,rev.getProperty("object_name"),"","",gy_name}); index++;
* gy=null; groupID=""; } System.out.println("结束"); } catch (Exception e) { // * gy=null; groupID=""; } System.out.println("结束"); } catch (Exception e) { //
* TODO Auto-generated catch block e.printStackTrace(); }finally { * Auto-generated catch block e.printStackTrace(); }finally {
* KUtil.setByPass(false); } * KUtil.setByPass(false); }
* *
* } }).start(); * } }).start();
@ -1692,7 +1691,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
@Override @Override
public void run() { public void run() {
// TODO Auto-generated method stub // Auto-generated method stub
ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(250, 50)); ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(250, 50));
setCompEnabled(false); setCompEnabled(false);
try { try {
@ -1742,7 +1741,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
controller.refushTable2(map_nodes.get(node)); controller.refushTable2(map_nodes.get(node));
clickNode = node; clickNode = node;
} catch (Exception e1) { } catch (Exception e1) {
// TODO Auto-generated catch block // Auto-generated catch block
MessageBox.post(CreateProcZYDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "", MessageBox.post(CreateProcZYDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "",
MessageBox.ERROR); MessageBox.ERROR);
e1.printStackTrace(); e1.printStackTrace();

@ -1,5 +1,6 @@
package com.connor.chint.sap2.proc_zy; package com.connor.chint.sap2.proc_zy;
import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -18,6 +19,7 @@ import com.connor.chint.sap2.proc.CreateProcessController;
import com.connor.chint.sap2.proc_by.BomBean; import com.connor.chint.sap2.proc_by.BomBean;
import com.connor.chint.sap2.proc_by.BYProcBean; import com.connor.chint.sap2.proc_by.BYProcBean;
import com.connor.chint.sap2.proc_by.ProcCellEditor; import com.connor.chint.sap2.proc_by.ProcCellEditor;
import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.sap2.util.ChintPreferenceUtil; import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.ProgressBar; import com.connor.chint.sap2.util.ProgressBar;
@ -30,12 +32,13 @@ import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow; import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType; import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentContextList; import com.teamcenter.rac.kernel.TCComponentContextList;
import com.teamcenter.rac.kernel.TCComponentGroup;
import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
import com.teamcenter.services.rac.core.DataManagementService;
public class CreateProcZYDialogController { public class CreateProcZYDialogController {
@ -45,14 +48,16 @@ public class CreateProcZYDialogController {
private TCSession session; private TCSession session;
protected List<BYProcBean> procBeanList = new ArrayList<>(); protected List<BYProcBean> procBeanList = new ArrayList<>();
private ProcCellEditor procEditoe; private ProcCellEditor procEditoe;
private String group;
private TCComponentGroup login_group = null; // private TCComponentGroup login_group = null;
private Map<String, TCComponent> mepMap = new HashMap<>();
public CreateProcZYDialogController(CreateProcZYDialog createProcBYDialog, AbstractAIFApplication app) { public CreateProcZYDialogController(CreateProcZYDialog createProcBYDialog, AbstractAIFApplication app) {
this.dialog = createProcBYDialog; this.dialog = createProcBYDialog;
this.app = app; this.app = app;
this.session = (TCSession) app.getSession(); this.session = (TCSession) app.getSession();
this.login_group = session.getCurrentGroup(); // this.login_group = session.getCurrentGroup();
} }
public void readData(ProgressBar pb) throws Exception { public void readData(ProgressBar pb) throws Exception {
@ -62,6 +67,7 @@ public class CreateProcZYDialogController {
if (target == null || !(target instanceof TCComponentItemRevision)) { if (target == null || !(target instanceof TCComponentItemRevision)) {
return; return;
} }
group = session.getCurrentGroup().getUid();
System.out.println("检查对象:" + target); System.out.println("检查对象:" + target);
TCComponentItemRevision rev = (TCComponentItemRevision) target; TCComponentItemRevision rev = (TCComponentItemRevision) target;
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
@ -71,7 +77,14 @@ public class CreateProcZYDialogController {
topBean = new BomBean(rev, topLine, 1); topBean = new BomBean(rev, topLine, 1);
DefaultMutableTreeNode topTreeNode = new DefaultMutableTreeNode(topBean); DefaultMutableTreeNode topTreeNode = new DefaultMutableTreeNode(topBean);
dialog.topNode.add(topTreeNode); dialog.topNode.add(topTreeNode);
readBom(topTreeNode, topLine, pb, rev, topBean, procBeanList);
List<String> codeList = new ArrayList<>();
List<String> noList = new ArrayList<>();
// readTemplate(topLine, rev, topBean, procBeanList);
com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService.getService(session);
Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(topLine, structureService);
readBom(topTreeNode, topLine, bomLineTree, pb, rev, topBean, procBeanList, codeList, noList);
getGY(procBeanList, codeList, noList);
KUtil.expandTree(dialog.tree, new TreePath(dialog.topNode)); KUtil.expandTree(dialog.tree, new TreePath(dialog.topNode));
if (procBeanList.size() > 0) { if (procBeanList.size() > 0) {
procEditoe = new ProcCellEditor(procBeanList); procEditoe = new ProcCellEditor(procBeanList);
@ -81,33 +94,33 @@ public class CreateProcZYDialogController {
win.close(); win.close();
} }
private void readBom(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine, ProgressBar pb, private void readBom(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine, Map<String, ExpandPSData[]> bomLineTree, ProgressBar pb,
TCComponentItemRevision parentRev, BomBean parentBean, List<BYProcBean> procBeanList) throws Exception { TCComponentItemRevision parentRev, BomBean parentBean, List<BYProcBean> procBeanList, List<String> codeList, List<String> noList) throws Exception {//TODO readBom
readTemplate(topLine, parentRev, parentBean, procBeanList); readTemplate(topLine, parentRev, parentBean, procBeanList, codeList, noList);
BomBean pBean = (BomBean) treeNode.getUserObject(); BomBean pBean = (BomBean) treeNode.getUserObject();
pb.setText("加载数据..." + pBean); pb.setText("加载数据" + pBean);
AIFComponentContext[] cLines = topLine.getChildren(); // AIFComponentContext[] cLines = topLine.getChildren();
TCComponentItemRevision parentRev2 = topLine.getItemRevision(); TCComponentItemRevision parentRev2 = topLine.getItemRevision();
for (int i = 0; i < cLines.length; i++) { for (ExpandPSData data : bomLineTree.get(topLine.getUid())) {
TCComponentBOMLine cLine = (TCComponentBOMLine) cLines[i].getComponent(); TCComponentBOMLine cLine = data.bomLine;
if (cLine.getProperty("zt2_Diagram").equals("是")) { if (cLine.getProperty("zt2_Diagram").equals("是")) {
System.out.println(cLine.getProperty("object_string") + "为虚拟项,已过滤!"); System.out.println(cLine.getProperty("object_string") + "为虚拟项,已过滤!");
continue; continue;
} }
TCComponentItemRevision cRev = cLine.getItemRevision(); TCComponentItemRevision cRev = data.itemRevOfBOMLine;
System.out.println("cRev:" + cRev); System.out.println("cRev:" + cRev);
BomBean cBean = new BomBean(cRev, cLine, procBeanList.size() + 1); BomBean cBean = new BomBean(cRev, cLine, procBeanList.size() + 1);
pBean.getChildren().add(cBean); pBean.getChildren().add(cBean);
DefaultMutableTreeNode cNode = new DefaultMutableTreeNode(cBean); DefaultMutableTreeNode cNode = new DefaultMutableTreeNode(cBean);
treeNode.add(cNode); treeNode.add(cNode);
System.out.println("添加:" + cBean); System.out.println("添加:" + cBean);
readBom(cNode, cLine, pb, parentRev2, cBean, procBeanList); readBom(cNode, cLine, bomLineTree, pb, parentRev2, cBean, procBeanList, codeList, noList);
} }
} }
private void readBom2(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine, ProgressBar pb, private void readBom2(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine, ProgressBar pb,
TCComponentItemRevision parentRev, BomBean parentBean, List<BYProcBean> procBeanList) throws Exception { TCComponentItemRevision parentRev, BomBean parentBean, List<BYProcBean> procBeanList, List<String> codeList, List<String> noList) throws Exception {
readTemplate(topLine, parentRev, parentBean, procBeanList); readTemplate(topLine, parentRev, parentBean, procBeanList, codeList, noList);
BomBean pBean = (BomBean) treeNode.getUserObject(); BomBean pBean = (BomBean) treeNode.getUserObject();
pb.setText("加载数据..." + pBean); pb.setText("加载数据..." + pBean);
AIFComponentContext[] cLines = topLine.getChildren(); AIFComponentContext[] cLines = topLine.getChildren();
@ -127,23 +140,25 @@ public class CreateProcZYDialogController {
DefaultMutableTreeNode cNode = new DefaultMutableTreeNode(cBean); DefaultMutableTreeNode cNode = new DefaultMutableTreeNode(cBean);
treeNode.add(cNode); treeNode.add(cNode);
System.out.println("添加:" + cBean); System.out.println("添加:" + cBean);
readBom2(cNode, cLine, pb, parentRev2, cBean, procBeanList); readBom2(cNode, cLine, pb, parentRev2, cBean, procBeanList, codeList, noList);
} }
} }
private void readTemplate(TCComponentBOMLine topLine, TCComponentItemRevision parentRev, BomBean parentBean, private void readTemplate(TCComponentBOMLine topLine, TCComponentItemRevision parentRev, BomBean parentBean,
List<BYProcBean> procBeanList) throws Exception { List<BYProcBean> procBeanList, List<String> codeList, List<String> noList) throws Exception {
TCComponentItemRevision comp = topLine.getItemRevision(); TCComponentItemRevision comp = topLine.getItemRevision();
TCComponentItemRevision rev_standard = null; TCComponentItemRevision rev_standard = null;
TCComponentItemRevision bzgy = null; // TCComponentItemRevision bzgy = null;
TCComponentItemRevision tlgx = null; TCComponentItemRevision tlgx = null;
TCComponentItemRevision cptlgx = null; TCComponentItemRevision cptlgx = null;
boolean flag = true; boolean flag = true;
List<TCComponentItemRevision> bzgys = new ArrayList<TCComponentItemRevision>(); List<TCComponentItemRevision> bzgys = new ArrayList<TCComponentItemRevision>();
String zt2_MaterialMark = ""; String zt2_MaterialMark = "";
System.out.println("type:" + comp.getType()); String type = comp.getType();
System.out.println("type:" + type);
zt2_MaterialMark = comp.getProperty("zt2_MaterialMark"); zt2_MaterialMark = comp.getProperty("zt2_MaterialMark");
if (comp.getType().equals("ZT2_Design3DRevision")) {
if (type.equals("ZT2_Design3DRevision")) {
String drawingNo = comp.getStringProperty("item_id"); String drawingNo = comp.getStringProperty("item_id");
System.out.println("查询标准工艺:" + comp + ", zt2_DrawingNo = " + drawingNo); System.out.println("查询标准工艺:" + comp + ", zt2_DrawingNo = " + drawingNo);
if (KUtil.isEmpty(drawingNo)) { if (KUtil.isEmpty(drawingNo)) {
@ -158,53 +173,9 @@ public class CreateProcZYDialogController {
drawingNo = drawingNo.substring(0, ind); drawingNo = drawingNo.substring(0, ind);
} }
} }
System.out.println("查询图号:" + drawingNo); codeList.add(drawingNo);
// 查询标准图工艺
Map<String, String> fields = new LinkedHashMap<>();
fields.put("DrawingNo", drawingNo);
TCComponentContextList res = KUtil.query(session, "chint_query_TYDH", fields);
if (res != null) {
int len = res.getListCount();
if (len > 1) {
throw new Exception("通过 DrawingNo = " + drawingNo + " 查询到多个对象");
}
if (len == 1) {
TCComponentItemRevision rev = (TCComponentItemRevision) res.get(0).getComponent();
rev_standard = rev;
String zt2_ClassificationCode = rev.getProperty("zt2_ClassificationCode");
if (zt2_ClassificationCode.length() > 0) {
flag = false;
Map<String, String> fields2 = new LinkedHashMap<>();
fields2.put("ID", zt2_ClassificationCode);
TCComponentContextList res2 = KUtil.query(session, "chint_query_item", fields2);
if (res2 != null) {
int len2 = res2.getListCount();
if (len2 > 1) {
throw new Exception("通过 ID = " + zt2_ClassificationCode + " 查询到多个对象");
}
if (len2 == 1) {
tlgx = (TCComponentItemRevision) res2.get(0).getComponent();
System.out.println("tlgx type:[" + tlgx.getType() + "]");
}
}
}
AIFComponentContext[] comps = rev.whereReferencedByTypeRelation(
new String[] { "MEProcessRevision" }, new String[] { "IMAN_METarget" });
System.out.println("查询到对象:" + rev + ", 引用数量:" + comps.length);
for (int i = 0; i < comps.length; i++) {
InterfaceAIFComponent cc = comps[i].getComponent();
if (KUtil.isSameGroup((TCComponent) cc, login_group)) {
// 添加到模板
bzgy = (TCComponentItemRevision) cc;
System.out.println("找到标准工艺:" + bzgy);
bzgys.add(bzgy);
}
}
}
}
} // 若未图纸,则取物料编码 } // 若未图纸,则取物料编码
else if (comp.getType().equals("Part Revision")) { else if (type.equals("Part Revision")) {
String drawingNo = comp.getStringProperty("zt2_MaterialNo"); String drawingNo = comp.getStringProperty("zt2_MaterialNo");
System.out.println("查询标准工艺:" + comp + ", zt2_MaterialNo = " + drawingNo); System.out.println("查询标准工艺:" + comp + ", zt2_MaterialNo = " + drawingNo);
if (KUtil.isEmpty(drawingNo)) { if (KUtil.isEmpty(drawingNo)) {
@ -216,82 +187,16 @@ public class CreateProcZYDialogController {
drawingNo = drawingNo.substring(0, ind); drawingNo = drawingNo.substring(0, ind);
} }
// 查询标准图工艺 // 查询标准图工艺
Map<String, String> fields = new LinkedHashMap<>(); codeList.add(drawingNo);
fields.put("零组件 ID", drawingNo); }else {
TCComponentContextList res = KUtil.query(session, "零组件版本...", fields); codeList.add("");
if (res != null) { }/**/
int len = res.getListCount();
if (len > 1) {
throw new Exception("通过 DrawingNo = " + drawingNo + " 查询到多个对象");
}
if (len == 1) {
TCComponentItemRevision rev = (TCComponentItemRevision) res.get(0).getComponent();
rev_standard = rev;
String zt2_ClassificationCode = rev.getProperty("zt2_ClassificationCode");
if (zt2_ClassificationCode.length() > 0) {
flag = false;
Map<String, String> fields2 = new LinkedHashMap<>();
fields2.put("ID", zt2_ClassificationCode);
TCComponentContextList res2 = KUtil.query(session, "chint_query_item", fields2);
if (res2 != null) {
int len2 = res2.getListCount();
if (len2 > 1) {
throw new Exception("通过 ID = " + zt2_ClassificationCode + " 查询到多个对象");
}
if (len2 == 1) {
tlgx = (TCComponentItemRevision) res2.get(0).getComponent();
System.out.println("tlgx type:[" + tlgx.getType() + "]");
}
}
}
AIFComponentContext[] comps = rev.whereReferencedByTypeRelation(
new String[] { "MEProcessRevision" }, new String[] { "IMAN_METarget" });
System.out.println("查询到对象:" + rev + ", 引用数量:" + comps.length);
for (int i = 0; i < comps.length; i++) {
InterfaceAIFComponent cc = comps[i].getComponent();
if (KUtil.isSameGroup((TCComponent) cc, login_group)) {
// 添加到模板
bzgy = (TCComponentItemRevision) cc;
System.out.println("找到标准工艺:" + bzgy);
bzgys.add(bzgy);
}
}
}
}
}
String zt2_ClassificationCode = topLine.getProperty("ZT2_ClassificationNo"); String zt2_ClassificationCode = topLine.getProperty("ZT2_ClassificationNo");
System.out.println("[ZT2_ClassificationNo=" + zt2_ClassificationCode + "]"); System.out.println("[ZT2_ClassificationNo=" + zt2_ClassificationCode + "]");
if (zt2_ClassificationCode.length() > 0) { noList.add(zt2_ClassificationCode);
flag = false;
Map<String, String> fields2 = new LinkedHashMap<>();
fields2.put("ID", zt2_ClassificationCode);
TCComponentContextList res2 = KUtil.query(session, "chint_query_item", fields2);
if (res2 != null) {
int len2 = res2.getListCount();
if (len2 > 1) {
throw new Exception("通过 ID = " + zt2_ClassificationCode + " 查询到多个对象");
}
if (len2 == 1) {
cptlgx = (TCComponentItemRevision) res2.get(0).getComponent();
}
}
}
// 查询产品工艺 // 查询产品工艺
TCComponentItemRevision cpgy = null; TCComponentItemRevision cpgy = (TCComponentItemRevision) getMeproces(comp.getUid(), session);
AIFComponentContext[] refs = comp.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
new String[] { "IMAN_METarget" });
System.out.println("查询产品工艺、投料工序:" + comp + ", 引用数量:" + refs.length);
for (int i = 0; i < refs.length; i++) {
InterfaceAIFComponent c = refs[i].getComponent();
if (KUtil.isSameGroup((TCComponent) c, login_group)) {
// 添加到模板
System.out.println("找到产品工艺:" + c);
cpgy = (TCComponentItemRevision) c;
}
}
BYProcBean bean = new BYProcBean(procBeanList.size() + 1, comp, bzgys, cpgy, tlgx, topLine, cptlgx, parentRev); BYProcBean bean = new BYProcBean(procBeanList.size() + 1, comp, bzgys, cpgy, tlgx, topLine, cptlgx, parentRev);
zt2_ClassificationCode = comp.getProperty("zt2_ClassificationCode"); zt2_ClassificationCode = comp.getProperty("zt2_ClassificationCode");
@ -374,6 +279,7 @@ public class CreateProcZYDialogController {
KUtil.info(dialog, "二次自动投料完成"); KUtil.info(dialog, "二次自动投料完成");
} }
@SuppressWarnings("deprecation")
public void oneAutoFeeding(Map<String, CHINT_ClassificationCode> maps, ProgressBar pb) throws Exception { public void oneAutoFeeding(Map<String, CHINT_ClassificationCode> maps, ProgressBar pb) throws Exception {
KUtil.stopTableEditing(dialog.t_part); KUtil.stopTableEditing(dialog.t_part);
pb.setText("一次自动投料..."); pb.setText("一次自动投料...");
@ -392,6 +298,7 @@ public class CreateProcZYDialogController {
pb.disposeDialog(); pb.disposeDialog();
} }
@SuppressWarnings("deprecation")
private void oneFeedingLine(Map<String, CHINT_ClassificationCode> maps, TCComponentBOMLine line) throws Exception { private void oneFeedingLine(Map<String, CHINT_ClassificationCode> maps, TCComponentBOMLine line) throws Exception {
AIFComponentContext[] children = line.getChildren(); AIFComponentContext[] children = line.getChildren();
String zt2_ClassificationCode; String zt2_ClassificationCode;
@ -411,7 +318,7 @@ public class CreateProcZYDialogController {
} }
} }
private void refushPros(TCComponentBOMLine line, BYProcBean bean) throws TCException { private void refushPros(TCComponentBOMLine line, BYProcBean bean) throws Exception {
System.out.println("line:" + line.getItemRevision() + "|子项:" + bean.getBomRev()); System.out.println("line:" + line.getItemRevision() + "|子项:" + bean.getBomRev());
if (line.getItemRevision().equals(bean.getBomRev())) { if (line.getItemRevision().equals(bean.getBomRev())) {
System.out.println("重新刷新子项可选工序"); System.out.println("重新刷新子项可选工序");
@ -592,13 +499,13 @@ public class CreateProcZYDialogController {
dialog.tm_part.setValueAt(proc.getProperty("object_name"), procBean.getIndex() - 1, BYProcBean.INDEX_CPGY); dialog.tm_part.setValueAt(proc.getProperty("object_name"), procBean.getIndex() - 1, BYProcBean.INDEX_CPGY);
} }
private void getGX(TCComponentBOMLine line, List<TCComponentItemRevision> lists) throws TCException { private void getGX(TCComponentBOMLine line, List<TCComponentItemRevision> lists) throws Exception {
TCComponentBOMLine parent = line.parent(); TCComponentBOMLine parent = line.parent();
if (parent == null) { if (parent == null) {
return; return;
} }
boolean flag = false; boolean flag = false;
AIFComponentContext[] contexts22 = (parent.getItemRevision()).whereReferencedByTypeRelation(null, null); /*AIFComponentContext[] contexts22 = (parent.getItemRevision()).whereReferencedByTypeRelation(null, null);
for (int i = 0; i < contexts22.length; i++) { for (int i = 0; i < contexts22.length; i++) {
String type = contexts22[i].getComponent().getType(); String type = contexts22[i].getComponent().getType();
System.out.println("type:" + type); System.out.println("type:" + type);
@ -616,11 +523,49 @@ public class CreateProcZYDialogController {
} }
} }
}*/
TCComponent meop = getMeproces(parent.getItemRevision().getUid(), session);
if(meop != null) {
flag = true;
if(!lists.contains(meop) && (meop instanceof TCComponentItemRevision))
lists.add((TCComponentItemRevision) meop);
} }
if (!flag) { if (!flag) {
getGX(parent, lists); getGX(parent, lists);
} }
}
private TCComponent getMeproces(String uid, TCSession session) throws Exception {
//TODO getMeproces
if(mepMap.containsKey(uid)) {
return mepMap.get(uid);
}
// String sql = SAPUtil.sqlRef.replace("\\?", "'" + uid + "'");
String sql = "select P.puid as supItemUID,V.puid as supRevUID,P.pitem_id as supItemID,ITRO.Pobject_Name as supItemName,"
+ "V.Pitem_Revision_Id as supRevID,cP.pitem_id as subItemID,cV.puid as subRevUID,RT.partifactname as 版本与版本关系 "
+ "from PWORKSPACEOBJECT ITRO,PIMANRELATION R,PIMANTYPE RT,PITEMREVISION V,PITEM P,PITEMREVISION cV,PITEM cP,PWORKSPACEOBJECT cITRO,PPOM_APPLICATION_OBJECT g "
+ "where g.puid=V.puid and V.Puid = R.Rprimary_Objectu and r.rrelation_typeu = RT.puid and P.Puid = V.Ritems_Tagu and ITRO.Puid = V.Puid "
+ "and R.Rsecondary_Objectu = cV.Puid and cP.Puid = cV.Ritems_Tagu and cV.Puid = cITRO.Puid and ITRO.Pactive_Seq<>0 "
+ "and cITRO.Pactive_Seq<>0 and RT.partifactname='IMAN_METarget' and g.ROWNING_GROUPU='" + group + "' and cV.PUID = '" + uid + "'";
try {
ResultSet read = SqlUtil.read(sql);//SAPUtil.sqlRef, new Object[] { uid }
// boolean next = read.next();
while (read.next()) {
String string = read.getString("supRevUID");
TCComponent mpComp = session.stringToComponent(string);
// TCComponent mpComp = SAPUtil.getSameGroupProcYH(meops, session);
if(mpComp != null) {
mepMap.put(uid, mpComp);
// SqlUtil.free();
return mpComp;
}
}
// SqlUtil.free();
}catch(Exception e) {
System.out.println("sql==>" + sql);
e.printStackTrace();
}
return null;
} }
public void assignProcess(ProgressBar pb) throws Exception { public void assignProcess(ProgressBar pb) throws Exception {
@ -682,6 +627,7 @@ public class CreateProcZYDialogController {
} }
// 创建工艺 // 创建工艺
@SuppressWarnings("deprecation")
public void createProcess(ProgressBar pb, MEProcessBean bean, TCSession session, List<TCComponentItemRevision> revs) public void createProcess(ProgressBar pb, MEProcessBean bean, TCSession session, List<TCComponentItemRevision> revs)
throws Exception { throws Exception {
if (revs.size() == 0) if (revs.size() == 0)
@ -725,8 +671,8 @@ public class CreateProcZYDialogController {
TCComponentItemRevision rev; TCComponentItemRevision rev;
TCComponentItemRevision newProc = null; TCComponentItemRevision newProc = null;
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
DefaultMutableTreeNode node; // DefaultMutableTreeNode node;
String object_name = proc.getProperty("object_name"); // String object_name = proc.getProperty("object_name");
// pb.setText("工艺路线创建......"); // pb.setText("工艺路线创建......");
int len = revs.size(); int len = revs.size();
List<BYProcBean> cout_beans = new ArrayList<>(); List<BYProcBean> cout_beans = new ArrayList<>();
@ -756,6 +702,7 @@ public class CreateProcZYDialogController {
BYProcBean.INDEX_CPGY); BYProcBean.INDEX_CPGY);
} }
if (procBean.getRev_standard() == procBean.getBomRev()) { if (procBean.getRev_standard() == procBean.getBomRev()) {
if(!procBean.getBzgys().contains(newProc))
procBean.getBzgys().add(newProc); procBean.getBzgys().add(newProc);
procBean.setTemplate(newProc); procBean.setTemplate(newProc);
if (procBean.isVisible) { if (procBean.isVisible) {
@ -775,6 +722,7 @@ public class CreateProcZYDialogController {
procBean = beans.get(j); procBean = beans.get(j);
procBean.setCpgy(proc); procBean.setCpgy(proc);
if (procBean.getRev_standard() == procBean.getBomRev()) { if (procBean.getRev_standard() == procBean.getBomRev()) {
if(!procBean.getBzgys().contains(proc))
procBean.getBzgys().add(proc); procBean.getBzgys().add(proc);
procBean.setTemplate(proc); procBean.setTemplate(proc);
} }
@ -805,14 +753,19 @@ public class CreateProcZYDialogController {
} }
public void refushTable2(List<BYProcBean> list) throws Exception { public void refushTable2(List<BYProcBean> list) throws Exception {
dialog.tm_part.getDataVector().clear(); // dialog.tm_part.getDataVector().clear();
dialog.t_part.clearSelection(); // dialog.t_part.clearSelection();
dialog.t_part.revalidate(); // dialog.t_part.revalidate();
dialog.t_part.repaint(); // dialog.t_part.repaint();
for(int i = dialog.t_part.getRowCount() - 1; i >= 0; i--) {
dialog.tm_part.removeRow(i);
}
for (int i = 0, len = list.size(); i < len; i++) { for (int i = 0, len = list.size(); i < len; i++) {
// long startTime = System.currentTimeMillis();
list.get(i).isVisible = true; list.get(i).isVisible = true;
dialog.tm_part.addRow(list.get(i).getRowData()); dialog.tm_part.addRow(list.get(i).getRowData());
// System.out.println("addRow:" + (System.currentTimeMillis() - startTime));
} }
} }
@ -875,10 +828,12 @@ public class CreateProcZYDialogController {
} }
public void readData(ProgressBar pb, DefaultMutableTreeNode topTreeNode) throws Exception { public void readData(ProgressBar pb, DefaultMutableTreeNode topTreeNode) throws Exception {
long startTime = System.currentTimeMillis();
pb.startProgress(); pb.startProgress();
pb.setText("加载数据..."); pb.setText("加载数据...");
dialog.rev_Beans.clear(); dialog.rev_Beans.clear();
// 预先加入的假节点 // 预先加入的假节点
group = session.getCurrentGroup().getUid();
int cout = topTreeNode.getChildCount(); int cout = topTreeNode.getChildCount();
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null); TCComponentBOMWindow win = bomWinType.create(null);
@ -895,12 +850,53 @@ public class CreateProcZYDialogController {
win.setWindowTopLine(rev.getItem(), rev, null, null); win.setWindowTopLine(rev.getItem(), rev, null, null);
TCComponentBOMLine topLine = win.getTopBOMLine(); TCComponentBOMLine topLine = win.getTopBOMLine();
List<BYProcBean> procBeanList2 = new ArrayList<>(); List<BYProcBean> procBeanList2 = new ArrayList<>();
List<String> codeList = new ArrayList<>();
List<String> noList = new ArrayList<>();
List<TCComponent> bomList = new ArrayList<>();
List<TCComponent> bomRevList = new ArrayList<>();
readBom(topTreeNode, topLine, pb, rev, topBean, procBeanList2); // getBomLineTreeNodeSOA
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
if (SqlUtil.getTCDataConnection(prefs) == null) {
MessageBox.post("数据库连接失败,请检查数据库连接配置!", "", 2);
return;
}
//预加载BOM及版本属性优化速度
com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService.getService(session);
Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(topLine, structureService);
getBOMList(topLine, bomLineTree, bomList, bomRevList);
DataManagementService dmService = DataManagementService.getService(session);
dmService.getProperties(bomList.toArray(new TCComponent[0]), new String[] { "zt2_Diagram", "object_string", "ZT2_ClassificationNo", "bl_sequence_no" });
dmService.getProperties(bomRevList.toArray(new TCComponent[0]), new String[] { "object_type", "item_id", "zt2_MaterialNo", "zt2_MaterialMark", "zt2_ClassificationCode" });
System.out.println("readData1:" + (System.currentTimeMillis() - startTime) / 1000);
readBom(topTreeNode, topLine, bomLineTree, pb, rev, topBean, procBeanList2, codeList, noList);
System.out.println("readData2:" + (System.currentTimeMillis() - startTime) / 1000);
getGY(procBeanList2, codeList, noList);
System.out.println("readData3:" + (System.currentTimeMillis() - startTime) / 1000);
procBeanList.clear(); procBeanList.clear();
procBeanList.addAll(procBeanList2); procBeanList.addAll(procBeanList2);
dialog.map_nodes.put(topTreeNode, procBeanList2); dialog.map_nodes.put(topTreeNode, procBeanList2);
TCComponent[] revs = new TCComponent[procBeanList2.size()];
ArrayList<TCComponent> gyList = new ArrayList<>();
for(int i = 0; i < revs.length; i++) {
BYProcBean bean = procBeanList2.get(i);
revs[i] = bean.getBomRev();
if(bean.getTemplate() != null)
gyList.add(bean.getTemplate());
if(bean.getCpgy() != null)
gyList.add(bean.getCpgy());
if(bean.getCptlgx() != null)
gyList.add(bean.getCptlgx());
if(bean.getTlgx() != null)
gyList.add(bean.getTlgx());
}
dmService.getProperties(revs, new String[] { "object_type", "item_id", "zt2_MaterialNo", "object_name", "zt2_Source" });
dmService.getProperties(gyList.toArray(new TCComponent[gyList.size()]), new String[] { "object_name" });
refushTable2(procBeanList2); refushTable2(procBeanList2);
System.out.println("readData4:" + (System.currentTimeMillis() - startTime) / 1000);
for (int i = cout - 1; i > -1; i--) { for (int i = cout - 1; i > -1; i--) {
topTreeNode.remove(i); topTreeNode.remove(i);
} }
@ -910,7 +906,118 @@ public class CreateProcZYDialogController {
dialog.t_part.getColumnModel().getColumn(4).setCellEditor(procEditoe); dialog.t_part.getColumnModel().getColumn(4).setCellEditor(procEditoe);
} }
win.close(); win.close();
SqlUtil.free();
System.out.println("readData5:" + (System.currentTimeMillis() - startTime) / 1000);
}
private void getBOMList(TCComponentBOMLine parentLine, Map<String, ExpandPSData[]> bomLineTree, List<TCComponent> bomList, List<TCComponent> bomRevList) {
for (ExpandPSData data : bomLineTree.get(parentLine.getUid())) {
TCComponentBOMLine cLine = data.bomLine;
bomList.add(cLine);
bomRevList.add(data.itemRevOfBOMLine);
getBOMList(cLine, bomLineTree, bomList, bomRevList);
}
}
private void getGY(List<BYProcBean> procBeanList, List<String> codeList, List<String> noList) throws Exception {
//TODO getGY
StringBuilder codes = new StringBuilder("");
ArrayList<String> noSet = new ArrayList<>();
for(String s : codeList) {
if(noSet.contains(s))
continue;
noSet.add(s);
codes.append("','").append(s);
}
//查询标准图投料工序和标准图工艺
StringBuilder sql1 = new StringBuilder("select b.puid,a.pitem_id,b.PZT2_CLASSIFICATIONCODE,t1.puid as tlgx,t2.bzgy from pitem a,pitemrevision b0,PPOM_APPLICATION_OBJECT b1,");
sql1.append("(select puid,PZT2_CLASSIFICATIONCODE from PZT2_DESIGN3DREVISION union select puid,PZT2_CLASSIFICATIONCODE from PPART_0_REVISION_ALT) b ")
.append("left join (select a2.puid,a1.PITEM_ID from pitem a1,pitemrevision a2 where a2.ritems_tagu=a1.puid) t1 on t1.pitem_id=b.PZT2_CLASSIFICATIONCODE ")
.append("left join (select cV.puid,V.puid as bzgy,ITRO.Pobject_Name as supItemName ")
.append("from PWORKSPACEOBJECT ITRO,PIMANRELATION R,PIMANTYPE RT,PITEMREVISION V,PITEM P,PITEMREVISION cV,PITEM cP,PWORKSPACEOBJECT cITRO,PPOM_APPLICATION_OBJECT g ")
.append("where g.puid=V.puid and V.Puid=R.Rprimary_Objectu and r.rrelation_typeu=RT.puid and P.Puid=V.Ritems_Tagu and ITRO.Puid=V.Puid and R.Rsecondary_Objectu=cV.Puid ")
.append("and cP.Puid=cV.Ritems_Tagu and cV.Puid=cITRO.Puid and ITRO.Pactive_Seq<>0 and cITRO.Pactive_Seq<>0 and RT.partifactname='IMAN_METarget' and g.ROWNING_GROUPU='" + group + "') t2 on t2.puid=b.puid ")
.append("where b1.PCREATION_DATE in (select max(r3.PCREATION_DATE) from pitem r1,PITEMREVISION r2,PPOM_APPLICATION_OBJECT r3 where r1.puid=r2.ritems_tagu and r2.puid=r3.puid and r1.pitem_id=a.pitem_id) ")
.append("and b.puid=b1.puid and b.puid=b0.puid and b0.ritems_tagu=a.puid and a.pitem_id in (")
.append(codes.substring(2))
.append("') order by b.puid");
System.out.println("sql1\n" + sql1);
ResultSet read = SqlUtil.read(sql1.toString());
String last = "";
HashMap<String, TCComponentItemRevision> uidMap = new HashMap<>();
while (read.next()) {
String uid = read.getString(1);
String code = read.getString(2);
String classification = read.getString(3);
if(classification == null)
classification = "";
// System.out.println("code" + code);
String tlgx = read.getString(4);
String bzgy = read.getString(5);
String one = uid + bzgy;
if(one.equals(last))
throw new Exception("通过 DrawingNo = " + code + " 查询到多个对象");
// BYProcBean bean = procBeanList.get(codeList.indexOf(code));
for(int i = 0; i < codeList.size(); i++) {
if(codeList.get(i).equals(code)) {
BYProcBean bean = procBeanList.get(i);
if(tlgx != null && !tlgx.isEmpty()) {
if(uidMap.containsKey(tlgx))
bean.setTlgx(uidMap.get(tlgx));
else {
TCComponentItemRevision tlgxRev = (TCComponentItemRevision) session.stringToComponent(tlgx);
bean.setTlgx(tlgxRev);
uidMap.put(tlgx, tlgxRev);
}
}
if(bzgy != null && !bzgy.isEmpty()) {
TCComponentItemRevision bzgyRev;
if(uidMap.containsKey(bzgy))
bzgyRev = uidMap.get(bzgy);
else {
bzgyRev = (TCComponentItemRevision) session.stringToComponent(bzgy);
uidMap.put(bzgy, bzgyRev);
}
bean.setTemplate(bzgyRev);
if(!bean.getBzgys().contains(bzgyRev))
bean.getBzgys().add(bzgyRev);
}
bean.setFeeding(classification.length() <= 0);
bean.setRev_standard((TCComponentItemRevision) session.stringToComponent(uid));
}
}
last = one;
}
// SqlUtil.free();
StringBuilder nos = new StringBuilder("");
noSet.clear();
for(String s : noList) {
if(noSet.contains(s))
continue;
noSet.add(s);
nos.append("','").append(s);
}
//查询产品图投料工序
String sql2 = "select b.puid,a.pitem_id from pitem a,pitemrevision b where b.ritems_tagu=a.puid and a.PITEM_ID in (" + nos.substring(2) + "') order by a.pitem_id";
System.out.println("sql2\n" + sql2);
read = SqlUtil.read(sql2.toString());
last = "";
while (read.next()) {
String id = read.getString(2);
if(id.equals(last))
throw new Exception("通过 ID = " + id + " 查询到多个对象");
String uid = read.getString(1);
for(int i = 0; i < noList.size(); i++) {
if(noList.get(i).equals(id)) {
BYProcBean bean = procBeanList.get(i);
bean.setCptlgx((TCComponentItemRevision) session.stringToComponent(uid));
}
}
last = id;
}
// SqlUtil.free();
} }
public void readData2(ProgressBar pb, DefaultMutableTreeNode topTreeNode) throws Exception { public void readData2(ProgressBar pb, DefaultMutableTreeNode topTreeNode) throws Exception {
@ -923,6 +1030,7 @@ public class CreateProcZYDialogController {
TCComponentBOMWindow win = bomWinType.create(null); TCComponentBOMWindow win = bomWinType.create(null);
BomBean topBean = (BomBean) topTreeNode.getUserObject(); BomBean topBean = (BomBean) topTreeNode.getUserObject();
TCComponentItemRevision rev = topBean.getRev(); TCComponentItemRevision rev = topBean.getRev();
group = session.getCurrentGroup().getUid();
dialog.bomrev = rev; dialog.bomrev = rev;
if (dialog.bomrev.getType().equals("Part Revision") if (dialog.bomrev.getType().equals("Part Revision")
@ -934,8 +1042,11 @@ public class CreateProcZYDialogController {
win.setWindowTopLine(rev.getItem(), rev, null, null); win.setWindowTopLine(rev.getItem(), rev, null, null);
TCComponentBOMLine topLine = win.getTopBOMLine(); TCComponentBOMLine topLine = win.getTopBOMLine();
List<BYProcBean> procBeanList2 = new ArrayList<>(); List<BYProcBean> procBeanList2 = new ArrayList<>();
List<String> codeList = new ArrayList<>();
List<String> noList = new ArrayList<>();
readBom2(topTreeNode, topLine, pb, rev, topBean, procBeanList2); readBom2(topTreeNode, topLine, pb, rev, topBean, procBeanList2, codeList, noList);
getGY(procBeanList2, codeList, noList);
procBeanList.clear(); procBeanList.clear();
procBeanList.addAll(procBeanList2); procBeanList.addAll(procBeanList2);
dialog.map_nodes.put(topTreeNode, procBeanList2); dialog.map_nodes.put(topTreeNode, procBeanList2);
@ -971,6 +1082,7 @@ public class CreateProcZYDialogController {
return nodes; return nodes;
} }
@SuppressWarnings("deprecation")
public void createProcess(ProgressBar pb, MEProcessBean bean, List<BomBean> beans) throws Exception { public void createProcess(ProgressBar pb, MEProcessBean bean, List<BomBean> beans) throws Exception {
TCComponentItemRevision template = bean.getMepRevision(); TCComponentItemRevision template = bean.getMepRevision();
TCComponentItemRevision proc = null; TCComponentItemRevision proc = null;
@ -1011,8 +1123,8 @@ public class CreateProcZYDialogController {
TCComponentItemRevision newProc = null; TCComponentItemRevision newProc = null;
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
DefaultMutableTreeNode node; // DefaultMutableTreeNode node;
String object_name = proc.getProperty("object_name"); // String object_name = proc.getProperty("object_name");
pb.setText("工艺路线创建......"); pb.setText("工艺路线创建......");
int len = beans.size(); int len = beans.size();
BYProcBean dyccBean; BYProcBean dyccBean;
@ -1037,7 +1149,7 @@ public class CreateProcZYDialogController {
newProc.add("IMAN_METarget", bomBean.getRev()); newProc.add("IMAN_METarget", bomBean.getRev());
} }
node = dialog.rev_nodes.get(bomBean.getRev()); // node = dialog.rev_nodes.get(bomBean.getRev());
if (dialog.bomLink_maps.containsKey(bomBean)) { if (dialog.bomLink_maps.containsKey(bomBean)) {
dyccBean = dialog.bomLink_maps.get(bomBean); dyccBean = dialog.bomLink_maps.get(bomBean);
dyccBean.setCpgy(newProc); dyccBean.setCpgy(newProc);
@ -1048,6 +1160,7 @@ public class CreateProcZYDialogController {
BYProcBean.INDEX_CPGY); BYProcBean.INDEX_CPGY);
} }
if (dyccBean.getRev_standard() == dyccBean.getBomRev()) { if (dyccBean.getRev_standard() == dyccBean.getBomRev()) {
if(!dyccBean.getBzgys().contains(newProc))
dyccBean.getBzgys().add(newProc); dyccBean.getBzgys().add(newProc);
dyccBean.setTemplate(newProc); dyccBean.setTemplate(newProc);
if (dyccBean.isVisible) { if (dyccBean.isVisible) {
@ -1062,7 +1175,7 @@ public class CreateProcZYDialogController {
System.out.println("正在为" + bomBean.getRev() + "创建工艺路线"); System.out.println("正在为" + bomBean.getRev() + "创建工艺路线");
pb.setText("正在为" + len + "/" + len + " " + bomBean.getRev() + "创建工艺路线"); pb.setText("正在为" + len + "/" + len + " " + bomBean.getRev() + "创建工艺路线");
proc.add("IMAN_METarget", bomBean.getRev()); proc.add("IMAN_METarget", bomBean.getRev());
node = dialog.rev_nodes.get(bomBean.getRev()); // node = dialog.rev_nodes.get(bomBean.getRev());
if (dialog.bomLink_maps.containsKey(bomBean)) { if (dialog.bomLink_maps.containsKey(bomBean)) {
dyccBean = dialog.bomLink_maps.get(bomBean); dyccBean = dialog.bomLink_maps.get(bomBean);
@ -1074,6 +1187,7 @@ public class CreateProcZYDialogController {
BYProcBean.INDEX_CPGY); BYProcBean.INDEX_CPGY);
} }
if (dyccBean.getRev_standard() == dyccBean.getBomRev()) { if (dyccBean.getRev_standard() == dyccBean.getBomRev()) {
if(!dyccBean.getBzgys().contains(proc))
dyccBean.getBzgys().add(proc); dyccBean.getBzgys().add(proc);
dyccBean.setTemplate(proc); dyccBean.setTemplate(proc);
if (dyccBean.isVisible) { if (dyccBean.isVisible) {

@ -226,4 +226,46 @@ public class BomToSapUtil {
} }
return bomLineMap; return bomLineMap;
} }
/**
* SOABOMStructureManagement
* @param bomLine BOM
* @param structureService StructureManagement
* @return BOMuid
*/
public static Map<String, ExpandPSData[]> getBomLineTreeNodeSOA(TCComponentBOMLine bomLine, StructureManagement structureService) {
long startTime = System.currentTimeMillis();
// List<String> bomLineNodes = list;
//预定义BOM父子对map及ItemRev map
Map<String, ExpandPSData[]> bomLineMap = new HashMap<>();
// Map<String, TCComponentItemRevision> bomLineItemRevMap = new HashMap();
try {
// 调用SOA方法批量展开BOM
// 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();
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsPref levelPref = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsPref();
levelInfo.parentBomLines = new TCComponentBOMLine[] { bomLine }; //输入顶层BOMLine对象
levelInfo.excludeFilter = "None";//zt2_BOMMaterial
levelPref.expItemRev = false;
levelPref.info = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelationAndTypesFilter[0];
// levelPref.info[0].relationName = "";
System.out.println("getBomLineTreeNodeSOA1:" + (System.currentTimeMillis() - startTime) / 1000);
//使用以下方法展开完整的BOM行
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsResponse levelResp = structureService.expandPSAllLevels(levelInfo, levelPref);
System.out.println("getBomLineTreeNodeSOA2:" + (System.currentTimeMillis() - startTime) / 1000);
if (levelResp.output.length > 0) {
//将BOM构建成uid父子对关系
for (ExpandPSAllLevelsOutput data : levelResp.output) {
ExpandPSData[] children = data.children;
TCComponentBOMLine parentBomLine = (TCComponentBOMLine) data.parent.bomLine;
bomLineMap.put(parentBomLine.getUid(), children);
}
}
System.out.println("getBomLineTreeNodeSOA3:" + (System.currentTimeMillis() - startTime) / 1000);
} catch (Exception e) {
e.printStackTrace();
}
return bomLineMap;
}
} }

@ -86,6 +86,7 @@ import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentListOfValues; import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentListOfValuesType; import com.teamcenter.rac.kernel.TCComponentListOfValuesType;
import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; import com.teamcenter.rac.kernel.TCComponentMEProcessRevision;
import com.teamcenter.rac.kernel.TCComponentPseudoFolder;
import com.teamcenter.rac.kernel.TCComponentQuery; import com.teamcenter.rac.kernel.TCComponentQuery;
import com.teamcenter.rac.kernel.TCComponentQueryType; import com.teamcenter.rac.kernel.TCComponentQueryType;
import com.teamcenter.rac.kernel.TCComponentRevisionRule; import com.teamcenter.rac.kernel.TCComponentRevisionRule;
@ -2203,4 +2204,30 @@ public class KUtil {
t_part.setValueAt(i + 1, i, 0); t_part.setValueAt(i + 1, i, 0);
} }
} }
/**
*
*
* @param parent
* @param relation
* @return
*/
public static TCComponentPseudoFolder getPseudoFolder(TCComponent parent, String relation) throws Exception {
TCComponentPseudoFolder pseudoFolder = null;
AIFComponentContext[] comps = parent.getChildren();
if (comps != null && comps.length > 0 && comps[0] != null) {
for (int i = 0; i < comps.length; i++) {
TCComponent comp = (TCComponent) comps[i].getComponent();
if (comp instanceof TCComponentPseudoFolder) {
if (comp.isTypeOf("PseudoFolder")) {
// System.out.println("PseudoFolder type:" + comp.getDefaultPasteRelation());
if (comp.getDefaultPasteRelation().equalsIgnoreCase(relation)) {
pseudoFolder = (TCComponentPseudoFolder) comp;
break;
}
}
}
}
}
return pseudoFolder;
}
} }

@ -705,9 +705,9 @@ public class SqlUtil {
*/ */
public final static ResultSet read(String sql, Object[] argments) throws SQLException { public final static ResultSet read(String sql, Object[] argments) throws SQLException {
PreparedStatement ps = SqlUtil.getPs(argments, sql); PreparedStatement ps = SqlUtil.getPs(argments, sql);
System.out.println("read1"); // System.out.println("read1");
SqlUtil.rs = ps.executeQuery(); SqlUtil.rs = ps.executeQuery();
System.out.println("read2"); // System.out.println("read2");
return SqlUtil.rs; return SqlUtil.rs;
} }

@ -262,9 +262,15 @@ public class TableBuilder {
//查询界面增加“停用”勾选项默认不勾选进行模糊查询时自动过滤掉“GoodsFullInfo”中包含“停用”的物料若勾选则不过滤。 //查询界面增加“停用”勾选项默认不勾选进行模糊查询时自动过滤掉“GoodsFullInfo”中包含“停用”的物料若勾选则不过滤。
sql.append(" and \"GoodsFullInfo\" not like '%停用%'"); sql.append(" and \"GoodsFullInfo\" not like '%停用%'");
} }
System.out.println("SQL:" + sql); System.out.println("SQL1:\n" + sql);
ResultSet rs = SqlUtil.read(sql.toString() + " order by \"GoodsUsed\"", String sql2 = sql.toString();//.replace("?", "'" + input + "'") + " order by \"GoodsUsed\"";
params.toArray(new Object[] {})); for(String s : params) {
sql2 = sql2.replaceFirst("\\?", "'" + s + "'");
}
sql2 += " order by \"GoodsUsed\"";
System.out.println("SQL2:\n" + sql2);
ResultSet rs = SqlUtil.read(sql2);//, params.toArray(new Object[] {})
while (rs.next()) { while (rs.next()) {
System.out.println("rs:" + rs.getRow()); System.out.println("rs:" + rs.getRow());
TableBean bean = new TableBean(rs.getString(1), ind_index); TableBean bean = new TableBean(rs.getString(1), ind_index);
@ -301,10 +307,18 @@ public class TableBuilder {
//查询界面增加“停用”勾选项默认不勾选进行模糊查询时自动过滤掉“GoodsFullInfo”中包含“停用”的物料若勾选则不过滤。 //查询界面增加“停用”勾选项默认不勾选进行模糊查询时自动过滤掉“GoodsFullInfo”中包含“停用”的物料若勾选则不过滤。
sql.append(" and \"GoodsFullInfo\" not like '%停用%'"); sql.append(" and \"GoodsFullInfo\" not like '%停用%'");
} }
System.out.println("SQL:" + sql); System.out.println("SQL1:" + sql);
System.out.println("PARAMS:" + params); System.out.println("PARAMS:" + params);
ResultSet rs = SqlUtil.read(sql.toString() + " order by \"GoodsUsed\"", params.toArray(new Object[] {})); String sql2 = sql.toString();//.replace("?", "'" + input + "'") + " order by \"GoodsUsed\"";
for(String s : params) {
sql2 = sql2.replaceFirst("\\?", "'" + s + "'");
}
sql2 += " order by \"GoodsUsed\"";
System.out.println("SQL2:\n" + sql2);
// ResultSet rs = SqlUtil.read(sql.toString() + " order by \"GoodsUsed\"", params.toArray(new Object[] {}));
ResultSet rs = SqlUtil.read(sql2);
System.out.println("index:" + index + " <---> cnt:" + cnt); System.out.println("index:" + index + " <---> cnt:" + cnt);
while (rs.next()) { while (rs.next()) {
System.out.println("rs:" + rs.getRow()); System.out.println("rs:" + rs.getRow());

Loading…
Cancel
Save