diff --git a/cn.net.connor.designtopart/.project b/cn.net.connor.designtopart/.project
new file mode 100644
index 0000000..b036b3e
--- /dev/null
+++ b/cn.net.connor.designtopart/.project
@@ -0,0 +1,28 @@
+
+
+ cn.net.connor.designtopart
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/cn.net.connor.designtopart/bin/.project b/cn.net.connor.designtopart/bin/.project
new file mode 100644
index 0000000..b036b3e
--- /dev/null
+++ b/cn.net.connor.designtopart/bin/.project
@@ -0,0 +1,28 @@
+
+
+ cn.net.connor.designtopart
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/src/cn/net/connor/designtopart/designtopart/DesignToPartDialogController.java b/src/cn/net/connor/designtopart/designtopart/DesignToPartDialogController.java
index defba3b..9a62703 100644
--- a/src/cn/net/connor/designtopart/designtopart/DesignToPartDialogController.java
+++ b/src/cn/net/connor/designtopart/designtopart/DesignToPartDialogController.java
@@ -50,7 +50,6 @@ public class DesignToPartDialogController extends KDialogController {
if (selectedRevMap.size() == 0) {
throw new TCException(DesigntopartLocale.getString("selectrev.INFO"));
}
- // Connor_Design_To_Part
String[] prefVals = KUtil.getPrefVals(session, PREF_TRANSFER);
int len = KUtil.getLen(prefVals);
int counter = 0;
diff --git a/src/cn/net/connor/designtopart/designtopart/TableBuilder.java b/src/cn/net/connor/designtopart/designtopart/TableBuilder.java
index 263891b..c5ede8f 100644
--- a/src/cn/net/connor/designtopart/designtopart/TableBuilder.java
+++ b/src/cn/net/connor/designtopart/designtopart/TableBuilder.java
@@ -1,11 +1,18 @@
package cn.net.connor.designtopart.designtopart;
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.log4j.Logger;
+
import com.connor.dfl.plm.util.DataBaseControl;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentForm;
@@ -37,6 +44,7 @@ import k.util.KUtil;
@SuppressWarnings("all")
public class TableBuilder {
+ static final Logger logger = Logger.getLogger(TableBuilder.class);
public static final String PROPLOC_ITEM = "I";
public static final String PROPLOC_REV = "R";
@@ -84,18 +92,39 @@ public class TableBuilder {
protected Map uomMap = new HashMap<>();
protected ObservableList uomList = FXCollections.observableArrayList();
+ /**
+ * SB6_YYXHQ_CUSTOME
+ */
protected Map khflMap = new HashMap<>();
+ /**
+ * SB6_YYXHQ_TZ
+ */
protected Map tzMap = new HashMap<>();
protected ObservableList khflList = FXCollections.observableArrayList();
protected ObservableList tzList = FXCollections.observableArrayList();
+ /**
+ * SB6_DYXHQ_CUSTOME
+ */
protected Map khfl2Map = new HashMap<>();
+ /**
+ * SB6_DYXHQ_TZ
+ */
protected Map tz2Map = new HashMap<>();
protected ObservableList khfl2List = FXCollections.observableArrayList();
protected ObservableList tz2List = FXCollections.observableArrayList();
+ /**
+ * SB6_DDXHQ_CUSTOME
+ */
protected Map khfl3Map = new HashMap<>();
+ /**
+ * SB6_DDXHQ_CGQ
+ */
protected Map cgqlxMap = new HashMap<>();
+ /**
+ * SB6_DDXHQ_TZ
+ */
protected Map tz3Map = new HashMap<>();
protected ObservableList khfl3List = FXCollections.observableArrayList();
protected ObservableList cgqlxList = FXCollections.observableArrayList();
@@ -104,6 +133,15 @@ public class TableBuilder {
protected String formName = "";
protected boolean isHave = false;
protected String sb6_PartRM14 = "";
+
+ private static String lineSeparator = System.lineSeparator();// 换行符
+ private static SimpleDateFormat sfd = new SimpleDateFormat("yyyyMMDDhhmmss");
+ private StringBuffer logInfo = new StringBuffer();
+
+ /**
+ * 图纸版本表单上是否临时图纸的值?
+ */
+ protected boolean isLsTZ = false;
public TableBuilder(TCSession session, String config, Map> selectedRevMap)
throws Exception {
@@ -284,7 +322,7 @@ public class TableBuilder {
public void addData(TCComponent comp, ColConfig colConfig) throws Exception {
if (colConfig.isRefType) {
TCComponent value = comp.getTCProperty(colConfig.fromPropName).getReferenceValue();
- System.out.println(colConfig.fromPropName + " = " + value);
+ logger.info(colConfig.fromPropName + " = " + value);
refDataMap.put(colConfig, new SimpleObjectProperty(value));
} else {
String value = comp.getProperty(colConfig.fromPropName);
@@ -385,25 +423,101 @@ public class TableBuilder {
}
}
- String type = rowData.fromRev.getType();
+ String type = rowData.fromRev.getType();//当前选中版本对象的类型
+ //TODO 判断图纸版本表单上是否临时图纸,更新公共属性-isLsTZ
+ TCComponentItemRevision fromRev = rowData.fromRev;
+ String targetRevName = fromRev.getStringProperty("object_name");
+ TCComponentForm formLS = (TCComponentForm) fromRev.getRelatedComponent("IMAN_master_form_rev");
+ if (formLS != null){
+// logger.info(targetRevName+"下存在表单");
+ logger.info(targetRevName+"下存在表单");
+ logInfo.append(String.format("【%s】下存在表单!",targetRevName) + lineSeparator);
+ logInfoAppend(String.format("【%s】下存在表单!",targetRevName));
+ String ifls = formLS.getStringProperty("sb6_ifls");
+ if (ifls != null){
+ logger.info("表单属性“是否临时图纸”:【"+ifls+"】临时图纸!");
+ logInfo.append(String.format("表单属性“是否临时图纸”:【%s】临时图纸!",ifls) + lineSeparator);
+ }else {
+ logInfo.append(String.format("表单属性“是否临时图纸”为空!") + lineSeparator);
+ }
+
+ if (ifls != null && ifls.equals("Y")) {
+ logger.info("111000");
+ logInfo.append(String.format("111000")+ lineSeparator);
+ this.isLsTZ = true;
+ }else {
+ logInfo.append(String.format("当前图纸非临时图纸")+ lineSeparator);
+ }
+ }else {
+ logger.info(targetRevName+"下不存在表单");
+ logInfo.append(String.format("【%s】下不存在表单!",targetRevName)+ lineSeparator);
+ }
+
+
+
switch (type) {
case "SB6_CatiaDesignLRevision":
- String khflStr = khflMap.get(khfl);
- String[] tzStr = tzMap.get(tz);
- id = id.length() > 8 ? id.substring(0, 8) : id;
+// logger.info("当前选中版本对象类型为:世宝液压循环球总成");
+ logger.info("当前选中版本对象类型为:世宝液压循环球总成");
+ logInfo.append(String.format("当前选中版本对象类型为:世宝液压循环球总成")+ lineSeparator);
+ String khflStr = khflMap.get(khfl);//客户分类的值
+ String[] tzStr = tzMap.get(tz);//特征首选项的配置
+
+ if(!isLsTZ){
+// logger.info("液压1");
+ logger.info("液压1");
+ logInfo.append(String.format("当前图纸不是临时图纸,走老逻辑")+ lineSeparator);
+ id = id.length() > 8 ? id.substring(0, 8) : id;
+ }else {
+// logger.info("液压2");
+ logger.info("当前图纸是临时图纸,走新逻辑");
+ logInfo.append(String.format("当前图纸是临时图纸,走新逻辑")+ lineSeparator);
+ String newId = "";
+ if (id.length() >= 9) {
+ newId = id.substring(0, 8);
+ if (id.length() > 12) {
+ newId = newId + id.substring(11);
+ }
+ }else{
+ newId = id;
+ }
+ id = newId;
+ }
+
+ logOut();
+
+ logger.info("id="+id);
+
prefix = id + khflStr;
- lshMin = tzStr[0];
- lshMax = tzStr[1];
- newCode = dataBaseControl.getNewCode(prefix, lshMin, lshMax);
+ logger.info("prefix"+prefix);
+ lshMin = tzStr[0];//特征首选项配置的:编码最小值
+ lshMax = tzStr[1];//特征首选项配置的:编码最大值
+ newCode = dataBaseControl.getNewCode(prefix, lshMin, lshMax);//获取特征列值
id = prefix + newCode;
break;
case "SB6_CatiaAssDLRevision":
+ logger.info("当前选中版本对象类型为:世宝电液循环球总成");
String khfl2Str = khfl2Map.get(khfl);
String tz2Str = tz2Map.get(tz);
- id = id.length() > 8 ? id.substring(0, 8) : id;
+// id = id.length() > 8 ? id.substring(0, 8) : id;
+ if(!isLsTZ){
+ id = id.length() > 8 ? id.substring(0, 8) : id;
+ }else {
+ String newId = "";
+ if (id.length() >= 9) {
+ newId = id.substring(0, 8);
+ if (id.length() > 12) {
+ newId = newId + id.substring(11);
+ }
+ }else{
+ newId = id;
+ }
+ id = newId;
+ }
+
prefix = id + khfl2Str + tz2Str;
- lshMin = "001";
- lshMax = "999";
+ lshMin = "001";//流水号
+ lshMax = "999";//流水号
newCode = dataBaseControl.getNewCode(prefix, lshMin, lshMax);
if ("".equals(newCode)) {
throw new TCException("对象" + prefix + "流水号已用完");
@@ -411,10 +525,25 @@ public class TableBuilder {
id = prefix + newCode;
break;
case "SB6_CatiaSDLRevision":
+ logger.info("当前选中版本对象类型为:世宝电动循环球总成");
String khfl3Str = khfl3Map.get(khfl);
String cgqlxStr = cgqlxMap.get(cgqlx);
String tz3Str = tz3Map.get(tz);
- id = id.length() > 8 ? id.substring(0, 8) : id;
+// id = id.length() > 8 ? id.substring(0, 8) : id;
+ if(!isLsTZ){
+ id = id.length() > 8 ? id.substring(0, 8) : id;
+ }else {
+ String newId = "";
+ if (id.length() >= 9) {
+ newId = id.substring(0, 8);
+ if (id.length() > 12) {
+ newId = newId + id.substring(11);
+ }
+ }else{
+ newId = id;
+ }
+ id = newId;
+ }
prefix = id + khfl3Str + tz3Str + cgqlxStr;
lshMin = "01";
lshMax = "99";
@@ -523,12 +652,12 @@ public class TableBuilder {
sb6_PartRM14 = laoMap.get(drm03);
}
- System.out.println("khfl = " + khfl);
- System.out.println("tz = " + tz);
- System.out.println("uom_tag_display = " + uom_tag_display + ", uom_tag_real = " + uom_tag_real);
- System.out.println("lshMin = " + lshMin);
- System.out.println("newCode = " + newCode);
- System.out.println("lshMax = " + lshMax);
+ logger.info("khfl = " + khfl);
+ logger.info("tz = " + tz);
+ logger.info("uom_tag_display = " + uom_tag_display + ", uom_tag_real = " + uom_tag_real);
+ logger.info("lshMin = " + lshMin);
+ logger.info("newCode = " + newCode);
+ logger.info("lshMax = " + lshMax);
TCComponentItem newItem = null;
TCComponent[] findItem = session.search("零组件 ID", new String[] { "零组件 ID" }, new String[] { id + "*" });
@@ -600,6 +729,24 @@ public class TableBuilder {
rev.refresh();
form.refresh();
}
+
+ private void logInfoAppend(String format) {
+ // TODO 自动生成的方法存根
+
+ }
+
+ private void logOut() {
+ if(logInfo.length() > 0) {
+ String format = sfd.format(new Date());
+ String outFilePath = System.getenv("TEMP") +"\\"+"SB_tzw_"+format+".txt";
+ try (BufferedWriter writer = new BufferedWriter(new FileWriter(outFilePath))) {
+ writer.write(logInfo.toString());
+ System.out.println("文件已成功写入:" + outFilePath);
+ } catch (IOException e) {
+ System.err.println("写入文件时发生错误:" + e.getMessage());
+ }
+ }
+ }
private void setProperties(TCComponent comp, Map props) throws Exception {
if (comp == null || props == null || props.size() == 0) {