feat(designtopart):增加临时图纸处理逻辑- 在 TableBuilder 类中添加了判断图纸是否为临时图纸的逻辑

- 根据图纸是否为临时图纸,执行不同的编码生成逻辑
main
熊朝柱 2 weeks ago
parent 049e3e2611
commit 0f747cf593

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>cn.net.connor.designtopart</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>cn.net.connor.designtopart</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

@ -50,7 +50,6 @@ public class DesignToPartDialogController extends KDialogController {
if (selectedRevMap.size() == 0) { if (selectedRevMap.size() == 0) {
throw new TCException(DesigntopartLocale.getString("selectrev.INFO")); throw new TCException(DesigntopartLocale.getString("selectrev.INFO"));
} }
// Connor_Design_To_Part
String[] prefVals = KUtil.getPrefVals(session, PREF_TRANSFER); String[] prefVals = KUtil.getPrefVals(session, PREF_TRANSFER);
int len = KUtil.getLen(prefVals); int len = KUtil.getLen(prefVals);
int counter = 0; int counter = 0;

@ -1,11 +1,18 @@
package cn.net.connor.designtopart.designtopart; 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.ArrayList;
import java.util.Arrays; import java.util.Arrays;
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 org.apache.log4j.Logger;
import com.connor.dfl.plm.util.DataBaseControl; import com.connor.dfl.plm.util.DataBaseControl;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentForm; import com.teamcenter.rac.kernel.TCComponentForm;
@ -37,6 +44,7 @@ import k.util.KUtil;
@SuppressWarnings("all") @SuppressWarnings("all")
public class TableBuilder { public class TableBuilder {
static final Logger logger = Logger.getLogger(TableBuilder.class);
public static final String PROPLOC_ITEM = "I"; public static final String PROPLOC_ITEM = "I";
public static final String PROPLOC_REV = "R"; public static final String PROPLOC_REV = "R";
@ -84,18 +92,39 @@ public class TableBuilder {
protected Map<String, Object> uomMap = new HashMap<>(); protected Map<String, Object> uomMap = new HashMap<>();
protected ObservableList<String> uomList = FXCollections.observableArrayList(); protected ObservableList<String> uomList = FXCollections.observableArrayList();
/**
* SB6_YYXHQ_CUSTOME
*/
protected Map<String, String> khflMap = new HashMap<>(); protected Map<String, String> khflMap = new HashMap<>();
/**
* SB6_YYXHQ_TZ
*/
protected Map<String, String[]> tzMap = new HashMap<>(); protected Map<String, String[]> tzMap = new HashMap<>();
protected ObservableList<String> khflList = FXCollections.observableArrayList(); protected ObservableList<String> khflList = FXCollections.observableArrayList();
protected ObservableList<String> tzList = FXCollections.observableArrayList(); protected ObservableList<String> tzList = FXCollections.observableArrayList();
/**
* SB6_DYXHQ_CUSTOME
*/
protected Map<String, String> khfl2Map = new HashMap<>(); protected Map<String, String> khfl2Map = new HashMap<>();
/**
* SB6_DYXHQ_TZ
*/
protected Map<String, String> tz2Map = new HashMap<>(); protected Map<String, String> tz2Map = new HashMap<>();
protected ObservableList<String> khfl2List = FXCollections.observableArrayList(); protected ObservableList<String> khfl2List = FXCollections.observableArrayList();
protected ObservableList<String> tz2List = FXCollections.observableArrayList(); protected ObservableList<String> tz2List = FXCollections.observableArrayList();
/**
* SB6_DDXHQ_CUSTOME
*/
protected Map<String, String> khfl3Map = new HashMap<>(); protected Map<String, String> khfl3Map = new HashMap<>();
/**
* SB6_DDXHQ_CGQ
*/
protected Map<String, String> cgqlxMap = new HashMap<>(); protected Map<String, String> cgqlxMap = new HashMap<>();
/**
* SB6_DDXHQ_TZ
*/
protected Map<String, String> tz3Map = new HashMap<>(); protected Map<String, String> tz3Map = new HashMap<>();
protected ObservableList<String> khfl3List = FXCollections.observableArrayList(); protected ObservableList<String> khfl3List = FXCollections.observableArrayList();
protected ObservableList<String> cgqlxList = FXCollections.observableArrayList(); protected ObservableList<String> cgqlxList = FXCollections.observableArrayList();
@ -104,6 +133,15 @@ public class TableBuilder {
protected String formName = ""; protected String formName = "";
protected boolean isHave = false; protected boolean isHave = false;
protected String sb6_PartRM14 = ""; 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<String, List<TCComponentItemRevision>> selectedRevMap) public TableBuilder(TCSession session, String config, Map<String, List<TCComponentItemRevision>> selectedRevMap)
throws Exception { throws Exception {
@ -284,7 +322,7 @@ public class TableBuilder {
public void addData(TCComponent comp, ColConfig colConfig) throws Exception { public void addData(TCComponent comp, ColConfig colConfig) throws Exception {
if (colConfig.isRefType) { if (colConfig.isRefType) {
TCComponent value = comp.getTCProperty(colConfig.fromPropName).getReferenceValue(); TCComponent value = comp.getTCProperty(colConfig.fromPropName).getReferenceValue();
System.out.println(colConfig.fromPropName + " = " + value); logger.info(colConfig.fromPropName + " = " + value);
refDataMap.put(colConfig, new SimpleObjectProperty<TCComponent>(value)); refDataMap.put(colConfig, new SimpleObjectProperty<TCComponent>(value));
} else { } else {
String value = comp.getProperty(colConfig.fromPropName); 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) { switch (type) {
case "SB6_CatiaDesignLRevision": case "SB6_CatiaDesignLRevision":
String khflStr = khflMap.get(khfl); // logger.info("当前选中版本对象类型为:世宝液压循环球总成");
String[] tzStr = tzMap.get(tz); logger.info("当前选中版本对象类型为:世宝液压循环球总成");
id = id.length() > 8 ? id.substring(0, 8) : id; 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; prefix = id + khflStr;
lshMin = tzStr[0]; logger.info("prefix"+prefix);
lshMax = tzStr[1]; lshMin = tzStr[0];//特征首选项配置的:编码最小值
newCode = dataBaseControl.getNewCode(prefix, lshMin, lshMax); lshMax = tzStr[1];//特征首选项配置的:编码最大值
newCode = dataBaseControl.getNewCode(prefix, lshMin, lshMax);//获取特征列值
id = prefix + newCode; id = prefix + newCode;
break; break;
case "SB6_CatiaAssDLRevision": case "SB6_CatiaAssDLRevision":
logger.info("当前选中版本对象类型为:世宝电液循环球总成");
String khfl2Str = khfl2Map.get(khfl); String khfl2Str = khfl2Map.get(khfl);
String tz2Str = tz2Map.get(tz); 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; prefix = id + khfl2Str + tz2Str;
lshMin = "001"; lshMin = "001";//流水号
lshMax = "999"; lshMax = "999";//流水号
newCode = dataBaseControl.getNewCode(prefix, lshMin, lshMax); newCode = dataBaseControl.getNewCode(prefix, lshMin, lshMax);
if ("".equals(newCode)) { if ("".equals(newCode)) {
throw new TCException("对象" + prefix + "流水号已用完"); throw new TCException("对象" + prefix + "流水号已用完");
@ -411,10 +525,25 @@ public class TableBuilder {
id = prefix + newCode; id = prefix + newCode;
break; break;
case "SB6_CatiaSDLRevision": case "SB6_CatiaSDLRevision":
logger.info("当前选中版本对象类型为:世宝电动循环球总成");
String khfl3Str = khfl3Map.get(khfl); String khfl3Str = khfl3Map.get(khfl);
String cgqlxStr = cgqlxMap.get(cgqlx); String cgqlxStr = cgqlxMap.get(cgqlx);
String tz3Str = tz3Map.get(tz); 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; prefix = id + khfl3Str + tz3Str + cgqlxStr;
lshMin = "01"; lshMin = "01";
lshMax = "99"; lshMax = "99";
@ -523,12 +652,12 @@ public class TableBuilder {
sb6_PartRM14 = laoMap.get(drm03); sb6_PartRM14 = laoMap.get(drm03);
} }
System.out.println("khfl = " + khfl); logger.info("khfl = " + khfl);
System.out.println("tz = " + tz); logger.info("tz = " + tz);
System.out.println("uom_tag_display = " + uom_tag_display + ", uom_tag_real = " + uom_tag_real); logger.info("uom_tag_display = " + uom_tag_display + ", uom_tag_real = " + uom_tag_real);
System.out.println("lshMin = " + lshMin); logger.info("lshMin = " + lshMin);
System.out.println("newCode = " + newCode); logger.info("newCode = " + newCode);
System.out.println("lshMax = " + lshMax); logger.info("lshMax = " + lshMax);
TCComponentItem newItem = null; TCComponentItem newItem = null;
TCComponent[] findItem = session.search("零组件 ID", new String[] { "零组件 ID" }, new String[] { id + "*" }); TCComponent[] findItem = session.search("零组件 ID", new String[] { "零组件 ID" }, new String[] { id + "*" });
@ -600,6 +729,24 @@ public class TableBuilder {
rev.refresh(); rev.refresh();
form.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<String, String> props) throws Exception { private void setProperties(TCComponent comp, Map<String, String> props) throws Exception {
if (comp == null || props == null || props.size() == 0) { if (comp == null || props == null || props.size() == 0) {

Loading…
Cancel
Save