熊朝柱 1 week ago
parent 65fcc5f26e
commit 07055f5eca

@ -0,0 +1 @@
/cn/

@ -3,6 +3,7 @@ package cn.com.origin.autocode.newitem.generatcode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute; import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute;
import com.teamcenter.rac.kernel.ics.ICSKeyLov; import com.teamcenter.rac.kernel.ics.ICSKeyLov;
@ -51,6 +52,7 @@ public class CNClassPropBean {
} else { } else {
this.isLov = false; this.isLov = false;
} }
} }
@Override @Override

@ -11,6 +11,7 @@ import java.awt.datatransfer.StringSelection;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.math.BigInteger; import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -103,6 +104,7 @@ 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.TCComponentListOfValues; import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentListOfValuesType;
import com.teamcenter.rac.kernel.TCComponentProject; import com.teamcenter.rac.kernel.TCComponentProject;
import com.teamcenter.rac.kernel.TCComponentProjectType; import com.teamcenter.rac.kernel.TCComponentProjectType;
import com.teamcenter.rac.kernel.TCComponentPseudoFolder; import com.teamcenter.rac.kernel.TCComponentPseudoFolder;
@ -316,6 +318,7 @@ public class NewCodeItemDialog extends Dialog {
public NewCodeItemDialog(Shell parentShell) { public NewCodeItemDialog(Shell parentShell) {
super(parentShell); super(parentShell);
System.out.println("NewCodeItemDialog~");
treeViewOperation = new TreeViewOperation(); treeViewOperation = new TreeViewOperation();
treeAndListCodeOperation = new TreeAndListCodeOperation(); treeAndListCodeOperation = new TreeAndListCodeOperation();
session = (TCSession) AIFUtility.getCurrentApplication().getSession(); session = (TCSession) AIFUtility.getCurrentApplication().getSession();
@ -2716,6 +2719,75 @@ public class NewCodeItemDialog extends Dialog {
} }
} }
public static TCComponentListOfValues findLOVByName(TCSession tcsession, String lovName) {
TCComponentListOfValues tccomponentlistofvalues = null;
try {
TCComponentListOfValuesType tccomponentlistofvaluestype = (TCComponentListOfValuesType) tcsession.getTypeComponent("ListOfValues");
TCComponentListOfValues atccomponentlistofvalues[] = tccomponentlistofvaluestype.find(lovName);
if (atccomponentlistofvalues != null && atccomponentlistofvalues.length > 0)
tccomponentlistofvalues = atccomponentlistofvalues[0];
else
tccomponentlistofvalues = null;
} catch (TCException tcexception) {
tccomponentlistofvalues = null;
}
return tccomponentlistofvalues;
}
/**
* TC LOV-
* @param seesion
* @return
* @throws TCException
*/
public static Map<String, String> getLOVDisplay_value(TCSession seesion,String lovProp) throws TCException
{
Map<String, String> Display_values = new HashMap<String, String>();
TCComponentListOfValues unitLov = TCLOVUtil.findLOVByName(seesion, lovProp);
if(unitLov !=null)
{
ListOfValuesInfo listOfValues = unitLov.getListOfValues();
String[] realval = listOfValues.getStringListOfValues();
String value="";
boolean flag = false;
for (int i = 0; i < realval.length; i++) {
String disval = listOfValues.getDisplayableValue(realval[i]);
Display_values.put(disval, realval[i]);
}
}
return Display_values;
}
/**
* "yyyy-MM-dd"Calendar
* @param dateStr "yyyy-MM-dd"
* @return Calendarnull
*/
public static Calendar stringToCalendar(String dateStr) {
if (dateStr == null || dateStr.isEmpty()) {
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
Date date = sdf.parse(dateStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 将时、分、秒、毫秒设置为0
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
System.out.println(">>>stringToCalendar方法 入参:"+dateStr+",转换后的日期="+calendar);
return calendar;
} catch (ParseException e) {
System.err.println("日期解析失败: " + dateStr + ", 错误信息: " + e.getMessage());
return null;
}
}
/** /**
* *
* *
@ -2724,6 +2796,7 @@ public class NewCodeItemDialog extends Dialog {
*/ */
private void setPropMapping(CreateInput createInput, List<CNProperty> cnProperties, private void setPropMapping(CreateInput createInput, List<CNProperty> cnProperties,
Map<String, String> stringMappingOld) { Map<String, String> stringMappingOld) {
System.out.println("setPropMapping方法开始执行~");
if (cnProperties == null) { if (cnProperties == null) {
return; return;
} }
@ -2745,8 +2818,14 @@ public class NewCodeItemDialog extends Dialog {
if (prop == null) { if (prop == null) {
continue; continue;
} }
// log.info( Boolean isLov = prop.getIsLov();
// "PROP MAP >>>>"+prop.getRealName()+"<===>"+prop.value); String lovName = prop.getLovName();
Object inputValue = prop.value;
//20250509 编码器移植功能增强对xml配置中所有isLOV=true且输入有效的属性通过输入or选择的“显示值”获取lov的真实值
if (isLov && inputValue != null) {
String trueNameString = getLovTrueValue(lovName,inputValue);
prop.value = (trueNameString == null ? prop.value : trueNameString);
}
switch (prop.getPropertyType().toUpperCase()) { switch (prop.getPropertyType().toUpperCase()) {
case "STRING": case "STRING":
stringMapping.put(prop.getRealName(), (String) (prop.value == null ? "" : prop.value)); stringMapping.put(prop.getRealName(), (String) (prop.value == null ? "" : prop.value));
@ -2755,7 +2834,10 @@ public class NewCodeItemDialog extends Dialog {
intMapping.put(prop.getRealName(), (BigInteger) (prop.value == null ? "" : prop.value)); intMapping.put(prop.getRealName(), (BigInteger) (prop.value == null ? "" : prop.value));
break; break;
case "DATE": case "DATE":
dateMapping.put(prop.getRealName(), (Calendar) (prop.value == null ? "" : prop.value)); System.out.println(">>>转换前的属性输入值="+prop.value);
String value = (String) (prop.value == null ? "" : prop.value);
System.out.println(">>>转换成string后的value="+value);
dateMapping.put(prop.getRealName(), stringToCalendar(value) );
break; break;
case "BOOLEAN": case "BOOLEAN":
booleanMapping.put(prop.getRealName(), (Boolean) (prop.value == null ? "" : prop.value)); booleanMapping.put(prop.getRealName(), (Boolean) (prop.value == null ? "" : prop.value));
@ -2776,12 +2858,16 @@ public class NewCodeItemDialog extends Dialog {
doubleMapping.put(prop.getRealName(), mydv); doubleMapping.put(prop.getRealName(), mydv);
break; break;
default: default:
System.out.println("意料之外的类型:"+prop.getPropertyType().toUpperCase());
break; break;
} }
} }
setBigAndS(createInput.boName, stringMapping); setBigAndS(createInput.boName, stringMapping);
System.out.println("开始打印string类型的属性");
printMap(stringMapping);
createInput.stringProps = stringMapping; createInput.stringProps = stringMapping;
createInput.intProps = intMapping; createInput.intProps = intMapping;
createInput.dateProps = dateMapping; createInput.dateProps = dateMapping;
@ -2790,6 +2876,46 @@ public class NewCodeItemDialog extends Dialog {
} }
/**
* lov
* @param lovName lov
* @param inputValue lov
* @return
*/
private String getLovTrueValue(String lovName, Object inputValue) {
if (lovName == null || inputValue == null) {
System.out.println("获取lov真实值传入的参数无效");
return null;
}
try {
Map<String, String> lovDisplay_value = getLOVDisplay_value(session, lovName);
String trueValue = lovDisplay_value.get(inputValue);
if (trueValue == null) {
System.out.println("未在lov中查到对应的显示值获取真实值失败请检查输入");
return null;
}else {
System.out.println("成功获取到lov的真实值=》"+inputValue+":"+trueValue);
return trueValue;
}
} catch (TCException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
// TODO 自动生成的方法存根
return null;
}
public static void printMap(Map<String, String> map) {
if (map == null || map.isEmpty()) {
System.out.println("The map is empty.");
return;
}
for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println("》》》Key: " + entry.getKey() + ", Value: " + entry.getValue());
}
}
public TCComponent[] queryTCComponent(TCSession session, String[] values, String[] keys, String value) public TCComponent[] queryTCComponent(TCSession session, String[] values, String[] keys, String value)
throws TCException { throws TCException {
// String[] keys={"零组件 ID","版本"}; // String[] keys={"零组件 ID","版本"};
@ -2905,6 +3031,7 @@ public class NewCodeItemDialog extends Dialog {
ex3.printStackTrace(); ex3.printStackTrace();
} }
} }
//创建对象的传入参数
com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput itemInput = new com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput(); com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput itemInput = new com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput();
itemInput.boName = itemType; itemInput.boName = itemType;
System.out.println("Item Type =>>>>" + itemType); System.out.println("Item Type =>>>>" + itemType);
@ -2913,8 +3040,10 @@ public class NewCodeItemDialog extends Dialog {
itemStringMap.put("item_id", itemID); itemStringMap.put("item_id", itemID);
itemStringMap.put("object_desc", itemDesc); itemStringMap.put("object_desc", itemDesc);
if (iComp != null) { if (iComp != null) {
System.out.println("iComp != null");
setPropMapping(itemInput, iComp.getPropertyList(), itemStringMap); setPropMapping(itemInput, iComp.getPropertyList(), itemStringMap);
} else { } else {
System.out.println("iComp == null");
itemInput.stringProps = itemStringMap; itemInput.stringProps = itemStringMap;
} }
@ -2968,8 +3097,10 @@ public class NewCodeItemDialog extends Dialog {
DataManagementService datamanagementservice = DataManagementService.getService(session); DataManagementService datamanagementservice = DataManagementService.getService(session);
com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn createin = new com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn(); com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn createin = new com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn();
createin.clientId = "Test"; createin.clientId = "Test";
createin.data = itemInput; createin.data = itemInput;
System.out.println("11111111111111"); System.out.println("11111111111111");
com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse createresponse = datamanagementservice com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse createresponse = datamanagementservice
.createObjects( .createObjects(
@ -3049,6 +3180,7 @@ public class NewCodeItemDialog extends Dialog {
} }
} }
System.out.println(">>" + cnpropList.get(i).getPropertyType().toUpperCase() + "|cnpropList.get(i).value =>" System.out.println(">>" + cnpropList.get(i).getPropertyType().toUpperCase() + "|cnpropList.get(i).value =>"
+ cnpropList.get(i).value); + cnpropList.get(i).value);
if (cnpropList.get(i).getIsMust()) { if (cnpropList.get(i).getIsMust()) {
@ -3618,9 +3750,9 @@ public class NewCodeItemDialog extends Dialog {
//判断是否要读分类的用户1的数据 //判断是否要读分类的用户1的数据
if (!codeRemark.replace(" ", "").equals("")) { if (!codeRemark.replace(" ", "").equals("")) {
System.out.println("当前对象要发送的分类ID为==================" + codeRemark); System.out.println("当前对象要发送的分类ID为==================" + codeRemark);
String[] pres = session.getPreferenceService().getStringValues("Connor_Part_SAPGroupInfo"); // String[] pres = session.getPreferenceService().getStringValues("Connor_Part_SAPGroupInfo");
for (String pre : pres) { // for (String pre : pres) {
if(newComp.getType().equals(pre)) { // if(newComp.getType().equals(pre)) {
//读取要发送的分类库上用户数据1的属性值设置到创建出的物料对象版本上sap分组(ld6_sapGroupInfo)属性上 //读取要发送的分类库上用户数据1的属性值设置到创建出的物料对象版本上sap分组(ld6_sapGroupInfo)属性上
TCClassificationService classService = session.getClassificationService(); TCClassificationService classService = session.getClassificationService();
ICSAdminClass adminClass = classService.newICSAdminClass(); ICSAdminClass adminClass = classService.newICSAdminClass();
@ -3628,9 +3760,9 @@ public class NewCodeItemDialog extends Dialog {
String user1 = adminClass.getUser1(); String user1 = adminClass.getUser1();
TCComponentItemRevision rev = ((TCComponentItem) newComp).getLatestItemRevision(); TCComponentItemRevision rev = ((TCComponentItem) newComp).getLatestItemRevision();
rev.setStringProperty("ld6_sapGroupInfo", user1); rev.setStringProperty("ld6_sapGroupInfo", user1);
break; // break;
} // }
} // }
} }
new GetCodeNumber().delete_recycleID(counterID); new GetCodeNumber().delete_recycleID(counterID);
setClipboard(newID); setClipboard(newID);

Loading…
Cancel
Save