main
李建辉 6 months ago
parent fd63bc99fd
commit bf5a9a54f9

@ -109,7 +109,7 @@ public class QDRWChooseDialog extends JFrame implements ActionListener {
if (this.okButton.equals(source)) {
String selectedItem = (String) objectComboBox.getSelectedItem();
ArrayList<String> arrayList = map.get(selectedItem);
new QDRWDialog((TCSession)app.getSession(),arrayList.get(0),arrayList.get(1));
new QDRWDialog((TCSession)app.getSession(),arrayList.get(0),arrayList.get(1),selectedItem);
System.out.println("newnewnwenew");
this.dispose();
} else if (this.concelButton.equals(source)) {

@ -117,11 +117,13 @@ public class QDRWDialog extends JFrame implements ActionListener {
private QDRWTableColorRender QDRWTableColorRender;
LinkedHashMap<String, LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>> valueMap;
private Connection conn = null;
public QDRWDialog(TCSession session, String pref, String taskName) {
private String tamplateName;
public QDRWDialog(TCSession session, String pref, String taskName,String tamplateName) {
// TODO Auto-generated constructor stub
this.session = session;
this.pref = pref;
this.taskName = taskName;
this.tamplateName = tamplateName;
initUI();
}
@ -560,10 +562,7 @@ public class QDRWDialog extends JFrame implements ActionListener {
condition += "and JHJS <= '" + jhwcSStr + "' ";
}
if (ids == null || ids.isEmpty()) {
MessageBox.post("请填写条件!", "提示", 2);
return;
}
if (ids != null && !ids.isEmpty()) {
if (ids.contains(";")) {
@ -602,7 +601,11 @@ public class QDRWDialog extends JFrame implements ActionListener {
fieldsSql = fieldsSql.substring(0, fieldsSql.length() - 1);
System.out.println("fieldsSql==========" + fieldsSql);
//System.out.println("condition===================" + condition);
String sqlIdString = "SELECT ID FROM LY_CHANGETASSKFORM_DETAILS where 1=1 " + condition;
if (condition == null || condition.isEmpty()) {
MessageBox.post("请填写条件!", "提示", 2);
return;
}
String sqlIdString = "SELECT ID FROM LY_CHANGETASSKFORM_DETAILS where TEMPLATENAME = '"+tamplateName+ "' " + condition;
System.out.println("sqlIdString=========" + sqlIdString);
conn = getConn();
PreparedStatement stmt = null;
@ -647,64 +650,70 @@ public class QDRWDialog extends JFrame implements ActionListener {
String sqlString = "SELECT * FROM LY_CHANGETASSKFORM_DETAILS where 1=1 " + lastCondition;
System.out.println("sqlString======" + sqlString);
try {
stmt = conn.prepareStatement(sqlString);
ResultSet result = stmt.executeQuery();
ResultSetMetaData metaData = result.getMetaData();
int columnCount = metaData.getColumnCount();
while (result.next()) {
String id = result.getString("ID");
String xh = result.getString("XH");
LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> tempMap1 = null;
if (valueMap.containsKey(id)) {
tempMap1 = valueMap.get(id);
} else {
tempMap1 = new LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>();
}
ArrayList<LinkedHashMap<String, String>> tempList = new ArrayList<LinkedHashMap<String, String>>();
for (int i = 1; i <= columnCount; i++) {
// 获取列名
String columnName = metaData.getColumnName(i); // 获取实际的列名
// 获取列的值
String columnValue = result.getString(i); // 使用 getObject() 获取列的值
LinkedHashMap<String, String> fieldMap = new LinkedHashMap<String, String>();
fieldMap.put(columnName,
columnValue == null ? columnValue : validateAndFormatDate(columnValue));
tempList.add(fieldMap);
}
if(lastCondition.isEmpty()) {
MessageBox.post("未查到数据!", "提示", 2);
return;
}else {
try {
stmt = conn.prepareStatement(sqlString);
ResultSet result = stmt.executeQuery();
ResultSetMetaData metaData = result.getMetaData();
int columnCount = metaData.getColumnCount();
while (result.next()) {
String id = result.getString("ID");
String xh = result.getString("XH");
LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> tempMap1 = null;
if (valueMap.containsKey(id)) {
tempMap1 = valueMap.get(id);
} else {
tempMap1 = new LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>();
}
ArrayList<LinkedHashMap<String, String>> tempList = new ArrayList<LinkedHashMap<String, String>>();
for (int i = 1; i <= columnCount; i++) {
// 获取列名
String columnName = metaData.getColumnName(i); // 获取实际的列名
// 获取列的值
String columnValue = result.getString(i); // 使用 getObject() 获取列的值
LinkedHashMap<String, String> fieldMap = new LinkedHashMap<String, String>();
fieldMap.put(columnName,
columnValue == null ? columnValue : validateAndFormatDate(columnValue));
tempList.add(fieldMap);
}
tempMap1.put(xh, tempList);
valueMap.put(id, tempMap1);
}
//System.out.println(valueMap.toString());
QDRWTableColorRender.valueMap = valueMap;
QDRWTableColorRender.colorMap = colorMap;
for (Entry<String, LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>> map : valueMap
.entrySet()) {
ArrayList<String> tableList = new ArrayList<String>();
tableList.add("0");
for (Entry<String, String> tempMap : fieldsMap.entrySet()) {
String pref = tempMap.getKey();
String[] split = pref.split("\\.");
LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> value2 = map.getValue();
ArrayList<LinkedHashMap<String, String>> arrayList = value2.get(split[0]);
if (arrayList != null) {
for (int i = 0; i < arrayList.size(); i++) {
LinkedHashMap<String, String> linkedHashMap = arrayList.get(i);
if (linkedHashMap.containsKey(split[1])) {
tableList.add(linkedHashMap.get(split[1]));
tempMap1.put(xh, tempList);
valueMap.put(id, tempMap1);
}
//System.out.println(valueMap.toString());
QDRWTableColorRender.valueMap = valueMap;
QDRWTableColorRender.colorMap = colorMap;
for (Entry<String, LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>> map : valueMap
.entrySet()) {
ArrayList<String> tableList = new ArrayList<String>();
tableList.add("0");
for (Entry<String, String> tempMap : fieldsMap.entrySet()) {
String pref = tempMap.getKey();
String[] split = pref.split("\\.");
LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> value2 = map.getValue();
ArrayList<LinkedHashMap<String, String>> arrayList = value2.get(split[0]);
if (arrayList != null) {
for (int i = 0; i < arrayList.size(); i++) {
LinkedHashMap<String, String> linkedHashMap = arrayList.get(i);
if (linkedHashMap.containsKey(split[1])) {
tableList.add(linkedHashMap.get(split[1]));
}
}
}
}
}
dtm1.addRow(tableList.toArray(new Object[0]));
}
dtm1.addRow(tableList.toArray(new Object[0]));
} catch (SQLException e1) {
e1.printStackTrace();
}
} catch (SQLException e1) {
e1.printStackTrace();
}
try {
if (stmt != null) {
stmt.close();

@ -118,12 +118,20 @@ public class QDRWRWFPDialog extends JFrame implements ActionListener {
return;
}
for (int i = 0; i < cfdj.length; i++) {
for (int i = 0; i < cfdj.length; i++) {
String[] split = cfdj[i].split("=");
cfdjPref.put(split[0],split[1]);
cfdJComboBox.addItem(split[0]);
}
if(split[0].equals(type)) {
String[] split2 = split[1].split(";");
for (int j = 0; j < split2.length; j++) {
String[] split3 = split2[j].split("\\|");
cfdjPref.put(split3[0],split3[1]);
cfdJComboBox.addItem(split3[0]);
}
break;
}
}
//获取首选项匹配的类型
String[] fields = session.getPreferenceService().getStringValues("Connor_ECRECNForm_Datbase_Config");
if (fields == null || fields.length <= 0) {

@ -55,7 +55,6 @@ import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.ListOfValuesInfo;
import com.teamcenter.rac.kernel.TCComponent;
@ -86,7 +85,8 @@ public class RWFPDialog extends JFrame implements ActionListener {
private LinkedHashMap<Integer, String> lovPositionMap = new LinkedHashMap<Integer, String>();
private LinkedHashMap<String, Integer> positionFieldMap = new LinkedHashMap<String, Integer>();
private LinkedHashMap<Integer, Integer> widtheMap = new LinkedHashMap<Integer, Integer>();
//public static final int[] HEADERWIDTH = new int[] { 50, 100, 200, 200, 100, 100, 80, 80, 100, 150, 150, 150, 150,150, 150, 150, 150, 150, 150 };
// public static final int[] HEADERWIDTH = new int[] { 50, 100, 200, 200, 100,
// 100, 80, 80, 100, 150, 150, 150, 150,150, 150, 150, 150, 150, 150 };
private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
private DefaultTableModel dtm1;
private JButton yyButton = new JButton("应用");
@ -97,19 +97,29 @@ public class RWFPDialog extends JFrame implements ActionListener {
private static ArrayList<String> dateConnList = new ArrayList<String>();
private String type;
private String id;
private String objectString;
private boolean readOnly;
private ArrayList<Integer> canWriteColume = new ArrayList<Integer>();
public RWFPDialog(TCSession session,String type,String id) {
public RWFPDialog(TCSession session, String type, String id, String objectString, boolean readOnly) {
// TODO Auto-generated constructor stub
this.session = session;
this.type = type;
this.id = id;
this.objectString = objectString;
this.readOnly = readOnly;
initUI();
}
public void initUI() {
// TODO Auto-generated method stub
this.setTitle("任务分配表");
if(readOnly) {
yyButton.setEnabled(false);
tzsjButton.setEnabled(false);
}
this.setTitle(objectString+"变更任务分配表");
this.setLayout(new BorderLayout());
String[] cfdj = session.getPreferenceService().getStringValues("Connor_ChangeTaskForm_TriggerLevelMapping");
@ -119,9 +129,18 @@ public class RWFPDialog extends JFrame implements ActionListener {
}
for (int i = 0; i < cfdj.length; i++) {
String[] split = cfdj[i].split("=");
cfdjPref.put(split[0],split[1]);
cfdJComboBox.addItem(split[0]);
if(split[0].equals(type)) {
String[] split2 = split[1].split(";");
for (int j = 0; j < split2.length; j++) {
String[] split3 = split2[j].split("\\|");
cfdjPref.put(split3[0],split3[1]);
cfdJComboBox.addItem(split3[0]);
}
break;
}
}
//获取首选项匹配的类型
@ -172,6 +191,11 @@ public class RWFPDialog extends JFrame implements ActionListener {
System.out.println("fieldsMap====="+fieldsMap);
System.out.println("positionMap====="+lovPositionMap);
System.out.println("widtheMap====="+widtheMap);
if(fieldsMap.size() == 0) {
MessageBox.post("该类型未匹配到首选项!", "提示 ", MessageBox.INFORMATION);
return;
}
Collection<String> valuesCollection = fieldsMap.values();
// 将集合转换为数组
@ -258,7 +282,6 @@ public class RWFPDialog extends JFrame implements ActionListener {
}
}
public void createActionEvent() {
this.yyButton.addActionListener(this);
this.gbButton.addActionListener(this);
@ -272,7 +295,7 @@ public class RWFPDialog extends JFrame implements ActionListener {
topPanel.setLayout(new PropertyLayout());
topPanel.add("1.1.left.center", new JLabel("触发等级 "));
topPanel.add("1.2.left.center",cfdJComboBox);
topPanel.add("1.2.left.center", cfdJComboBox);
topPanel.add("1.3.left.center", new JLabel(" 触发时间 "));
cfsjButton = new DateButton(null, "yyyy-MM-dd", false, false, false);
@ -286,16 +309,16 @@ public class RWFPDialog extends JFrame implements ActionListener {
}
// 查询部分
private JPanel getBottomPanel() {
// TODO Auto-generated method stub
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new PropertyLayout());
bottomPanel.add("1.1.left.center", new JLabel(" "));
bottomPanel.add("1.2.left.center", yyButton);
bottomPanel.add("1.3.left.center", new JLabel(" "));
bottomPanel.add("1.4.left.center", gbButton);
return bottomPanel;
}
private JPanel getBottomPanel() {
// TODO Auto-generated method stub
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new PropertyLayout());
bottomPanel.add("1.1.left.center", new JLabel(" "));
bottomPanel.add("1.2.left.center", yyButton);
bottomPanel.add("1.3.left.center", new JLabel(" "));
bottomPanel.add("1.4.left.center", gbButton);
return bottomPanel;
}
private JScrollPane getTablePanel() {
// TODO Auto-generated method stub
@ -310,12 +333,12 @@ public class RWFPDialog extends JFrame implements ActionListener {
for (Entry<Integer, String> map : lovPositionMap.entrySet()) {
JComboBox<String> jComboBox = new JComboBox<String>();
String value = map.getValue();
if(value.contains(",")) {
if (value.contains(",")) {
String[] split = value.split(",");
for (int i = 0; i < split.length; i++) {
jComboBox.addItem(split[i]);
}
}else {
} else {
jComboBox.addItem(value);
}
table.getColumnModel().getColumn(map.getKey()).setCellEditor(new DefaultCellEditor(jComboBox));
@ -365,10 +388,10 @@ public class RWFPDialog extends JFrame implements ActionListener {
dtm1 = new DefaultTableModel(values, titleNames) {
@Override
public boolean isCellEditable(int row, int column) {
if(canWriteColume.size() > 0) {
if (canWriteColume.size() > 0) {
for (int i = 0; i < canWriteColume.size(); i++) {
if(canWriteColume.get(i) == column) {
System.out.println("row=========="+row);
if (canWriteColume.get(i) == column) {
System.out.println("row==========" + row);
return true;
}
}
@ -389,32 +412,31 @@ public class RWFPDialog extends JFrame implements ActionListener {
if (source.equals(this.gbButton)) {
dispose();
}
else if(source.equals(this.yyButton)){
//保存数据
} else if (source.equals(this.yyButton)) {
// 保存数据
Connection conn = getConn();
PreparedStatement stmt = null;
for(int i = 0; i < table.getRowCount(); i++){
for (int i = 0; i < table.getRowCount(); i++) {
StringBuilder updateSql = new StringBuilder();
updateSql.append("update LY_CHANGETASSKFORM_DETAILS set ");
for (Entry<String, Integer> map : positionFieldMap.entrySet()) {
updateSql.append(map.getKey());
String valueAt = (String)table.getValueAt(i,map.getValue());
if(valueAt == null || valueAt.isEmpty()) {
String valueAt = (String) table.getValueAt(i, map.getValue());
if (valueAt == null || valueAt.isEmpty()) {
updateSql.append("=");
updateSql.append("null,");
}else {
} else {
updateSql.append("='");
updateSql.append(table.getValueAt(i,map.getValue()));
updateSql.append(table.getValueAt(i, map.getValue()));
updateSql.append("',");
}
}
//去掉最后一个,
// 去掉最后一个,
updateSql.deleteCharAt(updateSql.length() - 1);
updateSql.append(" where ID='"+id+"' and XH='"+table.getValueAt(i,0)+"'");
updateSql.append(" where ID='" + id + "' and XH='" + table.getValueAt(i, 0) + "'");
try {
stmt = conn.prepareStatement(updateSql.toString());
System.out.println("updateSql========="+updateSql.toString());
System.out.println("updateSql=========" + updateSql.toString());
stmt.execute();
} catch (SQLException e1) {
// TODO Auto-generated catch block
@ -423,149 +445,147 @@ public class RWFPDialog extends JFrame implements ActionListener {
}
try {
if(stmt != null) {
if (stmt != null) {
stmt.close();
}
if(conn != null) {
if (conn != null) {
conn.close();
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}else if(source.equals(this.tzsjButton)){
} else if (source.equals(this.tzsjButton)) {
gsPrefTopLine = new ArrayList<String>();
String selectedItem = (String)cfdJComboBox.getSelectedItem();
if(selectedItem == null || selectedItem.isEmpty()) {
String selectedItem = (String) cfdJComboBox.getSelectedItem();
if (selectedItem == null || selectedItem.isEmpty()) {
MessageBox.post("请选择触发等级!", "提示", 2);
return;
}
Date date = cfsjButton.getDate();
if(date == null) {
if (date == null) {
MessageBox.post("请选择触发时间!", "提示", 2);
return;
}
String cfsjDate = dateFormat.format(date);
String pref = cfdjPref.get(selectedItem);
if(pref == null || pref.isEmpty()) {
if (pref == null || pref.isEmpty()) {
MessageBox.post("未配置触发等级相关的首选项!", "提示", 2);
return;
}
String[] calculateTime = session.getPreferenceService().getStringValues(pref);
if (calculateTime == null || calculateTime.length <= 0) {
MessageBox.post("请配置首选项“"+pref+"”", "提示 ", MessageBox.INFORMATION);
MessageBox.post("请配置首选项“" + pref + "”", "提示 ", MessageBox.INFORMATION);
return;
}
for (int i = 0; i < calculateTime.length; i++) {
String[] split = calculateTime[i].split("\\|");
if(i == 0) {
if (i == 0) {
for (int j = 0; j < split.length; j++) {
gsPrefTopLine.add(split[j]);
}
}else {
gsPrefMap.put(split[0],calculateTime[i]);
} else {
gsPrefMap.put(split[0], calculateTime[i]);
}
}
System.out.println(positionFieldMap+"==================positionFieldMap");
System.out.println("gsPrefTopLine----------------"+gsPrefTopLine.size());
System.out.println(positionFieldMap + "==================positionFieldMap");
System.out.println("gsPrefTopLine----------------" + gsPrefTopLine.size());
Integer xh = positionFieldMap.get(gsPrefTopLine.get(0));
//表里table 开始计算
for(int i = 0; i < table.getRowCount(); i++){
String xhStr = table.getValueAt(i, xh).toString();
String gsStr = gsPrefMap.get(xhStr);
if(gsStr != null && !gsStr.isEmpty() ) {
String[] split = gsStr.split("\\|");
for (int j = 1; j < gsPrefTopLine.size(); j++) {
//如果有值
System.out.println("gsPrefTopLine.get(j)========"+gsPrefTopLine.get(j));
Integer colume = positionFieldMap.get(gsPrefTopLine.get(j));
if(colume != null) {
System.out.println(positionFieldMap.get(gsPrefTopLine.get(j))+"=================positionFieldMap.get(gsPrefTopLine.get(j))");
//处理公式
String gs = split[j];
System.out.println("gs========"+gs);
if(gs.equals("N")) {
table.setValueAt(cfsjDate,i, colume);
}else {
String[] split2 = gs.split("N");
String time = calculateDate(cfsjDate, Integer.parseInt(split2[1]));
System.out.println("time============"+time);
table.setValueAt(time,i, colume);
}
}
// 表里table 开始计算
for (int i = 0; i < table.getRowCount(); i++) {
String xhStr = table.getValueAt(i, xh).toString();
String gsStr = gsPrefMap.get(xhStr);
if (gsStr != null && !gsStr.isEmpty()) {
String[] split = gsStr.split("\\|");
for (int j = 1; j < gsPrefTopLine.size(); j++) {
// 如果有值
System.out.println("gsPrefTopLine.get(j)========" + gsPrefTopLine.get(j));
Integer colume = positionFieldMap.get(gsPrefTopLine.get(j));
if (colume != null) {
System.out.println(positionFieldMap.get(gsPrefTopLine.get(j))
+ "=================positionFieldMap.get(gsPrefTopLine.get(j))");
// 处理公式
String gs = split[j];
System.out.println("gs========" + gs);
if (gs.equals("N")) {
table.setValueAt(cfsjDate, i, colume);
} else {
String[] split2 = gs.split("N");
String time = calculateDate(cfsjDate, Integer.parseInt(split2[1]));
System.out.println("time============" + time);
table.setValueAt(time, i, colume);
}
}
}
}
}
}
//调用应用按钮
yyButton.doClick();
MessageBox.post("调整时间完成!", "提示", 2);
}
// 调用应用按钮
yyButton.doClick();
MessageBox.post("调整时间完成!", "提示", 2);
}
}
// 获取数据库连接
public static Connection getConn() {
Connection conn = null;
try {
conn = DbPool.getConnection(dateConnList.get(0), dateConnList.get(1));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
public static Connection getConn() {
Connection conn = null;
try {
conn = DbPool.getConnection(dateConnList.get(0), dateConnList.get(1));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
public static String calculateDate(String dateString, int daysToAdd) {
// 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
public static String calculateDate(String dateString, int daysToAdd) {
// 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 解析输入的日期字符串
LocalDate date;
try {
date = LocalDate.parse(dateString, formatter);
} catch (DateTimeParseException e) {
throw new IllegalArgumentException("Invalid date format. Please use yyyy-MM-dd.", e);
}
// 增加或减少天数
LocalDate resultDate = date.plusDays(daysToAdd);
// 格式化结果日期为字符串
return resultDate.format(formatter);
}
public String validateAndFormatDate(String input) {
// 定义输入和输出的日期格式
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S");
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
try {
// 尝试解析输入的日期时间字符串
LocalDateTime dateTime = LocalDateTime.parse(input, inputFormatter);
// 转换为只包含日期的LocalDate对象
LocalDate date = dateTime.toLocalDate();
// 格式化结果日期为字符串
return date.format(outputFormatter);
} catch (DateTimeParseException e) {
// 如果解析失败,说明输入不符合指定格式,返回原始字符串
return input;
}
}
// 解析输入的日期字符串
LocalDate date;
try {
date = LocalDate.parse(dateString, formatter);
} catch (DateTimeParseException e) {
throw new IllegalArgumentException("Invalid date format. Please use yyyy-MM-dd.", e);
}
// 增加或减少天数
LocalDate resultDate = date.plusDays(daysToAdd);
// 格式化结果日期为字符串
return resultDate.format(formatter);
}
public String validateAndFormatDate(String input) {
// 定义输入和输出的日期格式
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S");
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
try {
// 尝试解析输入的日期时间字符串
LocalDateTime dateTime = LocalDateTime.parse(input, inputFormatter);
// 转换为只包含日期的LocalDate对象
LocalDate date = dateTime.toLocalDate();
// 格式化结果日期为字符串
return date.format(outputFormatter);
} catch (DateTimeParseException e) {
// 如果解析失败,说明输入不符合指定格式,返回原始字符串
return input;
}
}
}

@ -31,18 +31,65 @@ public class RWFPHandler extends AbstractHandler {
// MessageBox.post(app.getDesktop(), "请选择系统总目录文件夹进行导入!", "导入位置选择", MessageBox.WARNING);
// return null;
// }
//ÅжÏÊÇ·ñ¿É±à¼­
boolean readOnly = true;
String userId = "";
try {
userId = session.getUser().getUserId();
} catch (TCException e3) {
// TODO Auto-generated catch block
e3.printStackTrace();
}
String[] templates = session.getPreferenceService().getStringValues("Connor_TaskForm_ChangeDateButton_User");
if(templates != null && templates.length > 0 && userId != null && !userId.isEmpty()) {
if(templates[0].contains(userId)) {
readOnly = false;
}
}
final boolean readOnlyFinal = readOnly;
InterfaceAIFComponent target = app.getTargetComponent();
if(target instanceof TCComponentItem) {
TCComponentItem item = (TCComponentItem)target;
String type = item.getType();
try {
String id = item.getStringProperty("item_id");
String objectString = item.getStringProperty("object_string");
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
new RWFPDialog(session,type,id,objectString,readOnlyFinal);
//d.setModal(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}else if(target instanceof TCComponentItemRevision){
TCComponentItemRevision rev = (TCComponentItemRevision)target;
TCComponentItem item = null;
try {
item = rev.getItem();
} catch (TCException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
String type = item.getType();
try {
String id = item.getStringProperty("item_id");
String objectString = item.getStringProperty("object_string");
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
new RWFPDialog(session,type,id);
new RWFPDialog(session,type,id,objectString,readOnlyFinal);
//d.setModal(true);
} catch (Exception e) {
e.printStackTrace();
@ -54,6 +101,7 @@ public class RWFPHandler extends AbstractHandler {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}else {
MessageBox.post(app.getDesktop(), "请选择正确对象!", "提示", MessageBox.WARNING);
return null;

@ -17,11 +17,14 @@ public class CheckBoxTreeNodeSelectionListener extends MouseAdapter
int y = event.getY();
int row = tree.getRowForLocation(x, y);
TreePath path = tree.getPathForRow(row);
System.out.println(path);
if(path != null)
{
CheckBoxTreeNode node = (CheckBoxTreeNode)path.getLastPathComponent();
System.out.println(node);
if(node != null)
{
boolean isSelected = !node.isSelected();
node.setSelected(isSelected);
((DefaultTreeModel)tree.getModel()).nodeStructureChanged(node);

@ -7,6 +7,8 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.JButton;
@ -44,7 +46,7 @@ public class CreateProjectStructDialog extends AbstractAIFDialog{
private JTree jtree;
private JButton okButton;
private JButton celButton;
private HashMap<String, String> preMap = new HashMap<String, String>();
private HashMap<String, ArrayList<String>> preMap = new HashMap<String, ArrayList<String>>();
public static final String preName = "connor_LY6_FolderTemp";
@ -90,7 +92,11 @@ public class CreateProjectStructDialog extends AbstractAIFDialog{
if(prefVal.contains("=")) {
String[] split = prefVal.split("=");
modelBox.addItem(split[0]);
preMap.put(split[0], split[1]);
ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add(split[1]);
arrayList.add(split[2]);
arrayList.add(split[3]);
preMap.put(split[0], arrayList);
}
}
}
@ -131,7 +137,8 @@ public class CreateProjectStructDialog extends AbstractAIFDialog{
* @param tree
*/
private void initTree(JTree tree){
String puid = preMap.get(modelBox.getSelectedItem());
ArrayList<String> list = preMap.get(modelBox.getSelectedItem());
String puid = list.get(0);
TCComponent component;
try {
component = session.stringToComponent(puid);
@ -214,18 +221,19 @@ public class CreateProjectStructDialog extends AbstractAIFDialog{
@Override
public void actionPerformed(ActionEvent e) {
String name = nameField.getText();
ArrayList<String> list = preMap.get(modelBox.getSelectedItem());
if (name.isEmpty()) {
MessageBox.post("请填写项目名称!", "提示 ", MessageBox.INFORMATION);
} else {
TCComponentFolderType folderType;
try {
KUtil.setByPass(true);
folderType = (TCComponentFolderType) session.getTypeComponent("LD6_CusProdFolder");
folderType = (TCComponentFolderType) session.getTypeComponent(list.get(1));
TCComponentFolder folder = KUtil.createFolderBySOA(folderType.getTypeName(), name);
//TCComponentFolder folder = folderType.create(name, "", "LD6_CusProdFolder");
target.add("contents", folder);
CheckBoxTreeNode root = (CheckBoxTreeNode) jtree.getModel().getRoot();
createFolderStruct(root,folder,(TCComponentFolderType) session.getTypeComponent("LD6_ProjMaFolder"),true);
createFolderStruct(root,folder,(TCComponentFolderType) session.getTypeComponent(list.get(2)),true);
KUtil.setByPass(false);
disposeDialog();
} catch (Exception e1) {
@ -239,6 +247,15 @@ public class CreateProjectStructDialog extends AbstractAIFDialog{
if(event.getStateChange() == ItemEvent.SELECTED) {
//重新刷新树
jtree.setModel(null);
// 获取并移除所有的 MouseListener
MouseListener[] mouseListeners = jtree.getMouseListeners();
for (MouseListener listener : mouseListeners) {
jtree.removeMouseListener(listener);
}
// 重新验证和重绘
jtree.revalidate();
jtree.repaint();
initTree(jtree);
}else if(event.getStateChange() == ItemEvent.DESELECTED){

@ -1,5 +1,18 @@
package com.langtech.plm.mpart;
/**
* ===============================================================================
* Copyright (c) 2012-2024 CONNOR lijh. Unpublished - All Rights Reserved
* ===============================================================================
* File description: Mpart
*
* ===============================================================================
* DATE Name Description of Change
*
* ===============================================================================
*/
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
@ -1094,6 +1107,7 @@ public class MpartDialog extends JFrame implements ActionListener {
return panel;
}
//获取右边的panel
private JPanel getTablePanel2() {
JPanel panel = new JPanel(new BorderLayout());
panel.setPreferredSize(new Dimension(200, 600));
@ -1239,6 +1253,7 @@ public class MpartDialog extends JFrame implements ActionListener {
return formattedNumber;
}
//创建流程
public static void CreateProcess(TCSession session, TCComponent target, String processName) throws TCException {
try {
TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job");

@ -1,77 +1,117 @@
package com.langtech.plm.template;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentSchedule;
import com.teamcenter.rac.kernel.TCComponentScheduleTask;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class TemplateHandler extends AbstractHandler{
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
TCSession session = (TCSession) app.getSession();
try {
new Thread() {
@Override
public void run() {
InterfaceAIFComponent targetComponent = app.getTargetComponent();
if(targetComponent instanceof TCComponentItemRevision) {
try {
String[] pref = session.getPreferenceService().getStringValues("LY6_MEOP_TemplateObject");
String types = "";
if(pref.length > 0) {
types = pref[0];
}else {
MessageBox.post("请配置首选项LY6_MEOP_TemplateObject","提示",2);
return;
}
TCComponentItemRevision rev = (TCComponentItemRevision)targetComponent;
String object_type = rev.getStringProperty("object_type");
if(types.contains(object_type)) {
new TemplateDialog(session,rev,object_type);
}else {
MessageBox.post("请选择首选项LY6_MEOP_TemplateObject中匹配的对象","提示",2);
return;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else {
MessageBox.post("请选择版本对象!","提示",2);
return;
}
}
}.start();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return null;
}
}
//package com.langtech.plm.template;
//
//import org.eclipse.core.commands.AbstractHandler;
//import org.eclipse.core.commands.ExecutionEvent;
//import org.eclipse.core.commands.ExecutionException;
//
//import com.teamcenter.rac.aif.AbstractAIFApplication;
//import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
//import com.teamcenter.rac.aifrcp.AIFUtility;
//import com.teamcenter.rac.kernel.TCComponent;
//import com.teamcenter.rac.kernel.TCComponentItemRevision;
//import com.teamcenter.rac.kernel.TCComponentSchedule;
//import com.teamcenter.rac.kernel.TCComponentScheduleTask;
//import com.teamcenter.rac.kernel.TCException;
//import com.teamcenter.rac.kernel.TCSession;
//import com.teamcenter.rac.util.MessageBox;
//
//public class TemplateHandler extends AbstractHandler{
//
//
// @Override
// public Object execute(ExecutionEvent arg0) throws ExecutionException {
// AbstractAIFApplication app = AIFUtility.getCurrentApplication();
// TCSession session = (TCSession) app.getSession();
// try {
//
//
//
// new Thread() {
// @Override
// public void run() {
// InterfaceAIFComponent targetComponent = app.getTargetComponent();
//
// String type = targetComponent.getType();
// System.out.println("type==========="+type);
// if(targetComponent instanceof TCComponentItemRevision) {
// try {
// String[] pref = session.getPreferenceService().getStringValues("LY6_MEOP_TemplateObject");
// String types = "";
// if(pref.length > 0) {
// types = pref[0];
// }else {
// MessageBox.post("请配置首选项LY6_MEOP_TemplateObject","提示",2);
// return;
// }
//
// TCComponentItemRevision rev = (TCComponentItemRevision)targetComponent;
// String object_type = rev.getStringProperty("object_type");
// if(types.contains(object_type)) {
// new TemplateDialog(session,rev,object_type);
// }else {
// MessageBox.post("请选择首选项LY6_MEOP_TemplateObject中匹配的对象","提示",2);
// return;
// }
//
//
//
//
// } catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }else if(type.equals("Mfg0BvrOperation")){
// TCComponent com = (TCComponent) targetComponent;
// try {
// TCComponent rev = com.getRelatedComponent("bl_line_object");
// if(rev instanceof TCComponentItemRevision) {
// try {
// String[] pref = session.getPreferenceService().getStringValues("LY6_MEOP_TemplateObject");
// String types = "";
// if(pref.length > 0) {
// types = pref[0];
// }else {
// MessageBox.post("请配置首选项LY6_MEOP_TemplateObject","提示",2);
// return;
// }
//
// TCComponentItemRevision revision = (TCComponentItemRevision)rev;
// String object_type = rev.getStringProperty("object_type");
// if(types.contains(object_type)) {
// new TemplateDialog(session,revision,object_type);
// }else {
// MessageBox.post("请选择首选项LY6_MEOP_TemplateObject中匹配的对象","提示",2);
// return;
// }
//
//
//
//
// } catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
// } catch (TCException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }else {
// MessageBox.post("请选择版本对象!","提示",2);
// return;
// }
//
//
// }
// }.start();
//
// } catch (Exception e) {
// // TODO: handle exception
// e.printStackTrace();
// }
//
// return null;
// }
//
//
//}

Loading…
Cancel
Save