|
|
|
@ -91,6 +91,11 @@ public class MpartDialog extends JFrame implements ActionListener {
|
|
|
|
|
TCComponentBOMWindow view;
|
|
|
|
|
TCComponentItemType type;
|
|
|
|
|
private String[] groupSplit;
|
|
|
|
|
private HashMap<String, String> fieldsMap = new HashMap<String, String>();
|
|
|
|
|
|
|
|
|
|
static TCComponentGroup group;
|
|
|
|
|
static TCComponentUser user;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MpartDialog(TCSession session, ArrayList<TCComponentItemRevision> list) throws TCException {
|
|
|
|
|
// TODO Auto-generated constructor stub
|
|
|
|
@ -105,6 +110,10 @@ public class MpartDialog extends JFrame implements ActionListener {
|
|
|
|
|
private void initUI() {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String[] fields = session.getPreferenceService().getStringValues("LY6_EPartToMPartType");
|
|
|
|
|
|
|
|
|
|
gsdwComboBox.addItemListener(new ItemListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void itemStateChanged(ItemEvent e) {
|
|
|
|
@ -305,17 +314,30 @@ public class MpartDialog extends JFrame implements ActionListener {
|
|
|
|
|
try {
|
|
|
|
|
ArrayList<Object> arrayList = valueList.get(i);
|
|
|
|
|
TCComponentItemRevision rev = (TCComponentItemRevision)arrayList.get(9);
|
|
|
|
|
TCComponentItem eItem = rev.getItem();
|
|
|
|
|
String eType = eItem.getType();
|
|
|
|
|
System.out.println("etype============="+eType);
|
|
|
|
|
TCComponentBOMLine topLine = view.setWindowTopLine(rev.getItem(), rev, null, null);
|
|
|
|
|
int childrenCount = topLine.getChildrenCount();
|
|
|
|
|
System.out.println("childrenCount========"+childrenCount);
|
|
|
|
|
TCComponent[] searchLs = session.search("_SearchMFKProperties", new String[] { "ID","工厂" }, new String[] { (String) arrayList.get(2),(String) tm_part.getValueAt(i, 7) });
|
|
|
|
|
|
|
|
|
|
String ly6_sequenceNum = "";
|
|
|
|
|
String ly6_sequenceNum = "01";
|
|
|
|
|
//去调用查询查看该工厂最大流水
|
|
|
|
|
if(searchLs != null && searchLs.length > 0) {
|
|
|
|
|
TCComponentItem mItem = (TCComponentItem)searchLs[0];
|
|
|
|
|
ly6_sequenceNum = mItem.getStringProperty("ly6_sequenceNum");
|
|
|
|
|
// if(searchLs != null && searchLs.length > 0) {
|
|
|
|
|
// TCComponentItem mItem = (TCComponentItem)searchLs[0];
|
|
|
|
|
// ly6_sequenceNum = mItem.getStringProperty("ly6_sequenceNum");
|
|
|
|
|
// System.out.println("ly6_sequenceNum==="+ly6_sequenceNum);
|
|
|
|
|
// System.out.println("pxuid==========="+mItem.getUid());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
for (int j = 0; j < searchLs.length; j++) {
|
|
|
|
|
TCComponentItem mItem = (TCComponentItem)searchLs[j];
|
|
|
|
|
System.out.println(mItem.getUid()+"===========mItem.uid");
|
|
|
|
|
String num = mItem.getStringProperty("ly6_sequenceNum");
|
|
|
|
|
System.out.println("num==="+num);
|
|
|
|
|
System.out.println("ly6_sequenceNum==="+ly6_sequenceNum);
|
|
|
|
|
ly6_sequenceNum = getLargerNumber(num,ly6_sequenceNum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(childrenCount == 0) {
|
|
|
|
@ -325,12 +347,103 @@ public class MpartDialog extends JFrame implements ActionListener {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TCComponentItem item = type.create(newID, newRev, "LY6_ProductM", "", "", null);
|
|
|
|
|
TCComponentItemRevision mRev = item.getLatestItemRevision();
|
|
|
|
|
item.setProperty("ly6_company", tm_part.getValueAt(i, 7).toString());
|
|
|
|
|
System.out.println("itemUid2============"+item.getUid());
|
|
|
|
|
if(ly6_sequenceNum.isEmpty()) {
|
|
|
|
|
item.setProperty("ly6_sequenceNum", "01");
|
|
|
|
|
}else {
|
|
|
|
|
item.setProperty("ly6_sequenceNum", incrementNumber(ly6_sequenceNum));
|
|
|
|
|
System.out.println("itemUid3============"+item.getUid());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//删除前两个对象
|
|
|
|
|
TCComponent delItem1 = session.stringToComponent((String) arrayList.get(2));
|
|
|
|
|
|
|
|
|
|
if(delItem1 != null) {
|
|
|
|
|
System.out.println("delItem1.getUid()===="+delItem1.getUid());
|
|
|
|
|
delItem1.delete();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TCComponent delItem2 = session.stringToComponent((String) arrayList.get(2)+(String) tm_part.getValueAt(i, 7));
|
|
|
|
|
|
|
|
|
|
if(delItem1 != null) {
|
|
|
|
|
System.out.println("delItem2.getUid()===="+delItem2.getUid());
|
|
|
|
|
delItem2.delete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//给属性赋值
|
|
|
|
|
String fiedsStr = fieldsMap.get(eType+":LY6_ProductM");
|
|
|
|
|
if(fiedsStr != null && !fiedsStr.isEmpty()) {
|
|
|
|
|
if(fiedsStr.contains(",")) {
|
|
|
|
|
String[] split = fiedsStr.split(",");
|
|
|
|
|
for (int j = 0; j < split.length; j++) {
|
|
|
|
|
//:分割
|
|
|
|
|
String[] split2 = split[j].split(":");
|
|
|
|
|
if(split2.length == 2) {
|
|
|
|
|
//.分割
|
|
|
|
|
String[] split3 = split2[0].split("\\.");
|
|
|
|
|
if(split3.length == 2) {
|
|
|
|
|
if(split3[0].equals("item")) {
|
|
|
|
|
String[] split4 = split2[1].split("\\.");
|
|
|
|
|
if(split4.length == 2) {
|
|
|
|
|
if(split4[0].equals("item")) {
|
|
|
|
|
item.setProperty(split4[1], eItem.getProperty(split2[1]));
|
|
|
|
|
}else if(split4[0].equals("rev")) {
|
|
|
|
|
mRev.setProperty(split4[1], eItem.getProperty(split2[1]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else if(split2[0].equals("rev")) {
|
|
|
|
|
String[] split4 = split2[1].split("\\.");
|
|
|
|
|
if(split4.length == 2) {
|
|
|
|
|
if(split4[0].equals("item")) {
|
|
|
|
|
item.setProperty(split4[1], rev.getProperty(split2[1]));
|
|
|
|
|
}else if(split4[0].equals("rev")) {
|
|
|
|
|
mRev.setProperty(split4[1], rev.getProperty(split2[1]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//:分割
|
|
|
|
|
String[] split2 = fiedsStr.split(":");
|
|
|
|
|
if(split2.length == 2) {
|
|
|
|
|
//.分割
|
|
|
|
|
String[] split3 = split2[0].split("\\.");
|
|
|
|
|
if(split3.length == 2) {
|
|
|
|
|
if(split3[0].equals("item")) {
|
|
|
|
|
String[] split4 = split2[1].split("\\.");
|
|
|
|
|
if(split4.length == 2) {
|
|
|
|
|
if(split4[0].equals("item")) {
|
|
|
|
|
item.setProperty(split4[1], eItem.getProperty(split2[1]));
|
|
|
|
|
}else if(split4[0].equals("rev")) {
|
|
|
|
|
mRev.setProperty(split4[1], eItem.getProperty(split2[1]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else if(split2[0].equals("rev")) {
|
|
|
|
|
String[] split4 = split2[1].split("\\.");
|
|
|
|
|
if(split4.length == 2) {
|
|
|
|
|
if(split4[0].equals("item")) {
|
|
|
|
|
item.setProperty(split4[1], rev.getProperty(split2[1]));
|
|
|
|
|
}else if(split4[0].equals("rev")) {
|
|
|
|
|
mRev.setProperty(split4[1], rev.getProperty(split2[1]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//添加流程
|
|
|
|
|
if(workflowTemplate != null || !workflowTemplate.isEmpty()) {
|
|
|
|
@ -355,6 +468,20 @@ public class MpartDialog extends JFrame implements ActionListener {
|
|
|
|
|
}else {
|
|
|
|
|
item.setProperty("ly6_sequenceNum", incrementNumber(ly6_sequenceNum));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//删除前两个对象
|
|
|
|
|
TCComponent delItem1 = session.stringToComponent((String) arrayList.get(2));
|
|
|
|
|
if(delItem1 != null) {
|
|
|
|
|
System.out.println("delItem1.getUid()===="+delItem1.getUid());
|
|
|
|
|
delItem1.delete();
|
|
|
|
|
}
|
|
|
|
|
TCComponent delItem2 = session.stringToComponent((String) arrayList.get(2)+(String) tm_part.getValueAt(i, 7));
|
|
|
|
|
if(delItem1 != null) {
|
|
|
|
|
System.out.println("delItem2.getUid()===="+delItem2.getUid());
|
|
|
|
|
delItem2.delete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//把对象放到管理文件夹下
|
|
|
|
|
rev.add("LY6_relatedMPart",item);
|
|
|
|
|
item.getLatestItemRevision().refresh();
|
|
|
|
@ -491,8 +618,12 @@ public class MpartDialog extends JFrame implements ActionListener {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else if(this.xrButton.equals(source)) {
|
|
|
|
|
TCComponentUser user = new KOrgDialog("").getUser();
|
|
|
|
|
System.out.println("Select User: " + user);
|
|
|
|
|
KOrgDialog kOrgDialog = new KOrgDialog("");
|
|
|
|
|
// TCComponentUser user = kOrgDialog.getUser();
|
|
|
|
|
// TCComponentGroup group = kOrgDialog.getGroup();
|
|
|
|
|
user = kOrgDialog.getUser();
|
|
|
|
|
group = kOrgDialog.getGroup();
|
|
|
|
|
System.out.println("Select User: " + user+"group==="+group);
|
|
|
|
|
String userName = "";
|
|
|
|
|
try {
|
|
|
|
|
userName = user.getUserName();
|
|
|
|
@ -943,7 +1074,7 @@ public class MpartDialog extends JFrame implements ActionListener {
|
|
|
|
|
TCComponentGroup group = session.getCurrentGroup();
|
|
|
|
|
String name = group.getTCProperty("full_name").getStringValue();
|
|
|
|
|
if(name.contains(".")) {
|
|
|
|
|
String[] split = name.split(".");
|
|
|
|
|
String[] split = name.split("\\.");
|
|
|
|
|
name = split[split.length];
|
|
|
|
|
System.out.println("name=============="+name);
|
|
|
|
|
}
|
|
|
|
@ -982,11 +1113,30 @@ public class MpartDialog extends JFrame implements ActionListener {
|
|
|
|
|
TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, 0);
|
|
|
|
|
if (taskTemplate != null) {
|
|
|
|
|
String name = target.getProperty("object_string");
|
|
|
|
|
processType.create(processName + "£º" + name, "", taskTemplate, new TCComponent[]{target}, new int[]{1});
|
|
|
|
|
TCComponent create = processType.create(processName + ":" + name, "", taskTemplate, new TCComponent[]{target}, new int[]{1});
|
|
|
|
|
System.out.println("uid==================="+create.getUid());
|
|
|
|
|
System.out.println("type=="+create.getType());
|
|
|
|
|
System.out.println("type=="+create.getStringProperty("object_type"));
|
|
|
|
|
}
|
|
|
|
|
} catch (TCException var7) {
|
|
|
|
|
var7.printStackTrace();
|
|
|
|
|
throw var7;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getLargerNumber(String num1, String num2) {
|
|
|
|
|
if(num1 == null || num1.isEmpty()) {
|
|
|
|
|
return num2;
|
|
|
|
|
}
|
|
|
|
|
// 将字符串转换为整数
|
|
|
|
|
int n1 = Integer.parseInt(num1);
|
|
|
|
|
int n2 = Integer.parseInt(num2);
|
|
|
|
|
|
|
|
|
|
// 比较两个整数,返回较大的一个的字符串形式
|
|
|
|
|
if (n1 > n2) {
|
|
|
|
|
return num1;
|
|
|
|
|
} else {
|
|
|
|
|
return num2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|