first commit

main
李建辉 1 month ago
commit 28621556b1

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="sqlServerLib/sqljdbc4.jar"/>
<classpathentry kind="lib" path="sqlServerLib/swingx-1.6.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

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

@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

@ -0,0 +1,33 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Performancemanagement
Bundle-SymbolicName: com.langtech.plm.performancemanagement;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: com.langtech.plm.performancemanagement.Activator
Bundle-Vendor: LANGTECH
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
com.teamcenter.rac.aifrcp;bundle-version="13000.1.0",
com.teamcenter.rac.tcapps;bundle-version="13000.1.0",
com.teamcenter.rac.ui;bundle-version="13000.1.0",
com.teamcenter.rac.ui.views;bundle-version="13000.1.0",
com.teamcenter.rac.util;bundle-version="13000.1.0",
com.teamcenter.rac.common;bundle-version="13000.1.0",
com.teamcenter.rac.kernel;bundle-version="13000.1.0",
com.teamcenter.rac.external;bundle-version="13000.1.0",
org.apache.poi.39;bundle-version="3.9.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Automatic-Module-Name: com.langtech.plm.performancemanagement
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: sqlServerLib/sqljdbc4.jar,
.,
sqlServerLib/swingx-1.6.1.jar
Export-Package: com.langtech.plm.form,
com.langtech.plm.performancemanagement,
com.langtech.plm.performancemanagement.dialogs,
com.langtech.plm.performancemanagement.handlers,
com.langtech.plm.performancemanagement.operations,
com.langtech.plm.performancemanagement.util,
com.microsoft.sqlserver.jdbc,
com.teamcenter.rac.stylesheet,
microsoft.sql

@ -0,0 +1,132 @@
功能描述
# 操作触发
选中项目文件夹点击“绩效报表”菜单输出该项目的绩效报表Excel
# 首选项配置
## ld_billboards_uid
```text
单值报表模板的puid
```
## ld_postCoefficient
```text
多值,描述岗位组对应的岗位系数,形式:
岗位组=岗位系数
绘图组=1
三维组=1.05
```
## ld_taskNature
```
多值,描述任务性质对应的任务系数,形式:
任务性质=任务系数
全新=10
可复制修改=5
临时=2.5
EC=2.5
```
## ld_taskDifficulty
```
多值,描述任务难度对应的难度系数,形式:
任务难度=难度系数
子项目=0.1
简单=1
一般=1.25
较难=1.5
很难=2
```
## ld_urgency
```
多值,描述紧急度对应的紧急系数,形式:
紧急度=紧急系数
一般=1
紧急=1.25
超紧急=1.5
```
## ld_overtime
```
多值,超时扣分配置,形式:
严重程度:天数区间:扣分比例,其中"()"代表开区间,"[]"代表闭区间
如:
一般:(0,1]:0.2
严重:(1,2]:0.33
超严重:(2,3]:0.5
未定义:(3,1000):0.6
```
## ld_processReview
```
多值,描述流程信息配置,用户获取特定流程节点的分派人和处理人,形式:
新品任务项名称=流程名称:审核节点名称
铸件资料=001铸件资料流程:铸件资料审核
```
## ld_requestTime
```
多值,描述任务要求完成时间对应的公式,形式:
新品任务项名称=公式E和F必须放在运算符前面例如
铸件资料=E-10
PPAP文件=F+1
其中E代表流程发起时间F代表工艺程序结束时间数据库表维护
```
## ld_sqlserver
```
多值描述sqlserver数据库连接信息
第一行:数据库用户名
第二行:数据库密码
第三行登录url
第四行:驱动
第五行:表名
infodba
infodba
jdbc:microsoft:sqlserver://10.10.22.39:1433;DatabaseName=TC13
com.microsoft.jdbc.sqlserver.SQLServerDriver
TASK_REQUIREMENT
```
## Connor_JXFolder
```
多值,描述现有的项目归档文件夹与绩效管理要求的任务包对应,形式:
任务包名称=一级文件夹名称/二级文件夹名称/三级文件夹名称/…….
```

1
bin/.gitignore vendored

@ -0,0 +1 @@
/com/

@ -0,0 +1,8 @@
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/,\
sqlServerLib/sqljdbc4.jar,\
sqlServerLib/swingx-1.6.1.jar

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.commands">
<category
id="com.langtech.plm.performancemanagement.commands.category"
name="Sample Category">
</category>
<command
categoryId="com.langtech.plm.performancemanagement.commands.category"
name="绩效报表"
id="com.langtech.plm.performancemanagement.commands.taskFolderMatching">
</command>
<command
categoryId="com.langtech.plm.form.QueryNewProdFormHandler"
name="绩效查询"
id="com.langtech.plm.form.QueryNewProdFormHandler">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.langtech.plm.performancemanagement.handlers.TaskFolderMatchingHandler"
commandId="com.langtech.plm.performancemanagement.commands.taskFolderMatching">
</handler>
<handler
class="com.langtech.plm.form.QueryNewProdFormHandler"
commandId="com.langtech.plm.form.QueryNewProdFormHandler">
</handler>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
id="com.langtech.plm.performancemanagement.menus.sampleMenu"
label="绩效"
mnemonic="M">
<command
commandId="com.langtech.plm.performancemanagement.commands.taskFolderMatching"
id="com.langtech.plm.performancemanagement.menus.taskFolderMatchingCommand"
mnemonic="S">
</command>
<command
commandId="com.langtech.plm.form.QueryNewProdFormHandler"
id="com.langtech.plm.form.QueryNewProdFormHandler"
mnemonic="S">
</command>
</menu>
<menu
id="com.langtech.plm.performancemanagement.menus.sampleMenu1"
label="菜单1111"
mnemonic="M">
<command
commandId="com.langtech.plm.performancemanagement.commands.taskFolderMatching"
id="com.langtech.plm.performancemanagement.menus.taskFolderMatchingCommand"
mnemonic="S">
</command>
<command
commandId="com.langtech.plm.form.QueryNewProdFormHandler"
id="com.langtech.plm.form.QueryNewProdFormHandler"
mnemonic="S">
</command>
</menu>
</menuContribution>
</extension>
</plugin>

Binary file not shown.

Binary file not shown.

@ -0,0 +1,147 @@
package com.langtech.plm.form;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map.Entry;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout;
public class ChooseDialog extends JFrame implements ActionListener {
protected DefaultTableModel tm_part;
private JComboBox<String> objectComboBox = new JComboBox<String>();
private JButton okButton = new JButton("确定");
private JButton concelButton = new JButton("取消");
private String[] strings;
private int row;
private int column;
public ChooseDialog(String[] strings,int row,int column,DefaultTableModel tm_part) {
// TODO Auto-generated constructor stub
this.strings = strings;
this.row = row;
this.column = column;
this.tm_part = tm_part;
initUI();
}
public void initUI() {
// TODO Auto-generated method stub
try {
this.setTitle("选择人员");
this.setLayout(new BorderLayout());
JPanel topPanel = getTopPanel();
JPanel btnPanel = getBtnPanel();
this.add(topPanel, BorderLayout.NORTH);
// this.add(pane,BorderLayout.CENTER);
this.add(btnPanel, BorderLayout.SOUTH);
this.setPreferredSize(new Dimension(350, 150));
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸
int screenWidth = screenSize.width; // 获取屏幕宽度
int screenHeight = screenSize.height; // 获取屏幕高度
int x = (screenWidth - 350) / 2; // 计算Frame的左上角x坐标
int y = (screenHeight - 150) / 2; // 计算Frame的左上角y坐标
this.setLocation(x, y); // 设置Frame的位置
// this.setLocationRelativeTo(null);
this.createActionEvent();
this.pack();
// this.validate();
this.setVisible(true);
// this.setAlwaysOnTop(true);
//设置下拉值
for (int i = 0; i < strings.length; i++) {
objectComboBox.addItem(strings[i]);
}
} catch (Exception e) {
e.printStackTrace();
return;
}
}
// 添加监听
public void createActionEvent() {
this.okButton.addActionListener(this);
this.concelButton.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Object source = e.getSource();
System.out.println("source==>+" + source);
if (this.okButton.equals(source)) {
String selectedItem = (String) objectComboBox.getSelectedItem();
tm_part.setValueAt(selectedItem, row, column);
this.dispose();
} else if (this.concelButton.equals(source)) {
this.dispose();
}
}
private JPanel getBtnPanel() {
JPanel topPanel = new JPanel();
topPanel.setLayout(new PropertyLayout());
topPanel.add("1.1.center", new JLabel(""));
topPanel.add("2.1.center", new JLabel(" "));
topPanel.add("2.2.center", okButton);
topPanel.add("2.3.center", new JLabel(""));
topPanel.add("2.4.center", concelButton);
topPanel.add("3.1.center", new JLabel(""));
topPanel.add("4.1.center", new JLabel(""));
return topPanel;
}
// 查询部分
private JPanel getTopPanel() {
// TODO Auto-generated method stub
JPanel topPanel = new JPanel();
topPanel.setLayout(new PropertyLayout());
topPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
topPanel.add("1.1.left.center", new JLabel(""));
topPanel.add("2.1.left.center", new JLabel(""));
topPanel.add("3.1.left.center", new JLabel(""));
topPanel.add("4.1.left.center", new JLabel(""));
topPanel.add("5.1.left.center", new JLabel(" 选择人员:"));
topPanel.add("5.2.left.center", objectComboBox);
return topPanel;
}
}

@ -0,0 +1,250 @@
package com.langtech.plm.form;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
public class DbPool {
public static Connection connection = null;
public static PreparedStatement ps = null;
public static ResultSet rs = null;
private static DbPool instance = null;
public static synchronized Connection getConnection(String url, String name) {
if (instance == null) {
instance = new DbPool();
}
return instance._getConnection(url, name);
}
private Connection _getConnection(String url, String name) {
try {
String sDBDriver = null;
String sConnection = null;
String sUser = null;
String sPassword = null;
Properties p = new Properties();
// InputStream is = getClass().getResourceAsStream(
// "/sqlconn.properties");
// p.load(is);
sDBDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
sConnection = "jdbc:sqlserver://" + url + ":1433; DatabaseName=" + name;// p.getProperty("Connection", "2");
sUser = "infodba";// p.getProperty("User", "");
sPassword = "infodba";// p.getProperty("Password", "");
if (sDBDriver == null || sConnection == null || sUser == null || sPassword == null) {
System.out.println("请检查数据库首选项是否配置正确");
}
Class.forName(sDBDriver);
connection = DriverManager.getConnection(sConnection, sUser, sPassword);
return connection;
} catch (Exception se) {
System.out.println(se);
}
return null;
}
public final static ResultSet read(String sql, Object[] argments) throws SQLException {
return DbPool.rs = DbPool.getPs(argments, sql).executeQuery();
}
/**
* Statement
*/
public final static PreparedStatement getPs(Object[] argments, String sql) throws SQLException {
return getPs(sql, argments);
}
/**
* Statement
*/
public final static PreparedStatement getPs(String sql, Object[] argments) throws SQLException {
DbPool.ps = DbPool.connection.prepareStatement(sql);
if (argments != null) {
for (int i = 0; i < argments.length; i++) {
DbPool.ps.setObject(i + 1, argments[i]);
}
}
return DbPool.ps;
}
/**
*
*/
public final static ResultSet read(String sql) throws SQLException {
return read(sql, null);
}
public static void executeUpdateSql(String sql) throws SQLException {
Statement st = connection.createStatement();
try {
connection.setAutoCommit(false);
// System.out.println("sql===" + sql);
int i = st.executeUpdate(sql);
} catch (SQLException e) {
System.out.println(e.getMessage());
if (st != null)
st.close();
connection.rollback();
connection.close();
} finally {
if (st != null)
st.close();
// connection.close();
}
}
public static void executeDeleteSql(String sql) throws SQLException {
Statement st = connection.createStatement();
try {
connection.setAutoCommit(false);
// System.out.println("sql===" + sql);
st.executeUpdate(sql);
connection.commit();
} catch (SQLException e) {
if (st != null)
st.close();
connection.rollback();
connection.close();
} finally {
if (st != null)
st.close();
connection.close();
}
}
/**
*
*/
public final static int write(String sql, Object[] argments) {
return update(sql, argments);
}
/**
* (Connection)
*/
public final static int update(String sql, Object[] argments) {
int i = -1;
try {
i = DbPool.getPs(argments, sql).executeUpdate();
DbPool.connection.commit();
} catch (SQLException e) {
e.printStackTrace();
} finally {
free(DbPool.rs, DbPool.ps);
}
return i;
}
public static ResultSet executeSelectSql(String sql) throws SQLException {
Statement st = connection.createStatement();
try {
connection.setAutoCommit(false);
// System.out.println("sql===" + sql);
rs = st.executeQuery(sql);
// conn.commit();
} catch (SQLException e) {
if (st != null)
st.close();
connection.rollback();
connection.close();
}
return rs;
}
/**
*
*/
public final static void free(ResultSet resultSet) {
free(resultSet, null, null);
}
/**
*
*/
public final static void free(Statement statement) {
free(null, statement, null);
}
/**
*
*/
public final static void free(Connection connection) {
free(null, null, connection);
}
/**
*
*/
public final static void free(ResultSet resultSet, Statement statement) {
free(resultSet, statement, null);
}
/**
*
*/
public final static void free(Statement statement, Connection connection) {
free(null, statement, connection);
}
/**
* ()
*/
public final static void free() {
free(DbPool.rs, DbPool.ps);
}
/**
* ()
*/
public final static void freeAll() {
free(DbPool.rs, DbPool.ps, DbPool.connection);
}
/**
* ()
*/
public final static void free(ResultSet resultSet, Statement statement, Connection connection) {
try {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
} finally {
try {
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
} finally {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
}
}

@ -0,0 +1,30 @@
package com.langtech.plm.form;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class JButtonEditor extends AbstractCellEditor implements TableCellEditor {
private JButton button;
private int row;
private int column;
public JButtonEditor(String text, ActionListener actionListener) {
button = new JButton(text);
button.addActionListener(actionListener);
}
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row, int column) {
this.row = row;
this.column = column;
button.setText(value.toString());
return button;
}
public Object getCellEditorValue() {
return new String(button.getText());
}
}

@ -0,0 +1,459 @@
package com.langtech.plm.form;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.ComboBoxEditor;
import javax.swing.DefaultButtonModel;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import org.jdesktop.swingx.renderer.DefaultTableRenderer;
import org.jdesktop.swingx.renderer.FormatStringValue;
import org.jdesktop.swingx.renderer.StringValue;
import org.jdesktop.swingx.table.DatePickerCellEditor;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCFormProperty;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.stylesheet.AbstractRendering;
import com.teamcenter.rac.util.MessageBox;
@SuppressWarnings("deprecation")
public class LD6_NewProdForm extends AbstractRendering {
private static ArrayList<String> dateConnList = new ArrayList<String>();
protected DefaultTableModel tm_part;
protected JTable t_part;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
public static final String[] HEADER = new String[] { "序号", "新品任务项", "分派人", "新品任务要求描述", "处理人", "岗位组", "任务性质", "难易程度",
"紧急程度", "额定业务工时/小时", "实际业务工时/小时", "要求完成时间", "实际完成时间", "备注" };
public static final int[] HEADERWIDTH = new int[] { 40, 60, 120, 100, 60, 60, 60, 60, 100, 100, 100, 120, 120,
120 };
private static final long serialVersionUID = 1L;
private static Date refreshDate = null;
private TCSession session;
private Hashtable<TCFormProperty, JComponent> indices;
TCComponentForm tcForm;
private List<Component> allComponents = new ArrayList<Component>();
private TCComponentForm arg0;
private String[] assignee;//分配人首选项分割
JButton jComboBox_fpr = new JButton();
public LD6_NewProdForm(TCComponentForm arg0) throws Exception {
super(arg0);
this.arg0 = arg0;
Date currDate = new Date();
if (refreshDate == null) {
arg0.refresh();
refreshDate = currDate;
} else {
long diff = currDate.getTime() - refreshDate.getTime();
long minutes = diff / 1000 / 60;
if (minutes >= 1) {
arg0.refresh();
refreshDate = currDate;
}
}
this.session = null;
this.session = arg0.getSession();
this.tcForm = arg0;
indices = new Hashtable<TCFormProperty, JComponent>();
initializeUI();
loadRendering();
}
private void initializeUI() {
try {
//获取分派人首选项
String[] form_defoult_value = session.getPreferenceService().getStringValues("LD6_NewProdForm_defoult_value");
assignee = form_defoult_value[1].split("-");//分派人
setLayout(new BorderLayout());
setBackground(new JLabel("").getBackground());
JTabbedPane tabPane = new JTabbedPane();
tabPane.addTab("表单", getProjectManInfoPanel());
add(BorderLayout.WEST, new JLabel(" "));
add(BorderLayout.CENTER, tabPane);
add(BorderLayout.EAST, new JLabel(" "));
} catch (Exception e) {
e.printStackTrace();
}
}
private JScrollPane getProjectManInfoPanel() {
JScrollPane returnPanel = new JScrollPane();
returnPanel.setViewportView(getTablePanel());
return returnPanel;
}
@SuppressWarnings("unchecked")
@Override
public void loadRendering() throws TCException {
System.out.println("loadForm------------------------start");
// 查数据库渲染table
String formUid = arg0.getUid();
String[] value2 = session.getPreferenceService().getStringValues("LD_dbinfo2");
if (value2 == null || value2.length == 0) {
MessageBox.post("首选项LD_dbinfo配置有误请检查。", "提示", 2);
return;
} else {
Collections.addAll(dateConnList, value2);
}
Connection conn = getConn();
// MES:写入数据库
String selectSql = "SELECT * FROM LD6_NewProdForm_VALUES WHERE FormUid = ?";
System.out.println(selectSql);
List<LD6_NewProdForm_Bean> lists = new ArrayList<LD6_NewProdForm_Bean>();
try (PreparedStatement stmt = conn.prepareStatement(selectSql)) {
// 执行插入语句
stmt.setString(1, formUid);
ResultSet result = stmt.executeQuery();
while (result.next()) {
LD6_NewProdForm_Bean ld6_NewProdForm_Bean = new LD6_NewProdForm_Bean(result.getString(1),
result.getString(2), result.getString(3), result.getString(4), result.getString(5),
result.getString(6), result.getString(7), result.getString(8), result.getString(9),
result.getString(10), result.getString(11), result.getString(12), result.getDate(13),
result.getDate(14), result.getString(15),result.getDate(16),result.getString(17),result.getString(18));
System.out.println(ld6_NewProdForm_Bean);
lists.add(ld6_NewProdForm_Bean);
}
} catch (SQLException e1) {
e1.printStackTrace();
}
// 表里lists
for (int i = 0; i < lists.size(); i++) {
LD6_NewProdForm_Bean ld6_NewProdForm_Bean = lists.get(i);
tm_part.addRow(new Object[] { i + 1, ld6_NewProdForm_Bean.getNewProductTaskItem(),
ld6_NewProdForm_Bean.getAssignee(), ld6_NewProdForm_Bean.getNewProductTaskDescription(),
ld6_NewProdForm_Bean.getProcessor(), ld6_NewProdForm_Bean.getPositionGroup(),
ld6_NewProdForm_Bean.getTaskNature(), ld6_NewProdForm_Bean.getDifficultyLevel(),
ld6_NewProdForm_Bean.getUrgencyLevelCode(), ld6_NewProdForm_Bean.getEstimatedBusinessHours(),
ld6_NewProdForm_Bean.getActualBusinessHours(), ld6_NewProdForm_Bean.getDueDate(),
ld6_NewProdForm_Bean.getCompletionDate(), ld6_NewProdForm_Bean.getRemarks() });
}
}
/**
* (non-Javadoc)
*
* @see com.teamcenter.rac.form.AbstractTCForm#saveForm()
*/
@SuppressWarnings("unchecked")
@Override
public void saveRendering() {
System.out.println("触发保存");
// 数据保存到数据库
Connection conn = getConn();
// MES:写入数据库
String updateSql = "UPDATE LD6_NewProdForm_VALUES SET NewProductTaskItem = ?,Assignee = ?,NewProductTaskDescription = ?,Processor = ?,PositionGroup = ?,TaskNature = ?,DifficultyLevel = ?,UrgencyLevelCode = ?,EstimatedBusinessHours = ?,ActualBusinessHours = ?,DueDate = ?,Remarks = ? WHERE FormUid = ? AND NewProductTaskItem = ?";
for (int j = 0; j < t_part.getRowCount(); j++) {
// 添加表单数据到数据库
try (PreparedStatement stmt = conn.prepareStatement(updateSql)) {
stmt.setString(1, (String) t_part.getValueAt(j, 1));
stmt.setString(2, (String) t_part.getValueAt(j, 2));
stmt.setString(3, (String) t_part.getValueAt(j, 3));
stmt.setString(4, (String) t_part.getValueAt(j, 4));
stmt.setString(5, (String) t_part.getValueAt(j, 5));
stmt.setString(6, (String) t_part.getValueAt(j, 6));
stmt.setString(7, (String) t_part.getValueAt(j, 7));
stmt.setString(8, (String) t_part.getValueAt(j, 8));
stmt.setString(9, (String) t_part.getValueAt(j, 9));
stmt.setString(10, (String) t_part.getValueAt(j, 10));
//java.util.date 转成Java.sql.date
java.sql.Date date = new java.sql.Date(((java.util.Date)t_part.getValueAt(j, 11)).getTime());
stmt.setDate(11, date);
//stmt.setDate(12, new java.sql.Date(10000000));
stmt.setString(12, (String) t_part.getValueAt(j, 13));
stmt.setString(13, arg0.getUid());
stmt.setString(14, (String) t_part.getValueAt(j, 1));
// 执行插入语句
stmt.executeUpdate();
System.out.println("保存成功");
} catch (SQLException e1) {
e1.printStackTrace();
}
}
}
private JPanel getTablePanel() {
JPanel panel = new JPanel(new BorderLayout());
tm_part = new DefaultTableModel();
t_part = new JTable(tm_part) {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public boolean isCellEditable(int row, int column) {
if (column == 2 || column == 0 || column == 1 || column == 5 || column == 12) {// 不可编辑的列
return false;
}
// else if(column == 2) {
//
// if(assignee[row].contains("、")) {
// return true;
// }else {
// return false;
// }
//
// }
else {
return true;
}
}
};
tm_part.setDataVector(null, HEADER);
t_part.getTableHeader().setReorderingAllowed(false); // 设置列不可移动,否则会发生类型转换错误(第三列)
this.t_part.setRowHeight(23);
TableColumnModel colModel = this.t_part.getColumnModel();
int colCnt = HEADERWIDTH.length;
colModel.getColumn(0).setMaxWidth(HEADERWIDTH[0]);
for (int i = 0; i < colCnt; i++) {
colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]);
}
// 获取首选项值
String[] ld_taskNature = session.getPreferenceService().getStringValues("ld_taskNature");// 任务性质
String[] ld_taskDifficulty = session.getPreferenceService().getStringValues("ld_taskDifficulty");// 难易程度
String[] ld_urgency = session.getPreferenceService().getStringValues("ld_urgency");// 紧急程度
Map<String, Double> ld_taskNatureMap = new HashMap<String, Double>();
Map<String, Double> ld_taskDifficultyMap = new HashMap<String, Double>();
Map<String, Double> ld_urgencyMap = new HashMap<String, Double>();
// 塞下拉框值
JComboBox<String> jComboBox1 = new JComboBox<String>();
JComboBox<String> jComboBox2 = new JComboBox<String>();
JComboBox<String> jComboBox3 = new JComboBox<String>();
for (int i = 0; i < ld_taskNature.length; i++) {
String[] split = ld_taskNature[i].split("=");
ld_taskNatureMap.put(split[0], Double.parseDouble(split[1]));
jComboBox1.addItem(split[0]);
}
for (int i = 0; i < ld_taskDifficulty.length; i++) {
String[] split = ld_taskDifficulty[i].split("=");
ld_taskDifficultyMap.put(split[0], Double.parseDouble(split[1]));
jComboBox2.addItem(split[0]);
}
for (int i = 0; i < ld_urgency.length; i++) {
String[] split = ld_urgency[i].split("=");
ld_urgencyMap.put(split[0], Double.parseDouble(split[1]));
jComboBox3.addItem(split[0]);
}
// JButtonEditor buttonEditor = new JButtonEditor("Button Text", new ActionListener() {
// @Override
// public void actionPerformed(ActionEvent e) {
// // 在这里处理按钮点击事件
//
// }
// });
//t_part.getColumnModel().getColumn(2).setCellEditor(buttonEditor);
t_part.getColumnModel().getColumn(6).setCellEditor(new DefaultCellEditor(jComboBox1));
t_part.getColumnModel().getColumn(7).setCellEditor(new DefaultCellEditor(jComboBox2));
t_part.getColumnModel().getColumn(8).setCellEditor(new DefaultCellEditor(jComboBox3));
// jComboBox_fpr.addActionListener(new ActionListener() {
// @Override
// public void actionPerformed(ActionEvent e) {
// if (((String) jComboBox_fpr.getSelectedItem()).isEmpty()) {
// // 恢复上一次的选择
//
// jComboBox_fpr.setSelectedIndex(jComboBox_fpr.getSelectedIndex() - 1);
// }
// }
// });
StringValue sv = new FormatStringValue(sdf);
TableCellRenderer r = new DefaultTableRenderer(sv);
t_part.getColumnModel().getColumn(11).setCellEditor(new DatePickerCellEditor(sdf));
t_part.getColumnModel().getColumn(11).setCellRenderer(r);
// 添加鼠标监听器
t_part.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2 && t_part.columnAtPoint(e.getPoint()) == 2) { // 判断是否双击并且是在第二列
int row = t_part.rowAtPoint(e.getPoint());
int column = t_part.columnAtPoint(e.getPoint());
if (column == 2) {
// 获取被双击的单元格的数据
String value = (String) t_part.getModel().getValueAt(row, column);
// 在这里处理双击事件
System.out.println("Double-clicked on cell: Row=" + row + ", Column=" + column + ", Value=" + value);
// 这里可以添加更多的逻辑来处理双击事件
String string = assignee[row];
if(string.contains("、")) {
String[] split = string.split("、");
new ChooseDialog(split,row,column,tm_part);
}
}
}
}
});
//添加处理人监听
tm_part.addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
if (e.getType() == TableModelEvent.UPDATE) {
int row = e.getFirstRow();
int column = e.getColumn();
if(column == 4) {
String value = (String)tm_part.getValueAt(row, column);
System.out.println("Cell changed at row " + row + ", column " + column + ": new value = " + value);
String[] split = value.split("-");
if(split.length == 2) {
tm_part.setValueAt(split[1], row, column+1);
}else {
MessageBox.post("请按规定的格式:“处理人-岗位组”填写", "提示", 2);
}
}
}
}
});
this.t_part.getTableHeader().setBackground(Color.blue);
JScrollPane scroll = new JScrollPane(t_part);
panel.add(BorderLayout.CENTER, scroll);
panel.setBorder(BorderFactory.createLoweredBevelBorder());
return panel;
}
// 获取数据库连接
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;
}
// class CustomCellEditor extends DefaultCellEditor {
// private JComboBox comboBox;
//
// public CustomCellEditor(JComboBox comboBox) {
// super(comboBox);
// this.comboBox = comboBox;
// comboBox.addMouseListener(new MouseAdapter() {
// @Override
// public void mouseClicked(MouseEvent e) {
//// // 得到选中的行列的索引值
// int r = t_part.getSelectedRow();
// int c = t_part.getSelectedColumn();
// if(c == 2) {
//
//
// if(assignee[r].contains("、")) {
// String[] split = assignee[r].split("、");
// jComboBox_fpr.removeAllItems();
// for (int i = 0; i < split.length; i++) {
// jComboBox_fpr.addItem(split[i]);
// }
// //t_part.getColumnModel().getColumn(2).setCellEditor(new CustomCellEditor(tempCom));
// }else {
// //JComboBox<String> tempCom = new JComboBox<String>();
// jComboBox_fpr.removeAllItems();
// jComboBox_fpr.addItem(assignee[r]);
// //t_part.getColumnModel().getColumn(2).setCellEditor(new CustomCellEditor(tempCom));
// }
//
// }
// }
// });
// }
//
// }
}

@ -0,0 +1,212 @@
package com.langtech.plm.form;
import java.sql.Date;
public class LD6_NewProdForm_Bean {
private String clientProductFolderName;
private String clientProductFolderPUID;
private String newProductTaskItem;
private String assignee;
private String newProductTaskDescription;
private String processor;
private String positionGroup;
private String taskNature;
private String difficultyLevel;
private String urgencyLevelCode;
private String estimatedBusinessHours;
private String actualBusinessHours;
private Date dueDate;
private Date completionDate;
private String remarks;
private Date TaskAssignmentDate;
private String CustomerName;
private String FormUid;
// Getters and Setters (Accessors and Mutators)
public String getClientProductFolderName() {
return clientProductFolderName;
}
public LD6_NewProdForm_Bean(String clientProductFolderName, String clientProductFolderPUID,
String newProductTaskItem, String assignee, String newProductTaskDescription, String processor,
String positionGroup, String taskNature, String difficultyLevel, String urgencyLevelCode,
String estimatedBusinessHours, String actualBusinessHours, Date dueDate, Date completionDate,
String remarks, Date taskAssignmentDate, String customerName, String formUid) {
super();
this.clientProductFolderName = clientProductFolderName;
this.clientProductFolderPUID = clientProductFolderPUID;
this.newProductTaskItem = newProductTaskItem;
this.assignee = assignee;
this.newProductTaskDescription = newProductTaskDescription;
this.processor = processor;
this.positionGroup = positionGroup;
this.taskNature = taskNature;
this.difficultyLevel = difficultyLevel;
this.urgencyLevelCode = urgencyLevelCode;
this.estimatedBusinessHours = estimatedBusinessHours;
this.actualBusinessHours = actualBusinessHours;
this.dueDate = dueDate;
this.completionDate = completionDate;
this.remarks = remarks;
TaskAssignmentDate = taskAssignmentDate;
CustomerName = customerName;
FormUid = formUid;
}
public Date getTaskAssignmentDate() {
return TaskAssignmentDate;
}
public void setTaskAssignmentDate(Date taskAssignmentDate) {
TaskAssignmentDate = taskAssignmentDate;
}
public String getCustomerName() {
return CustomerName;
}
public void setCustomerName(String customerName) {
CustomerName = customerName;
}
public String getFormUid() {
return FormUid;
}
public void setFormUid(String formUid) {
FormUid = formUid;
}
public void setClientProductFolderName(String clientProductFolderName) {
this.clientProductFolderName = clientProductFolderName;
}
public String getClientProductFolderPUID() {
return clientProductFolderPUID;
}
public void setClientProductFolderPUID(String clientProductFolderPUID) {
this.clientProductFolderPUID = clientProductFolderPUID;
}
public String getNewProductTaskItem() {
return newProductTaskItem;
}
public void setNewProductTaskItem(String newProductTaskItem) {
this.newProductTaskItem = newProductTaskItem;
}
public String getAssignee() {
return assignee;
}
public void setAssignee(String assignee) {
this.assignee = assignee;
}
public String getNewProductTaskDescription() {
return newProductTaskDescription;
}
public void setNewProductTaskDescription(String newProductTaskDescription) {
this.newProductTaskDescription = newProductTaskDescription;
}
public String getProcessor() {
return processor;
}
public void setProcessor(String processor) {
this.processor = processor;
}
public String getPositionGroup() {
return positionGroup;
}
public void setPositionGroup(String positionGroup) {
this.positionGroup = positionGroup;
}
public String getTaskNature() {
return taskNature;
}
public void setTaskNature(String taskNature) {
this.taskNature = taskNature;
}
public String getDifficultyLevel() {
return difficultyLevel;
}
public void setDifficultyLevel(String difficultyLevel) {
this.difficultyLevel = difficultyLevel;
}
public String getUrgencyLevelCode() {
return urgencyLevelCode;
}
public void setUrgencyLevelCode(String urgencyLevelCode) {
this.urgencyLevelCode = urgencyLevelCode;
}
public String getEstimatedBusinessHours() {
return estimatedBusinessHours;
}
public void setEstimatedBusinessHours(String estimatedBusinessHours) {
this.estimatedBusinessHours = estimatedBusinessHours;
}
public String getActualBusinessHours() {
return actualBusinessHours;
}
public void setActualBusinessHours(String actualBusinessHours) {
this.actualBusinessHours = actualBusinessHours;
}
public Date getDueDate() {
return dueDate;
}
public void setDueDate(Date dueDate) {
this.dueDate = dueDate;
}
public Date getCompletionDate() {
return completionDate;
}
public void setCompletionDate(Date completionDate) {
this.completionDate = completionDate;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
@Override
public String toString() {
return "LD6_NewProdForm_Bean [clientProductFolderName=" + clientProductFolderName + ", clientProductFolderPUID="
+ clientProductFolderPUID + ", newProductTaskItem=" + newProductTaskItem + ", assignee=" + assignee
+ ", newProductTaskDescription=" + newProductTaskDescription + ", processor=" + processor
+ ", positionGroup=" + positionGroup + ", taskNature=" + taskNature + ", difficultyLevel="
+ difficultyLevel + ", urgencyLevelCode=" + urgencyLevelCode + ", estimatedBusinessHours="
+ estimatedBusinessHours + ", actualBusinessHours=" + actualBusinessHours + ", dueDate=" + dueDate
+ ", completionDate=" + completionDate + ", remarks=" + remarks + "]";
}
}

@ -0,0 +1,808 @@
package com.langtech.plm.form;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Month;
import java.time.YearMonth;
import java.time.temporal.ChronoUnit;
import java.time.temporal.WeekFields;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import org.apache.poi.xssf.usermodel.XSSFCell;
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.AIFComponentContext;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.DateButton;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout;
public class QueryNewProdFormFram extends JFrame implements ActionListener {
private TCSession session;
private JTable table;
private String[] header = new String[] { "全选", "生产订单号", "产品代码", "物料编码", "产品名称", "同步时间", "生产计划号", "批次号", "工厂",
"ERP班组编码" };
protected DefaultTableModel tm_part;
private static ArrayList<String> dateConnList = new ArrayList<String>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
private JTextField pathJTextField = new JTextField(30);
private JTextField ljhField = new JTextField(15);
private JTextField fprzhField = new JTextField(15);
private JTextField clrField = new JTextField(15);
private JTextField gwzField = new JTextField(15);
private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
private DateButton TaskassignmentStartButton;
private DateButton TaskassignmentEndButton;
private DateButton CompletionDateStartButton;
private DateButton CompletionDateEndButton;
private JButton btnQry;
private JButton outputButton = new JButton("选择");
private JButton cleanButton1 = new JButton("清除");
private JButton cleanButton2 = new JButton("清除");
private JButton cleanButton3 = new JButton("清除");
private JButton cleanButton4 = new JButton("清除");
private JTextField cpdmField;
// 名称-系数 map
private HashMap<String, Double> ld_taskNatureMap = new HashMap<String, Double>();
private HashMap<String, Double> ld_taskDifficultyMap = new HashMap<String, Double>();
private HashMap<String, Double> ld_positionGroupMap = new HashMap<String, Double>();
private HashMap<String, Double> ld_demeritMap = new HashMap<String, Double>();
public QueryNewProdFormFram(TCSession session) {
// TODO Auto-generated constructor stub
this.session = session;
initUI();
}
// private String sqlString = "delete ML_CREATEORDERBOM where STATUS='2' and PRODUCTID=? and MATERIALNO=? "
// + "and OBJECTNAME=? and PRODPLANO=? and BATCHNO=?"
// + " and FACTORY=? and REPCODE=? and PRODORDERO=?";
private String sqlString = "";
private void initUI() {
// TODO Auto-generated method stub
try {
this.setTitle("查询绩效表");
this.setLayout(new BorderLayout());
JPanel topPanel = getTopPanel();
// JScrollPane pane = getTablePanel();
// pane.setBorder(BorderFactory.createTitledBorder(""));
// JPanel btnPanel = getRightPanel();
JPanel btnPanel = getBtnPanel();
this.add(topPanel, BorderLayout.NORTH);
// this.add(pane,BorderLayout.CENTER);
this.add(btnPanel, BorderLayout.SOUTH);
this.setPreferredSize(new Dimension(800, 292));
int width2 = this.getWidth();
int height2 = this.getHeight();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸
int screenWidth = screenSize.width; // 获取屏幕宽度
int screenHeight = screenSize.height; // 获取屏幕高度
int x = (screenWidth - 550) / 2; // 计算Frame的左上角x坐标
int y = (screenHeight - 300) / 2; // 计算Frame的左上角y坐标
this.setLocation(x, y); // 设置Frame的位置
// this.setLocationRelativeTo(null);
this.createActionEvent();
this.pack();
// this.validate();
this.setVisible(true);
// this.setAlwaysOnTop(true);
} catch (Exception e) {
e.printStackTrace();
return;
}
}
// 添加监听
public void createActionEvent() {
this.btnDis.addActionListener(this);
this.btnOk.addActionListener(this);
}
private List<TCComponent> compList = new ArrayList<TCComponent>();
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Object source = e.getSource();
System.out.println("source==>+" + source);
if (this.btnDis.equals(source)) {
this.dispose();
} else if (source.equals(this.btnOk)) {
File model_file = null;
File output_file = null;
String[] value2 = session.getPreferenceService().getStringValues("LD_dbinfo2");
if (value2 == null || value2.length == 0) {
MessageBox.post("首选项LD_dbinfo配置有误请检查。", "提示", 2);
return;
} else {
Collections.addAll(dateConnList, value2);
}
// 获取计算属性
getCalculate();
sqlString = "SELECT * FROM LD6_NewProdForm_VALUES WHERE 1=1 ";
// 1.根据条件查询数据
getQuerySQL();
System.out.println(sqlString);
Connection conn = getConn();
List<LD6_NewProdForm_Bean> lists = new ArrayList<LD6_NewProdForm_Bean>();
try (PreparedStatement stmt = conn.prepareStatement(sqlString)) {
ResultSet result = stmt.executeQuery();
while (result.next()) {
LD6_NewProdForm_Bean ld6_NewProdForm_Bean = new LD6_NewProdForm_Bean(result.getString(1),
result.getString(2), result.getString(3), result.getString(4), result.getString(5),
result.getString(6), result.getString(7), result.getString(8), result.getString(9),
result.getString(10), result.getString(11), result.getString(12), result.getDate(13),
result.getDate(14), result.getString(15), result.getDate(16), result.getString(17),
result.getString(18));
System.out.println(ld6_NewProdForm_Bean);
// 过滤有处理人的数据
if (ld6_NewProdForm_Bean.getProcessor() != null
&& ld6_NewProdForm_Bean.getProcessor().contains("-")) {
lists.add(ld6_NewProdForm_Bean);
}
}
} catch (SQLException e1) {
e1.printStackTrace();
}
if (lists.size() == 0) {
MessageBox.post("未查到数据,无法导出!", "提示", 2);
return;
} else {
// 导出数据的逻辑
InputStream input;
String targetPath = null;
try {
String[] lD6_NewProdForm_ModelUid = session.getPreferenceService()
.getStringValues("LD6_NewProdForm_ModelUid");
if (lD6_NewProdForm_ModelUid == null || lD6_NewProdForm_ModelUid.length == 0) {
MessageBox.post("首选项LD6_NewProdForm_ModelUid配置有误请检查。", "提示", 2);
return;
} else {
String pathJTextFieldStr = pathJTextField.getText();
if(pathJTextFieldStr == null || pathJTextFieldStr.isEmpty()) {
MessageBox.post("请选择需要导出的路径。", "提示", 2);
return;
}
TCComponentDataset excel = (TCComponentDataset) session
.stringToComponent(lD6_NewProdForm_ModelUid[0]);
model_file = ((TCComponentDataset) excel).getTcFiles()[0].getFmsFile();
String date = new SimpleDateFormat("yyyyMMddhhmmss").format(new Date());
String fileName = "绩效查询表_" + date + ".xlsx";
// 定义源文件路径
Path sourcePath = Paths.get(model_file.getPath()); // 替换为你的源文件路径
// 定义目标文件路径
// targetPath = System.getProperty("user.home")+"\\Desktop"+"\\"+fileName;
targetPath = pathJTextFieldStr + "\\" + fileName;
// 使用Files.copy()方法复制文件
// Files.copy(sourcePath, targetPath);
// 设置可写
// makeFileWritable(System.getProperty("user.home")+"\\Desktop"+"\\"+fileName);
// output_file = new
// File(System.getProperty("user.home")+"\\Desktop"+"\\"+fileName);
}
//获取文件夹的引用
input = new FileInputStream(model_file);
XSSFWorkbook wb = new XSSFWorkbook(input);// (
XSSFSheet sheet = wb.getSheetAt(0);
sheet.getSheetName();
for (int i = 0; i < lists.size(); i++) {
LD6_NewProdForm_Bean ld6_NewProdForm_Bean = lists.get(i);
TCComponent component = session.stringToComponent(ld6_NewProdForm_Bean.getClientProductFolderPUID());
AIFComponentContext[] whereReferenced = component.whereReferenced();
String object_name = "";
for (int j = 0; j < whereReferenced.length; j++) {
String type = whereReferenced[j].getComponent().getProperty("object_type");
System.out.println("type============="+type);
if(type.equals("LD6_Customer") || type.equals("客户文件夹")) {
object_name = whereReferenced[j].getComponent().getProperty("object_name");
}
}
System.out.println("name====="+object_name);
int row = i + 2;
XSSFRow titleRow = sheet.getRow(row);
setCellValue(titleRow, 0, i + 1 + "", sheet, row);
// 零件号合零件名称逻辑
String[] split = ld6_NewProdForm_Bean.getClientProductFolderName().split("_");
setCellValue(titleRow, 1,
split.length == 2 ? split[0] : ld6_NewProdForm_Bean.getClientProductFolderName(), sheet,
row);
setCellValue(titleRow, 2,
split.length == 2 ? split[1] : ld6_NewProdForm_Bean.getClientProductFolderName(), sheet,
row);
// 1
//setCellValue(titleRow, 3, ld6_NewProdForm_Bean.getCustomerName(), sheet, row);
setCellValue(titleRow, 3, object_name, sheet, row);
setCellValue(titleRow, 4, ld6_NewProdForm_Bean.getNewProductTaskItem(), sheet, row);
setCellValue(titleRow, 5, ld6_NewProdForm_Bean.getAssignee(), sheet, row);
setCellValue(titleRow, 6, ld6_NewProdForm_Bean.getNewProductTaskDescription(), sheet, row);
setCellValue(titleRow, 7, ld6_NewProdForm_Bean.getProcessor(), sheet, row);
setCellValue(titleRow, 8, ld6_NewProdForm_Bean.getPositionGroup(), sheet, row);
setCellValue(titleRow, 9, ld6_NewProdForm_Bean.getTaskNature(), sheet, row);
setCellValue(titleRow, 10, ld6_NewProdForm_Bean.getDifficultyLevel(), sheet, row);
setCellValue(titleRow, 11, ld6_NewProdForm_Bean.getUrgencyLevelCode(), sheet, row);
setCellValue(titleRow, 12, ld6_NewProdForm_Bean.getEstimatedBusinessHours(), sheet, row);
setCellValue(titleRow, 13, ld6_NewProdForm_Bean.getActualBusinessHours(), sheet, row);
setCellValue(titleRow, 14, ld6_NewProdForm_Bean.getTaskAssignmentDate() == null ? ""
: sdf.format(ld6_NewProdForm_Bean.getTaskAssignmentDate()), sheet, row);
if (ld6_NewProdForm_Bean.getTaskAssignmentDate() != null) {
// 转换为LocalDate
LocalDate localDate = ld6_NewProdForm_Bean.getTaskAssignmentDate().toLocalDate();
// 获取年份
int year = localDate.getYear();
int month = localDate.getMonthValue() - 1;
WeekFields weekFields = WeekFields.of(Locale.getDefault());
int weekOfYear = localDate.get(weekFields.weekOfWeekBasedYear());
setCellValue(titleRow, 15, year + "", sheet, row);
setCellValue(titleRow, 16, month + "", sheet, row);
setCellValue(titleRow, 17, weekOfYear + "", sheet, row);
}
setCellValue(titleRow, 18, ld6_NewProdForm_Bean.getDueDate() == null ? ""
: sdf.format(ld6_NewProdForm_Bean.getDueDate()), sheet, row);
if (ld6_NewProdForm_Bean.getDueDate() != null) {
// 转换为LocalDate
LocalDate localDate = ld6_NewProdForm_Bean.getDueDate().toLocalDate();
// 获取年份
int year = localDate.getYear();
int month = localDate.getMonthValue() - 1;
WeekFields weekFields = WeekFields.of(Locale.getDefault());
int weekOfYear = localDate.get(weekFields.weekOfWeekBasedYear());
setCellValue(titleRow, 19, year + "", sheet, row);
setCellValue(titleRow, 20, month + "", sheet, row);
setCellValue(titleRow, 21, weekOfYear + "", sheet, row);
}
setCellValue(titleRow, 22, ld6_NewProdForm_Bean.getCompletionDate() == null ? ""
: sdf.format(ld6_NewProdForm_Bean.getCompletionDate()), sheet, row);
if (ld6_NewProdForm_Bean.getCompletionDate() != null) {
// 转换为LocalDate
LocalDate localDate = ld6_NewProdForm_Bean.getCompletionDate().toLocalDate();
// 获取年份
int year = localDate.getYear();
int month = localDate.getMonthValue() - 1;
// int day = localDate.getDayOfMonth();
// 获取日期所在年份的第几周
WeekFields weekFields = WeekFields.of(Locale.getDefault());
int weekOfYear = localDate.get(weekFields.weekOfWeekBasedYear());
setCellValue(titleRow, 23, year + "", sheet, row);
setCellValue(titleRow, 24, month + "", sheet, row);
setCellValue(titleRow, 25, weekOfYear + "", sheet, row);
setCellValue(titleRow, 26, "已完成", sheet, row);// 完成状态
}
java.sql.Date dueDate = ld6_NewProdForm_Bean.getDueDate();
java.sql.Date completionDate = ld6_NewProdForm_Bean.getCompletionDate();
// 计算得分
Double score = null;
String gwz = ld6_NewProdForm_Bean.getPositionGroup();// 岗位组
String rwxz = ld6_NewProdForm_Bean.getTaskNature();// 任务性质
String nycd = ld6_NewProdForm_Bean.getDifficultyLevel();// 难易程度
if (completionDate != null && gwz != null && !gwz.isEmpty() && rwxz != null && !rwxz.isEmpty()
&& nycd != null && !nycd.isEmpty()) {
score = ld_positionGroupMap.get(gwz) * ld_taskNatureMap.get(rwxz)
* ld_taskDifficultyMap.get(nycd);
setCellValue(titleRow, 27, score == null ? "" : score + "", sheet, row);// 得分
} else if (completionDate == null) {
setCellValue(titleRow, 27, "0", sheet, row);// 得分
}
// 计算超时扣分
if (score != null && dueDate != null && completionDate != null) {
// 计算完成时间和计划时间之间差天数
// 比较是否超时
// 比较两个日期
int result = dueDate.compareTo(completionDate);
// 判断结果
if (result < 0) {// 逾期
System.out.println("Completion date is after Due date.");
// 将java.sql.Date转换为java.time.LocalDate
LocalDate dueDateLD = dueDate.toLocalDate();
LocalDate completionDateLD = completionDate.toLocalDate();
// 计算两个日期之间的天数差
long daysBetween = ChronoUnit.DAYS.between(dueDateLD, completionDateLD);
if (daysBetween == 1) {
System.out.println("1天内");
Double csdf = score * ld_demeritMap.get("一般");
setCellValue(titleRow, 28, csdf + "", sheet, row);// 超时扣分
} else if (daysBetween == 2) {
System.out.println("2天内");
Double csdf = score * ld_demeritMap.get("严重");
setCellValue(titleRow, 28, csdf + "", sheet, row);// 超时扣分
} else if (daysBetween == 3) {
System.out.println("3天内");
Double csdf = score * ld_demeritMap.get("超严重");
setCellValue(titleRow, 28, csdf + "", sheet, row);// 超时扣分
} else if (daysBetween > 3) {
setCellValue(titleRow, 28, "超过三天", sheet, row);// 超时扣分
}
}
}
setCellValue(titleRow, 29, ld6_NewProdForm_Bean.getRemarks(), sheet, row);
}
// // 调整列宽
// for (int i = 0; i <= lists.size(); i++) { // A-N列
// sheet.autoSizeColumn(i);
// }
// 写入输出文件
try (FileOutputStream outputStream = new FileOutputStream(new File(targetPath))) {
wb.write(outputStream);
} catch (FileNotFoundException e1) {
System.err.println("目标文件未找到: " + targetPath);
e1.printStackTrace();
} catch (IOException e2) {
System.err.println("写入文件时发生错误: " + targetPath);
e2.printStackTrace();
}
this.dispose();
MessageBox.post("成功导出" + lists.size() + "条数据!", "提示", 2);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}
private void getCalculate() {
// TODO Auto-generated method stub
String[] ld_taskNature = session.getPreferenceService().getStringValues("ld_taskNature");// 任务性质
String[] ld_taskDifficulty = session.getPreferenceService().getStringValues("ld_taskDifficulty");// 难易程度
String[] ld_positionGroup = session.getPreferenceService().getStringValues("ld_positionGroup");// 岗位系数
String[] ld_demerit = session.getPreferenceService().getStringValues("ld_demerit");// 超时扣分
for (int i = 0; i < ld_positionGroup.length; i++) {
ld_positionGroupMap.put(ld_positionGroup[i].split("=")[0],
Double.parseDouble(ld_positionGroup[i].split("=")[1]));
}
for (int i = 0; i < ld_taskNature.length; i++) {
ld_taskNatureMap.put(ld_taskNature[i].split("=")[0], Double.parseDouble(ld_taskNature[i].split("=")[1]));
}
for (int i = 0; i < ld_taskDifficulty.length; i++) {
ld_taskDifficultyMap.put(ld_taskDifficulty[i].split("=")[0],
Double.parseDouble(ld_taskDifficulty[i].split("=")[1]));
}
for (int i = 0; i < ld_demerit.length; i++) {
ld_demeritMap.put(ld_demerit[i].split("=")[0], Double.parseDouble(ld_demerit[i].split("=")[1]));
}
}
// public int getWeekOfMonth(int day) {
// if(day % 7 != 0) {
// return day / 7 + 1;
// }else {
// return day / 7;
// }
// }
//
/**
*
*
* @param filePath
*/
public static void makeFileWritable(String filePath) {
File file = new File(filePath);
if (!file.exists()) {
System.out.println("File does not exist.");
return;
}
try {
// 设置文件可写true 表示可写false 表示不可写null 表示使用系统默认值
boolean success = file.setWritable(true, false); // 第二个参数表示是否只改变文件所有者的权限
if (success) {
System.out.println("File permissions set to writable.");
} else {
System.out.println("Failed to set file as writable.");
}
} catch (SecurityException se) {
System.err.println("Security exception: " + se.getMessage());
}
}
public static void setCellValue(XSSFRow row, int colum, String str, XSSFSheet sheet, int rowNum) {
if (row == null) {
// 处理空行的情况,比如插入一行或者给出提示
row = sheet.createRow(rowNum);
}
XSSFCell cell = row.getCell(colum);
if (cell == null) {
cell = row.createCell(colum);
}
cell.setCellValue(str);
}
private void getQuerySQL() {
// TODO Auto-generated method stub
String cpwjjmc = ljhField.getText();
if (!cpwjjmc.isEmpty()) {
// 如果多值
if (cpwjjmc.contains(";") || cpwjjmc.contains("")) {
String[] split = cpwjjmc.split(";");
if (split.length == 0) {
split = cpwjjmc.split("");
}
for (int i = 0; i < split.length; i++) {
sqlString += "AND ClientProductFolderName LIKE '%" + split[i] + "%' ";
}
} else {
sqlString += "AND ClientProductFolderName LIKE '%" + cpwjjmc + "%' ";
}
}
String fprzh = fprzhField.getText();
if (!fprzh.isEmpty()) {
sqlString += "AND Assignee LIKE '%" + fprzh + "%' ";
}
String clr = clrField.getText();
if (!clr.isEmpty()) {
sqlString += "AND Processor = '%" + clr + "%' ";
}
String gwz = gwzField.getText();
if (!gwz.isEmpty()) {
sqlString += "AND PositionGroup = '%" + gwz + "%' ";
}
if (TaskassignmentStartButton.getDate() != null) {
sqlString += "AND TaskAssignmentDate <='" + dateFormat.format(TaskassignmentStartButton.getDate()) + "' ";
}
if (TaskassignmentEndButton.getDate() != null) {
sqlString += "AND TaskAssignmentDate >='" + dateFormat.format(TaskassignmentEndButton.getDate()) + "' ";
}
if (CompletionDateStartButton.getDate() != null) {
sqlString += "AND CompletionDate <='" + dateFormat.format(CompletionDateStartButton.getDate()) + "' ";
}
if (CompletionDateEndButton.getDate() != null) {
sqlString += "AND CompletionDate >='" + dateFormat.format(CompletionDateEndButton.getDate()) + "' ";
}
}
private JButton btnOk;
private JButton btnDis;
private JPanel getBtnPanel() {
JPanel topPanel = new JPanel();
topPanel.setLayout(new PropertyLayout());
btnOk = new JButton("导出");
btnDis = new JButton("取消");
topPanel.add("1.1.center", btnOk);
topPanel.add("1.2.center", btnDis);
return topPanel;
}
// 查询部分
private JPanel getTopPanel() {
// TODO Auto-generated method stub
JPanel topPanel = new JPanel();
topPanel.setLayout(new PropertyLayout());
topPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
// topPanel.add("1.1.left.center",field);
topPanel.setBorder(BorderFactory.createTitledBorder("查询条件"));
topPanel.add("1.1.left.center", new JLabel(" "));
topPanel.add("2.1.left.center", getJLabel("零件号:"));
topPanel.add("2.2.left.center", ljhField);
topPanel.add("2.3.left.center", cleanButton1);
topPanel.add("2.4.left.center", getJLabel("分派人账号:"));
topPanel.add("2.5.left.center", fprzhField);
topPanel.add("2.6.left.center", cleanButton2);
topPanel.add("3.1.left.center", getJLabel("处理人:"));
topPanel.add("3.2.left.center", clrField);
topPanel.add("3.3.left.center", cleanButton3);
topPanel.add("3.4.left.center", getJLabel("岗位组:"));
topPanel.add("3.5.left.center", gwzField);
topPanel.add("3.6.left.center", cleanButton4);
TaskassignmentStartButton = new DateButton(dateFormat);
TaskassignmentEndButton = new DateButton(dateFormat);
TaskassignmentStartButton.setDate("未设置日期");
TaskassignmentEndButton.setDate("未设置日期");
CompletionDateStartButton = new DateButton(dateFormat);
CompletionDateEndButton = new DateButton(dateFormat);
CompletionDateStartButton.setDate("未设置日期");
CompletionDateEndButton.setDate("未设置日期");
// startButton.set
topPanel.add("4.1.left.center", getJLabelDate("任务分派时间(早于):"));
topPanel.add("4.2.left.center", TaskassignmentStartButton);
topPanel.add("4.3.left.center", new JLabel(" ")); // 添加空面板作为间距
topPanel.add("4.4.center.center", getJLabelDate("任务分派时间(晚于):"));
topPanel.add("4.5.left.center", TaskassignmentEndButton);
topPanel.add("5.1.left.center", getJLabelDate("实际完成时间(早于):"));
topPanel.add("5.2.left.center", CompletionDateStartButton);
topPanel.add("5.3.left.center", new JLabel(" ")); // 添加空面板作为间距
topPanel.add("5.4.center.center", getJLabelDate("实际完成时间(晚于):"));
topPanel.add("5.5.left.center", CompletionDateEndButton);
topPanel.add("6.1.left.center", new JLabel(""));
topPanel.add("7.1.left.center", new JLabel("保存路径:"));
topPanel.add("7.2.left.center", pathJTextField);
topPanel.add("7.3.left.center", outputButton);
// 增加清除按钮监听
cleanButton1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
ljhField.setText("");
}
});
cleanButton2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
fprzhField.setText("");
}
});
cleanButton3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
clrField.setText("");
}
});
cleanButton4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
gwzField.setText("");
}
});
// 注册输出按钮的点击事件监听器
outputButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// 创建文件选择器
JFileChooser fileChooser = new JFileChooser();
// 设置文件选择器只能选择文件夹
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int result = fileChooser.showOpenDialog(topPanel);
if (result == JFileChooser.APPROVE_OPTION) {
// 获取用户选择的路径
String selectedPath = fileChooser.getSelectedFile().getPath();
// 输出用户选择的路径
System.out.println("用户选择的路径:" + selectedPath);
pathJTextField.setText(selectedPath);
}
}
});
return topPanel;
}
// private JScrollPane getTablePanel() {
// // TODO Auto-generated method stub
// table = getJTable(null, null, header, null);
// table.setRowHeight(30);
// //table.setPreferredSize(new Dimension(1200,400));
// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // 设置表格的自动调整模式为关闭自动调整
// table.getColumnModel().getColumn(0).setPreferredWidth(50);
// table.addMouseListener(new MouseListener() {
//
// @Override
// public void mouseReleased(MouseEvent e) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void mousePressed(MouseEvent e) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void mouseExited(MouseEvent e) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void mouseEntered(MouseEvent e) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void mouseClicked(MouseEvent e) {
// // TODO Auto-generated method stub
// int selectColumn = table.getTableHeader().columnAtPoint(e.getPoint());
// int selectedRow = table.rowAtPoint(e.getPoint());
//// System.out.println("selectColumn==>"+selectColumn);
// if(selectColumn != 0)
// {
// return;
// }else {
// Object valueAt = table.getValueAt(selectedRow, selectColumn);
// if(valueAt.toString().equals("1")) {
// table.setValueAt("0", selectedRow, selectColumn);
// }else {
// table.setValueAt("1", selectedRow, selectColumn);
// }
// }
// }
// });
// JScrollPane pane = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
// pane.setPreferredSize(new Dimension(1200,400));
// pane.setViewportView(table);//为scrollPane指定显示对象为table
// return pane;
// }
// private DefaultTableModel map;
// public JTable getJTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) {
// int simpleLen = 150;
//// int totleLen = 1000;
// if (partsTable == null) {
// map = new DefaultTableModel(values, titleNames) {
// @Override
// public boolean isCellEditable(int row, int column) {
// return false;
// }
// };
//
// partsTable = new JTable(map) ;
//
// partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
//// Adapter1 adapter = new Adapter1(partsTable);
// partsTable.getTableHeader().setDefaultRenderer(new CheckHeaderCellRenderer(partsTable));
//// setDefaultRenderer(new CheckHeaderCellRenderer(table));
//
// partsTable.setRowHeight(30);
// // //设置显示器渲染
// partsTable.getColumnModel().getColumn(0).setCellRenderer(new TableCellCheckboxRenderer(partsTable));
//// partsTable.setDefaultRenderer(Object.class, renderer);
// partsTable.getTableHeader().setReorderingAllowed(false);
//// if (simpleLen * titleNames.length >= totleLen) {
// for (int i = 0; i < titleNames.length; i++) {
// partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen);
// }
// partsTable.setAutoResizeMode(0);
//// } else {
//// partsTable.setAutoResizeMode(1);
//// }
// }
//
// //++
// return partsTable;
// }
private JLabel getJLabel(String name) {
JLabel label = new JLabel(name);
label.setPreferredSize(new Dimension(100, 30));
return label;
}
private JLabel getJLabelDate(String name) {
JLabel label = new JLabel(name);
label.setPreferredSize(new Dimension(140, 30));
return label;
}
// 获取数据库连接
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;
}
}

@ -0,0 +1,35 @@
package com.langtech.plm.form;
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.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCSession;
public class QueryNewProdFormHandler 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() {
new QueryNewProdFormFram(session);
}
}.start();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return null;
}
}

@ -0,0 +1,44 @@
package com.langtech.plm.performancemanagement;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "com.langtech.plm.performancemanagement"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}

@ -0,0 +1,114 @@
package com.langtech.plm.performancemanagement.dialogs;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.filechooser.FileSystemView;
import com.langtech.plm.performancemanagement.operations.TaskFolderMatchingOperation;
import com.langtech.plm.performancemanagement.util.ProgressBarThread;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.PropertyLayout;
public class TaskFolderMatchingDialog extends AbstractAIFDialog implements ActionListener {
private AbstractAIFApplication app;
private TCSession session;
private JLabel fileLabel;
private JTextField fileField;
private JButton searchButton;
private JButton okButton;
private JButton celButton;
ProgressBarThread wait;
TCComponent target;
private JFileChooser jFileChooser;
// 不同于一般的构造方法,尤其是参数那儿
public TaskFolderMatchingDialog(AbstractAIFApplication app, TCComponent target) {
super(false);// 千万别忘记
this.app = app;
this.session = (TCSession) app.getSession();
this.target = target;
}
public void initUI() {
FileSystemView fsv = FileSystemView.getFileSystemView();
String deskPath = fsv.getHomeDirectory().getPath();
this.setSize(new Dimension(500, 300));
this.setTitle("导出绩效报表");
this.fileLabel = new JLabel("导出路径:");
this.fileField = new JTextField(deskPath);
this.fileField.setEditable(false);
this.searchButton = new JButton("浏览...");
this.searchButton.addActionListener(this);
this.okButton = new JButton("确定");
this.okButton.addActionListener(this);
this.celButton = new JButton("取消");
this.celButton.addActionListener(this);
JPanel centerJPanel = new JPanel(new PropertyLayout());
centerJPanel.add("1.1.left.top", this.fileLabel);
centerJPanel.add("1.2.left.top", this.fileField);
centerJPanel.add("1.3.left.top", this.searchButton);
JPanel rootJPanel = new JPanel(new FlowLayout());
rootJPanel.add(okButton);
rootJPanel.add(celButton);
this.setLayout(new BorderLayout());
this.add(centerJPanel, BorderLayout.CENTER);
this.add(rootJPanel, BorderLayout.SOUTH);
this.centerToScreen();
this.pack();
this.showDialog();
// 初始化文件选择器
this.jFileChooser = new JFileChooser();
// 设置当前打开文件选择器的默认的路径
this.jFileChooser.setCurrentDirectory(new File(deskPath));
}
@Override
public void run() {
initUI();
}
public void selectFileButtonEvent() {
// 设定只能选择到文件
jFileChooser.setFileSelectionMode(1);// 只能选择到路径
// 此句是打开文件选择器界面的触发语句
int state = jFileChooser.showOpenDialog(null);
if (state == 1) {
return;
} else {
// f为选择到的目录,核心代码
File f = jFileChooser.getSelectedFile();
fileField.setText(f.getAbsolutePath());
}
}
public void actionPerformed(ActionEvent arg0) {
Object sourceObj = arg0.getSource();
if (sourceObj.equals(this.searchButton)) {
selectFileButtonEvent();
} else if (sourceObj.equals(this.okButton)) {
this.disposeDialog();
this.dispose();
String filePath = this.fileField.getText();
wait = new ProgressBarThread(" ", "执行中,请稍等...");
wait.start();
TaskFolderMatchingOperation operation = new TaskFolderMatchingOperation(filePath, target, session, wait);
this.session.queueOperation(operation);
} else {
this.disposeDialog();
this.dispose();
}
}
}

@ -0,0 +1,44 @@
package com.langtech.plm.performancemanagement.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.langtech.plm.performancemanagement.dialogs.TaskFolderMatchingDialog;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
/**
*
*
*
*/
public class TaskFolderMatchingHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
TCSession session = (TCSession) app.getSession();
TCComponent target = null;
target = (TCComponent) app.getTargetComponent();
// 选中项目类型,否则报错
if(target==null) {
MessageBox.post("请选择客户成品文件夹", "", MessageBox.INFORMATION);
}else {
String type = target.getType();
if (type.equals("LD6_CusProdFolder") || type.equals("客户成品文件夹")) {
TaskFolderMatchingDialog dialog = new TaskFolderMatchingDialog(app, target);
new Thread(dialog).start();
} else {
MessageBox.post("请选择客户成品文件夹", "", MessageBox.INFORMATION);
}
}
return null;
}
}

@ -0,0 +1,569 @@
package com.langtech.plm.performancemanagement.operations;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.langtech.plm.performancemanagement.util.ProgressBarThread;
import com.langtech.plm.performancemanagement.util.SqlUtil;
import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentTcFile;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.FileUtility;
import com.teamcenter.rac.util.MessageBox;
public class TaskFolderMatchingOperation extends AbstractAIFOperation {
// private AbstractAIFApplication app;
private String filePath;
private TCSession session;
private ProgressBarThread wait;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
TCComponent target;
Date processStartDate = null;
Date processEndDate = null;
public TaskFolderMatchingOperation(String filePath, TCComponent target, TCSession session, ProgressBarThread wait) {
this.filePath = filePath;
this.target = target;
this.session = session;
this.wait = wait;
}
@Override
public void executeOperation() throws Exception {
String[] ldSqlServer = session.getPreferenceService().getStringValues("ld_sqlserver");
if (!getMessageInfo(ldSqlServer, "ld_sqlserver")) {
return;
}
// 检查报表模板是否存在首选项ld_billboards_uid
String ldBillboardsUid = session.getPreferenceService().getStringValue("ld_billboards_uid");
if (!getMessageboxInfo(ldBillboardsUid, "ld_billboards_uid")) {
return;
}
TCComponent billboard = null;
try {
billboard = session.stringToComponent(ldBillboardsUid);
} catch (TCException e) {
e.printStackTrace();
MessageBox.post("请通知管理员检查首选项ld_billboards_uid是否配置", "", MessageBox.INFORMATION);
return;
}
if (billboard == null) {
MessageBox.post("请通知管理员检查首选项ld_billboards_uid是否配置", "", MessageBox.INFORMATION);
return;
}
// 获取岗位系数 任务性质 难度系数 紧张度系数 要求完成时间公式的首选项
String[] ldPostCoefficient = session.getPreferenceService().getStringValues("ld_postCoefficient");
String[] ldTaskNature = session.getPreferenceService().getStringValues("ld_taskNature");// 任务性质对应的系数
String[] ldTaskDifficulty = session.getPreferenceService().getStringValues("ld_taskDifficulty");// 难度系数
String[] ldUrgency = session.getPreferenceService().getStringValues("ld_urgency");
// 超时配置
String[] ldOvertime = session.getPreferenceService().getStringValues("ld_overtime");// 严重等级:天数区间(整数)[0,0]:扣分系数;一般:(0,1]:1/5;严重:(1,2]:1/3;超严重:(2,3]:1/2;未定义:[3,1000):0.6
// 流程信息配置成 任务包名称=流程名称:审核节点名称
String[] ldProcessReview = session.getPreferenceService().getStringValues("ld_processReview");
// 要求完成时间公式 多值形式 新品任务项名称=要求完成时间公式 例如铸件资料=E-30 其中 E代表流程发起时间 F代表工艺程序结束时间
String[] ldRequestTime = session.getPreferenceService().getStringValues("ld_requestTime");
if (!getMessageInfo(ldPostCoefficient, "ld_processReview")) {
return;
}
if (!getMessageInfo(ldTaskNature, "ld_taskNature")) {
return;
}
if (!getMessageInfo(ldUrgency, "ld_urgency")) {
return;
}
if (!getMessageInfo(ldTaskDifficulty, "ld_taskDifficulty")) {
return;
}
if (!getMessageInfo(ldProcessReview, "ld_processReview")) {
return;
}
if (!getMessageInfo(ldOvertime, "ld_overtime")) {
return;
}
if (!getMessageInfo(ldRequestTime, "ld_requestTime")) {
return;
}
Map<String, String> postCoefficientMap = new HashMap<String, String>();// 岗位,岗位系数
Map<String, String> taskNatureMap = new HashMap<String, String>();// 任务性质,任务系数
Map<String, String> taskDifficultyMap = new HashMap<String, String>();// 任务难度,难度系数
Map<String, String> urgencyMap = new HashMap<String, String>();// 紧急程度,紧急程度系数
Map<String, String> processReviewMap = new HashMap<String, String>();// 流程名称,指派的节点名称
Map<String, String> severityIntervalMap = new HashMap<String, String>();// 键:天数区间;值:扣分系数
Map<String, String> requestTimeMap = new HashMap<String, String>();// 键:新品任务项名称;值:公式
for (int i = 0; i < ldPostCoefficient.length; i++) {
String value = ldPostCoefficient[i];
postCoefficientMap.put(value.split("=")[0], value.split("=")[1]);
}
for (int i = 0; i < ldRequestTime.length; i++) {
String value = ldRequestTime[i];
requestTimeMap.put(value.split("=")[0], value.split("=")[1]);
}
for (int i = 0; i < ldTaskNature.length; i++) {
String value = ldTaskNature[i];
taskNatureMap.put(value.split("=")[0], value.split("=")[1]);
}
for (int i = 0; i < ldTaskDifficulty.length; i++) {
String value = ldTaskDifficulty[i];
taskDifficultyMap.put(value.split("=")[0], value.split("=")[1]);
}
for (int i = 0; i < ldUrgency.length; i++) {
String value = ldUrgency[i];
urgencyMap.put(value.split("=")[0], value.split("=")[1]);
}
for (int i = 0; i < ldProcessReview.length; i++) {
String value = ldProcessReview[i];
processReviewMap.put(value.split("=")[0], value.split("=")[1]);
}
for (int i = 0; i < ldOvertime.length; i++) {
String dayInterval = ldOvertime[i].split(":")[1];
// String severity = ldOvertime[i].split(":")[0];
String point = ldOvertime[i].split(":")[2];
severityIntervalMap.put(dayInterval, point);
}
// 下载报表命名引用和任务要求表的命名引用
String billboardAddress = downLoadFile(billboard);
// TODO 获取工艺结束时间
String targetName = "";
try {
targetName = target.getProperty("object_name");
} catch (TCException e) {
e.printStackTrace();
}
getProcessTime(targetName);// E、 F
if (processEndDate == null || processStartDate == null) {
MessageBox.post("请检查是否设置或者导入相关客户成品文件夹名称和工艺程序结束时间", "", MessageBox.INFORMATION);
return;
}
// 获取任务包的流程 组织
// 先遍历底层结构
String path = "";
String link = "/";
List<String> taskPathList = new ArrayList<String>();
Map<String, TCComponent> folderMap = new HashMap<String, TCComponent>();// 键:文件夹层级结构 值:文件夹对象
getAllFolderPath(target, path, link, taskPathList, folderMap);
// 获取首选项Connor_JXFolder
Map<String, List<String>> packageMap = new HashMap<String, List<String>>();
String connorJXFolderPreference = "Connor_JXFolder";
String[] ConnorJXFolders = session.getPreferenceService().getStringValues(connorJXFolderPreference);
if (!getMessageInfo(ConnorJXFolders, connorJXFolderPreference)) {
return;
}
for (int i = 0; i < ConnorJXFolders.length; i++) {
String[] values = ConnorJXFolders[i].split("=");
String[] folders = values[1].split(";");
List<String> folderList = Arrays.asList(folders);
packageMap.put(values[0], folderList);
}
// 读取报表信息
File file = new File(billboardAddress);
XSSFWorkbook workbook = null;
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
workbook = new XSSFWorkbook(fis);
} catch (IOException e) {
e.printStackTrace();
}
XSSFSheet sheet = workbook.getSheet("新品任务分配表");
int rowNum = sheet.getLastRowNum();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HHmm");
for (int i = 1; i < rowNum; i++) {
XSSFRow row = sheet.getRow(i);
String cellBValue = row.getCell(1).getStringCellValue().trim();// 任务包名
List<String> folderList = packageMap.get(cellBValue);
if (folderList != null && folderList.size() > 0) {
String folderPath = folderList.get(0);
System.out.println("任务包名:" + folderPath);
TCComponent folder = folderMap.get(folderPath);
if (folder == null) {
continue;
}
// "任务性质", "难易程度", "紧急程度", "额定业务工时(小时)",
String[] properties = new String[] { "object_desc", "ld6_WorkFold01", "ld6_WorkFold02",
"ld6_WorkFold03", "ld6_WorkFold04", "fnd0AllWorkflows" };
TCProperty[] tcproperties = null;
try {
tcproperties = folder.getTCProperties(properties);
} catch (TCException e) {
e.printStackTrace();
}
// 新品任务要求描述
String objectDesc = tcproperties[0].getStringValue();
String taskNature = tcproperties[1].getDisplayValue();
String difficulty = tcproperties[2].getDisplayValue();
String urgency = tcproperties[3].getDisplayValue();
String ratedBusinessHours = tcproperties[4].getStringValue();
String taskNatureCoefficient = taskNatureMap.get(taskNature);
String taskDifficultyCoefficient = taskDifficultyMap.get(difficulty);
String urgencyCoefficient = urgencyMap.get(urgency);
String postCoefficient = "";// 待定
// 获取流程信息
String processReview = processReviewMap.get(cellBValue);
System.out.println("processReview:" + processReview);
if (processReview.length() == 0) {
continue;
}
String processName = processReview.split(":")[0];
String reviewName = processReview.split(":")[1];
String assignee = "";// 被指派者fnd0Assignee如果流程任务没有经过转发被指派者即流程接受者等同于责任方
String assigner = "";// 指派者fnd0Assigner如果流程任务没有经过转发这个属性没有值可以取被指派者
String assigneeGroup = "";// 被指派者的组
String status = "";// 流程状态
// String startData = "";// 流程开始时间
String endDateValue = "";// 流程结束时间
String actualHours = "";// 实际业务工时
String deductPoints = "";// 超时扣分
// String remark = "";// 备注(暂时让用户导出后,自己手填)
String assignStartDay = "";// 任务分派时间
String requestEndDay = "";// 要求完成时间
row.getCell(5).setCellValue(objectDesc);
row.getCell(8).setCellValue(taskNature);
row.getCell(9).setCellValue(difficulty);
row.getCell(10).setCellValue(urgency);
row.getCell(11).setCellValue(ratedBusinessHours);
TCComponent[] workflows = tcproperties[5].getReferenceValueArray();
for (int j = 0; j < workflows.length; j++) {
TCComponent workflow = workflows[j];
try {
String[] workflowProperties = new String[] { "object_name", "fnd0ActuatedInteractiveTsks",
"fnd0EndDate", "fnd0StartDate", "fnd0Status" };
TCProperty[] workflowTcProperties = workflow.getTCProperties(workflowProperties);
String workflowName = workflowTcProperties[0].getDisplayValue();
TCComponent[] reviews = workflowTcProperties[1].getReferenceValueArray();
if (workflowName.equals(processName)) {
for (int k = 0; k < reviews.length; k++) {
TCComponent review = reviews[k];
String typeName = review.getType();
System.out.println("流程节点类型:" + typeName);
if (typeName.equals("签发") || typeName.equals("Signoff")) {// 任务fnd0AliasTaskName;执行者fnd0Performer
// fnd0AssigneeGroupRole owning_group
String[] reviewProperties = new String[] { "fnd0AliasTaskName", "fnd0Performer",
"owning_group", "fnd0Assigner", "fnd0Assignee" };
TCProperty[] reviewTcProperties = review.getTCProperties(reviewProperties);
String aliasTaskName = reviewTcProperties[0].getDisplayValue();
System.out.println("aliasTaskName:" + aliasTaskName);
if (aliasTaskName.contains(":")) {
String reviewNodeName = aliasTaskName.split(":")[0].trim();
System.out.println("reviewNodeName:" + reviewNodeName);
System.out.println("reviewName:" + reviewName);
if (reviewNodeName.equals(reviewName)) {
assignee = reviewTcProperties[4].getDisplayValue();
assigneeGroup = reviewTcProperties[2].getDisplayableValue();
System.out.println("岗位组:" + assigneeGroup);
TCProperty assigneeProperty = reviewTcProperties[3];
if (assigneeProperty.getDisplayValue().length() > 0) {
assigner = assigneeProperty.getDisplayValue();
} else {
assigner = assignee;
}
row.getCell(4).setCellValue(assigner);
row.getCell(6).setCellValue(assignee);
row.getCell(7).setCellValue(assigneeGroup);
}
}
status = workflowTcProperties[4].getDisplayValue().equals("已完成") ? "已完成" : "未完成";
row.getCell(16).setCellValue(status);
endDateValue = workflowTcProperties[2].getDisplayValue();
Date startDate = workflowTcProperties[3].getDateValue();
assignStartDay = new SimpleDateFormat("yyyy-MM-dd").format(processStartDate);
Date endDate = workflowTcProperties[2].getDateValue();
actualHours = "" + (endDate.getTime() - startDate.getTime()) / 1000 / 3600;
float point = (float) 0.0;
row.getCell(12).setCellValue(actualHours);
row.getCell(13).setCellValue(assignStartDay);
row.getCell(15).setCellValue(endDateValue);
if (status.equals("已完成")) {
ZoneId zoneId = ZoneId.systemDefault();
Instant instantEnd = endDate.toInstant();
// Instant instantProcessEnd = processEndDate.toInstant();
LocalDate localEndDate = instantEnd.atZone(zoneId).toLocalDate();
// LocalDate localProcessEndDate = instantProcessEnd.atZone(zoneId).toLocalDate();
// TODO 重新设定要求完成时间localEndDate
String formation = requestTimeMap.get(cellBValue);
System.out.println("formation:" + formation);
Date formateDate = null;
if (formation.contains("E")) {
formateDate = processStartDate;
} else if (formation.contains("F")) {
formateDate = processEndDate;
}
Instant instantFormateDate = formateDate.toInstant();
LocalDate localFormateDate = instantFormateDate.atZone(zoneId).toLocalDate();
if (formation.contains("+")) {
long daysToAdd = Long.valueOf(formation.split("+")[1]);
System.out.println("daysToAdd:" + daysToAdd);
localFormateDate = localFormateDate.plusDays(daysToAdd);
} else if (formation.contains("-")) {
long daysToMinus = Long.valueOf(formation.split("-")[1]);
System.out.println("前:" + localFormateDate);
localFormateDate = localFormateDate.minusDays(daysToMinus);
System.out.println("后:" + localFormateDate);
System.out.println("daysToMinus:" + daysToMinus);
}
requestEndDay = new SimpleDateFormat("yyyy-MM-dd").format(
Date.from(localFormateDate.atStartOfDay().atZone(zoneId).toInstant()));
row.getCell(14).setCellValue(requestEndDay);
// requestEndDay = sdf.format(Date.from(instantFormateDate));
long diff = localEndDate.toEpochDay() - localFormateDate.toEpochDay();
System.out.println("diff:" + diff);
String overtimeCoefficient = "";// 扣分系数
postCoefficient = postCoefficientMap.get(assigneeGroup);
for (Map.Entry<String, String> me : severityIntervalMap.entrySet()) {
String interval = me.getKey();
System.out.println("interval:" + interval);
String startDay = interval.split(",")[0];
String endDay = interval.split(",")[1];
boolean condition1 = false;
boolean condition2 = false;
if (startDay.startsWith("[")) {
int startInt = Integer
.valueOf(startDay.substring(1, startDay.length()));
System.out.println("startInt:" + startInt);
condition1 = diff >= startInt ? true : false;
} else if (startDay.startsWith("(")) {
int startInt = Integer
.valueOf(startDay.substring(1, startDay.length()));
System.out.println("startInt:" + startInt);
condition1 = diff > startInt ? true : false;
}
if (endDay.endsWith("]")) {
int endInt = Integer.valueOf(endDay.substring(0, endDay.length() - 1));
System.out.println("endInt:" + endInt);
condition2 = diff <= endInt ? true : false;
} else if (endDay.endsWith(")")) {
int endInt = Integer.valueOf(endDay.substring(0, endDay.length() - 1));
System.out.println("endInt:" + endInt);
condition2 = diff < endInt ? true : false;
}
if (condition1 == true && condition2 == true) {
overtimeCoefficient = me.getValue();
} else {
continue;
}
}
System.out.println("overtimeCoefficient:" + overtimeCoefficient);
System.out.println("postCoefficient:" + postCoefficient);
System.out.println("taskNatureCoefficient:" + taskNatureCoefficient);
System.out.println("taskDifficultyCoefficient:" + taskDifficultyCoefficient);
System.out.println("urgencyCoefficient:" + urgencyCoefficient);
if (!overtimeCoefficient.equals("")) {
point = 1 * Float.valueOf(overtimeCoefficient)
* Float.valueOf(postCoefficient)
* Float.valueOf(taskNatureCoefficient)
* Float.valueOf(taskDifficultyCoefficient)
* Float.valueOf(urgencyCoefficient);
deductPoints = point + "";
row.getCell(17).setCellValue(deductPoints);
}
}
}
}
}
} catch (TCException e) {
e.printStackTrace();
}
}
} else {
continue;
}
}
// 导出
String fileName = "绩效报表" + sdf.format(new Date()) + ".xlsx";
filePath = filePath + File.separator + fileName;
try {
FileOutputStream os = new FileOutputStream(filePath);
workbook.write(os);
os.close();
fis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
wait.setBool(true);
wait.interrupt();
MessageBox.post("完成,详见:" + filePath, "", MessageBox.INFORMATION);
}
/**
*
*
* @throws SQLException
* @throws ParseException
*/
private void getProcessTime(String targetName) throws SQLException, ParseException {
String[] ldSqlServer = session.getPreferenceService().getStringValues("ld_sqlserver");
String databaseName = ldSqlServer[0];
String databasePassword = ldSqlServer[1];
String databaseUrl = ldSqlServer[2];
String databaseDriver = ldSqlServer[3];
String tableName = ldSqlServer[4];
SqlUtil.getConnection(databaseName, databasePassword, databaseUrl, databaseDriver);
String searchQuestion = "";
String folderName = targetName;
searchQuestion = SqlUtil.getSelectSql_1(tableName, "proj_cus_prod_folder", folderName);
ResultSet set = SqlUtil.read(searchQuestion);// 执行语句
System.out.println(searchQuestion);
set = SqlUtil.read(searchQuestion);// 执行语句
String projProgEnd = "";
String projProgStart = "";
if (set.next()) {
projProgEnd = set.getString("proj_prog_end");// 工艺程序结束 字符串存储格式2023/12/14
projProgStart = set.getString("proj_prog_start");// 工艺程序开始 字符串存储格式2023/12/14
}
// 关闭数据库
SqlUtil.freeAll();//
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
processStartDate = sdf.parse(projProgStart);
processEndDate = sdf.parse(projProgEnd);
}
/**
*
*
* @param preferenceValue
* @param preferenceName
* @return false
*/
private boolean getMessageInfo(String[] preferenceValue, String preferenceName) {
if (preferenceValue == null || preferenceValue.length == 0) {
MessageBox.post("请通知管理员检查首选项" + preferenceName + "是否配置", "", MessageBox.INFORMATION);
return false;
}
return true;
}
/**
*
*
* @param preferenceValue
* @param preferenceName
* @return false
*/
private boolean getMessageboxInfo(String preferenceValue, String preferenceName) {
if (preferenceValue == null || preferenceValue.length() == 0) {
MessageBox.post("请通知管理员检查首选项" + preferenceName + "是否配置", "", MessageBox.INFORMATION);
return false;
}
return true;
}
/**
* 便map
*
* @param target
* @param path
* @param link
* @param taskPathList
* @param folderMap
*/
private void getAllFolderPath(TCComponent target, String path, String link, List<String> taskPathList,
Map<String, TCComponent> folderMap) {
try {
TCComponent[] contents = target.getRelatedComponents("contents");
for (int i = 0; i < contents.length; i++) {
TCComponent content = contents[i];
String contentType = content.getType();
String mergePath = "";
if (contentType.equals("LD6_ProjMaFolder")) {
TCComponent[] childContents = content.getRelatedComponents("contents");
if (path.length() > 0) {
mergePath = path + link;
}
mergePath = mergePath + content.getProperty("object_name");
if (childContents.length > 0) {
getAllFolderPath(content, mergePath, link, taskPathList, folderMap);
} else {
taskPathList.add(mergePath);
System.out.println("mergePath:" + mergePath);
folderMap.put(mergePath, content);
}
}
}
} catch (TCException e) {
e.printStackTrace();
}
}
/**
*
*
* @param
* @return
*/
public String downLoadFile(TCComponent comp) {
if (comp == null) {
return "";
}
String value = "";
String tempPath = System.getenv("TEMP");
if (tempPath == null) {
tempPath = "";
} else if (!tempPath.endsWith("\\")) {
tempPath = tempPath + "\\";
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
try {
if (comp instanceof TCComponentDataset) {
TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp).getTcFiles();
File file = null;
System.out.println("tcFiles:" + tcFiles.length);
if (tcFiles != null && tcFiles.length != 0) {
file = tcFiles[0].getFmsFile();
String fileName = file.getName();
System.out.println("fileName:" + fileName);
String fileDix = fileName.substring(fileName.lastIndexOf("."), fileName.length());
fileName = tempPath + sdf.format(new Date()) + fileDix;
File dirFile = new File(fileName);
FileUtility.copyFile(file, dirFile);
return fileName;
}
}
} catch (TCException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return value;
}
}

@ -0,0 +1,171 @@
/**
* @file ProgressBar.java
*
* @brief Create progress bar
*
* @author Yanghui
*
* @history
* ================================================================
* Date Name Description of Change
* 25-July-2008 Yanghui this class is used to create
* progress bar.
*/
package com.langtech.plm.performancemanagement.util;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.Timer;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.util.PropertyLayout;
import com.teamcenter.rac.util.Registry;
/**
* @class ProgressBar
* @brief Create progress bar
* @author Yanghui
*/
public class ProgressBar extends AbstractAIFDialog implements ActionListener {
/**
* @var ProgressBar.progressbar
* @brief JProgressBar
*/
private JProgressBar progressbar;
/**
* @var ProgressBar.label
* @brief label used to tips
*/
private JLabel label;
/**
* @var ProgressBar.timer
* @brief timer used to timing operation
*/
private Timer timer;
/**
* @var ProgressBar.bool
* @brief bool used to flag thread return
*/
private boolean bool = false;
/**
* @var Progressbar.registry
* @brief Registry
*/
private Registry registry;
/**
* @fn public ProgressBar()
* @brief constructor
* @param[in] null
*/
private String showLable = null ;
public ProgressBar(String showlable) {
super(true);
showLable = showlable;
this.setAlwaysOnTop(true);
}
/**
* @fn public void setBool(boolean bool)
* @brief set bool value
* @param[in] bool
* @param[out] null
*/
public void setBool(boolean bool) {
this.bool = bool;
}
/**
* @fn private void initUI()
* @brief createDialog method
* @param[in] null
* @param[out] null
*/
public void initUI() {
Container container = getContentPane();
JPanel mainPanel = new JPanel(new PropertyLayout());
this.label = new JLabel(showLable, JLabel.CENTER);
this.progressbar = new JProgressBar();
this.progressbar.setOrientation(JProgressBar.HORIZONTAL);
this.progressbar.setMinimum(0);
this.progressbar.setMaximum(100);
this.progressbar.setValue(0);
this.progressbar.setPreferredSize(new Dimension(200, 15));
this.progressbar.setBorderPainted(true);
this.timer = new Timer(50, (ActionListener) this);
this.timer.setRepeats(false);
mainPanel.add("1.1.center", new JLabel(" "));
mainPanel.add("2.1.center", label);
mainPanel.add("3.1.center", progressbar);
mainPanel.add("4.1.center", new JLabel(" "));
container.add(mainPanel);
pack();
setLocation(500, 200);
TaskThread thread = new TaskThread(this);
thread.start();
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
bool = true;
}
});
this.setVisible(true);
}
/**
* @class TaskThread
* @brief Create progressbar
*
*/
class TaskThread extends Thread {
private ProgressBar bar;
public TaskThread(ProgressBar bar) {
this.bar = bar;
}
public void run() {
if (bool == false) {
// Set Status is running.
// session.setStatus(registry.getString("export Running"));
}
for (int i = 0; i < i + 1; i++) {
timer.start();
int value = progressbar.getValue();
if (value < 100) {
value = value + 5;
progressbar.setValue(value);
} else {
timer.stop();
progressbar.setValue(0);
}
try {
sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (bool == true) {
bar.setVisible(false);
bar.dispose();
return;
}
}
}
}
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
}
}

@ -0,0 +1,41 @@
/**
* @file ProgressBarThread.java
*
* @brief control progressBar.
*
* @author Yanghui
*
* @history
* ================================================================
* Date Name Description of Change
* 08-Auguest-2008 Yanghui this class is used to control
* progress bar.
*/
package com.langtech.plm.performancemanagement.util;
/**
* @class ProgressBarThread
* @brief Create progress bar thread
* @author Yanghui
*/
public class ProgressBarThread extends Thread {
private ProgressBar bar;
private String title;
public ProgressBarThread(String title,String showLable) {
this.title = title;
bar = new ProgressBar(showLable);
}
public void run() {
bar.setTitle(title);
bar.initUI();
}
public void setBool(boolean bool) {
bar.setBool(true);
bar.setAlwaysOnTop(false);
}
}

@ -0,0 +1,819 @@
package com.langtech.plm.performancemanagement.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.Registry;
/**
* final,,便使 PreparedStatementResultSet
*
* @author hub 2015-02-06
*/
public final class SqlUtil {
public static Connection connection = null;
public static PreparedStatement ps = null;
public static ResultSet rs = null;
private static Registry reg = Registry.getRegistry("com.langtech.plm.performancemanagement.util.database");
/**
* new
*/
private SqlUtil() {
}
static {
String driver = reg.getString("SQLSERVER_DRIVER"); // 一旦注册成功,修改配置,就要清缓存重新注册
if (driver == null) {
driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
}
driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
System.out.println("driver " + driver);
try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
System.out.println("SQLSERVER DRIVER IS EXCEPTION");
e.printStackTrace();
}
}
/**
*
*/
public static Connection getConnection() {
try {
String driver_temp = reg.getString("SQLSERVER_DRIVER");
String url = reg.getString("SQLSERVER_URL");// getProperties("URL");
String dbName = reg.getString("SQLSERVER_NAME");// Util.getProperties("dbName");
String dbPassword = reg.getString("SQLSERVER_PASSWORD");// Util.getProperties("dbPassword");
// String driver_temp =
// "com.microsoft.jdbc.sqlserver.SQLServerDriver";
// String url =
// "jdbc:microsoft:sqlserver://10.200.1.33:1433;DatabaseName=ecology";//
// getProperties("URL");
// String dbName = "tc";// Util.getProperties("dbName");
// String dbPassword = "Tc123456";//
// Util.getProperties("dbPassword");
System.out.println("SQLSERVER_DRIVER:" + driver_temp);
System.out.println("SQLSERVER_URL:" + url);
System.out.println("SQLSERVER_NAME:" + dbName);
System.out.println("SQLSERVER_PASSWORD:" + dbPassword);
// int a=1;
// if(a==1){
// return connection;
// }
if (driver_temp == null || url == null || dbName == null || dbPassword == null) {
MessageBox.post("请检查数据库首选项是否配置正确", "错误提示", MessageBox.ERROR);
}
// else{
// MessageBox.post(driver_temp+" | "+url+" | "+dbName+" |
// "+dbPassword,"错误提示",MessageBox.ERROR);
//
// }
System.out.println(url + dbName + dbPassword);
connection = DriverManager.getConnection(url, dbName, dbPassword);
// connection.setAutoCommit(false);//在连接sqlserver数据库时必须注释
} catch (SQLException e) {
System.out.println(" CONNECT EXCEPTION");
e.printStackTrace();
return null;
// MessageBox.post("ORACEL CONNECT EXCEPTION
// \n"+e.getMessage(),"ERROR",MessageBox.ERROR);
}
return connection;
}
/**
*
*/
public static Connection getConnection(String dbName, String dbPassword, String url, String driverTemp) {
try {
if (driverTemp == null || url == null || dbName == null || dbPassword == null) {
MessageBox.post("请检查数据库首选项是否配置正确", "错误提示", MessageBox.ERROR);
}
// else{
// MessageBox.post(driver_temp+" | "+url+" | "+dbName+" |
// "+dbPassword,"错误提示",MessageBox.ERROR);
//
// }
System.out.println(url +":"+ dbName +":"+ dbPassword);
connection = DriverManager.getConnection(url, dbName, dbPassword);
// connection.setAutoCommit(false);
} catch (SQLException e) {
System.out.println("SQLSERVER CONNECT EXCEPTION");
e.printStackTrace();
return null;
// MessageBox.post("ORACEL CONNECT EXCEPTION
// \n"+e.getMessage(),"ERROR",MessageBox.ERROR);
}
return connection;
}
/**
*
*/
public static Connection getConnection(String url, String dbName, String dbPassword) {
try {
String driver_temp = reg.getString("SQLSERVER_DRIVER");
System.out.println(url + dbName + dbPassword);
connection = DriverManager.getConnection(url, dbName, dbPassword);
connection.setAutoCommit(false);
} catch (SQLException e) {
System.out.println("ORACEL CONNECT EXCEPTION");
e.printStackTrace();
// MessageBox.post("ORACEL CONNECT EXCEPTION
// \n"+e.getMessage(),"ERROR",MessageBox.ERROR);
return null;
}
return connection;
}
/**
* SELECT
*
* @param tableName
* @param selectElement
* @param args
* @return
*/
public static String getSelectSql(String tableName, String[] selectElement, String... args) {
StringBuffer valuesSB = new StringBuffer("SELECT ");
if (selectElement != null) {
for (String element : selectElement) {
valuesSB.append(element).append(",");
}
valuesSB.delete(valuesSB.length() - 1, valuesSB.length());
}
valuesSB.append(" FROM ");
valuesSB.append(tableName);
valuesSB.append(" WHERE");
for (int i = 0; i < args.length; i++) {
valuesSB.append(" ");
valuesSB.append(args[i]);
valuesSB.append("=? ");
valuesSB.append("AND");
}
valuesSB.delete(valuesSB.length() - 3, valuesSB.length());
return valuesSB.toString();
}
/**
* SELECT
*
* @param tableName
* @param selectElement
* @param args
* @return
*/
public static String getSelectSql_1(String tableName, String selectElement, String keyword) {
StringBuffer valuesSB = new StringBuffer("SELECT *");
valuesSB.append(" FROM ");
valuesSB.append(tableName);
valuesSB.append(" WHERE ");
valuesSB.append(selectElement);
valuesSB.append(" = '");
valuesSB.append(keyword);
valuesSB.append("'");
return valuesSB.toString();
}
/**
* SELECT
*
* @param tableName
* @param selectElement
* @param args
* @return
*/
public static String getSelectSql_2(String tableName, String[] selectElement, Object[] keyword) {
StringBuffer valuesSB = new StringBuffer("SELECT *");
valuesSB.append(" FROM ");
valuesSB.append(tableName);
valuesSB.append(" WHERE ");
for (int i = 0; i < keyword.length; i++) {
valuesSB.append(selectElement[i]);
valuesSB.append(" = '");
valuesSB.append(keyword[i]);
valuesSB.append("'");
if (i < keyword.length - 1) {
valuesSB.append(" and ");
}
}
return valuesSB.toString();
}
/**
* SELECT
*
* @param tableName
* @param selectElement
* @param args
* @return
*/
public static String getSelectSql_3(String tableName, String selectElement, String keyword) {
StringBuffer valuesSB = new StringBuffer("SELECT *");
valuesSB.append(" FROM ");
valuesSB.append(tableName);
valuesSB.append(" WHERE ");
valuesSB.append(selectElement);
valuesSB.append(" = '");
valuesSB.append(keyword);
valuesSB.append("'");
return valuesSB.toString();
}
/**
* SELECT
*
* @param tableName
* @param args
* @return
*/
public static String getSelectSql(String tableName, String... args) {
StringBuffer valuesSB = new StringBuffer("SELECT * FROM ");
valuesSB.append(tableName);
valuesSB.append(" WHERE");
for (int i = 0; i < args.length; i++) {
valuesSB.append(" ");
valuesSB.append(args[i]);
valuesSB.append("=? ");
valuesSB.append("AND");
}
valuesSB.delete(valuesSB.length() - 3, valuesSB.length());
return valuesSB.toString();
}
/**
*
*
* @param tableName
* @param args
* @param args2
* @return
*/
public static String getUpdataSQL(String tableName, String[] args, String[] args2) {
StringBuffer updateSB = new StringBuffer("UPDATE ");
updateSB.append(tableName);
updateSB.append(" SET ");
// 拼接更新语句
for (int i = 0; i < args.length; i++) {
if (args[i].toUpperCase().equals("OPERATE_TIME") || args[i].toUpperCase().equals("LAST_UPDATE_DATE")) {
updateSB.append(args[i]).append("=to_date(?,'yyyy-MM-dd HH24:mi:ss') ,");
} else {
updateSB.append(args[i]).append("=? ,");
}
}
updateSB.delete(updateSB.length() - 2, updateSB.length());
;
updateSB.append(" WHERE ");
for (int i = 0; i < args2.length; i++) {
updateSB.append(args2[i]).append("=? AND ");
}
updateSB.delete(updateSB.length() - 4, updateSB.length());
return updateSB.toString();
}
/**
* SQLinsert
*
* @param tableName
* @param args
* @return
*/
public static String getInsertSql_1(String tableName, String[] column, Object[] value) {
StringBuffer insertSql = new StringBuffer("insert into ");
StringBuffer values = new StringBuffer("values(");
if (tableName != null && column != null && column.length > 0) {
insertSql.append(tableName);
insertSql.append("(");
for (int i = 0; i < column.length; i++) {
insertSql.append(column[i]);
if (i < column.length - 1) {
insertSql.append(", ");
}
}
} else {
return null;
}
if (tableName != null && value != null && value.length > 0) {
System.out.println(value.length);
for (int i = 0; i < value.length; i++) {
if ((value[i] + "").trim().equals("")) {
value[i] = "";
}
if (i == 0) {
values.append(value[i]);
} else {
values.append("'" + value[i] + "'");
}
if (i < value.length - 1) {
values.append(",");
}
}
}
// insertSql.delete(insertSql.length() - 2, insertSql.length());
// values.delete(values.length() - 2, values.length());
insertSql.append(") ").append(values).append(")");
return insertSql.toString();
}
/**
* SQLinsert
*
* @param tableName
* @param args
* @return
*/
public static String getInsertSql_2(String tableName, String[] column, Object[] value) {
StringBuffer insertSql = new StringBuffer("insert into ");
StringBuffer values = new StringBuffer("values(");
if (tableName != null && column != null && column.length > 0) {
insertSql.append(tableName);
insertSql.append("(");
for (int i = 0; i < column.length; i++) {
insertSql.append(column[i]);
if (i < column.length - 1) {
insertSql.append(", ");
}
}
} else {
return null;
}
if (tableName != null && value != null && value.length > 0) {
System.out.println(value.length);
for (int i = 0; i < value.length; i++) {
if ((value[i] + "").trim().equals("")) {
value[i] = "";
}
if (i == 1) {
values.append(value[i]);
} else {
values.append("'" + value[i] + "'");
}
if (i < value.length - 1) {
values.append(",");
}
}
}
// insertSql.delete(insertSql.length() - 2, insertSql.length());
// values.delete(values.length() - 2, values.length());
insertSql.append(") ").append(values).append(")");
return insertSql.toString();
}
/**
* SQLinsert
*
* @param tableName
* @param args
* @return
*/
public static String getInsertSql_3(String tableName, String[] column, Object[] value) {
StringBuffer insertSql = new StringBuffer("insert into ");
StringBuffer values = new StringBuffer("values(");
if (tableName != null && column != null && column.length > 0) {
insertSql.append(tableName);
insertSql.append("(");
for (int i = 0; i < column.length; i++) {
insertSql.append(column[i]);
if (i < column.length - 1) {
insertSql.append(", ");
}
}
} else {
return null;
}
if (tableName != null && value != null && value.length > 0) {
// System.out.println(value.length);
for (int i = 0; i < value.length; i++) {
if ((value[i] + "").trim().equals("")) {
value[i] = "";
}
if (i == 3) {
values.append(value[i]);
} else {
values.append("'" + value[i] + "'");
}
if (i < value.length - 1) {
values.append(",");
}
}
}
// insertSql.delete(insertSql.length() - 2, insertSql.length());
// values.delete(values.length() - 2, values.length());
insertSql.append(") ").append(values).append(")");
return insertSql.toString();
}
/**
* SQLdelete
*
* @param tableName
* @param args
* @return
*/
public static String getDelete(String tableName, String column, String value) {
StringBuffer deleteSql = new StringBuffer("delete from ");
deleteSql.append(tableName);
deleteSql.append(" where ");
deleteSql.append(column);
deleteSql.append("='");
deleteSql.append(value);
deleteSql.append("'");
return deleteSql.toString();
}
/**
* SQLupdate
*
* @param tableName
* @param args
* @return
*/
public static String getUpdate(String tableName, String[] column, String[] value, String[] columns,
Object[] values) {
StringBuffer updateSql = new StringBuffer("update ");
updateSql.append(tableName);
updateSql.append(" set ");
// TODO 添加剩余所有字段
System.out.println("columns.length---->" + columns.length);
System.out.println("values.length---->" + values.length);
for (int i = 0; i < columns.length; i++) {
updateSql.append("");
updateSql.append(columns[i]);
updateSql.append("=");
updateSql.append("'");
updateSql.append(values[i]);
if (i == values.length - 1) {
updateSql.append("' ");
} else {
updateSql.append("', ");
}
}
updateSql.append(" where ");
for (int i = 0; i < column.length; i++) {
updateSql.append(column[i]);
updateSql.append("='");
updateSql.append(value[i]);
updateSql.append("'");
if (i < column.length - 1) {
updateSql.append(" and ");
}
}
// updateSql.append(column);
// updateSql.append("='");
// updateSql.append(value);
// updateSql.append("'");
return updateSql.toString();
}
/**
* SQLinsert
*
* @param tableName
* @param args
* @return
*/
public static String getInsertSql(String tableName, String... args) {
StringBuffer insertSql = new StringBuffer("insert into ");
StringBuffer values = new StringBuffer("values(");
if (tableName != null && args != null && args.length > 0) {
insertSql.append(tableName);
insertSql.append("(");
for (int i = 0; i < args.length; i++) {
insertSql.append(args[i]);
insertSql.append(", ");
if (args[i].toUpperCase().equals("COMMIT_TIME") || args[i].toUpperCase().equals("CREATE_DATE")
|| args[i].toUpperCase().equals("INVALID_DATE")) {
values.append("to_date(?,'yyyy-MM-dd HH24:mi:ss'), ");
} else {
values.append("?, ");
}
}
} else {
return null;
}
insertSql.delete(insertSql.length() - 2, insertSql.length());
values.delete(values.length() - 2, values.length());
insertSql.append(") ").append(values).append(")");
return insertSql.toString();
}
/**
*
*
* @param tableName
* @param args
* @param args2
* @return
*/
public final static String GetCreateTableSQL(String tableName, String[] args, String[] args2) {
if (args == null || args2 == null || args.length != args2.length) {
System.out.println("THE INPUT PRAGREMS IS ERROR");
return null;
}
StringBuffer createSQL = new StringBuffer("create table ");
createSQL.append(tableName);
createSQL.append("(");
for (int i = 0; i < args.length; i++) {
createSQL.append(args[i] + " ");
createSQL.append(args2[i] + ", ");
}
createSQL.delete(createSQL.length() - 2, createSQL.length());
createSQL.append(")");
return createSQL.toString();
}
/**
* Statement
*/
public final static PreparedStatement getPs(String sql) throws SQLException {
return getPs(sql, null);
}
/**
* Statement
*/
public final static PreparedStatement getPs(Object[] argments, String sql) throws SQLException {
// System.out.println("PreparedStatement getPs");
return getPs(sql, argments);
}
/**
* Statement
*/
public final static PreparedStatement getPs(String sql, Object[] argments) throws SQLException {
// System.out.println("PreparedStatement getPs2");
SqlUtil.ps = SqlUtil.connection.prepareStatement(sql);
if (argments != null) {
for (int i = 0; i < argments.length; i++) {
SqlUtil.ps.setObject(i + 1, argments[i]);
}
}
return SqlUtil.ps;
}
/**
*
*/
public final static int write(String sql) {
return write(sql, null);
}
/**
*
*/
public final static int write(Object[] argments, String sql) {
return write(sql, argments);
}
/**
*
*/
public final static int write(String sql, Object[] argments) {
return update(sql, argments);
}
/**
*
*/
public final static int delete(String sql) {
return delete(sql, null);
}
/**
*
*/
public final static int delete(Object[] argments, String sql) {
return delete(sql, argments);
}
/**
*
*/
public final static int delete(String sql, Object[] argments) {
return update(sql, argments);
}
/**
*
*/
public final static int update(String sql) {
return update(sql, null);
}
/**
*
*/
public final static int update(String[] argments, String sql) {
return update(sql, argments);
}
/**
* (Connection)
*/
public final static int update(String sql, Object[] argments) {
int i = -1;
try {
PreparedStatement ps = SqlUtil.getPs(argments, sql);
i = ps.executeUpdate();
// 2015-11-19
SqlUtil.connection.commit();
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
} finally {
free(SqlUtil.rs, SqlUtil.ps);
}
return i;
}
/**
*
*/
public final static ResultSet read(String sql) throws SQLException {
// System.out.println("ResultSet read");
return read(sql, null);
}
/**
*
*/
public final static ResultSet read(Object[] argments, String sql) throws SQLException {
return read(sql, argments);
}
/**
* (便finally)
*
* @throws SQLException
*/
public final static ResultSet read(String sql, Object[] argments) throws SQLException {
// System.out.println("ResultSet read2");
return SqlUtil.rs = SqlUtil.getPs(argments, sql).executeQuery();
}
/**
*
*/
public final static boolean createTable(String sql) {
return go(sql, null);
}
/**
*
*/
public final static boolean dropTable(String sql) {
return go(sql, null);
}
/**
*
*/
public final static boolean alterTable(String sql) {
return go(sql, null);
}
/**
* DDL(,,)
*/
private final static boolean go(String sql, Object[] argments) {
boolean flag = false;
try {
flag = SqlUtil.getPs(sql, argments).execute();
} catch (SQLException e) {
e.printStackTrace();
} finally {
free(SqlUtil.rs, SqlUtil.ps);
}
if (flag) {
try {
SqlUtil.connection.commit();
} catch (SQLException e) {
e.printStackTrace();
}
}
return flag;
}
/**
*
*/
public final static void free(ResultSet resultSet) {
free(resultSet, null, null);
}
/**
*
*/
public final static void free(Statement statement) {
free(null, statement, null);
}
/**
*
*/
public final static void free(Connection connection) {
free(null, null, connection);
}
/**
*
*/
public final static void free(ResultSet resultSet, Statement statement) {
free(resultSet, statement, null);
}
/**
*
*/
public final static void free(Statement statement, Connection connection) {
free(null, statement, connection);
}
/**
* ()
*/
public final static void free() {
free(SqlUtil.rs, SqlUtil.ps);
}
/**
* ()
*/
public final static void freeAll() {
free(SqlUtil.rs, SqlUtil.ps, SqlUtil.connection);
}
/**
* ()
*/
public final static void free(ResultSet resultSet, Statement statement, Connection connection) {
try {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
} finally {
try {
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
} finally {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
}
// public void findsth(String searchpart){
//
// }
}

@ -0,0 +1,20 @@
#
#ORACEL_NAME=tc
#
#ORACEL_PASSWORD=Tc123456
#
##ORACEL_URL=jdbc:oracle:thin:@192.168.1.248:1521:TOPPROD
#
#ORACEL_URL=jdbc:microsoft:sqlserver://10.200.1.33:1433;DatabaseName=ecology
#
#ORACEL_DRIVER=com.microsoft.jdbc.sqlserver.SQLServerDriver
SQLSERVER_NAME=infodba
SQLSERVER_PASSWORD=infodba
#ORACEL_URL=jdbc:oracle:thin:@192.168.1.248:1521:TOPPROD
SQLSERVER_URL=jdbc:sqlserver://10.10.22.39:1433;DatabaseName=TC13
SQLSERVER_DRIVER=com.microsoft.sqlserver.jdbc.SQLServerDriver

@ -0,0 +1 @@
LD6_NewProdForm.FORMJAVARENDERING=com.langtech.plm.form.LD6_NewProdForm
Loading…
Cancel
Save