From d88773ae0189a2e2da023217f8027218c826be36 Mon Sep 17 00:00:00 2001 From: xiongcz Date: Fri, 6 Jun 2025 17:53:28 +0800 Subject: [PATCH] 1 --- META-INF/MANIFEST.MF | 3 +- src/com/langtech/plm/mpart/MpartDialog.java | 83 +++++++++++++++++-- .../tqsx/PropertyToWordOrExcelOperation.java | 4 + 3 files changed, 80 insertions(+), 10 deletions(-) diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF index 540b604..afb03a3 100644 --- a/META-INF/MANIFEST.MF +++ b/META-INF/MANIFEST.MF @@ -51,4 +51,5 @@ Bundle-ClassPath: sqlServerLib/sqljdbc4.jar, axis2_lib/commons-httpclient-3.1.jar, axis2_lib/httpcore-4.0.jar, axis2_lib/commons-codec-1.3.jar -Import-Package: com.teamcenter.services.loose.core._2011_06 +Import-Package: com.teamcenter.rac.kernel, + com.teamcenter.services.loose.core._2011_06 diff --git a/src/com/langtech/plm/mpart/MpartDialog.java b/src/com/langtech/plm/mpart/MpartDialog.java index c755300..aa0329f 100644 --- a/src/com/langtech/plm/mpart/MpartDialog.java +++ b/src/com/langtech/plm/mpart/MpartDialog.java @@ -55,12 +55,14 @@ import com.langtech.plm.createProjectStruct.KUtil; import com.teamcenter.rac.aif.AIFDesktop; import com.teamcenter.rac.aif.kernel.AIFComponentContext; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentBOMWindow; import com.teamcenter.rac.kernel.TCComponentBOMWindowType; import com.teamcenter.rac.kernel.TCComponentForm; import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentICO; import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemType; @@ -72,6 +74,8 @@ import com.teamcenter.rac.kernel.TCComponentUser; import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.kernel.TCProperty; import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSProperty; import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.PropertyLayout; @@ -514,6 +518,7 @@ public class MpartDialog extends JFrame implements ActionListener { HashMap> revMap = new HashMap>();// object_String StringBuilder errMsg = new StringBuilder(); + int tMnum = 0;//统计下列子项中,已经转换MPart的子项数量 for (int j = 0; j < children.length; j++) { TCComponentBOMLine eLine = (TCComponentBOMLine) children[j].getComponent(); // 判断是否自制 @@ -524,16 +529,17 @@ public class MpartDialog extends JFrame implements ActionListener { if (tcProperty.equals("自制")) { - // 判断e下面的m是否唯一 - - + //先循环一遍判断有没有 mpart ArrayList list = new ArrayList(); - for (int k = 0; k < groupSplit.length; k++) { + //bomline子项的itemID TCComponent[] search = session.search("_SearchMFKProperties", new String[] { "ID", "工厂" }, new String[] { eId, groupSplit[k] }); + if (search == null || search.length == 0){ + System.out.println("当前bom对象["+eId+"]未通过[_SearchMFKProperties]查询到任何MPart信息!"); + } for (int l = 0; l < search.length; l++) { TCComponentItem tempItem = (TCComponentItem) search[l]; list.add(tempItem.getLatestItemRevision()); @@ -543,17 +549,26 @@ public class MpartDialog extends JFrame implements ActionListener { if (list.size() == 0) { errMsg.append(eId + "对象未创建MPart"+System.lineSeparator()); + }else if (list.size() > 0){ + System.out.println("当前子bom对象["+eId+"]已创建/派生了MPart"); + if (allowedToMPart(topLine)){ + tMnum ++;//放行,不禁止 + } + } } } - - if(errMsg.length() > 0) { - MessageBox.post(errMsg.toString(), "提示 ", MessageBox.INFORMATION); - KUtil.setByPass(false); - return; + + if (tMnum == 0){ + if(errMsg.length() > 0) { + MessageBox.post(errMsg.toString(), "提示 ", MessageBox.INFORMATION); + KUtil.setByPass(false); + return; + } } + // 和对应版本 @@ -874,6 +889,56 @@ public class MpartDialog extends JFrame implements ActionListener { } + /** + * 判断派生MPart时,选中的bomline对象分类是否是半成品的砂芯(允许派生MPart) + * @param topLine 选中对象 + * @return + */ + public boolean allowedToMPart(TCComponentBOMLine topLine){ + System.out.println("allowedToMPart开始执行!"); + Integer[] keys; + String[] values; + try { + TCComponentItemRevision itemRevision = topLine.getItemRevision(); + String itemID = itemRevision.getStringProperty("item_id"); +// 获取分类信息 + String classId = itemRevision.getClassificationClass(); + TCClassificationService classificationService = session.getClassificationService(); + if (classId != null) {//当前版本对象已经发送到分类 + ICSAdminClass adminClass = classificationService.newICSAdminClass(); + adminClass.load(classId); + String parentClassId = adminClass.getParent(); + if (parentClassId != null) { + String currenteClassificationName = adminClass.getName(); + System.out.println("当前分类["+currenteClassificationName+"]的父级分类ID="+parentClassId); + adminClass.load(parentClassId); + String parentClassificationName = adminClass.getName(); + System.out.println("父级分类名称=["+parentClassificationName+"]"); + if (currenteClassificationName.equals("砂芯") && parentClassificationName.equals("半成品")) { + System.out.println("true"); + return true; + }else { + System.out.println("当前对象["+itemID+"]的分类不是半成品下的砂芯,返回false!"); + } + } + + } + + + + + + } catch (TCException e) { + e.printStackTrace(); + } + return false; + } + + + + + + private JPanel getBtnPanel() { JPanel topPanel = new JPanel(); topPanel.setLayout(new PropertyLayout()); diff --git a/src/com/langtech/plm/tqsx/PropertyToWordOrExcelOperation.java b/src/com/langtech/plm/tqsx/PropertyToWordOrExcelOperation.java index d416de9..7ad11e7 100644 --- a/src/com/langtech/plm/tqsx/PropertyToWordOrExcelOperation.java +++ b/src/com/langtech/plm/tqsx/PropertyToWordOrExcelOperation.java @@ -321,6 +321,10 @@ public class PropertyToWordOrExcelOperation extends KOperation { public static String formatDateString(String input) { + if(input == null || input.isEmpty()) { + return ""; + } + // 定义两种可能的时间格式 SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm");