20250421备份:流程属性变更+旧版D转EBOM功能

main
熊朝柱 2 months ago
parent a48ce2f229
commit b4143b5322

@ -12,7 +12,7 @@
<command name="DBOM转EBOM" categoryId="com.connor.ml.tcm.outfile.commands.category" id="DBOMtoEBOM"> </command> <command name="DBOM转EBOM" categoryId="com.connor.ml.tcm.outfile.commands.category" id="DBOMtoEBOM"> </command>
<command name="依据设计创建物料" id="DesignToPartHandler"/> <command name="依据设计创建物料" id="DesignToPartHandler"/>
<command name="标准化审核" id="StandardHandler"/> <command name="标准化审核" id="StandardHandler"/>
<command name="编辑节点属性" id="ProcessAttriChangeHandler"/> <!-- <command name="编辑节点属性" id="ProcessAttriChangeHandler"/>-->
<command name="用户登录设置" id="LoginIPSetHandler"/> <command name="用户登录设置" id="LoginIPSetHandler"/>
</extension> </extension>
<extension point="org.eclipse.ui.handlers"> <extension point="org.eclipse.ui.handlers">
@ -22,7 +22,7 @@
<handler commandId="CodeApplyHandler" class="com.connor.jingdiao.handlers.CodeApplyHandler"/> <handler commandId="CodeApplyHandler" class="com.connor.jingdiao.handlers.CodeApplyHandler"/>
<handler commandId="DesignToPartHandler" class="com.connor.jingdiao.handlers.DesignToPartHandler"/> <handler commandId="DesignToPartHandler" class="com.connor.jingdiao.handlers.DesignToPartHandler"/>
<handler commandId="StandardHandler" class="com.connor.jingdiao.handlers.StandardHandler"/> <handler commandId="StandardHandler" class="com.connor.jingdiao.handlers.StandardHandler"/>
<handler commandId="ProcessAttriChangeHandler" class="com.connor.processAttributeModification.ProcessAttriChangeHandler"/> <!-- <handler commandId="ProcessAttriChangeHandler" class="com.connor.processAttributeModification.ProcessAttriChangeHandler"/>-->
<handler commandId="LoginIPSetHandler" class="com.connor.jingdiao.handlers.LoginIPSetHandler"/> <handler commandId="LoginIPSetHandler" class="com.connor.jingdiao.handlers.LoginIPSetHandler"/>
<handler class="com.connor.jd.erp.erpIntegrationHandler" commandId="erpIntegrationHandler"/> <handler class="com.connor.jd.erp.erpIntegrationHandler" commandId="erpIntegrationHandler"/>
<handler class="com.connor.jd.derive.deriveCenterHandler" commandId="deriveCenterHandler"/> <handler class="com.connor.jd.derive.deriveCenterHandler" commandId="deriveCenterHandler"/>
@ -39,7 +39,7 @@
<command commandId="DBOMtoEBOM" style="push"/> <command commandId="DBOMtoEBOM" style="push"/>
<command commandId="CodeApplyHandler" style="push"> </command> <command commandId="CodeApplyHandler" style="push"> </command>
<command commandId="StandardHandler" style="push"> </command> <command commandId="StandardHandler" style="push"> </command>
<command commandId="ProcessAttriChangeHandler" style="push"> </command> <!-- <command commandId="ProcessAttriChangeHandler" style="push"> </command>-->
<command commandId="erpIntegrationHandler" style="push"> </command> <command commandId="erpIntegrationHandler" style="push"> </command>
<command commandId="deriveCenterHandler" style="push"> </command> <command commandId="deriveCenterHandler" style="push"> </command>
<command commandId="deriveMBOMHandler" style="push"> </command> <command commandId="deriveMBOMHandler" style="push"> </command>

@ -4,10 +4,8 @@ import java.awt.BorderLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Font; import java.awt.Font;
import java.awt.Robot;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.util.ArrayList; import java.util.ArrayList;
@ -15,6 +13,8 @@ import java.util.Arrays;
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 java.util.Set;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JFrame; import javax.swing.JFrame;
@ -229,52 +229,33 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
try { try {
DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent(); DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
String status = nodeBean.getRefreshStatus();
if(!status.equals("属性发布") && !status.equals("流程中") && !status.isEmpty()
&& getChildRefresh(parentNode, false)) {
MessageBox.post("下层已勾选,上层不允许勾选已发布或没权限对象!", "错误", MessageBox.ERROR);
return;
}else if(!acs.checkAccessorsPrivilege(user, nodeBean.getTcComponent(), "WRITE")
&& getChildRefresh(parentNode, false)) {
MessageBox.post("下层已勾选,上层不允许勾选已发布或没权限对象!", "错误", MessageBox.ERROR);
return;
}
if(getTopRefresh(node)) {
MessageBox.post("上层已勾选发布或无权限的对象,下层不允许勾选!", "错误", MessageBox.ERROR);
return;
}
// if(getTopProcessRefresh(node)) {
// MessageBox.post("上层已勾选流程中的对象,下层不允许勾选!", "错误", MessageBox.ERROR);
// return;
// }
if(parentNode != null) {
// DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
// NodeBean rootNodeBean = (NodeBean) rootNode.getUserObject();
// if(!rootNodeBean.getDbom().equals("顶层") && !getTop(node) && nodeBean.getLabel().equals("0") ) {
// MessageBox.post("上层未勾选对象,下层不允许勾选!", "错误", MessageBox.ERROR);
// return;
// }
}
// TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item");
//TODO 勾选事件 //TODO 勾选事件
if(nodeBean.getLabel().equals("0")) { if(nodeBean.getLabel().equals("0")) {
String status = nodeBean.getRefreshStatus();
boolean access = !acs.checkAccessorsPrivilege(user, nodeBean.getTcComponent(), "WRITE")
|| !status.equals("属性发布") && !status.equals("流程中") && !status.isEmpty();
if(access && getChildRefresh(parentNode, false)) {
MessageBox.post("下层已勾选,上层不允许勾选已发布或没权限对象!", "错误", MessageBox.ERROR);
return;
}
if(getTopRefresh(node)) {
MessageBox.post("上层已勾选发布或无权限的对象,下层不允许勾选!", "错误", MessageBox.ERROR);
return;
}
//判断同一层是否已勾选 //判断同一层是否已勾选
if(parentNode != null) { if(parentNode != null) {
for (int i = 0; i < parentNode.getChildCount(); i++) { for (int i = 0; i < parentNode.getChildCount(); i++) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) parentNode.getChildAt(i); DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) parentNode.getChildAt(i);
// for (DefaultMutableTreeTableNode childNode : backMap.get(parentNode)) {
NodeBean childBean = (NodeBean) childNode.getUserObject(); NodeBean childBean = (NodeBean) childNode.getUserObject();
if(childBean.getLabel().equals("1") && !childBean.getEbom().isEmpty() && !nodeBean.getEbom().isEmpty()) { if(childBean.getLabel().equals("1") && !childBean.getEbom().isEmpty() && !nodeBean.getEbom().isEmpty()) {
MessageBox.post("同一层级只允许选中一个!", "错误", MessageBox.ERROR); MessageBox.post(this, "同一层级只允许选中一个!", "错误", MessageBox.ERROR);
return; return;
} }
} }
} }
nodeBean.setLabel("1"); nodeBean.setLabel("1");
if(parentNode != null) if(!access && parentNode != null)
autoCheck(parentNode, "1"); autoCheck(parentNode, "1");
//isHaveBom(node, nodeBean.getEbomId(), "1", itemType); //isHaveBom(node, nodeBean.getEbomId(), "1", itemType);
}else if(nodeBean.getLabel().equals("1")) { }else if(nodeBean.getLabel().equals("1")) {
@ -283,9 +264,10 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
autoCheck(parentNode, "0"); autoCheck(parentNode, "0");
//isHaveBom(node, nodeBean.getEbomId(), "0", itemType); //isHaveBom(node, nodeBean.getEbomId(), "0", itemType);
} }
Robot robot = new Robot(); this.repaint();
robot.keyPress(KeyEvent.VK_TAB); // Robot robot = new Robot();
robot.keyRelease(KeyEvent.VK_TAB); // robot.keyPress(KeyEvent.VK_TAB);
// robot.keyRelease(KeyEvent.VK_TAB);
} catch (Exception e2) { } catch (Exception e2) {
// : handle exception // : handle exception
e2.printStackTrace(); e2.printStackTrace();
@ -445,22 +427,23 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
boolean change = true; boolean change = true;
NodeBean eBean = null; NodeBean eBean = null;
for (int j = 0; j < node.getChildCount(); j++) { for (int j = 0; j < node.getChildCount(); j++) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) parentNode.getChildAt(i); DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) node.getChildAt(j);
NodeBean childBean = (NodeBean) childNode.getUserObject(); NodeBean childBean = (NodeBean) childNode.getUserObject();
if(!childBean.getEbom().isEmpty()) { if(!childBean.getEbom().isEmpty()) {
if(eBean == null) { if(val.equals("0")) {
childBean.setLabel(val);
}else if(eBean == null) {
eBean = childBean; eBean = childBean;
}else { }else {
change = false; change = false;
} }
}else if(!childBean.getDbom().isEmpty()) {
autoCheck(childNode, val);
} }
} }
System.out.println("autoCheck" + bean.getDbom() + "==" + change + "==" + eBean + ">>" + val); System.out.println("autoCheck" + bean.getDbom() + "==" + change + "==" + eBean + ">>" + val);
if(eBean != null && (change || val.equals("0"))) { if(val.equals("1") && eBean != null && change) {
eBean.setLabel(val); eBean.setLabel(val);
} }
autoCheck(node, val);
} }
} }
} }
@ -724,18 +707,20 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
if(num == null || num.isEmpty() || num.equals("0")) { if(num == null || num.isEmpty() || num.equals("0")) {
num = "1"; num = "1";
} }
TCComponentItemRevision latestItemRevision = item.getLatestItemRevision(); // TCComponentItemRevision latestItemRevision = item.getLatestItemRevision();
TCComponentItemRevision pRev = childNodeBean.getpRev(); TCComponentItemRevision pRev = childNodeBean.getpRev();
System.out.println("pRev" + pRev); System.out.println("pRev" + pRev);
if(dbom.isPacked() && bomValMap.containsKey(pRev)) { if(dbom.isPacked() && bomValMap.containsKey(pRev)) {
List<BomValBean> list = bomValMap.get(pRev); List<BomValBean> list = bomValMap.get(pRev);
childMap.put(latestItemRevision, list); childMap.put(nodeComp, list);
}else if(childMap.containsKey(nodeComp)) {//TODO lidy20250221
childMap.get(nodeComp).add(pValBean);
}else { }else {
//TODO lidy20241211 // lidy20241211
List<BomValBean> list = new ArrayList<>(); List<BomValBean> list = new ArrayList<>();
list.add(pValBean); list.add(pValBean);
childMap.put(latestItemRevision, list); childMap.put(nodeComp, list);
} }
TCComponent tcComponent = childNodeBean.getTcComponent(); TCComponent tcComponent = childNodeBean.getTcComponent();
@ -808,7 +793,7 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
TCComponentBOMLine topline = bomWindow.setWindowTopLine(topLineItem, TCComponentBOMLine topline = bomWindow.setWindowTopLine(topLineItem,
topLineItem.getLatestItemRevision(), null, null); topLineItem.getLatestItemRevision(), null, null);
bomWindow.lock(); bomWindow.lock();
recreateBom2(topLineItem, map2, topline); recreateBom2(topLineItem, map2, topline, bomWindow);
}catch(Exception e) { }catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -821,6 +806,7 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
} }
/** /**
* BOM * BOM
* @param bomWindow
* *
* @param item * @param item
* @param itemlists * @param itemlists
@ -828,7 +814,7 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void recreateBom2(TCComponentItem topItem, private void recreateBom2(TCComponentItem topItem,
Map<TCComponentItemRevision, List<BomValBean>> map2,TCComponentBOMLine topline) Map<TCComponentItemRevision, List<BomValBean>> map2, TCComponentBOMLine topline, TCComponentBOMWindow bomWindow)
throws Exception { throws Exception {
// TCComponentBOMWindow bomWindow = null; // TCComponentBOMWindow bomWindow = null;
try { try {
@ -836,6 +822,7 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
topline.lock(); topline.lock();
System.out.println("items==>" + items.toString()); System.out.println("items==>" + items.toString());
List<TCComponentBOMLine> bomLines = new ArrayList<TCComponentBOMLine>(); List<TCComponentBOMLine> bomLines = new ArrayList<TCComponentBOMLine>();
Set<TCComponentItemRevision> set = map2.keySet();
if (topline.hasChildren()) { if (topline.hasChildren()) {
System.out.println(topItem); System.out.println(topItem);
@ -861,12 +848,19 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
bomLines.add(bLine); bomLines.add(bLine);
} }
} }
}else if(set.size() > 0) {//lidy20250225 不包含BOM视图版本无法设置精确
TCComponentItemRevision rev = (TCComponentItemRevision) set.toArray()[0];
TCComponentItem item = rev.getItem();
TCComponentBOMLine line = topline.add(item, rev, null, false, "");
bomWindow.save();
line.cut();
bomWindow.save();
} }
String maxSeq = ""; String maxSeq = "";
System.out.println("topline===>" + topline); System.out.println("topline===>" + topline);
topline.setPrecision(true); topline.setPrecision(true);
for(TCComponentItemRevision rev : map2.keySet()) { for(TCComponentItemRevision rev : set) {
List<BomValBean> list = map2.get(rev); List<BomValBean> list = map2.get(rev);
System.out.println("list===>" + list.toString()); System.out.println("list===>" + list.toString());
for(BomValBean bean : list) { for(BomValBean bean : list) {
@ -888,7 +882,7 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
add.unlock(); add.unlock();
if(bomStructMap.containsKey(item)) { if(bomStructMap.containsKey(item)) {
Map<TCComponentItemRevision, List<BomValBean>> map3 = bomStructMap.get(item); Map<TCComponentItemRevision, List<BomValBean>> map3 = bomStructMap.get(item);
recreateBom2(item, map3, add); recreateBom2(item, map3, add, bomWindow);
} }
} }

@ -66,6 +66,7 @@ import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout; import com.teamcenter.rac.util.PropertyLayout;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
public class ProcessAttriChangeDialog extends JDialog { public class ProcessAttriChangeDialog extends JDialog {
@ -81,6 +82,10 @@ public class ProcessAttriChangeDialog extends JDialog {
private JButton closeBtn; private JButton closeBtn;
private JTable impTable; private JTable impTable;
private DefaultTableModel impModel; private DefaultTableModel impModel;
/**
*
*/
private JPanel propertyPanel;
private ArrayList<TCComponentItemRevision> revlist; private ArrayList<TCComponentItemRevision> revlist;
/** /**
* [rev,object_name] * [rev,object_name]
@ -120,22 +125,35 @@ public class ProcessAttriChangeDialog extends JDialog {
* @param task * @param task
* @param ruleOpsMap key()valueString[]String["item/rev","object_name"] * @param ruleOpsMap key()valueString[]String["item/rev","object_name"]
* @param cols * @param cols
* @param chooseRows2
* @throws Exception * @throws Exception
*/ */
public ProcessAttriChangeDialog(TCSession session, TCComponent[] models, TCComponentTask task, LinkedHashMap<String, String[]> ruleOpsMap, int[] cols) public ProcessAttriChangeDialog(
TCSession session,
TCComponent[] models,
TCComponentTask task,
LinkedHashMap<String, String[]> ruleOpsMap,
int[] cols, List<Integer> chooseRowsA,
List<TCComponentItemRevision> targetRevisionA)
throws Exception { throws Exception {
super(AIFUtility.getActiveDesktop()); super(AIFUtility.getActiveDesktop());
this.session = session; this.session = session;
this.modelsF = models; this.modelsF = models;
this.taskF = task; this.taskF = task;
this.ruleOpsMapF = ruleOpsMap; this.ruleOpsMapF = ruleOpsMap;
System.out.println("开始遍历存放首选项Jd_Standard_UI_Process_Attribute的信息的构造函数入参ruleOpsMap"); this.chooseRows = chooseRowsA;
for (String key : ruleOpsMap.keySet()){ this.targetRevision = targetRevisionA;
System.out.println(key+":"+Arrays.toString(ruleOpsMap.get(key))); if (chooseRowsA != null && chooseRowsA.size()>0) {
System.out.println("构造函数ProcessAttriChangeDialog的入参chooseRowsA:"+chooseRowsA.toString());
}else {
if (this.chooseRows != null) {
System.out.println("this.chooseRows:["+this.chooseRows.size()+"]");
}
System.out.println("构造函数ProcessAttriChangeDialog的入参chooseRowsA为空");
} }
this.colsF = cols; this.colsF = cols;
this.argMap = getHandlerArgs(task); this.argMap = getHandlerArgs(task);
initUi( modelsF, taskF, ruleOpsMapF, colsF,null); initUi( modelsF, taskF, ruleOpsMapF, colsF,chooseRowsA);
} }
/** /**
@ -148,7 +166,10 @@ public class ProcessAttriChangeDialog extends JDialog {
* @param chooseRows * @param chooseRows
* @throws Exception * @throws Exception
*/ */
private void initUi(TCComponent[] models, TCComponentTask task, LinkedHashMap<String, String[]> ruleOpsMapI, int[] cols, List<Integer> chooseRows2) throws Exception { private void initUi(TCComponent[] models,
TCComponentTask task,
LinkedHashMap<String, String[]> ruleOpsMapI,
int[] cols, List<Integer> chooseRows2) throws Exception {
// this.chooseRows.addAll(chooseRows2); // this.chooseRows.addAll(chooseRows2);
if (chooseRows2 != null && chooseRows2.size()>0) { if (chooseRows2 != null && chooseRows2.size()>0) {
System.out.println("当前选中行="+Arrays.toString(chooseRows2.toArray())); System.out.println("当前选中行="+Arrays.toString(chooseRows2.toArray()));
@ -159,95 +180,7 @@ public class ProcessAttriChangeDialog extends JDialog {
System.out.println("开始初始化/刷新面板···"); System.out.println("开始初始化/刷新面板···");
setTitle("编辑节点属性"); setTitle("编辑节点属性");
remarkBtn = new JButton("修改属性"); remarkBtn = new JButton("修改属性");
remarkBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {//修改属性按钮
System.out.println("触发修改属性事件~");
try {
// chooseRow = impTable.getSelectedRow();
System.out.println("当前选中行:" + impTable.getSelectedRow());
for (int i = 0; i < chooseRows.size(); i++) {
System.out.println("修改属性-选中行:" + chooseRows.get(i));
}
if(chooseRows.size() <= 0) {
MessageBox.post(ProcessAttriChangeDialog.this, "请选择要编辑的行!", "ERROR", MessageBox.ERROR);
return;
}
for (String key : textAreaMap.keySet()){
// String text = textAreaMap.get(key).getText();//获取输入框中的值
//
Object component = textAreaMap.get(key);
String text = getValueByAreaType(component);
if (text == null){
System.out.println("info获取输入框组件值异常");
}
String showAttr = argMap.get(key);//获取流程参数的value
if(text.getBytes().length > 1024) {
MessageBox.post(ProcessAttriChangeDialog.this, showAttr+"属性填写长度过长,无法修改!", "ERROR", MessageBox.ERROR);
return;
}else {
//获取列数
for (int t = 0; t < tableHeaderList.size(); t++){
if (tableHeaderList.get(t).equals(showAttr)){
for (int i = 0; i < chooseRows.size(); i++) {
impTable.setValueAt(text, chooseRows.get(i), t);
}
break;
}
}
}
}
for (int i = 0; i < chooseRows.size(); i++) {
TCComponentItemRevision rev = revlist.get(chooseRows.get(i));
TCComponentItem item = rev.getItem();
if(mark[0].equals("item") && item.isCheckedOut()) {
MessageBox.post(ProcessAttriChangeDialog.this, item+" 已签出,无法修改!", "ERROR", MessageBox.ERROR);
return;
}else if(mark[0].equals("rev") && rev.isCheckedOut()) {
MessageBox.post(ProcessAttriChangeDialog.this, rev+" 已签出,无法修改!", "E RROR", MessageBox.ERROR);
return;
}
MethodUtil.openByPass(session);
if(mark[0].equals("item")) {
for (String key : textAreaMap.keySet()){
// String value = textAreaMap.get(key).getText();
Object component = textAreaMap.get(key);
String inputValue = getValueByAreaType(component);
if (inputValue == null){
System.out.println("info获取输入框组件值异常");
}
item.setProperty(key, inputValue);
}
}else if(mark[0].equals("rev")) {
for (String key : textAreaMap.keySet()){
// String value = textAreaMap.get(key).getText();
Object component = textAreaMap.get(key);
String inputValue = getValueByAreaType(component);
if (inputValue == null){
System.out.println("info获取输入框组件值异常");
}
rev.setProperty(key, inputValue);
}
}
}
MethodUtil.closeByPass(session);
}catch(Exception e1) {
e1.printStackTrace();
MessageBox.post(ProcessAttriChangeDialog.this, "错误:"+e1.getMessage(), "ERROR", MessageBox.ERROR);
}finally {
try {
MethodUtil.closeByPass(session);
}catch(Exception e1) {
e1.printStackTrace();
}
}
}
});
exportBtn = new JButton("导出Excel"); exportBtn = new JButton("导出Excel");
closeBtn = new JButton("关闭"); closeBtn = new JButton("关闭");
JPanel btnPanel = new JPanel(new FlowLayout()); JPanel btnPanel = new JPanel(new FlowLayout());
@ -255,7 +188,6 @@ public class ProcessAttriChangeDialog extends JDialog {
btnPanel.add(exportBtn); btnPanel.add(exportBtn);
btnPanel.add(closeBtn); btnPanel.add(closeBtn);
// JPanel topPanel = new JPanel(new BorderLayout());
if (topPanel == null) { if (topPanel == null) {
topPanel = new JPanel(new BorderLayout()); topPanel = new JPanel(new BorderLayout());
@ -269,86 +201,87 @@ public class ProcessAttriChangeDialog extends JDialog {
return; return;
} }
// 创建属性面板 // 创建属性面板
JPanel propertyPanel = new JPanel(new PropertyLayout()); propertyPanel = new JPanel(new PropertyLayout());
int k = 0; // int k = 0;
for (String key : this.argMap.keySet()) {//将流程配置的属性逐个渲染到看板上 // for (String key : this.argMap.keySet()) {//将流程配置的属性逐个渲染到看板上
k++; // k++;
String value = this.argMap.get(key);//属性显示名称 // String value = this.argMap.get(key);//属性显示名称
System.out.println("流程配置信息Key: " + key + ", Value: " + value); // System.out.println("流程配置信息Key: " + key + ", Value: " + value);
String labLocation = String.valueOf(k)+".1.left.top"; // String labLocation = String.valueOf(k)+".1.left.top";
String fieldLocation = String.valueOf(k)+".2.left.top"; // String fieldLocation = String.valueOf(k)+".2.left.top";
propertyPanel.add(labLocation,new JLabel(value)); // propertyPanel.add(labLocation,new JLabel(value));
//
//TODO 逻辑重构:根据不同属性类型,渲染不同的输入框 // //TODO 逻辑重构:根据不同属性类型,渲染不同的输入框
String[] attrs = ruleOpsMapI.get(value); // String[] attrs = ruleOpsMapI.get(value);
if (attrs == null || attrs.length == 0){ // if (attrs == null || attrs.length == 0){
System.out.println("info根据属性显示字段【"+value+"】获取属性信息失败,请检查相关首选项配置!"); // System.out.println("info根据属性显示字段【"+value+"】获取属性信息失败,请检查相关首选项配置!");
} // }
String currentAttributeValue = null;//当前属性的值,用于渲染到看板输入框中 // String currentAttributeValue = null;//当前属性的值,用于渲染到看板输入框中
System.out.println("===================================================================="); // System.out.println("====================================================================");
if (this.targetRevision != null && this.targetRevision.size() > 0){ // if (this.targetRevision != null && this.targetRevision.size() > 0){
System.out.println("info已选中对象开始根据选中对象的属性类型渲染组件···"); // System.out.println("info已选中对象开始根据选中对象的属性类型渲染组件···");
//
//当选中多个对象时,默认将当前选中的第一个对象属性作为默认值渲染到属性编辑看板上 // //当选中多个对象时,默认将当前选中的第一个对象属性作为默认值渲染到属性编辑看板上
TCComponentItem targetItem = this.targetRevision.get(0).getItem(); // TCComponentItem targetItem = this.targetRevision.get(0).getItem();
//根据属性名称获取属性所属对象类型item/rev // //根据属性名称获取属性所属对象类型item/rev
String itemType = attrs[0];//item/rev // String itemType = attrs[0];//item/rev
String propertyName = attrs[1];//属性真实名称 // String propertyName = attrs[1];//属性真实名称
if (itemType.equals("item")){ // if (itemType.equals("item")){
currentAttributeValue = targetItem.getProperty(propertyName);//获取当前属性的值 // currentAttributeValue = targetItem.getProperty(propertyName);//获取当前属性的值
//
}else { // }else {
currentAttributeValue = targetRevision.get(0).getProperty(propertyName);//获取当前属性的值 // currentAttributeValue = targetRevision.get(0).getProperty(propertyName);//获取当前属性的值
//
} // }
// // //
if (isLovType(propertyName)){ // if (isLovType(propertyName)){
System.out.println("属性【"+propertyName+"】类型为LOV"); // System.out.println("属性【"+propertyName+"】类型为LOV");
//
Map<String, String> lovList = getUnitValue_display(session,propertyName); // Map<String, String> lovList = getUnitValue_display(session,propertyName);
// 创建下拉列表组件 // // 创建下拉列表组件
JComboBox<String> comboBox = new JComboBox<>(); // JComboBox<String> comboBox = new JComboBox<>();
//
// 将lovList中的value值添加到下拉列表 // // 将lovList中的value值添加到下拉列表
for (String lovValue : lovList.values()) { // for (String lovValue : lovList.values()) {
comboBox.addItem(lovValue); // comboBox.addItem(lovValue);
} // }
// 设置默认显示值假设defaultValue是您希望默认显示的选项 // // 设置默认显示值假设defaultValue是您希望默认显示的选项
comboBox.setSelectedItem(currentAttributeValue); // comboBox.setSelectedItem(currentAttributeValue);
propertyPanel.add(fieldLocation, comboBox); // propertyPanel.add(fieldLocation, comboBox);
this.textAreaMap.put(propertyName, comboBox); // // this.textAreaMap.put(propertyName, comboBox); //
}else {// // }else {//
System.out.println("属性【"+ propertyName+"】类型非LOV "); // System.out.println("属性【"+ propertyName+"】类型非LOV ");
//
JTextArea textArea = new JTextArea(); // 创建JTextArea // JTextArea textArea = new JTextArea(); // 创建JTextArea
textArea.setColumns(20); // 设置输入框宽度 // textArea.setColumns(20); // 设置输入框宽度
textArea.setLineWrap(true); // 启用自动换行 // textArea.setLineWrap(true); // 启用自动换行
textArea.setWrapStyleWord(true); // 按单词换行 // textArea.setWrapStyleWord(true); // 按单词换行
JScrollPane scrollPane = new JScrollPane(textArea); // JScrollPane scrollPane = new JScrollPane(textArea);
System.out.println("KUMA属性=" + value); // System.out.println("KUMA属性=" + value);
if (value != null && (value.trim().contains("备注") || "备注".equals(value.trim()))){//备注特殊处理:加高度 // if (value != null && (value.trim().contains("备注") || "备注".equals(value.trim()))){//备注特殊处理:加高度
System.out.println("KUMA:特殊字段特殊处理!"); // System.out.println("KUMA:特殊字段特殊处理!");
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); // scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
textArea.setRows(3); // textArea.setRows(3);
scrollPane.setPreferredSize(scrollPane.getPreferredSize()); // 设置 JScrollPane 的首选尺寸 // scrollPane.setPreferredSize(scrollPane.getPreferredSize()); // 设置 JScrollPane 的首选尺寸
} // }
//赋值到textArea输入框中 // //赋值到textArea输入框中
textArea.setText(currentAttributeValue); // textArea.setText(currentAttributeValue);
propertyPanel.add(fieldLocation, scrollPane); // propertyPanel.add(fieldLocation, scrollPane);
this.textAreaMap.put(key, textArea); // 将JTextArea保存到Map中 // this.textAreaMap.put(key, textArea); // 将JTextArea保存到Map中
} // }
//
// }else {
// System.out.println("info未选中任何行无法获取选中对象渲染默认组件···");
// //渲染默认组件
// JTextArea textArea = new JTextArea(); // 创建JTextArea
// textArea.setColumns(20); // 设置输入框宽度
// textArea.setLineWrap(true); // 启用自动换行
// textArea.setWrapStyleWord(true); // 按单词换行
// propertyPanel.add(fieldLocation, new JScrollPane(textArea));
// this.textAreaMap.put(key, textArea); // 将JTextArea保存到Map中
// }
// }
}else {
System.out.println("info未选中任何行无法获取选中对象渲染默认组件···");
//渲染默认组件
JTextArea textArea = new JTextArea(); // 创建JTextArea
textArea.setColumns(20); // 设置输入框宽度
textArea.setLineWrap(true); // 启用自动换行
textArea.setWrapStyleWord(true); // 按单词换行
propertyPanel.add(fieldLocation, new JScrollPane(textArea));
this.textAreaMap.put(key, textArea); // 将JTextArea保存到Map中
}
}
// 将属性面板放置在中心位置btnPanel 放置在南边(底部) // 将属性面板放置在中心位置btnPanel 放置在南边(底部)
topPanel.add(propertyPanel, BorderLayout.CENTER); topPanel.add(propertyPanel, BorderLayout.CENTER);
topPanel.add(btnPanel, BorderLayout.SOUTH); topPanel.add(btnPanel, BorderLayout.SOUTH);
@ -356,6 +289,7 @@ public class ProcessAttriChangeDialog extends JDialog {
topPanel.revalidate(); topPanel.revalidate();
topPanel.repaint(); topPanel.repaint();
//处理表格表头
String[] tableHeader = new String[ruleOpsMapI.size() + 1]; String[] tableHeader = new String[ruleOpsMapI.size() + 1];
tableHeader[0] = "序号"; tableHeader[0] = "序号";
int h = 1; int h = 1;
@ -383,55 +317,6 @@ public class ProcessAttriChangeDialog extends JDialog {
impTable.setModel(impModel); impTable.setModel(impModel);
impTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); impTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
impTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {//单机鼠标
System.out.println("触发单击选中事件~");
try {
// chooseRow= impTable.getSelectedRows();
int[] selectedRows = impTable.getSelectedRows();
if(selectedRows.length <= 0) {
System.out.println("当前未选中任何对象 ");
return;
}
//选中行
// List<Integer> chooseRowTemp = new ArrayList<Integer>();
chooseRows.clear();//放入新的选中行前,清空选中行集合
targetRevision.clear();
System.out.println("当前选中行:");
for (int i = 0; i < selectedRows.length; i++) {
//选中行序号之一
int selectPartRowNum = selectedRows[i];
System.out.println("=>"+selectPartRowNum+" ;");
if (revlist != null && revlist.size() > 0) {
TCComponentItemRevision selectRevision = revlist.get(selectPartRowNum);//根据选中行的序号从revlist中获取该行对应的版本对象
if (selectRevision != null) {
targetRevision.add(selectRevision);
chooseRows.add(selectPartRowNum);
}
}else {
System.out.println("版本list为空");
}
}
if (targetRevision != null && targetRevision.size() > 0) {
System.out.println("二次渲染前的选中行:"+Arrays.toString(chooseRows.toArray()));
initUi(modelsF, taskF, ruleOpsMapF, colsF, chooseRows);
System.out.println("二次渲染后的选中行:"+Arrays.toString(chooseRows.toArray()));
}
} catch (Exception e1) {
e1.printStackTrace();
MessageBox.post(ProcessAttriChangeDialog.this, "错误:" + e1.getMessage(), "ERROR", MessageBox.ERROR);
}
}
});
for (int i = 1; i < impModel.getColumnCount(); i++) { for (int i = 1; i < impModel.getColumnCount(); i++) {
TableColumn col = impTable.getColumnModel().getColumn(i); TableColumn col = impTable.getColumnModel().getColumn(i);
@ -444,7 +329,7 @@ public class ProcessAttriChangeDialog extends JDialog {
// for (MouseListener listener : impTable.getMouseListeners()) { // for (MouseListener listener : impTable.getMouseListeners()) {
// impTable.removeMouseListener(listener); // impTable.removeMouseListener(listener);
// } // }
// addActionListener(models, cols); addActionListener(models, cols);
setLayout(new BorderLayout()); setLayout(new BorderLayout());
topPanel.setPreferredSize(new Dimension(260, getHeight())); // 设置宽度 topPanel.setPreferredSize(new Dimension(260, getHeight())); // 设置宽度
@ -461,13 +346,13 @@ public class ProcessAttriChangeDialog extends JDialog {
//如果有选中行设置table的选中对应行状态 //如果有选中行设置table的选中对应行状态
if (chooseRows != null && chooseRows.size() > 0) { if (chooseRows != null && chooseRows.size() > 0) {
System.out.println("重新加载组件完成当前已选中行开始设置table选中状态"); System.out.println("重新加载组件完成当前已选中行开始设置table选中状态");
List<Integer> uniqueRows = new ArrayList<>(new HashSet<>(chooseRows2)); // 去重 List<Integer> uniqueRows = new ArrayList<>(new HashSet<>(chooseRows)); // 去重
Collections.sort(uniqueRows); // 排序 Collections.sort(uniqueRows); // 排序
for (int row : uniqueRows) { for (int row : uniqueRows) {
impTable.addRowSelectionInterval(row, row); impTable.addRowSelectionInterval(row, row);
} }
}else{ }else{
System.out.println("当前未选中任何行重新加载组件后无需设置table选中状态"); System.out.println("重新加载组件完成!当前未选中任何行重新加载组件后无需设置table选中状态");
} }
} }
@ -486,6 +371,7 @@ public class ProcessAttriChangeDialog extends JDialog {
if (lov.length > 0) if (lov.length > 0)
return true; return true;
} catch (TCException e) { } catch (TCException e) {
System.out.println("获取LOV异常");
e.printStackTrace(); e.printStackTrace();
} }
return false; return false;
@ -638,6 +524,106 @@ public class ProcessAttriChangeDialog extends JDialog {
} }
} }
/**
* Panel
* @throws TCException
*
*/
private void updatePropertyPanel(LinkedHashMap<String, String[]> ruleOpsMapI) throws TCException {
System.out.println("触发updatePropertyPanel方法~");
//1.更新前先清空属性Panel
propertyPanel.removeAll();
topPanel.remove(propertyPanel);
propertyPanel = new JPanel(new PropertyLayout());
int k = 0;
for (String key : this.argMap.keySet()) {//将流程配置的属性逐个渲染到看板上
k++;
String value = this.argMap.get(key);//属性显示名称
System.out.println("流程配置信息Key: " + key + ", Value: " + value);
String labLocation = String.valueOf(k)+".1.left.top";
String fieldLocation = String.valueOf(k)+".2.left.top";
propertyPanel.add(labLocation,new JLabel(value));
//TODO 逻辑重构:根据不同属性类型,渲染不同的输入框
String[] attrs = ruleOpsMapI.get(value);
if (attrs == null || attrs.length == 0){
System.out.println("info根据属性显示字段【"+value+"】获取属性信息失败,请检查相关首选项配置!");
}
String currentAttributeValue = null;//当前属性的值,用于渲染到看板输入框中
System.out.println("====================================================================");
if (this.targetRevision != null && this.targetRevision.size() > 0){
System.out.println("info已选中对象开始根据选中对象的属性类型渲染组件···");
//当选中多个对象时,默认将当前选中的第一个对象属性作为默认值渲染到属性编辑看板上
TCComponentItem targetItem = this.targetRevision.get(0).getItem();
//根据属性名称获取属性所属对象类型item/rev
String itemType = attrs[0];//item/rev
String propertyName = attrs[1];//属性真实名称
if (itemType.equals("item")){
currentAttributeValue = targetItem.getProperty(propertyName);//获取当前属性的值
}else {
currentAttributeValue = targetRevision.get(0).getProperty(propertyName);//获取当前属性的值
}
//
if (isLovType(propertyName)){
System.out.println("属性【"+propertyName+"】类型为LOV");
Map<String, String> lovList = getUnitValue_display(session,propertyName);
// 创建下拉列表组件
JComboBox<String> comboBox = new JComboBox<>();
// 将lovList中的value值添加到下拉列表
for (String lovValue : lovList.values()) {
comboBox.addItem(lovValue);
}
// 设置默认显示值假设defaultValue是您希望默认显示的选项
comboBox.setSelectedItem(currentAttributeValue);
propertyPanel.add(fieldLocation, comboBox);
this.textAreaMap.put(propertyName, comboBox); //
}else {//
System.out.println("属性【"+ propertyName+"】类型非LOV ");
JTextArea textArea = new JTextArea(); // 创建JTextArea
textArea.setColumns(20); // 设置输入框宽度
textArea.setLineWrap(true); // 启用自动换行
textArea.setWrapStyleWord(true); // 按单词换行
JScrollPane scrollPane = new JScrollPane(textArea);
System.out.println("KUMA属性=" + value);
if (value != null && (value.trim().contains("备注") || "备注".equals(value.trim()))){//备注特殊处理:加高度
System.out.println("KUMA:特殊字段特殊处理!");
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
textArea.setRows(3);
scrollPane.setPreferredSize(scrollPane.getPreferredSize()); // 设置 JScrollPane 的首选尺寸
}
//赋值到textArea输入框中
textArea.setText(currentAttributeValue);
propertyPanel.add(fieldLocation, scrollPane);
this.textAreaMap.put(key, textArea); // 将JTextArea保存到Map中
}
}else {
System.out.println("info未选中任何行无法获取选中对象渲染默认组件···");
//渲染默认组件
JTextArea textArea = new JTextArea(); // 创建JTextArea
textArea.setColumns(20); // 设置输入框宽度
textArea.setLineWrap(true); // 启用自动换行
textArea.setWrapStyleWord(true); // 按单词换行
propertyPanel.add(fieldLocation, new JScrollPane(textArea));
this.textAreaMap.put(key, textArea); // 将JTextArea保存到Map中
}
}
topPanel.add(propertyPanel, BorderLayout.CENTER);
topPanel.revalidate();
topPanel.repaint();//更新属性Panel
}
/** /**
* *
* @param models * @param models
@ -649,18 +635,27 @@ public class ProcessAttriChangeDialog extends JDialog {
public void mouseClicked(MouseEvent e) {//单机鼠标 public void mouseClicked(MouseEvent e) {//单机鼠标
System.out.println("触发单击选中事件~"); System.out.println("触发单击选中事件~");
try { try {
// chooseRow= impTable.getSelectedRows();
int[] selectedRows = impTable.getSelectedRows(); int[] selectedRows = impTable.getSelectedRows();
int length = selectedRows.length;
if(length <= 0) {
if(selectedRows.length <= 0) { System.out.println("当前选中行的长度为:"+length+",未选中任何对象 ");
System.out.println("当前未选中任何对象 ");
return; return;
}else {
System.out.println("当前选中行:"+ArrayUtil.toString(selectedRows));
} }
//选中行 //选中行
// List<Integer> chooseRowTemp = new ArrayList<Integer>(); if (chooseRows != null && chooseRows.size() > 0) {
chooseRows.clear();//放入新的选中行前,清空选中行集合 chooseRows.clear();//放入新的选中行前,清空选中行集合
targetRevision.clear(); }else {
chooseRows = new ArrayList<Integer> ();
}
if (targetRevision != null && targetRevision.size() > 0) {
targetRevision.clear();
}else {
targetRevision = new ArrayList<TCComponentItemRevision>();
}
System.out.println("当前选中行:"); System.out.println("当前选中行:");
@ -683,7 +678,10 @@ public class ProcessAttriChangeDialog extends JDialog {
if (targetRevision != null && targetRevision.size() > 0) { if (targetRevision != null && targetRevision.size() > 0) {
System.out.println("二次渲染前的选中行:"+Arrays.toString(chooseRows.toArray())); System.out.println("二次渲染前的选中行:"+Arrays.toString(chooseRows.toArray()));
initUi(modelsF, taskF, ruleOpsMapF, colsF, chooseRows); // initUi(modelsF, taskF, ruleOpsMapF, colsF, chooseRows);
// ProcessAttriChangeDialog.this.dispose();
// new ProcessAttriChangeDialog(session, models, taskF, ruleOpsMapF, colsF, chooseRows, targetRevision);
updatePropertyPanel(ruleOpsMapF);
System.out.println("二次渲染后的选中行:"+Arrays.toString(chooseRows.toArray())); System.out.println("二次渲染后的选中行:"+Arrays.toString(chooseRows.toArray()));
} }

@ -70,7 +70,7 @@ public class ProcessAttriChangeHandler extends AbstractHandler implements IHandl
MessageBox.post(desktop, "首选项j6_Standard_puid配置不正确", "ERROR", MessageBox.ERROR);//QiAAAI4S5kSPsC MessageBox.post(desktop, "首选项j6_Standard_puid配置不正确", "ERROR", MessageBox.ERROR);//QiAAAI4S5kSPsC
return null; return null;
} }
new ProcessAttriChangeDialog(session, datasets, task, ruleOpsMap, cols); new ProcessAttriChangeDialog(session, datasets, task, ruleOpsMap, cols, null, null);
}catch(Exception e) { }catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
MessageBox.post(desktop, "错误:"+e.getMessage(), "ERROR", MessageBox.ERROR); MessageBox.post(desktop, "错误:"+e.getMessage(), "ERROR", MessageBox.ERROR);

Loading…
Cancel
Save