熊朝柱 2 weeks ago
commit 809dfe753d

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/core-renderer.jar"/>
<classpathentry exported="true" kind="lib" path="lib/iTextAsian.jar"/>
<classpathentry exported="true" kind="lib" path="lib/iTextAsianCmaps.jar"/>
<classpathentry exported="true" kind="lib" path="lib/itextpdf-5.0.6.jar"/>
<classpathentry exported="true" kind="lib" path="lib/ojdbc7.jar"/>
<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="output" path="bin"/>
</classpath>

1
.gitignore vendored

@ -0,0 +1 @@
/bin/

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>cn.net.connor.designtopart</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,4 @@
eclipse.preferences.version=1
encoding//src/cn/net/connor/plm/util/ExcelWriteTable1.java=UTF-8
encoding//src/cn/net/connor/plm/util/ExcelWriteTable2.java=UTF-8
encoding//src/cn/net/connor/plm/util/ExcelWriteTable3.java=UTF-8

@ -0,0 +1,7 @@
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.source=1.8

@ -0,0 +1,75 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Designtopart
Bundle-SymbolicName: cn.net.connor.designtopart;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: cn.net.connor.designtopart.Activator
Eclipse-RegisterBuddy: k.util
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
com.teamcenter.rac.aifrcp;bundle-version="12000.3.0",
com.teamcenter.rac.common;bundle-version="12000.3.0",
com.teamcenter.rac.external;bundle-version="12000.3.0",
com.teamcenter.rac.kernel;bundle-version="12000.3.0",
com.teamcenter.rac.tcapps;bundle-version="12000.3.0",
com.teamcenter.rac.ui;bundle-version="12000.3.0",
com.teamcenter.rac.ui.commands;bundle-version="12000.3.0",
com.teamcenter.rac.util;bundle-version="12000.3.0",
k.util;bundle-version="1.0.0",
TcSoaCoreLoose;bundle-version="12000.3.0",
TcSoaCoreRac;bundle-version="12000.3.0",
TcSoaCoreTypes;bundle-version="12000.3.0",
org.apache.poi.315;bundle-version="3.15.0",
TcSoaWorkflowLoose;bundle-version="12000.3.0",
TcSoaWorkflowRac;bundle-version="12000.3.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Automatic-Module-Name: cn.net.connor.designtopart
Bundle-ActivationPolicy: lazy
Export-Package: cn.net.connor.designtopart,
cn.net.connor.designtopart.commands,
cn.net.connor.designtopart.designtopart,
com.connor.dfl.plm.util,
oracle.core.lmx,
oracle.core.lvf,
oracle.jdbc,
oracle.jdbc.aq,
oracle.jdbc.babelfish,
oracle.jdbc.connector,
oracle.jdbc.dcn,
oracle.jdbc.diagnostics,
oracle.jdbc.driver,
oracle.jdbc.internal,
oracle.jdbc.oci,
oracle.jdbc.oracore,
oracle.jdbc.pool,
oracle.jdbc.pooling,
oracle.jdbc.proxy,
oracle.jdbc.proxy.annotation,
oracle.jdbc.replay,
oracle.jdbc.replay.driver,
oracle.jdbc.replay.internal,
oracle.jdbc.rowset,
oracle.jdbc.util,
oracle.jdbc.xa,
oracle.jdbc.xa.client,
oracle.jpub.runtime,
oracle.net.ano,
oracle.net.aso,
oracle.net.jdbc.TNSAddress,
oracle.net.jdbc.nl,
oracle.net.jdbc.nl.mesg,
oracle.net.jndi,
oracle.net.ns,
oracle.net.nt,
oracle.net.resolver,
oracle.security.o3logon,
oracle.security.o5logon,
oracle.sql,
oracle.sql.converter
Bundle-ClassPath: .,
lib/ojdbc7.jar,
lib/core-renderer.jar,
lib/iTextAsian.jar,
lib/iTextAsianCmaps.jar,
lib/itextpdf-5.0.6.jar
Import-Package: com.teamcenter.rac.ui.common

@ -0,0 +1,17 @@
## 图纸转物料
> 配置首选项Connor_Design_To_Part
```text
需要转换Design对象类型=[-]关系名称=转换后对象类型+“|”分隔后边为属性继承对应关系R为版本上属性RM为版本表单属性I为对象上的属性+“*”标识属性为必填+“!”为可编辑;
Design版本=Part版本|R.Design属性值=R.Part属性值*RM. Design属性值=RM.Part属性值;
关系名称前加“-”表示将需要转换的对象版本添加到转换后的对象版本的关系下
```
示例
```text
ItemRevision=-IMAN_reference=Part Revision|R.object_desc=R.object_desc;RM.object_desc=RM.object_desc*!
Ac5_ProductInfoRevision=IMAN_reference=Ac5_ProductInfoRevision|R.object_string=R.object_desc;R.object_name=R.object_name;RM.ac5_BearingResearchDepart=RM.ac5_BearingResearchDepart!*;RM.ac5_ByTheHost=RM.ac5_ByTheHost;RM.ac5_CAE=rm.ac5_CAE;rm.ac5_ChiefDesigner=rm.ac5_ChiefDesigner;rm.ac5_ContractSigningTime=rm.ac5_ContractSigningTime;rm.ac5_CustomerIndustry=rm.ac5_CustomerIndustry;rm.ac5_Laboratory=rm.ac5_Laboratory;rm.ac5_MainEnginePlants=rm.ac5_MainEnginePlants;rm.ac5_NumberOfUnitsInstalled=rm.ac5_NumberOfUnitsInstalled
```

@ -0,0 +1,11 @@
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
icons/,\
.,\
lib/ojdbc7.jar,\
lib/core-renderer.jar,\
lib/iTextAsian.jar,\
lib/iTextAsianCmaps.jar,\
lib/itextpdf-5.0.6.jar
source.. = src/

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.commands">
<command name="图纸创建物料" id="cn.net.connor.designtopart.commands.DesignToPartCommand"/>
<command name="数据发放" id="cn.net.connor.designtopart.commands.DataAllocationCommand"/>
<!--新增杭州世宝按钮-->
<command name="派生更改请求ECR" id="com.connor.plm.sb02.DerivedChangeRequestCommand"/>
<command name="派生更改通知ECN" id="com.connor.plm.sb02.DerivedChangeNoticeCommand"/>
<command name="派生更改通知ECO" id="com.connor.plm.sb02.DerivedChangeOptionCommand"/>
<command name="批量修订" id="cn.net.connor.plm.batchRevisionCommand"/>
</extension>
<extension point="org.eclipse.ui.handlers">
<handler commandId="cn.net.connor.designtopart.commands.DesignToPartCommand" class="k.KHandler"/>
<handler class="cn.net.connor.plm.handlers.DataAllocationHandler" commandId="cn.net.connor.designtopart.commands.DataAllocationCommand"/>
<handler commandId="com.connor.plm.sb02.DerivedChangeRequestCommand" class="com.connor.plm.KHandler"/>
<handler commandId="com.connor.plm.sb02.DerivedChangeNoticeCommand" class="com.connor.plm.KHandler"/>
<handler commandId="com.connor.plm.sb02.DerivedChangeOptionCommand" class="com.connor.plm.KHandler"/>
<handler commandId="cn.net.connor.plm.batchRevisionCommand" class="cn.net.connor.plm.batchRevision.BatchRevisionHandler"/>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:custWJ?after=projectCust">
<command commandId="cn.net.connor.designtopart.commands.DesignToPartCommand" id="cn.net.connor.designtopart.menu.designtopart"/>
</menuContribution>
<menuContribution locationURI="popup:org.eclipse.ui.popup.any?before=additions">
<command commandId="cn.net.connor.designtopart.commands.DataAllocationCommand" mnemonic="S" icon="icons/refresh_16.png" id="com.LINIX.sap.commands.batchDownload">
<visibleWhen>
<and>
<or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.cme.mpp.inMainView"/>
</or>
<iterate ifEmpty="false">
<adapt type="com.teamcenter.rac.kernel.TCComponent">
<!-- A8_ProductRevision==> 指定版本类型-->
<test property="com.teamcenter.rac.kernel.TCComponent.type" value="DocumentRevision" />
</adapt>
</iterate>
<with variable="rac_command_suppression">
<not>
<iterate operator="or"><equals value="com.nancal.XXXHandler" /> </iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<!--杭州世宝新增:派生按钮-->
<command id="com.connor.plm.sb02.menus.DerivedChangeRequestCommand" commandId="com.connor.plm.sb02.DerivedChangeRequestCommand">
<visibleWhen>
<and>
<iterate ifEmpty="false">
<adapt type="com.teamcenter.rac.kernel.TCComponent">
<or>
<test property="com.teamcenter.rac.kernel.TCComponent.typeClass"
value="ItemRevision">
</test>
</or>
</adapt>
</iterate>
</and>
</visibleWhen>
</command>
<command id="com.connor.plm.sb02.menus.DerivedChangeNoticeCommand" commandId="com.connor.plm.sb02.DerivedChangeNoticeCommand">
<visibleWhen>
<and>
<iterate ifEmpty="false">
<adapt type="com.teamcenter.rac.kernel.TCComponent">
<or>
<test property="com.teamcenter.rac.kernel.TCComponent.typeClass"
value="ItemRevision">
</test>
</or>
</adapt>
</iterate>
</and>
</visibleWhen>
</command>
<command id="com.connor.plm.sb02.menus.DerivedChangeOptionCommand" commandId="com.connor.plm.sb02.DerivedChangeOptionCommand">
<visibleWhen>
<and>
<iterate ifEmpty="false">
<adapt type="com.teamcenter.rac.kernel.TCComponent">
<or>
<test property="com.teamcenter.rac.kernel.TCComponent.typeClass"
value="ItemRevision">
</test>
</or>
</adapt>
</iterate>
</and>
</visibleWhen>
</command>
</menuContribution>
<!--右键菜单:批量修订-->
<menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<command id="cn.net.connor.plm.menus.batchRevision" commandId="cn.net.connor.plm.batchRevisionCommand">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.ui.inMainPerspective">
</reference>
<iterate ifEmpty="false">
<adapt type="com.teamcenter.rac.kernel.TCComponent">
<or>
<!-- <test property="com.teamcenter.rac.kernel.TCComponent.type" value="ChangeNoticeRevision" />-->
<test
property="com.teamcenter.rac.kernel.TCComponent.property"
args="object_string" value="问题项">
</test>
<test
property="com.teamcenter.rac.kernel.TCComponent.property"
args="object_string" value="受影响项">
</test>
</or>
</adapt>
</iterate>
<with
variable="rac_command_suppression">
<not>
<iterate
operator="or">
<equals
value="cn.com.origin.autocode.handlers.AutoCodeNewItemHandler">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution>
</extension>
</plugin>

@ -0,0 +1,44 @@
package cn.net.connor.designtopart;
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 = "cn.net.connor.designtopart"; //$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,22 @@
package cn.net.connor.designtopart;
import com.teamcenter.rac.util.Registry;
public class DesigntopartLocale {
public static final Registry reg = Registry.getRegistry(DesigntopartLocale.class);
public static String getString(String title) {
if (isEmpty(title)) {
return "";
} else {
String res = reg.getString(title);
return isEmpty(res) ? title : res;
}
}
private static boolean isEmpty(String title) {
return title == null || "".equals(title.trim());
}
}

@ -0,0 +1,16 @@
package cn.net.connor.designtopart.commands;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import cn.net.connor.designtopart.designtopart.DesignToPartDialog;
import cn.net.connor.designtopart.designtopart.DesignToPartDialogController;
import k.KCommand;
public class DesignToPartCommand extends KCommand {
public DesignToPartCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
this.setRunnable(new DesignToPartDialog(new DesignToPartDialogController(app)));
}
}

@ -0,0 +1,35 @@
package cn.net.connor.designtopart.designtopart;
import java.awt.BorderLayout;
import java.awt.Dimension;
import cn.net.connor.designtopart.DesigntopartLocale;
import javafx.embed.swing.JFXPanel;
import k.KDialog;
import k.KDialogController;
@SuppressWarnings("serial")
public class DesignToPartDialog extends KDialog {
protected DesignToPartDialogController controller;
public DesignToPartDialog(KDialogController controller) {
super(controller);
this.controller = (DesignToPartDialogController) controller;
}
@Override
protected void addListeners() {
}
@Override
protected void initUI() {
this.setTitle(DesigntopartLocale.getString("designtopart"));
this.setPreferredSize(new Dimension(800, 600));
this.setMinimumSize(new Dimension(800, 600));
JFXPanel panel = new JFXPanel();
panel.setScene(new DesignToPartPanel(this).getScene());
this.add(BorderLayout.CENTER, panel);
}
}

@ -0,0 +1,72 @@
package cn.net.connor.designtopart.designtopart;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import cn.net.connor.designtopart.DesigntopartLocale;
import k.KDialogController;
import k.util.KUtil;
public class DesignToPartDialogController extends KDialogController {
public static final String PREF_TRANSFER = DesigntopartLocale.getString("DESIGNTOPART.PREF");
protected List<TableBuilder> tableBuilders = new ArrayList<TableBuilder>();
public DesignToPartDialogController(AbstractAIFApplication app) {
super(app);
}
@Override
public boolean init() throws Exception {
InterfaceAIFComponent[] targets = app.getTargetComponents();
Map<String, List<TCComponentItemRevision>> selectedRevMap = new HashMap<>(64);
int targetCnt = KUtil.getLen(targets);
for (int i = 0; i < targetCnt; i++) {
InterfaceAIFComponent target = targets[i];
if (!(target instanceof TCComponentItemRevision)) {
continue;
}
TCComponentItemRevision rev = (TCComponentItemRevision) target;
String type = rev.getType();
List<TCComponentItemRevision> list;
if (selectedRevMap.containsKey(type)) {
list = selectedRevMap.get(type);
} else {
list = new ArrayList<TCComponentItemRevision>();
selectedRevMap.put(type, list);
}
if (!list.contains(rev)) {
list.add(rev);
}
}
selectedRevMap.forEach((k, v) -> System.out.println("ÀàÐÍ = " + k + ", " + v));
if (selectedRevMap.size() == 0) {
throw new TCException(DesigntopartLocale.getString("selectrev.INFO"));
}
// Connor_Design_To_Part
String[] prefVals = KUtil.getPrefVals(session, PREF_TRANSFER);
int len = KUtil.getLen(prefVals);
int counter = 0;
for (int i = 0; i < len; i++) {
String prefVal = prefVals[i];
TableBuilder builder = new TableBuilder(session, prefVal, selectedRevMap);
tableBuilders.add(builder);
counter += (builder.fromRevList == null ? 0 : builder.fromRevList.size());
}
if (tableBuilders.size() == 0) {
throw new TCException(String.format(DesigntopartLocale.getString("pref.ERROR1"), PREF_TRANSFER));
}
if (counter == 0) {
throw new TCException(DesigntopartLocale.getString("notransferdata.INFO"));
}
return true;
}
}

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<StackPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0"
xmlns="http://javafx.com/javafx/8"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="cn.net.connor.designtopart.designtopart.DesignToPartPanelController">
<children>
<BorderPane prefHeight="200.0" prefWidth="200.0">
<center>
<ScrollPane fx:id="scrollPane" fitToHeight="true" fitToWidth="true" prefViewportHeight="400.0" prefViewportWidth="600.0" styleClass="edge-to-edge" BorderPane.alignment="CENTER">
<content>
<VBox fx:id="vBox" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="150.0" spacing="12.0">
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
</padding>
</VBox>
</content>
</ScrollPane>
</center>
<bottom>
<GridPane alignment="CENTER" hgap="50.0" BorderPane.alignment="CENTER">
<columnConstraints>
<ColumnConstraints hgrow="NEVER" minWidth="10.0" />
<ColumnConstraints hgrow="NEVER" minWidth="10.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Button mnemonicParsing="false" onAction="#createBtnClick" text=" 创建 " />
<Button mnemonicParsing="false" onAction="#closeBtnClick" text=" 取消 " GridPane.columnIndex="1" />
</children>
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
</padding>
</GridPane>
</bottom>
</BorderPane>
<AnchorPane fx:id="cover" prefHeight="600.0" prefWidth="800.0" visible="false">
<children>
<ProgressIndicator prefHeight="30.0" prefWidth="30.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0" />
</children>
</AnchorPane>
</children>
</StackPane>

@ -0,0 +1,14 @@
package cn.net.connor.designtopart.designtopart;
import java.awt.Window;
import k.ui.KFXPanel;
public class DesignToPartPanel extends KFXPanel{
public DesignToPartPanel(Window dialog) {
super(dialog, DesignToPartPanel.class, "style.css");
initData();
}
}

@ -0,0 +1,186 @@
package cn.net.connor.designtopart.designtopart;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.util.MessageBox;
import cn.net.connor.designtopart.DesigntopartLocale;
import cn.net.connor.designtopart.designtopart.TableBuilder.RowData;
import javafx.application.Platform;
import javafx.beans.value.ObservableValue;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TableView;
import javafx.scene.control.TitledPane;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import k.KOperation;
import k.KOperation2;
import k.ui.KFXPanel;
import k.ui.KFXPanelController;
import k.util.KUtil;
public class DesignToPartPanelController extends KFXPanelController {
@FXML
private AnchorPane cover;
@FXML
private VBox vBox;
@FXML
private ScrollPane scrollPane;
private DesignToPartDialog dialog;
private List<TableBuilder> tableBuilders;
protected boolean flag = false;
protected double scrollVal;
@Override
public void initData(KFXPanel panel) throws Exception {
this.dialog = (DesignToPartDialog) ((DesignToPartPanel) panel).getParentDialog();
this.tableBuilders = dialog.controller.tableBuilders;
setProgressVisible(true);
new KOperation(AIFUtility.getCurrentApplication(), DesigntopartLocale.getString("readdata.STATUS")) {
@Override
public boolean init() throws Exception {
return true;
}
@Override
public void execute() throws Exception {
int tableBuilderCnt = tableBuilders.size();
for (int i = 0; i < tableBuilderCnt; i++) {
TableBuilder tableBuilder = tableBuilders.get(i);
TableView<RowData> table = tableBuilder.build();
if (table == null) {
continue;
}
table.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
flag = true;
scrollVal = scrollPane.getVvalue();
scrollPane.setVvalue(scrollVal);
System.out.println("---MOUSE_CLICKED---");
}
});
Platform.runLater(() -> {
TitledPane pane = new TitledPane(tableBuilder.title, table);
int height = (100 + 35 * tableBuilder.fromRevList.size()) > 205
? (100 + 35 * tableBuilder.fromRevList.size())
: 205;
pane.setMinHeight(170);
pane.setMaxHeight(height);
pane.expandedProperty().addListener((observable, wasExpanded, isExpanded) -> {
pane.setMaxHeight(isExpanded ? height : 0);
pane.setMinHeight(isExpanded ? 230 : Region.USE_PREF_SIZE);
});
pane.setAnimated(false);
VBox.setVgrow(pane, Priority.ALWAYS);
vBox.getChildren().add(pane);
});
}
setProgressVisible(false);
}
}.executeModeless();
scrollPane.vvalueProperty()
.addListener((ObservableValue<? extends Number> ov, Number old_val, Number new_val) -> {
if (flag) {
scrollPane.setVvalue(scrollVal);
flag = false;
}
});
}
public void closeBtnClick() {
dialog.disposeDialog();
}
public void createBtnClick() {
setProgressVisible(true);
new KOperation2(AIFUtility.getCurrentApplication(), DesigntopartLocale.getString("create.STATUS")) {
@Override
public boolean init() throws Exception {
try {
checkCanCreate();
return true;
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(dialog, e);
}
return false;
}
@Override
public void execute() {
try {
doCreate();
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(dialog, e);
}
}
@Override
public void clearCache() throws Exception {
setProgressVisible(false);
}
}.executeModeless();
}
public void checkCanCreate() throws Exception {
for (int i = 0; i < tableBuilders.size(); i++) {
tableBuilders.get(i).checkCanCreate();
}
}
public void doCreate() throws Exception {
StringBuilder err = new StringBuilder();
for (int i = 0; i < tableBuilders.size(); i++) {
TableBuilder tableBuilder = tableBuilders.get(i);
String status = tableBuilder.title + ": " + DesigntopartLocale.getString("create.STATUS");
try {
tableBuilder.doCreate(status);
} catch (Exception e) {
e.printStackTrace();
err.append("[" + tableBuilder.title + "]" + e.getMessage() + "\r\n");
}
}
if (err.length() > 0) {
String errTitle = DesigntopartLocale.getString("createerror.TITLE");
String exportFileName = errTitle + KUtil.getDateStr(new Date(), "_yyyyMMdd_HHmmss") + ".txt";
KUtil.showScrollDialogWithExport(dialog, err.toString(), errTitle, exportFileName);
} else {
KUtil.info(dialog, DesigntopartLocale.getString("create.SUCCESS"));
}
}
public void setProgressVisible(boolean visible) {
if (cover != null) {
if (Platform.isFxApplicationThread()) {
cover.setVisible(visible);
} else {
Platform.runLater(() -> {
cover.setVisible(visible);
});
}
try {
TimeUnit.MILLISECONDS.sleep(20);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

@ -0,0 +1,817 @@
package cn.net.connor.designtopart.designtopart;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.connor.dfl.plm.util.DataBaseControl;
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.TCComponentItemRevisionType;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCPropertyDescriptor;
import com.teamcenter.rac.kernel.TCSession;
import cn.net.connor.designtopart.DesigntopartLocale;
import javafx.application.Platform;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.ComboBoxTableCell;
import javafx.util.Callback;
import k.ui.KFXEditableStringTableCell;
import k.ui.KFXUtil;
import k.util.KUtil;
@SuppressWarnings("all")
public class TableBuilder {
public static final String PROPLOC_ITEM = "I";
public static final String PROPLOC_REV = "R";
public static final String PROPLOC_REVMASTER = "RM";
public static final String CSS_REDCELL = "redcell";
public static final String DEFAULTNAME = DesigntopartLocale.getString("designtopart");
protected TCSession session;
protected TCComponentItemRevisionType fromRevType;
protected TCComponentItemRevisionType toRevType;
protected TCComponentType fromRevMasterType;
protected TCComponentType toRevMasterType;
protected List<ColConfig> colConfigs = new ArrayList<TableBuilder.ColConfig>();
protected List<TCComponentItemRevision> fromRevList;
protected TableView<RowData> table;
protected String title;
private String relation;
protected TCComponentItemType toItemType;
protected ColConfig colConfig_Name;
private boolean reverseRelation;
protected String drm01;
protected String drm22;
protected String drm03;
protected String[] connor_laoShiBao;
protected String[] connor_xinShiBao;
protected String[] drawingtypes;
protected String[] dbStrings;
protected boolean laoShiBao;
protected boolean xinShiBao;
protected long parseLong;
protected DataBaseControl dataBaseControl = null;
private TCComponentItem newItem;
private Map<String, String[]> xinMap = new HashMap<>();
private Map<String, String> laoMap = new HashMap<>();
private String[] xinValues = null, laoValues = null;
protected List<String> list = Arrays.asList(new String[] { "SB6_AutocadDLRevision", "SB6_AutocadSDLRevision",
"SB6_AutocadAssDLRevision", "SB6_CatiaAssDLRevision", "SB6_CatiaSDLRevision", "SB6_CatiaDesignLRevision",
"SB6_AutocadDXRevision", "SB6_AutocadSDXRevision", "SB6_AutocadAssDXRevision", "SB6_CatiaAssDXRevision",
"SB6_CatiaSDXRevision", "SB6_CatiaDesignXRevision" });
protected List<String> list2 = Arrays
.asList(new String[] { "SB6_CatiaAssDLRevision", "SB6_CatiaSDLRevision", "SB6_CatiaDesignLRevision" });
protected List<String> list3 = Arrays.asList(new String[] { "SB6_CatiaDesignLRevision", "SB6_CatiaAssDLRevision",
"SB6_CatiaSDLRevision", "SB6_AutocadAssDLRevision", "SB6_AutocadDLRevision", "SB6_AutocadSDLRevision" });
protected Map<String, Object> uomMap = new HashMap<>();
protected ObservableList<String> uomList = FXCollections.observableArrayList();
protected Map<String, String> khflMap = new HashMap<>();
protected Map<String, String[]> tzMap = new HashMap<>();
protected ObservableList<String> khflList = FXCollections.observableArrayList();
protected ObservableList<String> tzList = FXCollections.observableArrayList();
protected Map<String, String> khfl2Map = new HashMap<>();
protected Map<String, String> tz2Map = new HashMap<>();
protected ObservableList<String> khfl2List = FXCollections.observableArrayList();
protected ObservableList<String> tz2List = FXCollections.observableArrayList();
protected Map<String, String> khfl3Map = new HashMap<>();
protected Map<String, String> cgqlxMap = new HashMap<>();
protected Map<String, String> tz3Map = new HashMap<>();
protected ObservableList<String> khfl3List = FXCollections.observableArrayList();
protected ObservableList<String> cgqlxList = FXCollections.observableArrayList();
protected ObservableList<String> tz3List = FXCollections.observableArrayList();
protected String formName = "";
protected boolean isHave = false;
protected String sb6_PartRM14 = "";
public TableBuilder(TCSession session, String config, Map<String, List<TCComponentItemRevision>> selectedRevMap)
throws Exception {
this.session = session;
initData();
parseConfig(config, selectedRevMap);
}
protected void parseConfig(String config, Map<String, List<TCComponentItemRevision>> selectedRevMap)
throws Exception {
if (KUtil.isEmpty(config)) {
throw new TCException(DesigntopartLocale.getString("prefconfig.EMPTY"));
}
int ind = config.indexOf('|');
if (ind <= 0) {
throw new TCException(String.format(DesigntopartLocale.getString("prefvalue.ERROR1"), config));
}
String[] typeSplit = config.substring(0, ind).split("=");
String[] propConfigSplit = config.substring(ind + 1).split(";");
if (KUtil.getLen(typeSplit) == 3) {
String fromTypeName = typeSplit[0].trim();
this.relation = typeSplit[1].trim();
this.reverseRelation = this.relation.startsWith("-");
if (this.reverseRelation) {
this.relation = this.relation.substring(1);
}
String toTypeName = typeSplit[2].trim();
try {
if (!KUtil.isEmpty(fromTypeName)) {
this.fromRevType = (TCComponentItemRevisionType) session.getTypeComponent(fromTypeName);
this.fromRevMasterType = session.getTypeComponent(fromTypeName + "Master");
if (this.fromRevMasterType == null) {
this.fromRevMasterType = session.getTypeComponent(fromTypeName + " Master");
}
}
if (!KUtil.isEmpty(toTypeName)) {
this.toRevType = (TCComponentItemRevisionType) session.getTypeComponent(toTypeName);
this.toRevMasterType = session.getTypeComponent(toTypeName + "Master");
if (this.toRevMasterType == null) {
this.toRevMasterType = session.getTypeComponent(toTypeName + " Master");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
if (KUtil.isEmpty(this.relation) || this.fromRevType == null || this.toRevType == null
|| this.fromRevMasterType == null || this.toRevMasterType == null) {
throw new TCException(String.format(DesigntopartLocale.getString("prefvalue.ERROR1"), config));
}
this.toItemType = this.toRevType.getItemType();
String fromRevTypeName = fromRevType.getTypeName();
if (list.contains(fromRevTypeName)) {
ColConfig colConfig = new ColConfig(true, false, false, "对象ID", "I", "item_id", "I", "item_id");
ColConfig colConfig2 = new ColConfig(false, true, false, "单位", "I", "uom_tag", "I", "uom_tag");
this.colConfigs.add(colConfig);
this.colConfigs.add(colConfig2);
if (list2.contains(fromRevTypeName)) {
ColConfig colConfig3 = new ColConfig(true, true, false, "客户分类", "I", "khfl", "I", "khfl");
ColConfig colConfig4 = new ColConfig(true, true, false, "特征", "I", "tz", "I", "tz");
this.colConfigs.add(colConfig3);
if(fromRevTypeName.equals("SB6_CatiaSDLRevision")) {
ColConfig colConfig5 = new ColConfig(true, true, false, "传感器类型", "I", "cgqlx", "I", "cgqlx");
this.colConfigs.add(colConfig5);
}
this.colConfigs.add(colConfig4);
}
}
int len = KUtil.getLen(propConfigSplit);
for (int i = 0; i < len; i++) {
String[] split = propConfigSplit[i].trim().split("=");
if (KUtil.getLen(split) != 2) {
continue;
}
String[] fromConfig = split[0].trim().split("\\.");
String[] toConfig = split[1].trim().split("\\.");
if (KUtil.getLen(fromConfig) != 2 || KUtil.getLen(toConfig) != 2) {
continue;
}
String fromPropLoc = fromConfig[0].trim().toUpperCase();
String fromPropName = fromConfig[1].trim();
String toPropLoc = toConfig[0].trim().toUpperCase();
String toPropName = toConfig[1].trim().replace("*", "").replace("!", "");
if (KUtil.isEmpty(fromPropLoc) || KUtil.isEmpty(fromPropName) || KUtil.isEmpty(toPropLoc)
|| KUtil.isEmpty(toPropName)) {
continue;
}
TCComponentType type = null;
switch (toPropLoc) {
case PROPLOC_ITEM:
type = toItemType;
break;
case PROPLOC_REV:
type = toRevType;
break;
case PROPLOC_REVMASTER:
type = toRevMasterType;
break;
default:
break;
}
if (type == null) {
continue;
}
TCPropertyDescriptor prop = type.getPropDesc(toPropName);
if (prop == null) {
throw new TCException(String.format(DesigntopartLocale.getString("propnotdefinedintype.ERROR2"),
toPropName, type.getDisplayTypeName()));
}
boolean require = toConfig[1].contains("*");
boolean editable = toConfig[1].contains("!");
String colName = prop.getDisplayName();
ColConfig colConfig = new ColConfig(require, editable, prop.getType2() == TCProperty.PROP_reference,
colName, fromPropLoc, fromPropName, toPropLoc, toPropName);
this.colConfigs.add(colConfig);
if (PROPLOC_REV.equals(toPropLoc) && "object_name".equals(toPropName)) {
this.colConfig_Name = colConfig;
}
}
if (this.colConfigs.size() == 0) {
throw new TCException(String.format(DesigntopartLocale.getString("prefvalue.ERROR1"), config));
}
this.fromRevList = selectedRevMap.get(fromRevTypeName);
this.title = fromRevType.getDisplayTypeName();
}
public static class ColConfig {
public boolean require;
public boolean editable;
public boolean isRefType;
public String colName;
public String fromPropLoc;
public String fromPropName;
public String toPropLoc;
public String toPropName;
public ColConfig(boolean require, boolean editable, boolean isRefType, String colName, String fromPropLoc,
String fromPropName, String toPropLoc, String toPropName) {
super();
this.require = require;
this.editable = editable;
this.isRefType = isRefType;
this.colName = colName;
this.fromPropLoc = fromPropLoc;
this.fromPropName = fromPropName;
this.toPropLoc = toPropLoc;
this.toPropName = toPropName;
}
}
public static class RowData {
public Map<ColConfig, SimpleStringProperty> dataMap = new HashMap<>();
public Map<ColConfig, SimpleObjectProperty<TCComponent>> refDataMap = new HashMap<>();
public TCComponentItemRevision fromRev;
public RowData(TCComponentItemRevision rev, List<ColConfig> colConfigs) throws Exception {
this.fromRev = rev;
rev.refresh();
TCComponent form = rev.getRelatedComponent("IMAN_master_form_rev");
form.refresh();
TCComponentItem item = rev.getItem();
item.refresh();
for (ColConfig colConfig : colConfigs) {
if (PROPLOC_REV.equals(colConfig.fromPropLoc)) {
addData(rev, colConfig);
} else if (PROPLOC_REVMASTER.equals(colConfig.fromPropLoc)) {
addData(form, colConfig);
} else if (PROPLOC_ITEM.equals(colConfig.fromPropLoc)) {
addData(item, colConfig);
}
}
}
public void addData(TCComponent comp, ColConfig colConfig) throws Exception {
if (colConfig.isRefType) {
TCComponent value = comp.getTCProperty(colConfig.fromPropName).getReferenceValue();
System.out.println(colConfig.fromPropName + " = " + value);
refDataMap.put(colConfig, new SimpleObjectProperty<TCComponent>(value));
} else {
String value = comp.getProperty(colConfig.fromPropName);
dataMap.put(colConfig, new SimpleStringProperty(value));
}
}
}
public void checkCanCreate() throws Exception {
if (table == null) {
return;
}
ObservableList<RowData> items = table.getItems();
int rowCounter = 0;
for (RowData rowData : items) {
rowCounter++;
for (ColConfig colConfig : rowData.dataMap.keySet()) {
if (colConfig.require) {
if (KUtil.isEmpty(rowData.dataMap.get(colConfig).getValueSafe())) {
Platform.runLater(() -> {
table.scrollTo(rowData);
});
throw new TCException(String.format(DesigntopartLocale.getString("tablerowdataempty.ERROR2"),
title, rowCounter));
}
}
}
}
}
public void doCreate(String status) throws Exception {
if (table == null) {
return;
}
ObservableList<RowData> items = table.getItems();
int rowCounter = 0;
int rowCount = items.size();
StringBuilder err = new StringBuilder();
for (RowData rowData : items) {
rowCounter++;
session.setStatus(String.format("%s ( %d / %d )", status, rowCounter, rowCount));
try {
createItem(rowData);
} catch (Exception e) {
e.printStackTrace();
err.append("\r\n" + rowData.fromRev + ": " + e.getMessage());
}
}
if (err.length() > 0) {
throw new Exception(err.toString());
}
}
protected void createItem(RowData rowData) throws Exception {
if (rowData == null || rowData.fromRev == null) {
return;
}
dbStrings = session.getPreferenceService().getStringValues("connor_xinshibao_db");
String strDriver = "oracle.jdbc.driver.OracleDriver";
String strUrl = "jdbc:oracle:thin:@" + dbStrings[0];
String strUserName = dbStrings[1];
String strPassword = dbStrings[2];
dataBaseControl = new DataBaseControl(strDriver, strUrl, strUserName, strPassword);
String id = "";
String lshMin = "";
String lshMax = "";
String prefix = "";
String newCode = "";
String khfl = "";
String cgqlx = "";
String tz = "";
String sb6_DRM03 = "";
String uom_tag_display = "";
Object uom_tag_real = null;
Map<ColConfig, SimpleStringProperty> dataMap = rowData.dataMap;
for (ColConfig colConfig : dataMap.keySet()) {
if ("item_id".equals(colConfig.fromPropName)) {
id = dataMap.get(colConfig).getValue();
}
if ("khfl".equals(colConfig.fromPropName)) {
khfl = dataMap.get(colConfig).getValue();
}
if ("cgqlx".equals(colConfig.fromPropName)) {
cgqlx = dataMap.get(colConfig).getValue();
}
if ("tz".equals(colConfig.fromPropName)) {
tz = dataMap.get(colConfig).getValue();
}
if ("sb6_DRM03".equals(colConfig.fromPropName)) {
sb6_DRM03 = dataMap.get(colConfig).getValue();
}
if ("uom_tag".equals(colConfig.fromPropName)) {
uom_tag_display = dataMap.get(colConfig).getValue();
uom_tag_real = uomMap.get(uom_tag_display);
}
}
String type = rowData.fromRev.getType();
switch (type) {
case "SB6_CatiaDesignLRevision":
String khflStr = khflMap.get(khfl);
String[] tzStr = tzMap.get(tz);
id = id.length() > 8 ? id.substring(0, 8) : id;
prefix = id + khflStr;
lshMin = tzStr[0];
lshMax = tzStr[1];
newCode = dataBaseControl.getNewCode(prefix, lshMin, lshMax);
id = prefix + newCode;
break;
case "SB6_CatiaAssDLRevision":
String khfl2Str = khfl2Map.get(khfl);
String tz2Str = tz2Map.get(tz);
id = id.length() > 8 ? id.substring(0, 8) : id;
prefix = id + khfl2Str + tz2Str;
lshMin = "001";
lshMax = "999";
newCode = dataBaseControl.getNewCode(prefix, lshMin, lshMax);
if ("".equals(newCode)) {
throw new TCException("对象" + prefix + "流水号已用完");
}
id = prefix + newCode;
break;
case "SB6_CatiaSDLRevision":
String khfl3Str = khfl3Map.get(khfl);
String cgqlxStr = cgqlxMap.get(cgqlx);
String tz3Str = tz3Map.get(tz);
id = id.length() > 8 ? id.substring(0, 8) : id;
prefix = id + khfl3Str + tz3Str + cgqlxStr;
lshMin = "01";
lshMax = "99";
newCode = dataBaseControl.getNewCode(prefix, lshMin, lshMax);
if ("".equals(newCode)) {
throw new TCException("对象" + prefix + "流水号已用完");
}
id = prefix + newCode;
break;
case "SB6_AutocadAssDLRevision":
prefix = id + "M";
lshMin = "01";
lshMax = "99";
newCode = dataBaseControl.getNewCode(prefix, lshMin, lshMax);
if ("".equals(newCode)) {
throw new TCException("对象" + prefix + "流水号已用完");
}
id = prefix + newCode;
break;
case "SB6_AutocadDLRevision":
prefix = id + "M";
lshMin = "01";
lshMax = "99";
newCode = dataBaseControl.getNewCode(prefix, lshMin, lshMax);
if ("".equals(newCode)) {
throw new TCException("对象" + prefix + "流水号已用完");
}
id = prefix + newCode;
break;
case "SB6_AutocadSDLRevision":
prefix = id + "M";
lshMin = "01";
lshMax = "99";
newCode = dataBaseControl.getNewCode(prefix, lshMin, lshMax);
if ("".equals(newCode)) {
throw new TCException("对象" + prefix + "流水号已用完");
}
id = prefix + newCode;
break;
default:
break;
}
// 新老世宝对象类型
connor_xinShiBao = session.getPreferenceService().getStringValues("connor_xinshibao");
xinShiBao = Arrays.asList(connor_xinShiBao).contains(fromRevType.getTypeName());
xinValues = session.getPreferenceService().getStringValues("Conno_Design_to_Part_CHDLX");
for (int i = 0; i < xinValues.length; i++) {
String[] split = xinValues[i].split("=");
xinMap.put(split[0], split[1].split(":"));
}
if (xinShiBao) {
if (!list3.contains(type)) {
if ("".equals(sb6_DRM03)) {
throw new TCException("图纸类型为空,无法创建物料");
}
if (!xinMap.containsKey(sb6_DRM03)) {
throw new TCException("Conno_Design_to_Part_CHDLX不包含该图纸类型" + sb6_DRM03);
}
prefix = xinMap.get(sb6_DRM03)[0];
lshMin = xinMap.get(sb6_DRM03)[1];
int length = 11 - prefix.length() - lshMin.length();
while (length > 0) {
lshMin = "0" + lshMin;
length--;
}
length = 11 - prefix.length();
while (length > 0) {
lshMax = "9" + lshMax;
length--;
}
// lshMax = prefix + lshMax;
newCode = dataBaseControl.getNewCode(prefix, lshMin, lshMax);
id = prefix + newCode;
// id = id.substring(prefix.length());
TCComponentItem find = toItemType.find(id);
while (find != null) {
newCode = dataBaseControl.getNewCode(prefix, lshMin, lshMax);
id = prefix + newCode;
// id = id.substring(prefix.length());
find = toItemType.find(id);
}
}
sb6_PartRM14 = id;
}
connor_laoShiBao = session.getPreferenceService().getStringValues("connor_laoshibao");
laoShiBao = Arrays.asList(connor_laoShiBao).contains(fromRevType.getTypeName());
drawingtypes = session.getPreferenceService().getStringValues("connor_laoshibao_sb6_DRM03");
laoValues = session.getPreferenceService().getStringValues("Conno_Design_to_Part_CHDL");
for (int i = 0; i < laoValues.length; i++) {
String[] split = laoValues[i].split("=");
laoMap.put(split[0], split[1]);
}
if (laoShiBao) {
TCComponent component = rowData.fromRev.getRelatedComponent("IMAN_master_form_rev");
drm03 = component.getProperty("sb6_DRM03");// 图纸类型
drm01 = component.getProperty("sb6_DRM01");// 图号
drm22 = component.getProperty("sb6_DRM22");// 图纸代号
if (Arrays.asList(drawingtypes).contains(drm03)) {
return;
}
if (!list3.contains(type)) {
id = component.getProperty("sb6_DRM22");
}
sb6_PartRM14 = laoMap.get(drm03);
}
System.out.println("khfl = " + khfl);
System.out.println("tz = " + tz);
System.out.println("uom_tag_display = " + uom_tag_display + ", uom_tag_real = " + uom_tag_real);
System.out.println("lshMin = " + lshMin);
System.out.println("newCode = " + newCode);
System.out.println("lshMax = " + lshMax);
TCComponentItem newItem = null;
TCComponent[] findItem = session.search("零组件 ID", new String[] { "零组件 ID" }, new String[] { id + "*" });
for (TCComponent item : findItem) {
if (item.getProperty("item_id").equals(id)) {
newItem = (TCComponentItem) item;
isHave = true;
}
}
if (newItem == null) {
String revId = toItemType.getNewRev(null);
String name = this.colConfig_Name == null ? null : dataMap.get(colConfig_Name).getValueSafe();
if (KUtil.isEmpty(name)) {
name = DEFAULTNAME;
}
newItem = toItemType.create(id, revId, toItemType.getTypeName(), name, "", null);
}
this.newItem = newItem;
Map<String, String> itemProps = new HashMap<>();
Map<String, String> revProps = new HashMap<>();
Map<String, String> revMasterProps = new HashMap<>();
Map<String, TCComponent> itemRefProps = new HashMap<>();
Map<String, TCComponent> revRefProps = new HashMap<>();
Map<String, TCComponent> revMasterRefProps = new HashMap<>();
for (ColConfig colConfig : dataMap.keySet()) {
String value = dataMap.get(colConfig).getValueSafe();
if (PROPLOC_REV.equals(colConfig.toPropLoc)) {
revProps.put(colConfig.toPropName, value);
} else if (PROPLOC_REVMASTER.equals(colConfig.toPropLoc)) {
revMasterProps.put(colConfig.toPropName, value);
} else if (PROPLOC_ITEM.equals(colConfig.toPropLoc)) {
itemProps.put(colConfig.toPropName, value);
}
}
for (ColConfig colConfig : rowData.refDataMap.keySet()) {
TCComponent value = rowData.refDataMap.get(colConfig).getValue();
if (PROPLOC_REV.equals(colConfig.toPropLoc)) {
revRefProps.put(colConfig.toPropName, value);
} else if (PROPLOC_REVMASTER.equals(colConfig.toPropLoc)) {
revMasterRefProps.put(colConfig.toPropName, value);
} else if (PROPLOC_ITEM.equals(colConfig.toPropLoc)) {
itemRefProps.put(colConfig.toPropName, value);
}
}
TCComponentItemRevision rev = newItem.getLatestItemRevision();
if (!isHave) {
if (reverseRelation) {
rev.add(relation, rowData.fromRev);
rev.refresh();
} else {
rowData.fromRev.add(relation, rev);
rowData.fromRev.refresh();
}
}
TCComponent form = rev.getRelatedComponent("IMAN_master_form_rev");
this.formName = rev.getProperty("object_string").split(";")[0];
setProperties(newItem, itemProps);
setProperties(rev, revProps);
setProperties(form, revMasterProps);
setRefProperties(newItem, itemRefProps);
setRefProperties(rev, revRefProps);
setRefProperties(form, revMasterRefProps);
if (uom_tag_real != null) {
newItem.setReferenceProperty("uom_tag", (TCComponent) uom_tag_real);
}
newItem.refresh();
rev.refresh();
form.refresh();
}
private void setProperties(TCComponent comp, Map<String, String> props) throws Exception {
if (comp == null || props == null || props.size() == 0) {
return;
}
comp.lock();
try {
props.remove("item_id");
props.remove("khfl");
props.remove("cgqlx");
props.remove("tz");
props.remove("uom_tog");
comp.setProperties(props);
if (laoShiBao && comp instanceof TCComponentForm) {
comp.setStringProperty("sb6_PartRM14", sb6_PartRM14);
if (!isHave) {
comp.setStringProperty("object_name", formName);
}
}
if (xinShiBao && comp instanceof TCComponentForm) {
comp.setStringProperty("sb6_PartRM14", sb6_PartRM14);
comp.setStringProperty("object_name", formName);
}
comp.save();
} finally {
comp.unlock();
}
comp.refresh();
}
private void setRefProperties(TCComponent comp, Map<String, TCComponent> props) throws Exception {
if (comp == null || props == null || props.size() == 0) {
return;
}
comp.lock();
try {
for (String propName : props.keySet()) {
comp.setReferenceProperty(propName, props.get(propName));
}
comp.save();
} finally {
comp.unlock();
}
comp.refresh();
}
public TableView<RowData> build() throws Exception {
if (fromRevList == null || fromRevList.size() == 0) {
return null;
}
this.table = new TableView<TableBuilder.RowData>();
this.table.setEditable(true);
int colCnt = this.colConfigs.size();
for (int i = 0; i < colCnt; i++) {
ColConfig colConfig = colConfigs.get(i);
if (colConfig.isRefType) {
TableColumn<RowData, TCComponent> col = new TableColumn<TableBuilder.RowData, TCComponent>(
colConfig.colName);
col.setCellValueFactory(p -> p.getValue().refDataMap.get(colConfig));
this.table.getColumns().add(col);
continue;
}
TableColumn<RowData, String> col = new TableColumn<>(colConfig.colName);
col.setPrefWidth(110);
col.setCellValueFactory(p -> p.getValue().dataMap.get(colConfig));
this.table.getColumns().add(col);
if (colConfig.editable) {
col.setCellFactory(new Callback<TableColumn<RowData, String>, TableCell<RowData, String>>() {
@Override
public TableCell<RowData, String> call(TableColumn<RowData, String> param) {
return new KFXEditableStringTableCell<RowData, String>() {
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (colConfig.require) {
this.getStyleClass().remove(CSS_REDCELL);
if (KUtil.isEmpty(getString())) {
this.getStyleClass().add(CSS_REDCELL);
}
}
};
};
}
});
} else {
col.setCellFactory(new Callback<TableColumn<RowData, String>, TableCell<RowData, String>>() {
@Override
public TableCell<RowData, String> call(TableColumn<RowData, String> param) {
return new TableCell<RowData, String>() {
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText(null);
} else {
setText(item);
}
if (colConfig.require) {
this.getStyleClass().remove(CSS_REDCELL);
if (KUtil.isEmpty(item)) {
this.getStyleClass().add(CSS_REDCELL);
}
}
};
};
}
});
}
String fromRevTypeName = fromRevType.getTypeName();
if (list.contains(fromRevTypeName)) {
if ("uom_tag".equals(colConfig.fromPropName)) {
col.setCellFactory(ComboBoxTableCell.forTableColumn(uomList));
}
if ("SB6_CatiaDesignLRevision".equals(fromRevTypeName)) {
if ("khfl".equals(colConfig.fromPropName)) {
col.setCellFactory(ComboBoxTableCell.forTableColumn(khflList));
}
if ("tz".equals(colConfig.fromPropName)) {
col.setCellFactory(ComboBoxTableCell.forTableColumn(tzList));
}
}
if ("SB6_CatiaAssDLRevision".equals(fromRevTypeName)) {
if ("khfl".equals(colConfig.fromPropName)) {
col.setCellFactory(ComboBoxTableCell.forTableColumn(khfl2List));
}
if ("tz".equals(colConfig.fromPropName)) {
col.setCellFactory(ComboBoxTableCell.forTableColumn(tz2List));
}
}
if ("SB6_CatiaSDLRevision".equals(fromRevTypeName)) {
if ("khfl".equals(colConfig.fromPropName)) {
col.setCellFactory(ComboBoxTableCell.forTableColumn(khfl3List));
}
if ("cgqlx".equals(colConfig.fromPropName)) {
col.setCellFactory(ComboBoxTableCell.forTableColumn(cgqlxList));
}
if ("tz".equals(colConfig.fromPropName)) {
col.setCellFactory(ComboBoxTableCell.forTableColumn(tz3List));
}
}
}
}
// read data
int rowCnt = fromRevList == null ? 0 : fromRevList.size();
for (int i = 0; i < rowCnt; i++) {
TCComponentItemRevision rev = fromRevList.get(i);
RowData row = new RowData(rev, colConfigs);
this.table.getItems().add(row);
}
KFXUtil.autoResizeColumn(this.table);
return this.table;
}
public void initData() {
getLovValue("Design", "uom_tag", uomMap);
getKHFL("SB6_YYXHQ_CUSTOME", khflMap);
getKHFL("SB6_DYXHQ_CUSTOME", khfl2Map);
getKHFL("SB6_DDXHQ_CUSTOME", khfl3Map);
getKHFL("SB6_DDXHQ_CGQ", cgqlxMap);
getTZ("SB6_YYXHQ_TZ", tzMap);
getTZ2("SB6_DYXHQ_TZ", tz2Map);
getTZ2("SB6_DDXHQ_TZ", tz3Map);
uomMap.forEach((k, v) -> uomList.add(k));
khflMap.forEach((k, v) -> khflList.add(k));
khfl2Map.forEach((k, v) -> khfl2List.add(k));
khfl3Map.forEach((k, v) -> khfl3List.add(k));
cgqlxMap.forEach((k, v) -> cgqlxList.add(k));
tzMap.forEach((k, v) -> tzList.add(k));
tz2Map.forEach((k, v) -> tz2List.add(k));
tz3Map.forEach((k, v) -> tz3List.add(k));
}
public void getLovValue(String type, String property, Map<String, Object> map) {
try {
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(type);
TCPropertyDescriptor descriptor = itemType.getPropertyDescriptor(property);
TCComponentListOfValues lov = descriptor.getLOV();
Object[] listOfValues = lov.getListOfValues().getListOfValues();
for (int i = 0; i < listOfValues.length; ++i) {
String displayVal = lov.getListOfValues().getDisplayableValue(listOfValues[i]);
map.put(displayVal, listOfValues[i]);
}
} catch (TCException e) {
e.printStackTrace();
}
}
public void getKHFL(String str, Map<String, String> map) {
String[] values = session.getPreferenceService().getStringValues(str);
for (String val : values) {
String[] split = val.split("-");
map.put(val, split[1]);
}
}
public void getTZ(String str, Map<String, String[]> map) {
String[] values = session.getPreferenceService().getStringValues(str);
for (String val : values) {
String[] split = val.split(":");
map.put(val, split[1].split("-"));
}
}
public void getTZ2(String str, Map<String, String> map) {
String[] values = session.getPreferenceService().getStringValues(str);
for (String val : values) {
String[] split = val.split("-");
map.put(val, split[1]);
}
}
}

@ -0,0 +1,18 @@
.table-view {
-fx-faint-focus-color: transparent;
-fx-focus-color: rgba(0, 0, 0, 0.2);
-fx-background-insets: 0;
}
.redcell:filled {
-fx-background-color: #f5696c;
-fx-background-insets: 0.5;
}
.table-view:row-selection .table-row-cell:selected .redcell {
-fx-background-color: null;
}
.table-view:cell-selection .redcell:selected {
-fx-background-color: -fx-table-cell-border-color, -fx-background;
}

@ -0,0 +1,15 @@
#
#Wed Dec 23 10:14:08 CST 2020
designtopart=Design To Part
DESIGNTOPART.PREF=Connor_Design_To_Part
notransferdata.INFO=\u6CA1\u6709\u627E\u5230\u53EF\u4EE5\u8F6C\u6362\u7684\u7C7B\u578B
propnotdefinedintype.ERROR2=\u5C5E\u6027"%s"\u672A\u5728\u7C7B\u578B"%s"\u4E2D\u5B9A\u4E49
create.SUCCESS=\u56FE\u7EB8\u8F6C\u7269\u6599\u5B8C\u6210
selectrev.INFO=\u672A\u9009\u62E9\u7248\u672C\u7C7B\u578B
prefvalue.ERROR1=\u65E0\u6CD5\u89E3\u6790\u9996\u9009\u9879\u914D\u7F6E "%s"
create.STATUS=\u56FE\u7EB8\u8F6C\u7269\u6599
prefconfig.EMPTY=\u914D\u7F6E\u4E0D\u53EF\u4E3A\u7A7A
readdata.STATUS=\u52A0\u8F7D\u6570\u636E
createerror.TITLE=\u56FE\u7EB8\u8F6C\u7269\u6599\u9519\u8BEF
tablerowdataempty.ERROR2="%s"\u8868\u7B2C%d\u884C\u5FC5\u586B\u5C5E\u6027\u5B58\u5728\u7A7A\u503C\uFF0C\u8BF7\u5B8C\u5584\u540E\u518D\u6267\u884C\u521B\u5EFA
pref.ERROR1=\u9996\u9009\u9879"%s"\u914D\u7F6E\u9519\u8BEF

@ -0,0 +1,15 @@
#
#Wed Dec 23 10:14:08 CST 2020
designtopart=\u56FE\u7EB8\u8F6C\u7269\u6599
DESIGNTOPART.PREF=Connor_Design_To_Part
notransferdata.INFO=\u6CA1\u6709\u627E\u5230\u53EF\u4EE5\u8F6C\u6362\u7684\u7C7B\u578B
propnotdefinedintype.ERROR2=\u5C5E\u6027"%s"\u672A\u5728\u7C7B\u578B"%s"\u4E2D\u5B9A\u4E49
create.SUCCESS=\u56FE\u7EB8\u8F6C\u7269\u6599\u5B8C\u6210
selectrev.INFO=\u672A\u9009\u62E9\u7248\u672C\u7C7B\u578B
prefvalue.ERROR1=\u65E0\u6CD5\u89E3\u6790\u9996\u9009\u9879\u914D\u7F6E "%s"
create.STATUS=\u56FE\u7EB8\u8F6C\u7269\u6599
prefconfig.EMPTY=\u914D\u7F6E\u4E0D\u53EF\u4E3A\u7A7A
readdata.STATUS=\u52A0\u8F7D\u6570\u636E
createerror.TITLE=\u56FE\u7EB8\u8F6C\u7269\u6599\u9519\u8BEF
tablerowdataempty.ERROR2="%s"\u8868\u7B2C%d\u884C\u5FC5\u586B\u5C5E\u6027\u5B58\u5728\u7A7A\u503C\uFF0C\u8BF7\u5B8C\u5584\u540E\u518D\u6267\u884C\u521B\u5EFA
pref.ERROR1=\u9996\u9009\u9879"%s"\u914D\u7F6E\u9519\u8BEF

@ -0,0 +1,155 @@
package cn.net.connor.plm.batchRevision;
import java.awt.Frame;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentPseudoFolder;
import com.teamcenter.rac.kernel.TCComponentReleaseStatus;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class BatchRevisionAction extends AbstractAIFAction {
private AbstractAIFApplication application;
private TCSession session;
public BatchRevisionAction(AbstractAIFApplication application, Frame frame, String param) {
super(application, frame, param);
this.application = application;
this.session = (TCSession)application.getSession();
}
@Override
public void run() {
// MessageBox.post("触发“批量修订”逻辑!", "我的打印信息", MessageBox.INFORMATION);
System.out.println("触发“批量修订”按钮!");
try {
for (InterfaceAIFComponent targetComponent : application.getTargetComponents()) {
String targetName = targetComponent.getProperty("object_string");
String folderTrueName = null;
if (targetComponent instanceof TCComponentPseudoFolder) {
TCComponentPseudoFolder folder = (TCComponentPseudoFolder)targetComponent;
//选中文件夹所在的版本对象
TCComponentItemRevision owningRevision = (TCComponentItemRevision)folder.getOwningComponent();
String folderName = folder.getStringProperty("object_string");
System.out.println("选中文件夹的显示名称="+folderName+"-"+folder.getType());
if (folderName != null && folderName.equals("问题项")) {
folderTrueName = "CMHasProblemItem";
}else if (folderName != null && folderName.equals("受影响项")) {
folderTrueName = "CMHasImpactedItem";
}
System.out.println("选中文件夹对应的真实名称="+folderTrueName);
if (folderTrueName != null) {
//获取选中文件夹内的对象 -referenceListProperty
TCComponent[] referenceListProperty = owningRevision.getReferenceListProperty(folderTrueName);
if (referenceListProperty != null && referenceListProperty.length > 0) {
// session.getUserService().call("bypass", new Object[] { true });
String xdErroItemRevString = "";//未发布的修订失败的版本对象信息,用换行分割
//将选中文件夹下的对象遍历:升版,并将新版放到【解决方案零组件】-CMHasSolutionItem 下
for (int i = 0; i < referenceListProperty.length; i++) {
TCComponentItemRevision rev = (TCComponentItemRevision)referenceListProperty[i];
TCComponentItem item = rev.getItem();
//判断该版本对象是否已发布,若未发布则跳过,无法修订
if (!isRelease(rev)) {
System.out.println(">>>版本【"+rev.getStringProperty("object_string")+"】未发布,不允许修订,跳过!");
xdErroItemRevString += " "+rev.getStringProperty("object_string")+"\n";
continue;
}else {
//版本已发布,升版,加入文件夹下
try {
TCComponentItemRevision newItemRevision = rev.saveAs(null);
owningRevision.add("CMHasSolutionItem", newItemRevision);
} catch (Exception e) {
try {
TCComponentItemRevision latestItemRevision = rev.getItem().getLatestItemRevision();
owningRevision.add("CMHasSolutionItem", latestItemRevision);
System.out.println("已存在新版本");
}catch (Exception e2) {
e2.printStackTrace();
}
}
}
}
// session.getUserService().call("bypass", new Object[] { false });
System.out.println("批量修订完成!");
if (xdErroItemRevString != null && !xdErroItemRevString.equals("")){
MessageBox.post("批量修订完成!\n部分版本修订失败。原因未发布\n "+xdErroItemRevString, "我的打印信息", MessageBox.INFORMATION);
}else {
MessageBox.post("批量修订完成!", "修订结果", MessageBox.INFORMATION);
}
}else {
System.out.println("未获取到文件夹["+folderName+"-"+folderTrueName+"]下的子项!");
MessageBox.post("未获取到文件夹["+folderName+"-"+folderTrueName+"]下的子项!", "修订结果", MessageBox.INFORMATION);
}
}else {
System.out.println("获取选中文件夹的属性真实值失败!");
}
}else {
System.out.println("选中对象【"+targetName+"】的类型 [非文件夹] ,为:"+targetComponent.getType());
}
}
} catch (Exception e) {
System.out.println("批量修订失败:");
e.printStackTrace();
}
}
/**
*
* @param rev
* @return
* @throws TCException
*/
private boolean isRelease(TCComponentItemRevision rev) throws TCException {
AIFComponentContext[] releaseList = rev.getChildren("release_status_list");
if (releaseList != null && releaseList.length > 0) {
TCComponentReleaseStatus status = (TCComponentReleaseStatus) releaseList[releaseList.length-1].getComponent();
String releaseName = status.getProperty("name");
if (!releaseName.contains("发布")||!releaseName.contains("TCM")) {
return false;
}else {
return true;
}
}else {
return false;
}
}
}

@ -0,0 +1,22 @@
package cn.net.connor.plm.batchRevision;
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;
public class BatchRevisionHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
BatchRevisionAction action = new BatchRevisionAction(application, null, null);
new Thread(action).start();
return null;
}
}

@ -0,0 +1,288 @@
package cn.net.connor.plm.dialogs;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import cn.net.connor.plm.entity.Prop;
import cn.net.connor.plm.util.ExcelWriteTable1;
import cn.net.connor.plm.util.ExcelWriteTable2;
import cn.net.connor.plm.util.ExcelWriteTable3;
import cn.net.connor.plm.util.SignPDF;
import java.awt.*;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class DataAllocationHandlerDialog extends JFrame implements Runnable{
private JLabel selectUploadLabel;
private JComponent uploadInput;
private JButton importButton;
private JButton okButton;
private JButton celButton;
private AbstractAIFUIApplication app;
private List<Prop> propList1;
private List<Prop> propList2;
private List<Prop> propList3;
private List<TCComponentItemRevision> relationRevs;
public DataAllocationHandlerDialog(AbstractAIFUIApplication app, List<Prop> propList1, List<Prop> propList2,
List<Prop> propList3, List<TCComponentItemRevision> relationRevs) {
// TODO Auto-generated constructor stub
this.app = app;
this.propList1 = propList1;
this.propList2 = propList2;
this.propList3 = propList3;
this.relationRevs = relationRevs;
}
public void initializationComponent() {
selectUploadLabel = new JLabel("请选择下载位置");
uploadInput = new JTextField(14);
importButton = new JButton("浏览");
okButton = new JButton("确定");
celButton = new JButton("取消");
SwingUtilities.getWindowAncestor(importButton);
}
/**
*
*/
public void initUi() {
initializationComponent();
JDialog dialog = new JDialog((JFrame) SwingUtilities.getWindowAncestor(importButton), "请选择下载路径", true);
dialog.setLayout(null);
// 创建标签
selectUploadLabel.setBounds(35, 40, 110, 25);
dialog.add(selectUploadLabel);
// 创建输入框
uploadInput.setBounds(140, 40, 150, 25);
dialog.add(uploadInput);
// 创建选择按钮
importButton.setBounds(305, 40, 90, 25);
importButton.addActionListener(e -> {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
// fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
// fileChooser.setMultiSelectionEnabled(false);
fileChooser.setAcceptAllFileFilterUsed(false); // 不显示 "所有文件" 选项
// FileNameExtensionFilter filter = new FileNameExtensionFilter("Excel Files", "xlsx", "xls");
// fileChooser.setFileFilter(filter);
// 设置默认打开的文件夹为桌面
File desktopDir = new File(System.getProperty("user.home"), "Desktop");
fileChooser.setCurrentDirectory(desktopDir);
int result = fileChooser.showOpenDialog(dialog);
if (result == JFileChooser.APPROVE_OPTION) {
((JTextField) uploadInput).setText(fileChooser.getSelectedFile().getAbsolutePath());
}
});
dialog.add(importButton, BorderLayout.EAST);
okButton.addActionListener(e -> {
String path = ((JTextField) uploadInput).getText();
if (path.isEmpty()) {
JOptionPane.showMessageDialog(dialog, "请选择文件下载位置");
} else {
// 检查文件是否为目录
File file = new File(path);
if (file.exists()) {
// 处理上传逻辑
doTask(file);
dialog.dispose();
}
}
});
celButton.addActionListener(e -> {
dialog.dispose();
});
// 创建确定和取消按钮
okButton.setBounds(90, 90, 100, 25);
celButton.setBounds(210, 90, 100, 25);
dialog.add(okButton);
dialog.add(celButton);
// 设置对话框大小和位置
dialog.pack();
dialog.setSize(440, 190);
// 获取 importButton 的祖先窗口
Window ancestor = SwingUtilities.getWindowAncestor(importButton);
if (ancestor instanceof JFrame) {
dialog.setLocationRelativeTo((JFrame) ancestor);
} else {
// 如果祖先不是 JFrame可以选择居中显示在屏幕中央
dialog.setLocationRelativeTo(null);
}
dialog.setVisible(true);
}
public void doTask(File file) {
System.out.println("fileName : " + file.getName());
String absolutePath = file.getAbsolutePath();
System.out.println(propList1);
System.out.println(propList2);
System.out.println(propList3);
try {
if (propList1 != null) {
ExcelWriteTable1.generateFromTemplateStructure(absolutePath + "\\技术工艺【图纸】发放回收记录表.xlsx",
propList1);
}
if (propList2 != null) {
ExcelWriteTable2.generateFromTemplateStructure(absolutePath + "\\技术工艺【变更】发放回收记录表.xlsx",
propList2);
}
if (propList3 != null) {
ExcelWriteTable3.generateFromTemplateStructure(absolutePath + "\\【试制工作联系单】发放回收记录.xlsx",
propList3);
}
List<String> filePaths = new ArrayList<String>();
for (TCComponentItemRevision rev : relationRevs) {
String itemId = rev.getStringProperty("item_id");
String itemRevId = rev.getStringProperty("item_revision_id");
String name = rev.getStringProperty("object_name");
TCComponent[] components = rev.getRelatedComponents("IMAN_specification");
for (TCComponent tcComponent : components) {
if(tcComponent instanceof TCComponentDataset) {
String type = tcComponent.getType();
System.out.println("type : "+type);
if(type.toLowerCase().equals("pdf")) {
String downLoadExcel = downLoadExcel((TCComponentDataset)tcComponent,absolutePath);
StringBuffer newFileName = new StringBuffer("");
newFileName.append(itemId);
newFileName.append("_");
newFileName.append(itemRevId);
newFileName.append("_");
newFileName.append(name);
newFileName.append("_");
newFileName.append(downLoadExcel.substring(downLoadExcel.lastIndexOf("\\")+1));
File renameFile = renameFile(downLoadExcel,newFileName.toString());
downLoadExcel = renameFile.getAbsolutePath();
System.out.println("download path : " + downLoadExcel);
filePaths.add(downLoadExcel);
}
}
}
}
for (String path : filePaths) {
SignPDF.sign(path, addSignSuffix(path));
// deleteFileIfExists(path);
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
/**
*
*
* @param oldFilePath "D:/test/123.pdf"
* @param newFileName "123_sign.pdf"
* @return null
*/
public static File renameFile(String oldFilePath, String newFileName) {
File oldFile = new File(oldFilePath);
if (!oldFile.exists()) {
System.out.println("原文件不存在: " + oldFilePath);
return null;
}
// 获取父目录路径
String parentDir = oldFile.getParent();
// 构建新文件对象
File newFile = new File(parentDir, newFileName);
// 如果目标文件已存在,则删除
if (newFile.exists()) {
if (newFile.delete()) {
System.out.println("已删除旧的目标文件: " + newFile.getAbsolutePath());
} else {
System.out.println("无法删除旧的目标文件: " + newFile.getAbsolutePath());
return null;
}
}
// 重命名文件
if (oldFile.renameTo(newFile)) {
System.out.println("文件重命名为: " + newFile.getAbsolutePath());
return newFile;
} else {
System.out.println("文件重命名失败: " + oldFile.getAbsolutePath());
return null;
}
}
public static void deleteFileIfExists(String filePath) {
File file = new File(filePath);
if (file.exists()) {
if (file.delete()) {
System.out.println("文件已成功删除: " + filePath);
} else {
System.out.println("无法删除文件: " + filePath);
}
} else {
System.out.println("文件不存在,无需处理: " + filePath);
}
}
public static String addSignSuffix(String fileName) {
if (fileName == null || fileName.isEmpty()) {
return fileName;
}
int dotIndex = fileName.lastIndexOf(".");
if (dotIndex == -1 || dotIndex == 0 || dotIndex == fileName.length() - 1) {
// 没有有效扩展名,直接追加 _sign
return fileName + "_sign";
}
String namePart = fileName.substring(0, dotIndex);
String extensionPart = fileName.substring(dotIndex);
return namePart + "_sign" + extensionPart;
}
public String downLoadExcel(TCComponentDataset dataset,String path) {
try {
String refs = dataset.getProperty("ref_names");
String[] ref = refs.split(",");
File file = dataset.getFiles(ref[0], path)[0];
String templateFilePath = file.getAbsolutePath();
// 获取到本地文件的绝对路径templateFilePath
System.out.println("filePath: " + templateFilePath);
return templateFilePath;
} catch (TCException e) {
e.printStackTrace();
}
return "";
}
@Override
public void run() {
// TODO Auto-generated method stub
initUi();
}
}

@ -0,0 +1,127 @@
package cn.net.connor.plm.entity;
/**
* @ClassName Prop
* @Description TODO
* @Author chenzc
* @Date 2025/5/9 11:58
**/
public class Prop {
//从1开始自动增加步长为1
private String sNo;
// B
private String fileName;
// C
private String productName;
// D
private String productDrawingNum;
// E
private String drawingStatus;
// F
private String drawingRevision;
// G
private String compiler;
// O
private String drawingDate;
// P
private String relationFileNo;
public Prop(String sNo, String fileName, String productName, String productDrawingNum, String drawingStatus, String drawingRevision, String compiler, String drawingDate, String relationFileNo) {
this.sNo = sNo;
this.fileName = fileName;
this.productName = productName;
this.productDrawingNum = productDrawingNum;
this.drawingStatus = drawingStatus;
this.drawingRevision = drawingRevision;
this.compiler = compiler;
this.drawingDate = drawingDate;
this.relationFileNo = relationFileNo;
}
public String getsNo() {
return sNo;
}
public void setsNo(String sNo) {
this.sNo = sNo;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getProductDrawingNum() {
return productDrawingNum;
}
public void setProductDrawingNum(String productDrawingNum) {
this.productDrawingNum = productDrawingNum;
}
public String getDrawingStatus() {
return drawingStatus;
}
public void setDrawingStatus(String drawingStatus) {
this.drawingStatus = drawingStatus;
}
public String getDrawingRevision() {
return drawingRevision;
}
public void setDrawingRevision(String drawingRevision) {
this.drawingRevision = drawingRevision;
}
public String getCompiler() {
return compiler;
}
public void setCompiler(String compiler) {
this.compiler = compiler;
}
public String getDrawingDate() {
return drawingDate;
}
public void setDrawingDate(String drawingDate) {
this.drawingDate = drawingDate;
}
public String getRelationFileNo() {
return relationFileNo;
}
public void setRelationFileNo(String relationFileNo) {
this.relationFileNo = relationFileNo;
}
@Override
public String toString() {
return "Prop{" +
"sNo='" + sNo + '\'' +
", fileName='" + fileName + '\'' +
", productName='" + productName + '\'' +
", productDrawingNum='" + productDrawingNum + '\'' +
", drawingStatus='" + drawingStatus + '\'' +
", drawingRevision='" + drawingRevision + '\'' +
", compiler='" + compiler + '\'' +
", drawingDate='" + drawingDate + '\'' +
", relationFileNo='" + relationFileNo + '\'' +
'}';
}
}

@ -0,0 +1,173 @@
package cn.net.connor.plm.handlers;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import cn.net.connor.plm.dialogs.DataAllocationHandlerDialog;
import cn.net.connor.plm.entity.Prop;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.util.MessageBox;
public class DataAllocationHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
// TODO Auto-generated method stub
AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
TCComponent rev = (TCComponent) app.getTargetComponent();
try {
TCComponent[] components = rev.getRelatedComponents("SB6_XGWJ");
String[] type1 = { "SB6_CatiaDesignXRevision", "SB6_AutocadDXRevision", "SB6_CatiaAssDXRevision",
"SB6_CatiaSDXRevision", "SB6_AutocadAssDXRevision", "SB6_AutocadSDXRevision",
"SB6_CatiaDesignLRevision", "SB6_AutocadDLRevision", "SB6_CatiaAssDLRevision",
"SB6_CatiaSDLRevision", "SB6_AutocadAssDLRevision", "SB6_AutocadSDLRevision" };
String type3 = "SB6_SZLXDRevisionMaster";
String[] prop1 = { "object_name", "item_id", "item_revision_id" };
String[] prop3 = { "sb6_SZRM01", "sb6_SZRM02", "sb6_SZRM03", "sb6_SZRM04"};
// 获取当前本地日期和时间
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd");
String localTime = now.format(formatter);
System.out.println("localTime : "+ localTime);
List<Prop> propList1 = new ArrayList<>();
List<Prop> propList2 = new ArrayList<>();
List<Prop> propList3 = new ArrayList<>();
List<TCComponentItemRevision> relationRevs = new ArrayList<TCComponentItemRevision>();
for (int i = 0; i < components.length; i++) {
if (components[i] instanceof TCComponentItemRevision) {
TCComponentItemRevision tcComponent = (TCComponentItemRevision) components[i];
TCComponent[] components1 = tcComponent.getRelatedComponents("release_status_list");
if (components1 == null || components1.length == 0) {
MessageBox.post("存在未发布版本对象", "Error", MessageBox.ERROR);
return null;
}
String type = tcComponent.getType();
System.out.println("type : "+ type);
boolean flag1 = false;
for (String tempType : type1) {
if (type.equals(tempType)) {
flag1 = true;
break;
}
}
TCComponent form = tcComponent.getRelatedComponent("IMAN_master_form_rev");
String itemId = tcComponent.getStringProperty("item_id");
TCComponent owningUeserRelation = tcComponent.getRelatedComponent("owning_user");
String ownerUser = owningUeserRelation.getStringProperty("user_name");
if (ownerUser.contains("(")) {
ownerUser = ownerUser.substring(0, ownerUser.indexOf("("));
}
int cnt = 0;
if (flag1) {
relationRevs.add(tcComponent);
String[] properties = tcComponent.getProperties(prop1);
String property1 = form.getStringProperty("sb6_ifls");
if(property1 != null) {
if (property1.equals("是")) {
property1 = "临时";
} else if (property1.equals("否")) {
property1 = "正式";
} else {
System.out.println("null");
}
}else {
System.out.println("sb6_ifls属性为空");
}
String property2 = form.getStringProperty("sb6_relatedfileno");
propList1.add(new Prop("", "图纸", properties[cnt++], properties[cnt++], property1,
properties[cnt++], ownerUser, localTime, property2));
continue;
}
if (type.equals("ChangeNoticeRevision")) {
relationRevs.add(tcComponent);
String[] properties = form.getProperties(new String[] { "sb6_CNRM05", "sb6_CNRM05" });
TCComponent[] tempGx = tcComponent.getRelatedComponents("CMSolutionItems");
String itemIds = getItemId(tempGx);
String status = getDrawingStatu(tempGx);
propList2.add(new Prop("", "技术文件更改通知单", properties[cnt++], properties[cnt++], itemIds, status,
ownerUser, localTime, itemId));
} else if (type.equals("SB6_JSWTLSCLTZDRevision")) {
relationRevs.add(tcComponent);
String[] properties = form.getProperties(new String[] { "sb6_LSRM05", "sb6_LSRM05" });
TCComponent[] tempGx = tcComponent.getRelatedComponents("SB6_LSSJRelation");
String itemIds = getItemId(tempGx);
String status = getDrawingStatu(tempGx);
propList2.add(new Prop("", "临时问题处理通知单", properties[cnt++], properties[cnt++], itemIds, status,
ownerUser, localTime, itemId));
}
if (type3.equals(type)) {
relationRevs.add(tcComponent);
String[] properties = form.getProperties(prop3);
propList3.add(new Prop("", "样件试制/试生产联系单", properties[cnt++], properties[cnt++], properties[cnt++],properties[cnt++],
ownerUser, localTime, itemId));
}
}
}
DataAllocationHandlerDialog cmbd = new DataAllocationHandlerDialog(app,propList1,propList2,propList3,relationRevs);
new Thread(cmbd).start();
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public String getItemId(TCComponent[] tempGx) throws TCException {
StringBuffer str = new StringBuffer();
for (int i = 0; i < tempGx.length; i++) {
TCComponent tcComponent = tempGx[i];
str.append(tcComponent.getStringProperty("item_id"));
if (i != tempGx.length - 1) {
str.append("\n");
}
}
return str.toString();
}
public String getDrawingStatu(TCComponent[] tempGx) throws TCException {
StringBuffer str = new StringBuffer();
for (int i = 0; i < tempGx.length; i++) {
TCComponent tcComponent = tempGx[i];
TCComponent form = tcComponent.getRelatedComponent("IMAN_master_form_rev");
String ifls = form.getStringProperty("sb6_ifls");
if (ifls.equals("是")) {
ifls = "临时" + tcComponent.getStringProperty("item_revision_id");
} else if (ifls.equals("否")) {
ifls = "正式" + tcComponent.getStringProperty("item_revision_id");
} else {
System.out.println("getDrawingStatu null");
}
System.out.println("ifls : " + ifls);
str.append(ifls);
if (i != tempGx.length - 1 || !ifls.isEmpty()) {
str.append("\n");
}
}
return str.toString();
}
}

@ -0,0 +1,284 @@
package cn.net.connor.plm.util;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import cn.net.connor.plm.entity.Prop;
public class ExcelWriteTable1 {
public static void main(String[] args) throws Exception {
List<Prop> props = new ArrayList<>();
props.add(new Prop("图纸", "减速箱壳体", "123",
"正式", "A", "test1", "2024.4.18", "TCN_1", "TCN_2"));
props.add(new Prop("图纸", "减速箱壳体", "123",
"正式", "A", "test1", "2024.4.18", "TCN_1", "TCN_2"));
props.add(new Prop("1", "2", "3", "4", "5", "6", "7", "8", "9"));
ExcelWriteTable1.generateFromTemplateStructure(
"C:\\Users\\Administrator\\Desktop\\test\\generated_file.xlsx",
props
);
}
public static void generateFromTemplateStructure(String outputPath, List<Prop> props) throws Exception {
try (Workbook workbook = new HSSFWorkbook()) {
Sheet sheet = workbook.createSheet("sheet1");
// ====================== 创建固定表头 ======================
createHeader(workbook, sheet);
// ====================== 创建数据区域 ======================
int rowNum = 2; // 数据起始行(第三行)
for (int i = 0; i < props.size(); i++) {
Prop prop = props.get(i);
// 创建四行数据(合并行)
Row row1 = sheet.createRow(rowNum++);
Row row2 = sheet.createRow(rowNum++);
Row row3 = sheet.createRow(rowNum++);
Row row4 = sheet.createRow(rowNum++);
// 设置行高为 16.8 磅336 单位)
row1.setHeight((short) 336);
row2.setHeight((short) 336);
row3.setHeight((short) 336);
row4.setHeight((short) 336);
// 设置行高为 16.8 磅336 单位)
row1.setHeight((short) 336);
row2.setHeight((short) 336);
// ====================== 填充动态数据 ======================
fillDynamicData(workbook, row1, prop, i + 1);
setRow2Style(workbook, row2);
setRow2Style(workbook, row3);
setRow2Style(workbook, row4);
// ====================== 创建固定模板内容 ======================
createFixedContent(workbook, row1, row2, row3, row4);
// ====================== 设置合并区域 ======================
addMergedRegions(sheet, row1, row2, row3, row4);
}
// ====================== 自动调整列宽 ======================
autoSizeColumns(sheet);
// 保存文件
try (FileOutputStream fos = new FileOutputStream(outputPath)) {
workbook.write(fos);
}
}
}
private static void setRow2Style(Workbook workbook, Row row2) {
CellStyle dataStyle = createDataStyle(workbook);
for (int i = 0; i < 8; i++) {
Cell cell = row2.createCell(i);
cell.setCellStyle(dataStyle);
}
for (int i = 14; i < 18; i++) {
Cell cell = row2.createCell(i);
cell.setCellStyle(dataStyle);
}
}
private static void createHeader(Workbook workbook, Sheet sheet) {
// 第一行标题
Row titleRow = sheet.createRow(0);
titleRow.setHeight((short) 436);
Cell titleCell = titleRow.createCell(0);
titleCell.setCellValue("\u6280\u672F/\u5DE5\u827A\u3010\u56FE\u7EB8\u3011\u53D1\u653E\u3001\u56DE\u6536\u8BB0\u5F55\u8868");
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 17));
// 创建带实线边框的标题样式
CellStyle headerStyle = workbook.createCellStyle();
Font titleFont = workbook.createFont();
titleFont.setBold(true);
titleFont.setFontHeightInPoints((short) 14);
headerStyle.setFont(titleFont);
headerStyle.setAlignment(HorizontalAlignment.CENTER);
headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
// 设置实线边框
headerStyle.setBorderTop(BorderStyle.THIN);
headerStyle.setBorderBottom(BorderStyle.THIN);
headerStyle.setBorderLeft(BorderStyle.THIN);
headerStyle.setBorderRight(BorderStyle.THIN);
// 应用样式到合并后的标题单元格
titleCell.setCellStyle(headerStyle);
// 单独创建第二行表头的样式
CellStyle secondHeaderStyle = workbook.createCellStyle();
Font secondHeaderFont = workbook.createFont();
secondHeaderFont.setBold(true);
secondHeaderFont.setFontHeightInPoints((short) 10);
secondHeaderStyle.setFont(secondHeaderFont);
secondHeaderStyle.setAlignment(HorizontalAlignment.CENTER);
secondHeaderStyle.setVerticalAlignment(VerticalAlignment.CENTER);
secondHeaderStyle.setWrapText(true); // 允许换行
// 设置实线边框
secondHeaderStyle.setBorderTop(BorderStyle.THIN);
secondHeaderStyle.setBorderBottom(BorderStyle.THIN);
secondHeaderStyle.setBorderLeft(BorderStyle.THIN);
secondHeaderStyle.setBorderRight(BorderStyle.THIN);
// 第二行表头
Row headerRow = sheet.createRow(1);
headerRow.setHeight((short) 556);
String[] headers = {"\u5E8F\u53F7", "\u6587\u4EF6\u540D\u79F0", "\u4EA7\u54C1/\u96F6\u90E8\u4EF6\u540D\u79F0", "\u4EA7\u54C1/\u96F6\u90E8\u4EF6\u56FE\u53F7",
"\u56FE\u7EB8\u72B6\u6001", "\u56FE\u7EB8\u7248\u672C", "\u7F16\u5236\u4EBA", "\u9875\u6570", "\u2714 \u7B7E\u6536\u90E8\u95E8",
"", "", "", "", "", "\u7B7E\u6536\u65E5\u671F", "\u76F8\u5173\u6587\u4EF6\u7F16\u53F7", "\u5907\u6CE8", ""};
for (int i = 0; i < headers.length; i++) {
Cell cell = headerRow.createCell(i);
cell.setCellValue(headers[i]);
cell.setCellStyle(secondHeaderStyle);
}
sheet.addMergedRegion(new CellRangeAddress(1, 1, 8, 13));
sheet.addMergedRegion(new CellRangeAddress(1, 1, 16, 17));
}
private static void fillDynamicData(Workbook workbook, Row row, Prop prop, int serialNumber) {
CellStyle dataStyle = createDataStyle(workbook);
// 序号A列
createStyledCell(row, 0, String.valueOf(serialNumber), dataStyle);
// 动态字段
createStyledCell(row, 1, prop.getFileName(), dataStyle);
createStyledCell(row, 2, prop.getProductName(), dataStyle);
createStyledCell(row, 3, prop.getProductDrawingNum(), dataStyle);
createStyledCell(row, 4, prop.getDrawingStatus(), dataStyle);
createStyledCell(row, 5, prop.getDrawingRevision(), dataStyle);
createStyledCell(row, 6, prop.getCompiler(), dataStyle);
createStyledCell(row, 14, prop.getDrawingDate(), dataStyle); // O列
createStyledCell(row, 15, prop.getRelationFileNo(), dataStyle); // P列
}
private static void createFixedContent(Workbook workbook, Row row1, Row row2, Row row3, Row row4) {
CellStyle fixedStyle = createFixedStyle(workbook);
CellStyle dataStyle = createDataStyle(workbook);
// H列固定内容合并单元格
createStyledCell(row1, 7, "1", dataStyle);
// I-N列固定模板
// I-N列固定模板按行分配
String[][] fixedRows = {
{"", "\u91C7\u8D2D\u90E8:", "", "PMC\u90E8:", "", "\u751F\u4EA7\u90E8:"},
{"", "\u5DE5\u827A\u90E8:", "", "\u8D28\u4FDD\u90E8\uFF1A", "", "SQE:"},
{"", "\u56FD\u96451\u90E8:", "", "\u56FD\u96452\u90E8:", "", "\u9500\u552E:"},
{"", "\u96F6\u552E:", "", "\u8BD5\u9A8C\u5BA4:", "", "\u7EFC\u7BA1:"}
};
int colIndex = 8; // I列开始
for (int i = 0; i < fixedRows.length; i++) {
Row currentRow = null;
switch (i) {
case 0:
currentRow = row1;
break;
case 1:
currentRow = row2;
break;
case 2:
currentRow = row3;
break;
case 3:
currentRow = row4;
break;
}
if (currentRow != null) {
for (int j = 0; j < fixedRows[i].length; j++) {
createStyledCell(currentRow, colIndex + j, fixedRows[i][j], fixedStyle);
}
}
}
// Q-R列固定内容
createStyledCell(row1, 16, "\u56DE\u65362023.4.26\uFF0CS6\u7248", dataStyle);
createStyledCell(row1, 17, "\u25A1", dataStyle);
}
private static void addMergedRegions(Sheet sheet, Row row1, Row row2, Row row3, Row row4) {
int startRow = row1.getRowNum();
int endRow = row4.getRowNum();
// 合并 A-H 列(索引 0-7
for (int i = 0; i < 8; i++) {
sheet.addMergedRegion(new CellRangeAddress(
startRow,
endRow,
i,
i
));
}
// 合并 O-R 列(索引 14-17
for (int i = 14; i < 18; i++) {
sheet.addMergedRegion(new CellRangeAddress(
startRow,
endRow,
i,
i
));
}
}
private static CellStyle createFixedStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
style.setBorderTop(BorderStyle.THIN);
style.setBorderBottom(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN);
return style;
}
private static CellStyle createDataStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
Font dataFont = workbook.createFont();
dataFont.setFontHeightInPoints((short) 10);
style.setBorderTop(BorderStyle.THIN);
style.setBorderBottom(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFont(dataFont);
return style;
}
private static void createStyledCell(Row row, int column, String value, CellStyle style) {
Cell cell = row.createCell(column);
cell.setCellValue(value);
cell.setCellStyle(style);
}
private static void autoSizeColumns(Sheet sheet) {
for (int i = 0; i < 18; i++) {
if (i == 8 || i == 10 || i == 12) {
sheet.setColumnWidth(i, 5 * 256);
} else if(i == 16 ){
sheet.setColumnWidth(i, 20 * 256);
} else {
sheet.setColumnWidth(i, 12 * 256);
}
}
}
}

@ -0,0 +1,259 @@
package cn.net.connor.plm.util;
import java.io.FileOutputStream;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import cn.net.connor.plm.entity.Prop;
public class ExcelWriteTable2 {
public static void generateFromTemplateStructure(String outputPath, List<Prop> props) throws Exception {
try (Workbook workbook = new HSSFWorkbook()) {
Sheet sheet = workbook.createSheet("sheet1");
// ====================== 创建固定表头 ======================
createHeader(workbook, sheet);
// ====================== 创建数据区域 ======================
int rowNum = 2; // 数据起始行(第三行)
for (int i = 0; i < props.size(); i++) {
Prop prop = props.get(i);
// 创建四行数据(合并行)
Row row1 = sheet.createRow(rowNum++);
Row row2 = sheet.createRow(rowNum++);
Row row3 = sheet.createRow(rowNum++);
Row row4 = sheet.createRow(rowNum++);
// 设置行高为 16.8 磅336 单位)
row1.setHeight((short) 336);
row2.setHeight((short) 336);
row3.setHeight((short) 336);
row4.setHeight((short) 336);
// 设置行高为 16.8 磅336 单位)
row1.setHeight((short) 336);
row2.setHeight((short) 336);
// ====================== 填充动态数据 ======================
fillDynamicData(workbook, row1, prop, i + 1);
setRow2Style(workbook, row2);
setRow2Style(workbook, row3);
setRow2Style(workbook, row4);
// ====================== 创建固定模板内容 ======================
createFixedContent(workbook, row1, row2, row3, row4);
// ====================== 设置合并区域 ======================
addMergedRegions(sheet, row1, row2, row3, row4);
}
// ====================== 自动调整列宽 ======================
autoSizeColumns(sheet);
// 保存文件
try (FileOutputStream fos = new FileOutputStream(outputPath)) {
workbook.write(fos);
}
}
}
private static void setRow2Style(Workbook workbook, Row row2) {
CellStyle dataStyle = createDataStyle(workbook);
for (int i = 0; i < 8; i++) {
Cell cell = row2.createCell(i);
cell.setCellStyle(dataStyle);
}
for (int i = 14; i < 18; i++) {
Cell cell = row2.createCell(i);
cell.setCellStyle(dataStyle);
}
}
private static void createHeader(Workbook workbook, Sheet sheet) {
// 第一行标题
Row titleRow = sheet.createRow(0);
titleRow.setHeight((short) 436);
Cell titleCell = titleRow.createCell(0);
titleCell.setCellValue(
"\u6280\u672F/\u5DE5\u827A\u3010\u53D8\u66F4\u3011\u53D1\u653E\u3001\u56DE\u6536\u8BB0\u5F55\u8868");
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 17));
// 创建带实线边框的标题样式
CellStyle headerStyle = workbook.createCellStyle();
Font titleFont = workbook.createFont();
titleFont.setBold(true);
titleFont.setFontHeightInPoints((short) 14);
headerStyle.setFont(titleFont);
headerStyle.setAlignment(HorizontalAlignment.CENTER);
headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
// 设置实线边框
headerStyle.setBorderTop(BorderStyle.THIN);
headerStyle.setBorderBottom(BorderStyle.THIN);
headerStyle.setBorderLeft(BorderStyle.THIN);
headerStyle.setBorderRight(BorderStyle.THIN);
// 应用样式到合并后的标题单元格
titleCell.setCellStyle(headerStyle);
// 单独创建第二行表头的样式
CellStyle secondHeaderStyle = workbook.createCellStyle();
Font secondHeaderFont = workbook.createFont();
secondHeaderFont.setBold(true);
secondHeaderFont.setFontHeightInPoints((short) 10);
secondHeaderStyle.setFont(secondHeaderFont);
secondHeaderStyle.setAlignment(HorizontalAlignment.CENTER);
secondHeaderStyle.setVerticalAlignment(VerticalAlignment.CENTER);
secondHeaderStyle.setWrapText(true); // 允许换行
// 设置实线边框
secondHeaderStyle.setBorderTop(BorderStyle.THIN);
secondHeaderStyle.setBorderBottom(BorderStyle.THIN);
secondHeaderStyle.setBorderLeft(BorderStyle.THIN);
secondHeaderStyle.setBorderRight(BorderStyle.THIN);
// 第二行表头
Row headerRow = sheet.createRow(1);
headerRow.setHeight((short) 556);
String[] headers = { "\u5E8F\u53F7", "\u6587\u4EF6\u540D\u79F0", "\u4EA7\u54C1/\u96F6\u90E8\u4EF6\u540D\u79F0",
"\u4EA7\u54C1/\u96F6\u90E8\u4EF6\u56FE\u53F7", "\u540C\u65F6\u4E0B\u53D1\u56FE\u7EB8",
"\u56FE\u7EB8\u72B6\u6001/\u7248\u672C", "\u7F16\u5236\u4EBA", "\u9875\u6570",
"\u2714 \u7B7E\u6536\u90E8\u95E8", "", "", "", "", "", "\u7B7E\u6536\u65E5\u671F",
"\u6587\u4EF6\u7F16\u53F7", "\u5907\u6CE8", "" };
for (int i = 0; i < headers.length; i++) {
Cell cell = headerRow.createCell(i);
cell.setCellValue(headers[i]);
cell.setCellStyle(secondHeaderStyle);
}
sheet.addMergedRegion(new CellRangeAddress(1, 1, 8, 13));
sheet.addMergedRegion(new CellRangeAddress(1, 1, 16, 17));
}
private static void fillDynamicData(Workbook workbook, Row row, Prop prop, int serialNumber) {
CellStyle dataStyle = createDataStyle(workbook);
// 序号A列
createStyledCell(row, 0, String.valueOf(serialNumber), dataStyle);
// 动态字段
createStyledCell(row, 1, prop.getFileName(), dataStyle);
createStyledCell(row, 2, prop.getProductName(), dataStyle);
createStyledCell(row, 3, prop.getProductDrawingNum(), dataStyle);
createStyledCell(row, 4, prop.getDrawingStatus(), dataStyle);
createStyledCell(row, 5, prop.getDrawingRevision(), dataStyle);
createStyledCell(row, 6, prop.getCompiler(), dataStyle);
createStyledCell(row, 14, prop.getDrawingDate(), dataStyle); // O列
createStyledCell(row, 15, prop.getRelationFileNo(), dataStyle); // P列
}
private static void createFixedContent(Workbook workbook, Row row1, Row row2, Row row3, Row row4) {
CellStyle fixedStyle = createFixedStyle(workbook);
CellStyle dataStyle = createDataStyle(workbook);
// H列固定内容合并单元格
createStyledCell(row1, 7, "1", dataStyle);
// I-N列固定模板
// I-N列固定模板按行分配
String[][] fixedRows = { { "", "\u91C7\u8D2D\u90E8:", "", "PMC\u90E8:", "", "\u751F\u4EA7\u90E8:" },
{ "", "\u5DE5\u827A\u90E8:", "", "\u8D28\u4FDD\u90E8\uFF1A", "", "SQE:" },
{ "", "\u56FD\u96451\u90E8:", "", "\u56FD\u96452\u90E8:", "", "\u9500\u552E:" },
{ "", "\u96F6\u552E:", "", "\u8BD5\u9A8C\u5BA4:", "", "\u7EFC\u7BA1:" } };
int colIndex = 8; // I列开始
for (int i = 0; i < fixedRows.length; i++) {
Row currentRow = null;
switch (i) {
case 0:
currentRow = row1;
break;
case 1:
currentRow = row2;
break;
case 2:
currentRow = row3;
break;
case 3:
currentRow = row4;
break;
}
if (currentRow != null) {
for (int j = 0; j < fixedRows[i].length; j++) {
createStyledCell(currentRow, colIndex + j, fixedRows[i][j], fixedStyle);
}
}
}
// Q-R列固定内容
createStyledCell(row1, 16, "", dataStyle);
createStyledCell(row1, 17, "", dataStyle);
}
private static void addMergedRegions(Sheet sheet, Row row1, Row row2, Row row3, Row row4) {
int startRow = row1.getRowNum();
int endRow = row4.getRowNum();
// 合并 A-H 列(索引 0-7
for (int i = 0; i < 8; i++) {
sheet.addMergedRegion(new CellRangeAddress(startRow, endRow, i, i));
}
// 合并 O-R 列(索引 14-15
for (int i = 14; i < 16; i++) {
sheet.addMergedRegion(new CellRangeAddress(startRow, endRow, i, i));
}
sheet.addMergedRegion(new CellRangeAddress(startRow, endRow, 16, 17));
}
private static CellStyle createFixedStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
style.setBorderTop(BorderStyle.THIN);
style.setBorderBottom(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN);
return style;
}
private static CellStyle createDataStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
Font dataFont = workbook.createFont();
dataFont.setFontHeightInPoints((short) 10);
style.setBorderTop(BorderStyle.THIN);
style.setBorderBottom(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFont(dataFont);
return style;
}
private static void createStyledCell(Row row, int column, String value, CellStyle style) {
Cell cell = row.createCell(column);
cell.setCellValue(value);
cell.setCellStyle(style);
}
private static void autoSizeColumns(Sheet sheet) {
for (int i = 0; i < 18; i++) {
if (i == 8 || i == 10 || i == 12) {
sheet.setColumnWidth(i, 5 * 256);
} else {
sheet.setColumnWidth(i, 10 * 256);
}
}
}
}

@ -0,0 +1,277 @@
package cn.net.connor.plm.util;
import java.io.FileOutputStream;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import cn.net.connor.plm.entity.Prop;
public class ExcelWriteTable3 {
public static void generateFromTemplateStructure(String outputPath, List<Prop> props) throws Exception {
try (Workbook workbook = new HSSFWorkbook()) {
Sheet sheet = workbook.createSheet("sheet1");
// ====================== 创建固定表头 ======================
createHeader(workbook, sheet);
// ====================== 创建数据区域 ======================
int rowNum = 2; // 数据起始行(第三行)
for (int i = 0; i < props.size(); i++) {
Prop prop = props.get(i);
// 创建四行数据(合并行)
Row row1 = sheet.createRow(rowNum++);
Row row2 = sheet.createRow(rowNum++);
Row row3 = sheet.createRow(rowNum++);
Row row4 = sheet.createRow(rowNum++);
// 设置行高为 16.8 磅336 单位)
row1.setHeight((short) 336);
row2.setHeight((short) 336);
row3.setHeight((short) 336);
row4.setHeight((short) 336);
// 设置行高为 16.8 磅336 单位)
row1.setHeight((short) 336);
row2.setHeight((short) 336);
// ====================== 填充动态数据 ======================
fillDynamicData(workbook, row1, prop, i + 1);
setRow2Style(workbook, row2);
setRow2Style(workbook, row3);
setRow2Style(workbook, row4);
// ====================== 创建固定模板内容 ======================
createFixedContent(workbook, row1, row2, row3, row4);
// ====================== 设置合并区域 ======================
addMergedRegions(sheet, row1, row2, row3, row4);
}
// ====================== 自动调整列宽 ======================
autoSizeColumns(sheet);
// 保存文件
try (FileOutputStream fos = new FileOutputStream(outputPath)) {
workbook.write(fos);
}
}
}
private static void setRow2Style(Workbook workbook,Row row2) {
CellStyle dataStyle = createDataStyle(workbook);
for (int i = 0; i < 8; i++) {
Cell cell = row2.createCell(i);
cell.setCellStyle(dataStyle);
}
for (int i = 14; i < 18; i++) {
Cell cell = row2.createCell(i);
cell.setCellStyle(dataStyle);
}
}
private static void createHeader(Workbook workbook, Sheet sheet) {
// 第一行标题
Row titleRow = sheet.createRow(0);
titleRow.setHeight((short) 436);
Cell titleCell = titleRow.createCell(0);
titleCell.setCellValue("\u3010\u8BD5\u5236/\u5DE5\u4F5C\u8054\u7CFB\u5355\u3011\u53D1\u653E\u3001\u56DE\u6536\u8BB0\u5F55");
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 17));
// 创建带实线边框的标题样式
CellStyle headerStyle = workbook.createCellStyle();
Font titleFont = workbook.createFont();
titleFont.setBold(true);
titleFont.setFontHeightInPoints((short) 14);
headerStyle.setFont(titleFont);
headerStyle.setAlignment(HorizontalAlignment.CENTER);
headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
// 设置实线边框
headerStyle.setBorderTop(BorderStyle.THIN);
headerStyle.setBorderBottom(BorderStyle.THIN);
headerStyle.setBorderLeft(BorderStyle.THIN);
headerStyle.setBorderRight(BorderStyle.THIN);
// 应用样式到合并后的标题单元格
titleCell.setCellStyle(headerStyle);
// 单独创建第二行表头的样式
CellStyle secondHeaderStyle = workbook.createCellStyle();
Font secondHeaderFont = workbook.createFont();
secondHeaderFont.setBold(true);
secondHeaderFont.setFontHeightInPoints((short) 10);
secondHeaderStyle.setFont(secondHeaderFont);
secondHeaderStyle.setAlignment(HorizontalAlignment.CENTER);
secondHeaderStyle.setVerticalAlignment(VerticalAlignment.CENTER);
secondHeaderStyle.setWrapText(true); // 允许换行
// 设置实线边框
secondHeaderStyle.setBorderTop(BorderStyle.THIN);
secondHeaderStyle.setBorderBottom(BorderStyle.THIN);
secondHeaderStyle.setBorderLeft(BorderStyle.THIN);
secondHeaderStyle.setBorderRight(BorderStyle.THIN);
// 第二行表头
Row headerRow = sheet.createRow(1);
headerRow.setHeight((short) 556);
String[] headers = {"\u5E8F\u53F7", "\u6587\u4EF6\u540D\u79F0", "\u4EA7\u54C1/\u96F6\u90E8\u4EF6\u540D\u79F0", "\u4EA7\u54C1/\u96F6\u90E8\u4EF6\u56FE\u53F7",
"\u5B8C\u6210\u65F6\u95F4", "\u8BD5\u5236\u6570\u91CF", "\u7F16\u5236\u4EBA", "\u9875\u6570", "\u2714 \u7B7E\u6536\u4EBA\uFF08\u4EFD\u6570\uFF09",
"", "", "", "", "", "\u7B7E\u6536\u65E5\u671F", "\u6587\u4EF6\u7F16\u53F7", "\u5907\u6CE8", ""};
for (int i = 0; i < headers.length; i++) {
Cell cell = headerRow.createCell(i);
cell.setCellValue(headers[i]);
cell.setCellStyle(secondHeaderStyle);
}
sheet.addMergedRegion(new CellRangeAddress(1, 1, 8, 13));
sheet.addMergedRegion(new CellRangeAddress(1, 1, 16, 17));
}
private static void fillDynamicData(Workbook workbook, Row row, Prop prop, int serialNumber) {
CellStyle dataStyle = createDataStyle(workbook);
// 序号A列
createStyledCell(row, 0, String.valueOf(serialNumber), dataStyle);
// 动态字段
createStyledCell(row, 1, prop.getFileName(), dataStyle);
createStyledCell(row, 2, prop.getProductName(), dataStyle);
createStyledCell(row, 3, prop.getProductDrawingNum(), dataStyle);
createStyledCell(row, 4, prop.getDrawingStatus(), dataStyle);
createStyledCell(row, 5, prop.getDrawingRevision(), dataStyle);
createStyledCell(row, 6, prop.getCompiler(), dataStyle);
createStyledCell(row, 14, prop.getDrawingDate(), dataStyle); // O列
createStyledCell(row, 15, prop.getRelationFileNo(), dataStyle); // P列
}
private static void createFixedContent(Workbook workbook, Row row1, Row row2, Row row3, Row row4) {
CellStyle fixedStyle = createFixedStyle(workbook);
CellStyle dataStyle = createDataStyle(workbook);
// H列固定内容合并单元格
createStyledCell(row1, 7, "1", dataStyle);
// I-N列固定模板
// I-N列固定模板按行分配
String[][] fixedRows = {
{"", "\u91C7\u8D2D\u90E8:", "", "PMC\u90E8:", "", "\u751F\u4EA7\u90E8:"},
{"", "\u5DE5\u827A\u90E8:", "", "\u8D28\u4FDD\u90E8\uFF1A", "", "SQE:"},
{"", "\u56FD\u96451\u90E8:", "", "\u56FD\u96452\u90E8:", "", "\u9500\u552E:"},
{"", "\u96F6\u552E:", "", "\u8BD5\u9A8C\u5BA4:", "", "\u7EFC\u7BA1:"}
};
int colIndex = 8; // I列开始
for (int i = 0; i < fixedRows.length; i++) {
Row currentRow = null;
switch (i) {
case 0:
currentRow = row1;
break;
case 1:
currentRow = row2;
break;
case 2:
currentRow = row3;
break;
case 3:
currentRow = row4;
break;
}
if (currentRow != null) {
for (int j = 0; j < fixedRows[i].length; j++) {
createStyledCell(currentRow, colIndex + j, fixedRows[i][j], fixedStyle);
}
}
}
// Q-R列固定内容
createStyledCell(row1, 16, "", dataStyle);
createStyledCell(row1, 17, "", dataStyle);
}
private static void addMergedRegions(Sheet sheet, Row row1, Row row2, Row row3, Row row4) {
int startRow = row1.getRowNum();
int endRow = row4.getRowNum();
// 合并 A-H 列(索引 0-7
for (int i = 0; i < 8; i++) {
sheet.addMergedRegion(new CellRangeAddress(
startRow,
endRow,
i,
i
));
}
// 合并 O-R 列(索引 14-15
for (int i = 14; i < 16; i++) {
sheet.addMergedRegion(new CellRangeAddress(
startRow,
endRow,
i,
i
));
}
sheet.addMergedRegion(new CellRangeAddress(
startRow,
endRow,
16,
17
));
}
private static CellStyle createFixedStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
style.setBorderTop(BorderStyle.THIN);
style.setBorderBottom(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN);
return style;
}
private static CellStyle createDataStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
Font dataFont = workbook.createFont();
dataFont.setFontHeightInPoints((short) 10);
style.setBorderTop(BorderStyle.THIN);
style.setBorderBottom(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFont(dataFont);
return style;
}
private static void createStyledCell(Row row, int column, String value, CellStyle style) {
Cell cell = row.createCell(column);
cell.setCellValue(value);
cell.setCellStyle(style);
}
private static void autoSizeColumns(Sheet sheet) {
for (int i = 0; i < 18; i++) {
if(i ==8 || i ==10 || i==12){
sheet.setColumnWidth(i,5 * 256);
}else{
sheet.setColumnWidth(i, 10 * 256);
}
}
}
}

@ -0,0 +1,277 @@
package cn.net.connor.plm.util;
import java.io.File;
import java.io.FileOutputStream;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfGState;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
public class SignPDF {
public static void main(String[] args) {
String pdfUrl = "C:\\测试用例\\ECN2.pdf";
String newPdfUrl = "C:\\测试用例\\ECN_2.pdf";
String dateSign = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy.MM.dd"));
try {
PdfReader reader = new PdfReader(pdfUrl);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(newPdfUrl));
Rectangle rectangle = reader.getPageSize(1);
Float[] fposition = getSize(rectangle);
float x1 = 0.0F;
float y1 = 0.0F;
if (fposition[0] == 2384.0 && fposition[1] == 3370.0F) { // A0
System.out.println("A0");
x1 = 2718.42F;
y1 = 28.3F;
} else if (fposition[0] == 2384.0F && fposition[1] == 1684.0F) { // A1
System.out.println("A1");
x1 = 1731.9F;
y1 = 28.3F;
} else if (fposition[0] == 1684.0F && fposition[1] == 1191.0F) { // A2
System.out.println("A2");
x1 = 1031.8F;
y1 = 28.3F;
} else if (fposition[0] == 1191.0F && fposition[1] == 842.0F) { // A3
System.out.println("A3");
x1 = 552.7F;
y1 = 14.1F;
} else if (fposition[0] == 842.0F && fposition[1] == 595.0F) { // A4
System.out.println("A4");
x1 = 714.3F;
y1 = 467.7F;
} else if (fposition[0] == 3370.4F && fposition[1] == 2383.94F) { // CATIA A0
System.out.println("CATIA A0");
x1 = 2718.4F;
y1 = 28.3F;
} else if (fposition[0] == 2383.94F && fposition[1] == 1683.78F) { // CATIA A1
System.out.println("CATIA A1");
x1 = 1731.9F;
y1 = 28.3F;
} else if (fposition[0] == 1683.78F && fposition[1] == 1190.56F) { // CATIA A2
System.out.println("CATIA A2");
x1 = 1031.8F;
y1 = 28.3F;
} else if (fposition[0] == 1190.56F && fposition[1] == 841.89F) { // CATIA A3
System.out.println("CATIA A3");
x1 = 552.7F;
y1 = 14.1F;
} else if (fposition[0] == 595.28F && fposition[1] == 841.89F) { // CATIA A4
System.out.println("CATIA A4");
x1 = 467.7F;
y1 = 714.3F;
} else if (fposition[0] == 5054.18F && fposition[1] == 2383.94F) { // CATIA S0 A0
System.out.println("CATIA S0 A0");
x1 = 4402.2F;
y1 = 28.3F;
} else if (fposition[0] == 6740.79F && fposition[1] == 2383.94F) { // CATIA S0 A1
System.out.println("CATIA S0 A1");
x1 = 6088.8F;
y1 = 28.3F;
} else if (fposition[0] == 8424.57F && fposition[1] == 2383.94F) { // CATIA S0 A2
System.out.println("CATIA S0 A2");
x1 = 7772.6F;
y1 = 28.3F;
} else if (fposition[0] == 10111.19F && fposition[1] == 2383.94F) { // CATIA S0 A3
System.out.println("CATIA S0 A3");
x1 = 9459.2F;
y1 = 28.3F;
} else if (fposition[0] == 11794.97F && fposition[1] == 2383.94F) { // CATIA S0 A4
System.out.println("CATIA S0 A4");
x1 = 11143F;
y1 = 28.3F;
} else if (fposition[0] == 595.0F && fposition[1] == 842.0F) { // A4
System.out.println("-A4");
x1 = 467.7F;
y1 = 714.3F;
}
if (fposition[0] == 841.92F && fposition[1] == 595.32F) { // A4
System.out.println("技术文件变更通知单");
dateSign = "文档发放日期:" + dateSign;
System.out.println(dateSign);
x1 += 701;
y1 += 570;
}else if(fposition[0] == 595.32F && fposition[1] == 841.92F) { // A4
System.out.println("技术文件变更通知单");
dateSign = "文档发放日期:" + dateSign;
System.out.println(dateSign);
x1 += 454;
y1 += 821;
}else{
x1 += 33;
y1 += 15;
}
System.out.println("当前盖章x1坐标:" + x1);
System.out.println("当前盖章y1坐标:" + y1);
String getenv = System.getenv("TC_ROOT");
getenv += "\\simsun.ttf";
System.out.println(getenv);
PdfContentByte under = stamper.getOverContent(1);
PdfGState fontState = new PdfGState();
under.setGState(fontState);
under.saveState();
// 2. 插入时间字符串formattedTime2
// 定义字体Times New Roman常规小四红色
BaseFont baseFont = BaseFont.createFont(getenv, // Times New Roman 字体文件路径
BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
under.beginText();
under.setFontAndSize(baseFont, 10);
under.setColorFill(new BaseColor(225, 0, 0));
under.setTextMatrix(x1, y1);
under.showText(dateSign);
under.endText();
under.restoreState();
stamper.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void sign(String pdfUrl, String newPdfUrl) {
String dateSign = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy.MM.dd"));
try {
PdfReader reader = new PdfReader(pdfUrl);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(newPdfUrl));
Rectangle rectangle = reader.getPageSize(1);
Float[] fposition = getSize(rectangle);
float x1 = 0.0F;
float y1 = 0.0F;
if (fposition[0] == 2384.0 && fposition[1] == 3370.0F) { // A0
System.out.println("A0");
x1 = 2718.42F;
y1 = 28.3F;
} else if (fposition[0] == 2384.0F && fposition[1] == 1684.0F) { // A1
System.out.println("A1");
x1 = 1731.9F;
y1 = 28.3F;
} else if (fposition[0] == 1684.0F && fposition[1] == 1191.0F) { // A2
System.out.println("A2");
x1 = 1031.8F;
y1 = 28.3F;
} else if (fposition[0] == 1191.0F && fposition[1] == 842.0F) { // A3
System.out.println("A3");
x1 = 552.7F;
y1 = 14.1F;
} else if (fposition[0] == 842.0F && fposition[1] == 595.0F) { // A4
System.out.println("A4");
x1 = 714.3F;
y1 = 467.7F;
} else if (fposition[0] == 3370.4F && fposition[1] == 2383.94F) { // CATIA A0
System.out.println("CATIA A0");
x1 = 2718.4F;
y1 = 28.3F;
} else if (fposition[0] == 2383.94F && fposition[1] == 1683.78F) { // CATIA A1
System.out.println("CATIA A1");
x1 = 1731.9F;
y1 = 28.3F;
} else if (fposition[0] == 1683.78F && fposition[1] == 1190.56F) { // CATIA A2
System.out.println("CATIA A2");
x1 = 1031.8F;
y1 = 28.3F;
} else if (fposition[0] == 1190.56F && fposition[1] == 841.89F) { // CATIA A3
System.out.println("CATIA A3");
x1 = 552.7F;
y1 = 14.1F;
} else if (fposition[0] == 595.28F && fposition[1] == 841.89F) { // CATIA A4
System.out.println("CATIA A4");
x1 = 467.7F;
y1 = 714.3F;
} else if (fposition[0] == 5054.18F && fposition[1] == 2383.94F) { // CATIA S0 A0
System.out.println("CATIA S0 A0");
x1 = 4402.2F;
y1 = 28.3F;
} else if (fposition[0] == 6740.79F && fposition[1] == 2383.94F) { // CATIA S0 A1
System.out.println("CATIA S0 A1");
x1 = 6088.8F;
y1 = 28.3F;
} else if (fposition[0] == 8424.57F && fposition[1] == 2383.94F) { // CATIA S0 A2
System.out.println("CATIA S0 A2");
x1 = 7772.6F;
y1 = 28.3F;
} else if (fposition[0] == 10111.19F && fposition[1] == 2383.94F) { // CATIA S0 A3
System.out.println("CATIA S0 A3");
x1 = 9459.2F;
y1 = 28.3F;
} else if (fposition[0] == 11794.97F && fposition[1] == 2383.94F) { // CATIA S0 A4
System.out.println("CATIA S0 A4");
x1 = 11143F;
y1 = 28.3F;
} else if (fposition[0] == 595.0F && fposition[1] == 842.0F) { // A4
System.out.println("-A4");
x1 = 467.7F;
y1 = 714.3F;
}
if (fposition[0] == 841.92F && fposition[1] == 595.32F) { // A4
System.out.println("技术文件变更通知单");
dateSign = "文档发放日期:" + dateSign;
System.out.println(dateSign);
x1 += 701;
y1 += 570;
}else if(fposition[0] == 595.32F && fposition[1] == 841.92F) { // A4
System.out.println("技术文件变更通知单");
dateSign = "文档发放日期:" + dateSign;
System.out.println(dateSign);
x1 += 454;
y1 += 821;
}else{
x1 += 33;
y1 += 15;
}
System.out.println("当前盖章x1坐标:" + x1);
System.out.println("当前盖章y1坐标:" + y1);
String getenv = System.getenv("TC_ROOT");
getenv += "\\bin\\simsun.ttf";
System.out.println(getenv);
PdfContentByte under = stamper.getOverContent(1);
PdfGState fontState = new PdfGState();
under.setGState(fontState);
under.saveState();
// 2. 插入时间字符串formattedTime2
// 定义字体Times New Roman常规小四红色
BaseFont baseFont = BaseFont.createFont(getenv, // Times New Roman 字体文件路径
BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
under.beginText();
under.setFontAndSize(baseFont, 10);
under.setColorFill(new BaseColor(225, 0, 0));
under.setTextMatrix(x1, y1);
under.showText(dateSign);
under.endText();
under.restoreState();
stamper.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static Float[] getSize(Rectangle rectangle) {
Float[] sizef = new Float[2];
float toleft = rectangle.getLeft();
float tobottom = rectangle.getBottom();
float toright = rectangle.getRight();
float totop = rectangle.getTop();
sizef[0] = (Float.valueOf(toright - toleft));
sizef[1] = (Float.valueOf(totop - tobottom));
System.out.println("bean.getH------------>................." + sizef[0]);
System.out.println("bean.getW------------>................." + sizef[1]);
return sizef;
}
}

@ -0,0 +1,43 @@
package cn.net.connor.test;
public class Colconfig {
private String name;
private String age;
private String code;
public Colconfig(String name, String age, String code) {
super();
this.name = name;
this.age = age;
this.code = code;
}
public Colconfig() {
super();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}

@ -0,0 +1,45 @@
package cn.net.connor.test;
import javafx.beans.property.SimpleStringProperty;
public class Data {
private SimpleStringProperty name = new SimpleStringProperty();
private SimpleStringProperty age = new SimpleStringProperty();
private SimpleStringProperty code = new SimpleStringProperty();
public Data() {
super();
}
public Data(String name, String age, String code) {
super();
this.name.set(name);
this.age.set(age);
this.code.set(code);
}
public SimpleStringProperty getName() {
return name;
}
public void setName(SimpleStringProperty name) {
this.name = name;
}
public SimpleStringProperty getAge() {
return age;
}
public void setAge(SimpleStringProperty age) {
this.age = age;
}
public SimpleStringProperty getCode() {
return code;
}
public void setCode(SimpleStringProperty code) {
this.code = code;
}
}

@ -0,0 +1,79 @@
package cn.net.connor.test;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.ComboBoxTableCell;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.util.Callback;
@SuppressWarnings("all")
public class Main extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage stage) {
StackPane root = new StackPane();
ObservableList<String> list = FXCollections.observableArrayList();
list.add("One");
list.add("Two");
list.add("Three");
list.add("Four");
TableColumn name = new TableColumn("Name");
TableColumn age = new TableColumn("age");
TableColumn code = new TableColumn("code");
name.setCellValueFactory(new PropertyValueFactory<Colconfig, String>("name"));
name.setCellFactory(ComboBoxTableCell.forTableColumn(list));
age.setCellValueFactory(new PropertyValueFactory<Colconfig, String>("age"));
age.setCellFactory(TextFieldTableCell.forTableColumn());
code.setCellValueFactory(new PropertyValueFactory<Colconfig, String>("code"));
code.setCellFactory(TextFieldTableCell.forTableColumn());
name.setOnEditCommit(new EventHandler<Event>() {
@Override
public void handle(Event arg0) {
}
});
ObservableList<Colconfig> datas = FXCollections.observableArrayList();
datas.add(new Colconfig("A", "12", "1212"));
datas.add(new Colconfig("B", "13", "1313"));
datas.add(new Colconfig("C", "14", "1414"));
TableView table = new TableView(datas);
table.setEditable(true);
table.getColumns().addAll(name, age, code);
root.getChildren().add(table);
Scene scene = new Scene(root, 300, 250);
stage.setTitle("Test");
stage.setScene(scene);
stage.show();
}
}

@ -0,0 +1,75 @@
package cn.net.connor.test;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TitledPane;
import javafx.scene.control.cell.ComboBoxTableCell;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Main2 extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage stage) {
VBox vBox = new VBox();
Scene scene = new Scene(vBox, 500, 250);
ObservableList<String> list = FXCollections.observableArrayList();
list.add("One");
list.add("Two");
list.add("Three");
list.add("Four");
for (int i = 0; i < 3; i++) {
ObservableList<Colconfig> datas = FXCollections.observableArrayList();
datas.add(new Colconfig("A", "12", "1212"));
datas.add(new Colconfig("B", "13", "1313"));
datas.add(new Colconfig("C", "14", "1414"));
TableColumn<Colconfig, String> name = new TableColumn<>("Name");
TableColumn<Colconfig, String> age = new TableColumn<>("Age");
TableColumn<Colconfig, String> code = new TableColumn<>("Code");
name.setCellValueFactory(new PropertyValueFactory<Colconfig, String>("name"));
name.setCellFactory(ComboBoxTableCell.forTableColumn(list));
age.setCellValueFactory(new PropertyValueFactory<Colconfig, String>("age"));
age.setCellFactory(TextFieldTableCell.forTableColumn());
code.setCellValueFactory(new PropertyValueFactory<Colconfig, String>("code"));
code.setCellFactory(TextFieldTableCell.forTableColumn());
TableView<Colconfig> table = new TableView<>(datas);
name.setEditable(false);
table.setEditable(true);
table.getColumns().addAll(name, age, code);
TitledPane titledPane = new TitledPane("AutocadSDX" + i, table);
titledPane.setMaxHeight(500);
titledPane.setMinHeight(230);
titledPane.expandedProperty().addListener((observable, wasExpanded, isExpanded) -> {
titledPane.setMaxHeight(isExpanded ? 500 : 0);
titledPane.setMinHeight(isExpanded ? 230 : Region.USE_PREF_SIZE);
});
titledPane.setAnimated(false);
VBox.setVgrow(titledPane, Priority.ALWAYS);
vBox.getChildren().add(titledPane);
}
stage.setScene(scene);
stage.show();
}
}

@ -0,0 +1,56 @@
package cn.net.connor.test;
public class PartBean {
private String id;
private String uom;
private String material;
private String weight;
public PartBean() {
super();
}
public PartBean(String id, String uom, String material, String weight) {
super();
this.id = id;
this.uom = uom;
this.material = material;
this.weight = weight;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUom() {
return uom;
}
public void setUom(String uom) {
this.uom = uom;
}
public String getMaterial() {
return material;
}
public void setMaterial(String material) {
this.material = material;
}
public String getWeight() {
return weight;
}
public void setWeight(String weight) {
this.weight = weight;
}
}

@ -0,0 +1,37 @@
package cn.net.connor.test;
import java.util.ArrayList;
import java.util.List;
public class Test {
public List<Inner> inners;
public Test() {
inners = new ArrayList<Test.Inner>();
Inner inner = new Inner(true, "A");
Inner inner2 = new Inner(true, "A");
;
inners.add(inner);
inners.add(inner2);
System.out.println(inner);
System.out.println(inner2);
System.out.println(inner == inner2);
}
public static class Inner {
public boolean flag;
public String name;
public Inner(boolean flag, String name) {
super();
this.flag = flag;
this.name = name;
}
}
public static void main(String[] args) {
new Test();
}
}

@ -0,0 +1,256 @@
package com.connor.dfl.plm.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;
import com.teamcenter.rac.util.MessageBox;
public class DataBaseControl {
/** ************************数据库类调用:声明部分*********************************** */
/**
* kelsen ....
*/
Connection conn;
ResultSet rs;
PreparedStatement pstmt;
Statement stmt;
String strSQLQuery;
public String str_Information = "";
private String strDriver = "oracle.jdbc.driver.OracleDriver";
private String strUrl = "jdbc:oracle:thin:@localhost:1521:tc12";
// private String strUrl = "jdbc:oracle:thin:@192.168.3.22:1521:tc12";
private String strUserName = "infodba";
private String strPassword = "infodba";
public DataBaseControl(String strDriver, String strUrl, String strUserName, String strPassword) {
this.strDriver = strDriver;
this.strUrl = strUrl;
this.strUserName = strUserName;
this.strPassword = strPassword;
try {
Class.forName(strDriver);
} catch (ClassNotFoundException cnfe) {
cnfe.printStackTrace();
}
}
/**
* 2
*/
public ResultSet dbQuery2(String strSQLQuery, Object[] strs) {
ResultSet rs_result = null;
if (conn == null)
openDataBase();
try {
// stmt = conn.createStatement();
PreparedStatement ps = conn.prepareStatement(strSQLQuery);
for (int i = 0; i < strs.length; i++) {
ps.setObject(i + 1, strs[i]);
}
rs_result = ps.executeQuery();
} catch (SQLException sqle2) {
sqle2.printStackTrace();
}
return rs_result;
}
/**
* 2
*/
public void dbModify2(String strSQLQuery, Object[] strs) {
try {
PreparedStatement ps = conn.prepareStatement(strSQLQuery);
for (int i = 0; i < strs.length; i++) {
ps.setObject(i + 1, strs[i]);
}
ps.executeUpdate();
} catch (SQLException sqle2) {
sqle2.printStackTrace();
}
}
/**
*
*
*/
public void openDataBase() {
try {
if (conn == null || conn.isClosed()) {
conn = DriverManager.getConnection(this.strUrl, this.strUserName, this.strPassword);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
*
*/
public void closeDataBase() {
try {
if (rs != null) {
try {
rs.close();
} catch (SQLException sqlec) {
sqlec.printStackTrace();
}
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException sqlec) {
sqlec.printStackTrace();
}
}
if (conn != null && !conn.isClosed()) {
try {
conn.close();
} catch (SQLException sqlecon) {
sqlecon.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
*
*
* @param type
* @param prefix
* @param col 4"0000"
* @return
* @throws Exception
*/
public String getNewCode(String type, String col) throws Exception {
openDataBase();
String lshstr = "";
if (col != null && !"".equals(col)) {
lshstr = col;
} else {
lshstr = "00000000000";
}
openDataBase();
// 根据图纸类型查询 前缀 流水码
String query = "select TYPE,PREFIX,LSH from XINSHIBAO where TYPE= ?";
String query2 = "select LSH from XINSHIBAO where PREFIX = ? ";
String query3 = "select LSH from XINSHIBAO where PREFIX = ? and LSH is not null order by LSH DESC";
ResultSet rs = dbQuery2(query, new Object[] { type });
if (rs.next()) {
String t = rs.getString(1);
String pre = rs.getString(2);
String lsh = rs.getString(3);
if (pre == null || "".equals(pre) || "null".equals(pre)) {
return "该新世宝未分配前缀无法构建ERP编码";
}
ResultSet rs2 = dbQuery2(query2, new Object[] { pre });
boolean flag = rs2.next();
if (flag) {
lsh = rs2.getString(1);
if (lsh == null || "null".equals(lsh) || "".equals(lsh)) {
int temp = col.length() - pre.length();
lsh = pre;
while (temp > 0) {
lsh += "0";
temp--;
}
} else {
ResultSet rs3 = dbQuery2(query3, new Object[] { pre });
rs3.next();
lsh = rs3.getString(1);
}
}
long ls = Long.parseLong(lsh) + 1;// 新的流水码数
lshstr = ls + "";
String upin = "update XINSHIBAO set LSH = ? where TYPE = ? ";
dbModify2(upin, new Object[] { lshstr, t });
}
closeDataBase();
return lshstr;
}
public String getNewCode(String prefix, String min, String max) throws Exception {
openDataBase();
String lshstr = "";
String query = "SELECT LSH FROM SHIBAO_LSH WHERE PREFIX = ? AND LSHMIN = ?";
ResultSet rs = dbQuery2(query, new Object[] { prefix, min });
if (rs.next()) {
String lsh = rs.getString(1);
long parseLong = Long.parseLong(lsh) + 1;
if (parseLong > Long.parseLong(max)) {
return "";
}
lshstr = parseLong + "";
if (lshstr.length() < max.length()) {
int temp = max.length() - lshstr.length();
while (temp > 0) {
lshstr = "0" + lshstr;
temp--;
}
}
String update = "UPDATE SHIBAO_LSH SET LSH = ? WHERE PREFIX = ? AND LSHMIN = ?";
dbModify2(update, new Object[] { lshstr, prefix, min });
} else {
lshstr = min;
String update = "INSERT INTO SHIBAO_LSH(PREFIX,LSH,LSHMIN) VALUES(?,?,?)";
dbModify2(update, new Object[] { prefix, min, min });
}
closeDataBase();
return lshstr;
}
public static void main(String args[]) {
try {
// String strDriver = "oracle.jdbc.driver.OracleDriver";
// String strUrl = "jdbc:oracle:thin:@localhost:1521:tc12";
// String strUserName = "infodba";
// String strPassword = "infodba";
//
// DataBaseControl dbc = new DataBaseControl(strDriver, strUrl, strUserName, strPassword);
// dbc.openDataBase();
// String newid = dbc.getNewCode("1123456746", "01", "55");
// System.out.println(newid);
// dbc.closeDataBase();
// String min = "099";
// String max = "999";
// String lsh = "";
// long parseLong = Long.parseLong(min)+1;
// System.out.println(parseLong);
// lsh = parseLong + "";
// if (lsh.length() < max.length()) {
// int temp = max.length() - lsh.length();
// while (temp > 0) {
// lsh = "0" +lsh;
// temp--;
// }
// }
// System.out.println(lsh);
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,44 @@
package com.connor.plm;
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 = "cn.net.connor.ml.plm"; //$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,64 @@
package com.connor.plm;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ChangeRequestTypeSelectDialog extends JDialog {
private String selectedValue = null;
// 静态方法:显示对话框并返回选中的值
public static String showComboBoxDialog(Component parent, String title, String labelText, String[] options) {
// 创建一个模式化的 JDialog
ChangeRequestTypeSelectDialog dialog = new ChangeRequestTypeSelectDialog(parent, title, labelText, options);
dialog.setVisible(true); // 显示对话框,阻塞后续执行
return dialog.selectedValue; // 返回用户选择的值
}
// 私有构造函数
private ChangeRequestTypeSelectDialog(Component parent, String title, String labelText, String[] options) {
super(JOptionPane.getFrameForComponent(parent), title, true); // 模式化对话框
// 初始化组件
JLabel label = new JLabel(labelText + ":");
comboBox = new JComboBox<>(options);
cancelButton = new JButton("取消");
confirmButton = new JButton("确认");
// 设置布局
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.CENTER));
panel.add(label);
panel.add(comboBox);
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
buttonPanel.add(cancelButton);
buttonPanel.add(confirmButton);
this.add(panel, BorderLayout.CENTER);
this.add(buttonPanel, BorderLayout.SOUTH);
// 事件处理
confirmButton.addActionListener(e -> {
selectedValue = (String) comboBox.getSelectedItem();
dispose(); // 关闭对话框
});
cancelButton.addActionListener(e -> {
selectedValue = null;
dispose(); // 关闭对话框
});
// 设置窗口属性
this.setSize(400, 150);
this.setLocationRelativeTo(parent); // 居中显示
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
}
private JComboBox<String> comboBox;
private JButton cancelButton, confirmButton;
}

@ -0,0 +1,603 @@
package com.connor.plm;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.Date;
public class DateUtil {
private static final String HYPHEN = "-";
private static final String COLON = ":";
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 时间格式 DateTimeFormatter (Java8) ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
enum FormatEnum {
/**
* DateTimeFormatter "yyyy-MM-dd HH:mm:ss"
*/
FORMAT_DATA_TIME(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT)),
/**
* DateTimeFormatter "yyyyMMddHHmmss"
*/
FORMAT_DATA_TIME_NO_SYMBOL(DateTimeFormatter.ofPattern(DATETIME_FORMAT)),
/**
* DateTimeFormatter "yyyy-MM-dd"
*/
FORMAT_DATE(DateTimeFormatter.ofPattern(DATE_FORMAT)),
/**
* DateTimeFormatter "HH:mm:ss"
*/
FORMAT_TIME(DateTimeFormatter.ofPattern(TIME_FORMAT));
private DateTimeFormatter value;
FormatEnum(DateTimeFormatter format) {
this.value = format;
}
}
/*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ 时间格式 DateTimeFormatter (Java8) ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 时间格式 字符串 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
/**
*
* <br/>
* "yyyy"
*/
public static final String YEAR_FORMAT = "yyyy";
/**
*
* <br/>
* "MM"
*/
public static final String MONTH_FORMAT = "MM";
/**
*
* <br/>
* "dd"
*/
public static final String DAY_FORMAT = "dd";
/**
*
* <br/>
* "HH"
*/
public static final String HOUR_FORMAT = "HH";
/**
*
* <br/>
* "mm"
*/
public static final String MINUTE_FORMAT = "mm";
/**
*
* <br/>
* "ss"
*/
public static final String SECOND_FORMAT = "ss";
/**
* <span color='red'>--</span>
* <br/>
* "yyyy-MM-dd"
*/
public static final String DATE_FORMAT = YEAR_FORMAT + HYPHEN + MONTH_FORMAT + HYPHEN + DAY_FORMAT;
/**
* <span color='red'>::</span>
* <br/>
* "HH:mm:ss"
*/
public static final String TIME_FORMAT = HOUR_FORMAT + COLON + MINUTE_FORMAT + COLON + SECOND_FORMAT;
/**
* <span color='red'>-- ::</span>
* <br/>
* "yyyy-MM-dd HH:mm:ss"
*/
public static final String DATE_TIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT;
/**
* <span color='red'></span>
* <br/>
* "yyyyMMddHHmmss"
*/
public static final String DATETIME_FORMAT = YEAR_FORMAT + MONTH_FORMAT + DAY_FORMAT + HOUR_FORMAT + MINUTE_FORMAT + SECOND_FORMAT;
/*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ 时间格式 字符串 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 时间戳 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
/**
*
*/
public static Long epochSecond() {
return localDateTime().toEpochSecond(ZoneOffset.of("+8"));
}
/**
*
*/
public static Long epochMilli() {
return localDateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli();
}
/*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ 时间戳 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 当前时间相关 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
/**
* like 2018-08-27 17:20:06
*/
public static String dateTime() {
return localDateTime().format(FormatEnum.FORMAT_DATA_TIME.value);
}
/**
* like 20180827172006
*/
public static String dateTimeNoSymbol() {
return localDateTime().format(FormatEnum.FORMAT_DATA_TIME_NO_SYMBOL.value);
}
/**
* like 2018-08-27
*/
public static String date() {
return localDate() + "";
}
/**
* like 17:20:06
*/
public static String time() {
return localTime().format(FormatEnum.FORMAT_TIME.value);
}
/**
*
*/
public static Integer year() {
return localDate().getYear();
}
/**
*
*/
public static int month() {
return localDate().getMonthValue();
}
/**
*
*/
public static Integer dayOfYear() {
return localDate().getDayOfYear();
}
/**
*
*/
public static Integer dayOfMonth() {
return localDate().getDayOfMonth();
}
/**
*
*/
public static Integer dayOfWeek() {
return localDate().getDayOfWeek().getValue();
}
/**
*
*/
public static Integer hour() {
return localTime().getHour();
}
/**
*
*/
public static Integer minute() {
return localTime().getMinute();
}
/**
*
*/
public static Integer second() {
return localTime().getSecond();
}
/*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ 当前时间相关 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 未来、历史时间相关 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
/**
*
* <p>
*
* @param years
* @param formatEnum
* @return
*/
public static String minusYears(Long years, FormatEnum formatEnum) {
return minusOrPlusYears(-years, formatEnum);
}
/**
*
* <p>
*
* @param years
* @param formatEnum
* @return
*/
public static String plusYears(Long years, FormatEnum formatEnum) {
return minusOrPlusYears(years, formatEnum);
}
/**
*
*
* @param months
* @param formatEnum
* @return
*/
public static String minusMonths(Long months, FormatEnum formatEnum) {
return minusOrPlusMonths(-months, formatEnum);
}
/**
*
*
* @param months
* @param formatEnum
* @return
*/
public static String plusMonths(Long months, FormatEnum formatEnum) {
return minusOrPlusMonths(months, formatEnum);
}
/**
*
*
* @param days
* @param formatEnum
* @return
*/
public static String minusDays(Long days, FormatEnum formatEnum) {
return minusOrPlusDays(-days, formatEnum);
}
/**
*
*
* @param days
* @param formatEnum
* @return
*/
public static String plusDays(Long days, FormatEnum formatEnum) {
return minusOrPlusDays(days, formatEnum);
}
/**
*
*
* @param weeks
* @param formatEnum
* @return
*/
public static String minusWeeks(Long weeks, FormatEnum formatEnum) {
return minusOrPlusWeeks(-weeks, formatEnum);
}
/**
*
*
* @param weeks
* @param formatEnum
* @return
*/
public static String plusWeeks(Long weeks, FormatEnum formatEnum) {
return minusOrPlusWeeks(weeks, formatEnum);
}
/**
*
*
* @param hours
* @param formatEnum
* @return
*/
public static String minusHours(Long hours, FormatEnum formatEnum) {
return minusOrPlusHours(-hours, formatEnum);
}
/**
*
*
* @param hours
* @param formatEnum
* @return
*/
public static String plusHours(Long hours, FormatEnum formatEnum) {
return minusOrPlusHours(hours, formatEnum);
}
/**
*
*
* @param minutes
* @param formatEnum
* @return
*/
public static String minusMinutes(Long minutes, FormatEnum formatEnum) {
return minusOrPlusMinutes(-minutes, formatEnum);
}
/**
*
*
* @param minutes
* @param formatEnum
* @return
*/
public static String plusMinutes(Long minutes, FormatEnum formatEnum) {
return minusOrPlusMinutes(minutes, formatEnum);
}
/**
*
*
* @param seconds
* @param formatEnum
* @return
*/
public static String minusSeconds(Long seconds, FormatEnum formatEnum) {
return minusOrPlusSeconds(-seconds, formatEnum);
}
/**
* /
*
* @param seconds
* @param formatEnum
* @return
*/
public static String plusSeconds(Long seconds, FormatEnum formatEnum) {
return minusOrPlusSeconds(seconds, formatEnum);
}
/*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ 未来、历史时间相关 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 时间转换相关 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
/**
* DateLocalDateTime
* <p>
*
* @param date date
* @return LocalDateTime
*/
public static LocalDateTime toLocalDateTime(Date date) {
return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
}
/**
* DateLocalDate
* <p>
*
* @param date date
* @return LocalDate
*/
public static LocalDate toLocalDate(Date date) {
return toLocalDateTime(date).toLocalDate();
}
/**
* DateLocalTime
* <p>
*
* @param date date
* @return LocalTime
*/
public static LocalTime toLocalTime(Date date) {
return toLocalDateTime(date).toLocalTime();
}
/**
* LocalDateTime Date
*
* @param localDateTime localDateTime
* @return Date
*/
public static Date toDate(LocalDateTime localDateTime) {
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}
/**
* LocalDateDate
*
* @param localDate localDate
* @return Date
*/
public static Date toDate(LocalDate localDate) {
return toDate(localDate.atStartOfDay());
}
/**
* LocalTimeDate
*
* @param localTime localTime
* @return Date
*/
public static Date toDate(LocalTime localTime) {
return toDate(LocalDateTime.of(localDate(), localTime));
}
/*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ 时间转换相关 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 时间间隔相关 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
/**
* endDate-startDate
* <br> leigq
* <br> 2018-11-07 09:55
* <br>
*
* @param startDate
* @param endDate
* @return
*/
public static Long daysInterval(LocalDate startDate, LocalDate endDate) {
return endDate.toEpochDay() - startDate.toEpochDay();
}
/**
* endDate-startDate
* <br> leigq
* <br> 2018-11-07 09:55
* <br>
*
* @param startDate
* @param endDate
* @return
*/
public static Long daysInterval(String startDate, String endDate) {
return daysInterval(LocalDateTime.parse(endDate, FormatEnum.FORMAT_DATA_TIME.value).toLocalDate(),
LocalDateTime.parse(startDate, FormatEnum.FORMAT_DATA_TIME.value).toLocalDate());
}
/**
* endDate-startDate
* <br> leigq
* <br> 2018-11-07 09:55
* <br>
*
* @param startDate
* @param endDate
* @return
*/
public static Long daysInterval(LocalDateTime startDate, LocalDateTime endDate) {
return daysInterval(startDate.toLocalDate(), endDate.toLocalDate());
}
/*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ 时间间隔相关 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
/*↓↓↓只允许此类调用↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
/**
* /
* <p>
*
* @param yearsToAddOrSubtract
* @param formatEnum
* @return /
*/
private static String minusOrPlusYears(Long yearsToAddOrSubtract, FormatEnum formatEnum) {
return localDateTime().plusYears(yearsToAddOrSubtract).format(formatEnum.value);
}
/**
* /
*
* @param monthsToAddOrSubtract
* @param formatEnum
* @return /
*/
private static String minusOrPlusMonths(Long monthsToAddOrSubtract, FormatEnum formatEnum) {
return localDateTime().plusMonths(monthsToAddOrSubtract).format(formatEnum.value);
}
/**
* /
*
* @param daysToAddOrSubtract
* @param formatEnum
* @return /
*/
private static String minusOrPlusDays(Long daysToAddOrSubtract, FormatEnum formatEnum) {
return localDateTime().plusDays(daysToAddOrSubtract).format(formatEnum.value);
}
/**
* /
*
* @param weeksToAddOrSubtract
* @param formatEnum
* @return /
*/
private static String minusOrPlusWeeks(Long weeksToAddOrSubtract, FormatEnum formatEnum) {
return localDateTime().plusWeeks(weeksToAddOrSubtract).format(formatEnum.value);
}
/**
* /
*
* @param hoursToAddOrSubtract
* @param formatEnum
* @return /
*/
private static String minusOrPlusHours(Long hoursToAddOrSubtract, FormatEnum formatEnum) {
return localDateTime().plusHours(hoursToAddOrSubtract).format(formatEnum.value);
}
/**
* /
*
* @param minutesToAddOrSubtract
* @param formatEnum
* @return /
*/
private static String minusOrPlusMinutes(Long minutesToAddOrSubtract, FormatEnum formatEnum) {
return localDateTime().plusMinutes(minutesToAddOrSubtract).format(formatEnum.value);
}
/**
* /
*
* @param secondsToAddOrSubtract
* @param formatEnum
* @return /
*/
private static String minusOrPlusSeconds(Long secondsToAddOrSubtract, FormatEnum formatEnum) {
return localDateTime().plusSeconds(secondsToAddOrSubtract).format(formatEnum.value);
}
/**
* LocalDate
*/
private static LocalDate localDate() {
return localDateTime().toLocalDate();
}
/**
* LocalTime
*/
private static LocalTime localTime() {
return localDateTime().toLocalTime();
}
/**
* LocalDateTime
*/
private static LocalDateTime localDateTime() {
return LocalDateTime.now();
}
}

@ -0,0 +1,37 @@
package com.connor.plm;
import java.lang.reflect.Constructor;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
import com.teamcenter.rac.util.MessageBox;
public class KAction extends AbstractAIFAction {
KAction(AbstractAIFUIApplication app, String string) {
super(app,string);
}
@Override
public void run() {
try {
int ind = actionName.indexOf('#');
String action=actionName;
String actionData="";
if(ind>0) {
action=actionName.substring(0,ind);//actionName中#号前面的内容
actionData=actionName.substring(ind+1);//actionName中#号后面的内容
}
Class<?> c = Class.forName(action);
Constructor<?> constructor = c.getConstructor(AbstractAIFApplication.class, String.class,String.class);
KCommand command = (KCommand) constructor.newInstance(this.application, action, actionData);
command.executeModal();
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(e.toString(),KLocale.getString("error"),MessageBox.ERROR);
}
}
}

@ -0,0 +1,16 @@
package com.connor.plm;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFCommand;
public abstract class KCommand extends AbstractAIFCommand {
protected AbstractAIFApplication app;
protected String actionInfo;
public KCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
this.app = app;
this.actionInfo = actionInfo;
}
}

@ -0,0 +1,24 @@
package com.connor.plm;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
/**
* Add following config to MANIFEST.MF
* Eclipse-RegisterBuddy: k.util
* @author Administrator
*
*/
public class KHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) {
AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
new Thread(new KAction(app,arg0.getCommand().getId())).start();
return null;
}
}

@ -0,0 +1,22 @@
package com.connor.plm;
import com.teamcenter.rac.util.Registry;
public class KLocale {
public static final Registry reg = Registry.getRegistry(KLocale.class);
public static String getString(String title) {
if (isEmpty(title)) {
return "";
} else {
String res = reg.getString(title);
return isEmpty(res) ? title : res;
}
}
private static boolean isEmpty(String title) {
return title == null || "".equals(title.trim());
}
}

@ -0,0 +1,52 @@
package com.connor.plm;
import java.awt.Dimension;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.kernel.TCSession;
/*
* do not call executeOperation yourself
* use session.performOperation
*/
public abstract class KOperation extends AbstractAIFOperation {
protected AbstractAIFApplication app;
protected TCSession session;
public String messageLabel;
public KOperation(AbstractAIFApplication app, String opName, String messageLabel) {
super(opName, true);
this.app = app;
this.session = (TCSession) app.getSession();
this.messageLabel = messageLabel;// ½ø¶ÈÌõÐÅÏ¢
setSession(session);
}
public abstract boolean init() throws Exception;
public abstract void execute() throws Exception;
@Override
public void executeOperation() {
ProgressBar pb = new ProgressBar(getCurrentDesktop(), new Dimension(250, 50), true);
try {
pb.showDialog();
pb.setText(messageLabel);
setStatus("Checking Data...");
if (!init()) {
pb.disposeDialog();
return;
}
setStatus("Execute...");
pb.setText(messageLabel);
execute();
pb.disposeDialog();
} catch (Exception e) {
pb.disposeDialog();
KUtil.error(getCurrentDesktop(), "·¢ÉúÒì³££º\n" + e.getMessage());
e.printStackTrace();
}
}
}

@ -0,0 +1,51 @@
package com.connor.plm;
import java.awt.Dimension;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.kernel.TCSession;
/*
* do not call executeOperation yourself
* use session.performOperation
*/
public abstract class KOperation2 extends AbstractAIFOperation {
protected AbstractAIFApplication app;
protected TCSession session;
protected ProgressBar pb;
public KOperation2(AbstractAIFApplication app, String opName) {
super(opName, true);
this.app = app;
this.session = (TCSession) app.getSession();
setSession(session);
}
public abstract boolean init() throws Exception;
public abstract void execute() throws Exception;
@Override
public void executeOperation() {
pb = new ProgressBar(getCurrentDesktop(), new Dimension(250, 50), true);
try {
pb.showDialog();
setStatus(KLocale.getString("initop.STATUS"));
if (!init()) {
pb.disposeDialog();
return;
}
setStatus(KLocale.getString("exeop.STATUS"));
execute();
KUtil.setByPass(false);
pb.disposeDialog();
} catch (Exception e) {
pb.disposeDialog();
KUtil.setByPass(false);
KUtil.error(getCurrentDesktop(), "·¢ÉúÒì³££º\n" + e);
e.printStackTrace();
}
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,130 @@
package com.connor.plm;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.KeyStroke;
import com.teamcenter.rac.aif.AIFDesktop;
import com.teamcenter.rac.aif.AbstractAIFDialog;
@SuppressWarnings("serial")
public class ProgressBar extends AbstractAIFDialog {
private JLabel messageLabel;
private JProgressBar progressBar;
private boolean showBar = false;
public ProgressBar(AIFDesktop aifDesktop, Dimension dim, boolean showBar) {
super(aifDesktop, false);
this.showBar = showBar;
initUI(dim);
}
public ProgressBar(AbstractAIFDialog pd, Dimension dimension) {
super(pd, false);
initUI(dimension);
}
public ProgressBar(Dimension dim, boolean showBar) {
super(false);
this.showBar = showBar;
initUI(dim);
}
public ProgressBar(AbstractAIFDialog pd, Dimension dimension, boolean showBar) {
super(pd, false);
this.showBar = showBar;
initUI(dimension);
}
private void initUI(Dimension dim) {
this.setLayout(new BorderLayout(0, 0));
this.setUndecorated(true);
JPanel main = new JPanel(new GridBagLayout());
GridBagConstraints s = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0);
main.setBackground(new Color(53, 53, 53));
if (dim != null) {
this.setPreferredSize(dim);
} else {
this.setPreferredSize(new Dimension(200, 40));
}
messageLabel = new JLabel(" ");
messageLabel.setForeground(Color.white);
progressBar = new JProgressBar();
progressBar.setForeground(Color.black);
main.add(messageLabel, s);
s.gridy++;
s.insets = new Insets(0, 5, 2, 5);
if (showBar) {
main.add(progressBar, s);
}
this.add(BorderLayout.CENTER, main);
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
this.getRootPane().registerKeyboardAction(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
disposeDialog();
}
}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
MouseAdapter ma = new MouseAdapter() {
private Point pressPoint = new Point();
@Override
public void mousePressed(MouseEvent e) {
pressPoint = e.getPoint();
}
@Override
public void mouseReleased(MouseEvent e) {
pressPoint = new Point();
}
@Override
public void mouseDragged(MouseEvent e) {
Rectangle r = ProgressBar.this.getBounds();
setLocation(r.x + (e.getX() - pressPoint.x), r.y + (e.getY() - pressPoint.y));
}
};
this.addMouseListener(ma);
this.addMouseMotionListener(ma);
}
public void setText(String message) {
// System.out.println(message);
messageLabel.setText(message);
}
public void setText(String txt, int percent) {
setText(txt);
if (percent > progressBar.getMaximum()) {
percent = progressBar.getMaximum();
}
progressBar.setValue(percent);
}
public void cancel() {
disposeDialog();
}
public void startProgress() {
showDialog();
}
}

@ -0,0 +1,58 @@
#
#Thu Jan 21 10:28:16 CST 2021
createscheduledeliverable.ERROR2=\u4E3A [%s] \u521B\u5EFA\u65F6\u95F4\u8868\u4EA4\u4ED8\u7269 [%s] \u5931\u8D25
project=Project
dsuidinpref.ERROR1=Error dataset uid set in preference\: %s
valuenotinlov.ERROR2=LOV "%s" does not contain value\: %s
writedata=Write Data
querynotexist.ERROR1=Query not exist\: %s
dialoginit.ERROR=Init Error
preferror.ERROR1=Preference error\: %s
norefindataset.ERROR1=Download file from dataset "%s" failed. No ref file.
cancel=Cancel
exeop.STATUS=Execute...
initop.STATUS=Checking Data...
noflowkey.ERROR=Missing key for flow number.
wordfield_pagecount.NAME=\u9875\u6570
nopropintype.ERROR2=Property is not defined in type "%s"\: %s.
getflowno.ERROR1=Error getting new flow number for key\: %s
formsave.ERRORTITLE=Error Saving Data
wordfield_pageno.NAME=\u9875\u7801
wordfield_totalpagenominus1.NAME=\u603B\u9875\u7801\u51CF\u4E00
wordfield_totalpagecount.NAME=\u603B\u9875\u6570
exceltitlenorelateinfo.ERROR=Title row in sheet does not have any relation info.
selectProject=Select Project
proplocationnotdefined.ERROR1=\u672A\u77E5\u5C5E\u6027\u4F4D\u7F6E\u201C%s\u201D\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E
excelnotitle.ERROR=Can't find title row in excel sheet.
loadCompFromUid.Error2=Error loading component "%s", UID \= "%s".
uploadfilewhencheckout.ERROR1=Dataset "%s" is checked out. Upload file failed.
wordfield_totalactualpagecountminus1.NAME=\u603B\u5B9E\u9645\u9875\u6570\u51CF\u4E00
nodatainfile.ERROR1=No Data in File\: %s
noexportdata.ERROR=\u6CA1\u6709\u6570\u636E\u53EF\u4EE5\u5BFC\u51FA
notscheduleadmin.INFO=\u53EA\u6709\u534F\u8C03\u8005\u624D\u80FD\u64CD\u4F5C
error=Error
mergefile=Merge File...
index=Index
forminit.ERRORTITLE=Error Loading Rendering
ok=OK
wordfield_totalactualpagecount.NAME=\u603B\u5B9E\u9645\u9875\u6570
requireprop.INFO1=\u8BF7\u586B\u5199\u5C5E\u6027\uFF1A%s
functionnotavailable.INFO=\u6B64\u5BF9\u8C61\u4E0D\u53EF\u4F7F\u7528\u6B64\u529F\u80FD
multiuserbyid.ERROR1=Find multiple users by id\: %s
preparedata=Prepare Data
dbconn.ERROR=Connect to database failed.
typenotfound.ERROR1=Type not found\: %s
filenotexist.ERROR1=File not exist\: %s
wordfield_totalpagecountminus1.NAME=\u603B\u9875\u6570\u51CF\u4E00
readdata=Read Data
clearcache=Clear Cache
exportsuccess.INFO=Export Complete.
uploadfile=Upload File
propnotdefinedintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u672A\u5B9A\u4E49\u5C5E\u6027\uFF1A%s
foldernotexist.ERROR1=Folder not exist\: %s
info=Info
wordfield_totalpageno.NAME=\u603B\u9875\u7801
multiuserbyname.ERROR1=Find multiple users by name\: %s
exportopenfile.INFO=Export complete. Open file?
prefnotconfiged.ERROR1=Prefernce not found\: %s
export=Export

@ -0,0 +1,58 @@
#
#Thu Jan 21 10:28:16 CST 2021
createscheduledeliverable.ERROR2=\u4E3A [%s] \u521B\u5EFA\u65F6\u95F4\u8868\u4EA4\u4ED8\u7269 [%s] \u5931\u8D25
project=\u9879\u76EE
dsuidinpref.ERROR1=\u8BF7\u68C0\u67E5\u9996\u9009\u9879<%s>\uFF0C\u901A\u8FC7\u914D\u7F6EUID\u672A\u627E\u5230\u6570\u636E\u96C6
valuenotinlov.ERROR2=LOV "%s" \u4E2D\u672A\u5B9A\u4E49\u6570\u503C\uFF1A%s
writedata=\u5199\u5165\u6570\u636E
querynotexist.ERROR1=\u67E5\u8BE2\u4E0D\u5B58\u5728\uFF1A%s
dialoginit.ERROR=\u521D\u59CB\u5316\u5F02\u5E38
preferror.ERROR1=\u9996\u9009\u9879\u914D\u7F6E\u9519\u8BEF\uFF1A%s
norefindataset.ERROR1=\u4ECE\u6570\u636E\u96C6\u201C%s\u201D\u4E0B\u8F7D\u6587\u4EF6\u5931\u8D25\uFF0C\u6CA1\u6709\u627E\u5230\u5F15\u7528\u6587\u4EF6\u3002
cancel=\u53D6\u6D88
exeop.STATUS=\u6B63\u5728\u6267\u884C...
initop.STATUS=\u68C0\u67E5\u6570\u636E...
noflowkey.ERROR=\u6D41\u6C34\u7801\u952E\u503C\u4E0D\u53EF\u4E3A\u7A7A
wordfield_pagecount.NAME=\u9875\u6570
nopropintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u4E0D\u5B58\u5728\u5C5E\u6027\uFF1A%s
getflowno.ERROR1=\u83B7\u53D6\u6D41\u6C34\u7801\u5931\u8D25\uFF1A%s
formsave.ERRORTITLE=\u4FDD\u5B58\u6570\u636E\u51FA\u9519
wordfield_pageno.NAME=\u9875\u7801
wordfield_totalpagenominus1.NAME=\u603B\u9875\u7801\u51CF\u4E00
wordfield_totalpagecount.NAME=\u603B\u9875\u6570
exceltitlenorelateinfo.ERROR=\u6807\u9898\u884C\u6CA1\u6709\u89E3\u6790\u5230\u6620\u5C04\u5185\u5BB9
selectProject=\u9009\u62E9\u9879\u76EE
proplocationnotdefined.ERROR1=\u672A\u77E5\u5C5E\u6027\u4F4D\u7F6E\u201C%s\u201D\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E
excelnotitle.ERROR=\u672A\u627E\u5230\u5DE5\u4F5C\u8868\u4E2D\u7684\u6807\u9898\u884C
loadCompFromUid.Error2=\u52A0\u8F7D\u5BF9\u8C61\u201C%s\u201D\u5931\u8D25\uFF0CUID\=\u201C%s\u201D\u3002
uploadfilewhencheckout.ERROR1=\u6570\u636E\u96C6\u201C%s\u201D\u5DF2\u7B7E\u51FA\uFF0C\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25\u3002\u8BF7\u7B7E\u5165\u540E\u518D\u8FDB\u884C\u64CD\u4F5C\u3002
wordfield_totalactualpagecountminus1.NAME=\u603B\u5B9E\u9645\u9875\u6570\u51CF\u4E00
nodatainfile.ERROR1=\u6587\u4EF6\u4E2D\u6CA1\u6709\u6570\u636E\uFF1A%s
noexportdata.ERROR=\u6CA1\u6709\u6570\u636E\u53EF\u4EE5\u5BFC\u51FA
notscheduleadmin.INFO=\u53EA\u6709\u534F\u8C03\u8005\u624D\u80FD\u64CD\u4F5C
error=\u9519\u8BEF
mergefile=\u5408\u5E76\u6587\u4EF6
index=\u5E8F\u53F7
forminit.ERRORTITLE=\u521D\u59CB\u5316\u754C\u9762\u5F02\u5E38
ok=\u786E\u5B9A
wordfield_totalactualpagecount.NAME=\u603B\u5B9E\u9645\u9875\u6570
requireprop.INFO1=\u8BF7\u586B\u5199\u5C5E\u6027\uFF1A%s
functionnotavailable.INFO=\u6B64\u5BF9\u8C61\u4E0D\u53EF\u4F7F\u7528\u6B64\u529F\u80FD
multiuserbyid.ERROR1=\u901A\u8FC7id\u67E5\u8BE2\u5230\u591A\u4E2A\u7528\u6237\uFF1A%s
preparedata=\u51C6\u5907\u6570\u636E
dbconn.ERROR=\u8FDE\u63A5\u6570\u636E\u5E93\u5931\u8D25\u3002
typenotfound.ERROR1=\u672A\u627E\u5230\u7C7B\u578B\uFF1A%s
filenotexist.ERROR1=\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A%s
wordfield_totalpagecountminus1.NAME=\u603B\u9875\u6570\u51CF\u4E00
readdata=\u8BFB\u53D6\u6570\u636E
clearcache=\u6E05\u7406\u7F13\u5B58
exportsuccess.INFO=\u5BFC\u51FA\u5B8C\u6210
uploadfile=\u4E0A\u4F20\u6587\u4EF6
propnotdefinedintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u672A\u5B9A\u4E49\u5C5E\u6027\uFF1A%s
foldernotexist.ERROR1=\u6587\u4EF6\u5939\u4E0D\u5B58\u5728\uFF1A%s
info=\u63D0\u793A
wordfield_totalpageno.NAME=\u603B\u9875\u7801
multiuserbyname.ERROR1=\u901A\u8FC7\u59D3\u540D\u67E5\u8BE2\u5230\u591A\u4E2A\u7528\u6237\uFF1A%s
exportopenfile.INFO=\u5BFC\u51FA\u5B8C\u6210\uFF0C\u6253\u5F00\u6587\u4EF6\uFF1F
prefnotconfiged.ERROR1=\u672A\u914D\u7F6E\u9996\u9009\u9879\uFF1A%s
export=\u5BFC\u51FA

@ -0,0 +1,86 @@
package com.connor.plm.sb02;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.util.Comparator;
import javax.swing.Icon;
import javax.swing.RowSorter;
import javax.swing.RowSorter.SortKey;
import javax.swing.SortOrder;
import javax.swing.table.TableRowSorter;
import antlr.collections.List;
public class ArrowIcon implements Icon {
private final SortOrder sortOrder;
private final int size;
private final boolean ascending;
public ArrowIcon(TableRowSorter<?> sorter, int column, boolean ascending) {
this.ascending = ascending;
this.size = 12;
java.util.List<? extends SortKey> sortKeys = sorter.getSortKeys();
if (sortKeys.size() > 0 && ((RowSorter.SortKey) sortKeys.get(0)).getColumn() == column) {
this.sortOrder = ((RowSorter.SortKey) sortKeys.get(0)).getSortOrder();
} else {
this.sortOrder = SortOrder.ASCENDING;
}
}
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g.create();
g2.translate(x, y);
if (ascending) {
g2.rotate(Math.PI, size / 2.0, size / 2.0);
}
if (sortOrder == SortOrder.ASCENDING) {
g2.draw(createUpTriangle(size));
} else {
g2.draw(createDownTriangle(size));
}
g2.dispose();
}
public int getIconWidth() {
return size;
}
public int getIconHeight() {
return size;
}
private Polygon createUpTriangle(int size) {
Polygon triangle = new Polygon();
triangle.addPoint(0, size);
triangle.addPoint(size / 2, 0);
triangle.addPoint(size, size);
return triangle;
}
private Polygon createDownTriangle(int size) {
Polygon triangle = new Polygon();
triangle.addPoint(0, 0);
triangle.addPoint(size, 0);
triangle.addPoint(size / 2, size);
return triangle;
}
}
//±í¸ñÁÐÅÅÐòÀà
class ColumnSorter implements Comparator<Object> {
private final int col;
private final boolean ascending;
public ColumnSorter(int col, boolean ascending) {
this.col = col;
this.ascending = ascending;
}
@Override
public int compare(Object a, Object b) {
if (a instanceof Comparable && b instanceof Comparable) {
if (ascending) {
return ((Comparable) a).compareTo((Comparable) b);
} else {
return ((Comparable) b).compareTo((Comparable) a);
}
} else {
return 0;
}
}
}

@ -0,0 +1,114 @@
package com.connor.plm.sb02;
import java.util.HashMap;
import javax.swing.JComboBox;
import com.teamcenter.rac.common.lov.view.components.LOVDisplayer;
public class ControlBean {
private String propName;
private String propRelName;
private String defaultValue = "";
private String propType;
private HashMap<String, String> lovMap;
private String lovType;//"DLOV" "LOV"
private String propTo; // ÊôÐÔдÔÚItem/Rev/Form
public String getLovType() {
return lovType;
}
public void setLovType(String lovType) {
this.lovType = lovType;
}
private JComboBox<String> combox;
private boolean ifMust = false;
public boolean isIfMust() {
return ifMust;
}
public void setIfMust(boolean ifMust) {
this.ifMust = ifMust;
}
public JComboBox<String> getCombox() {
return combox;
}
public void setCombox(JComboBox<String> combox) {
this.combox = combox;
}
public String getPropTo() {
return propTo;
}
public void setPropTo(String propTo) {
this.propTo = propTo;
}
public HashMap<String, String> getLovMap() {
return lovMap;
}
public void setLovMap(HashMap<String, String> lovMap) {
this.lovMap = lovMap;
}
public String getPropName() {
return propName;
}
public void setPropName(String propName) {
this.propName = propName;
}
public String getPropRelName() {
return propRelName;
}
public void setPropRelName(String propRelName) {
this.propRelName = propRelName;
}
public String getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public String getPropType() {
return propType;
}
public void setPropType(String propType) {
this.propType = propType;
}
@Override
public String toString() {
return "ControlBean {\n" +
" propName = " + propName + ",\n" +
" propRelName = " + propRelName + ",\n" +
" defaultValue = " + defaultValue + ",\n" +
" propType = " + propType + ",\n" +
" lovMap = " + lovMap + ",\n" +
" propTo = " + propTo + ",\n" +
" ifMust = " + ifMust + ",\n" +
" combox = " + combox + "\n" +
"}";
}
}

@ -0,0 +1,18 @@
package com.connor.plm.sb02;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class DateTest {
public static void main(String[] args) {
String ssString = "sss.sss";
String[] split = ssString.split("\\.");
System.out.println(split.length);
String takeeffect = "";
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-M-dd HH:mm");
//LocalDateTime createDate = LocalDateTime.parse(create, fmt);
LocalDateTime takeeffectDate = LocalDateTime.parse(takeeffect, fmt);
}
}

@ -0,0 +1,54 @@
package com.connor.plm.sb02;
import java.util.ArrayList;
import com.connor.plm.KCommand;
import com.connor.plm.KUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
/**
* ECN
* @author kuma
*
*/
public class DerivedChangeNoticeCommand extends KCommand {
public DerivedChangeNoticeCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
TCSession session = (TCSession) app.getSession();
String preName = "Connor_Derive_CN";
try {
String[] prefVals = KUtil.getPrefVals(session, preName);
InterfaceAIFComponent targetComponent = app.getTargetComponent();
StringBuffer newType = new StringBuffer();
if (prefVals == null) {
MessageBox.post(preName + "首选项未配置", "提示", MessageBox.INFORMATION);
return;
}
ArrayList<ControlBean> beanList = new ArrayList<ControlBean>();
KUtil.dealPref(prefVals, targetComponent, beanList, newType);
for (ControlBean bean : beanList) {
System.out.println("beanList" + bean.toString());
}
if (newType.toString().isEmpty()) {
// MessageBox.post(preName + "首选项配置有误,不存在新建的对象类型", "提示", MessageBox.INFORMATION);
System.out.println("获取新建的对象类型失败,如果取消选择请忽略此条提醒!");
return;
}
if (beanList.size() == 0) {
MessageBox.post(preName + "首选项配置有误,不存在选中对象类型的配置", "提示", MessageBox.INFORMATION);
return;
}
this.setRunnable(
new DerivedChangeRequestDialog(app, beanList, newType, (TCComponentItemRevision) targetComponent));
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,48 @@
package com.connor.plm.sb02;
import java.util.ArrayList;
import com.connor.plm.KCommand;
import com.connor.plm.KUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class DerivedChangeOptionCommand extends KCommand {
public DerivedChangeOptionCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
TCSession session = (TCSession) app.getSession();
String preName = "Connor_Derive_CO";
try {
String[] prefVals = KUtil.getPrefVals(session, preName);
InterfaceAIFComponent targetComponent = app.getTargetComponent();
StringBuffer newType = new StringBuffer();
if (prefVals == null) {
MessageBox.post(preName + "首选项未配置", "提示", MessageBox.INFORMATION);
return;
}
ArrayList<ControlBean> beanList = new ArrayList<ControlBean>();
KUtil.dealPref(prefVals, targetComponent, beanList, newType);
for (ControlBean bean : beanList) {
System.out.println("beanList" + bean.toString());
}
if (newType.toString().isEmpty()) {
// MessageBox.post(preName + "首选项配置有误,不存在新建的对象类型", "提示", MessageBox.INFORMATION);
System.out.println("获取新建的对象类型失败,如果取消选择请忽略此条提醒!");
return;
}
if (beanList.size() == 0) {
MessageBox.post(preName + "首选项配置有误,不存在选中对象类型的配置", "提示", MessageBox.INFORMATION);
return;
}
this.setRunnable(
new DerivedChangeRequestDialog(app, beanList, newType, (TCComponentItemRevision) targetComponent));
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,53 @@
package com.connor.plm.sb02;
import java.util.ArrayList;
import com.connor.plm.KCommand;
import com.connor.plm.KUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
/**
* ECR
* @author kuma
*
*/
public class DerivedChangeRequestCommand extends KCommand {
public DerivedChangeRequestCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
TCSession session = (TCSession) app.getSession();
String preName = "Connor_Derive_CR";
try {
String[] prefVals = KUtil.getPrefVals(session, preName);
InterfaceAIFComponent targetComponent = app.getTargetComponent();
StringBuffer newType = new StringBuffer();
if (prefVals == null) {
MessageBox.post(preName + "首选项未配置", "提示", MessageBox.INFORMATION);
return;
}
ArrayList<ControlBean> beanList = new ArrayList<ControlBean>();
KUtil.dealPref(prefVals, targetComponent, beanList, newType);
System.out.println("newType:" + newType);
if (newType.toString().isEmpty()) {
// MessageBox.post(preName + "首选项配置有误,不存在新建的对象类型", "提示", MessageBox.INFORMATION);
System.out.println("获取新建的对象类型失败,如果取消选择请忽略此条提醒!");
return;
}
if (beanList.size() == 0) {
MessageBox.post(preName + "首选项配置有误,不存在选中对象类型的配置", "提示", MessageBox.INFORMATION);
return;
}
this.setRunnable(
new DerivedChangeRequestDialog(app, beanList, newType, (TCComponentItemRevision) targetComponent));
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,968 @@
package com.connor.plm.sb02;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.LineBorder;
import org.apache.log4j.Logger;
import com.connor.plm.KUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.commands.newitem.NamingRule;
import com.teamcenter.rac.commands.newitem.NamingRulesHelper;
import com.teamcenter.rac.commands.revise.RevisionNamingRuleHelper;
import com.teamcenter.rac.kernel.SoaUtil;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentNameRule;
import com.teamcenter.rac.kernel.TCComponentNameRuleType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCExceptionPartial;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.DateButton;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout;
import com.teamcenter.schemas.core._2014_10.datamanagement.GenerateIdInput;
import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException;
import com.teamcenter.services.rac.core.DataManagementService;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateOut;
import com.teamcenter.services.rac.workflow.WorkflowService;
import com.teamcenter.services.rac.workflow._2008_06.Workflow.ContextData;
import com.teamcenter.services.rac.workflow._2008_06.Workflow.InstanceInfo;
//import com.teamcenter.rac.kernel.TCComponentNameRule;
//import com.teamcenter.rac.kernel.TCComponentNameRuleType;
import com.teamcenter.services.rac.core.DataManagementService;
import com.teamcenter.services.rac.core._2006_03.DataManagement;
@SuppressWarnings("serial")
public class DerivedChangeRequestDialog extends AbstractAIFDialog implements ActionListener {
Logger logger = Logger.getLogger(DerivedChangeRequestDialog.class);
protected TCSession session;
private ArrayList<ControlBean> beanList;
private String newType;
private JPanel centerPanel;
private JButton okButton;
private JButton celButton;
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm");
private TCComponentItemRevision tarRev;
private JTextField idField = null;
private JComboBox<String> idRulebox = new JComboBox<String>();
private static final Pattern ECN_PATTERN = Pattern.compile("ECN-[0-9]{8}");
private static final Pattern ECR_PATTERN = Pattern.compile("ECR-[0-9]{8}");
private JButton assignButton;
private String prefRuleName;
//id命名规则
private String ITEMTYPE;
// 属性类型真实值和类型
private HashMap<String, ControlBean> beanMap = new HashMap<String, ControlBean>();
// 选中的物料集合
private ArrayList<TCComponentItemRevision> partList = new ArrayList<TCComponentItemRevision>();
public DerivedChangeRequestDialog(
AbstractAIFApplication app,
ArrayList<ControlBean> beanList,
StringBuffer newType,
TCComponentItemRevision tarRev) {
super(false);
this.session = (TCSession) app.getSession();
this.beanList = beanList;
this.newType = newType.toString();
this.tarRev = tarRev;
}
public DerivedChangeRequestDialog(
AbstractAIFApplication app,
ArrayList<ControlBean> beanList,
StringBuffer newType,
TCComponentItemRevision tarRev,
ArrayList<TCComponentItemRevision> partList) {
super(false);
this.session = (TCSession) app.getSession();
this.beanList = beanList;
this.newType = newType.toString();
this.tarRev = tarRev;
this.partList = partList;
run();
}
@Override
public void run() {
try {
logger.info("hahahahhahahalog4j");
this.ITEMTYPE = this.newType;
initUI();
} catch (Exception e) {
e.printStackTrace();
}
}
private void initUI() throws Exception {
this.setPreferredSize(new Dimension(620, 888));
centerPanel = new JPanel(new PropertyLayout());
JLabel label1 = new JLabel(" ");
centerPanel.add("1.1.center", label1);
for (int i = 0; i < beanList.size(); i++) {
int row = i + 2;
ControlBean bean = beanList.get(i);
System.out.println(">>>beanMap.put"+bean.toString());
beanMap.put(bean.getPropRelName(), bean);
String labelValue = bean.getPropName();
if (bean.isIfMust()) {
labelValue = bean.getPropName() + "(必填)";
}
System.out.println("》》》属性条目:"+labelValue);
JLabel oneLabel = new JLabel(" ");
centerPanel.add(row + ".1.center", oneLabel);
JLabel label = new JLabel(labelValue);//属性标签名称
label.setPreferredSize(new Dimension(180, 40));
centerPanel.add(row + ".2.center", label);
if (bean.getPropType().equals("lov")) {
System.out.println("属性类型lov");
JComboBox<String> combox = bean.getCombox();
combox.setName(bean.getPropRelName());
combox.setPreferredSize(new Dimension(350, 25));
System.out.println("默认值为:" + bean.getDefaultValue());
combox.setSelectedItem(bean.getDefaultValue());
System.out.println("bean==>" + bean.toString());
centerPanel.add(row + ".3.center", combox);
} else if (bean.getPropType().equals("string")) {
System.out.println("属性类型String");
if ("object_name".equals(bean.getPropRelName()) || "object_desc".equals(bean.getPropRelName())) {
JTextArea area = new JTextArea(bean.getDefaultValue());
area.setName(bean.getPropRelName());
area.setPreferredSize(new Dimension(350, 50));
area.setBorder(new LineBorder(new java.awt.Color(127, 157, 185), 1, false));
centerPanel.add(row + ".3.center", area);
} else {
if("item_id".equals(bean.getPropRelName())) {
idField = new JTextField(bean.getDefaultValue());
idField.setName(bean.getPropRelName());
// idField.setPreferredSize(new Dimension(350, 25));
idField.setPreferredSize(new Dimension(150, 25));
centerPanel.add(row + ".3.center", idField);
//TODO 1.获取系统自带的ID命名规则放进下拉框
idRulebox.removeAllItems();
assignRule();
idRulebox.setPreferredSize(new Dimension(100,25));
centerPanel.add(row + ".4.center",idRulebox);
//TODO 2.指派按钮
assignButton = new JButton("指派");
assignButton.setPreferredSize(new Dimension(100,25));
centerPanel.add(row + ".5.center",assignButton);
assignButton.addActionListener(this);
}else {
JTextField field = new JTextField(bean.getDefaultValue());
field.setName(bean.getPropRelName());
field.setPreferredSize(new Dimension(350, 25));
centerPanel.add(row + ".3.center", field);
}
}
} else if (bean.getPropType().equals("boolean")) {
System.out.println("属性类型boolean");
JComboBox<String> combox = new JComboBox<String>();
combox.addItem("是");
combox.addItem("否");
combox.setPreferredSize(new Dimension(350, 25));
centerPanel.add(row + ".3.center", combox);
} else if (bean.getPropType().equals("date")) {
System.out.println("属性类型date");
DateButton dateButton = new DateButton(sdf);
dateButton.setName(bean.getPropRelName());
dateButton.setText(bean.getDefaultValue());
dateButton.setPreferredSize(new Dimension(350, 25));
centerPanel.add(row + ".3.center", dateButton);
}
}
JScrollPane jsp = new JScrollPane(centerPanel);
okButton = new JButton("创建");
okButton.addActionListener(this);
celButton = new JButton("取消");
celButton.addActionListener(this);
JPanel buttonPanel = new JPanel();
buttonPanel.add(celButton);
buttonPanel.add(okButton);
this.setLayout(new BorderLayout());
this.add(BorderLayout.CENTER, jsp);
this.add(BorderLayout.SOUTH, buttonPanel);
showDialog();
}
/**
* id
* @throws Exception
*/
private void assignRule() throws Exception {
TCComponentNameRuleType nameRuleType;
String preName = "Connor_DeriveChangeItem_NameRule";
try {
nameRuleType = (TCComponentNameRuleType) session.getTypeComponent("NameRule");
//根据选中对象类型从首选项中获取命名规则名称
String[] prefVals = KUtil.getPrefVals(session, preName);
if (prefVals != null && prefVals.length > 0) {
for (int i = 0; i < prefVals.length; i++) {
String prefVal = prefVals[i];
String[] split = prefVal.split("=");
if (split.length == 2) {
if (split[0].equals(newType)) {
prefRuleName = split[1];
break;
}
}
}
}else {
MessageBox.post(preName + "首选项未配置", "提示", MessageBox.INFORMATION);
return;
}
TCComponentNameRule nameRule = nameRuleType.find(prefRuleName);
if (nameRule == null) {
System.out.println("未找到命名规则:"+prefRuleName);
}else {
String[] patterns = nameRule.getPatterns();
for (String string : patterns) {
idRulebox.addItem(string);
}
}
} catch (TCException e) {
e.printStackTrace();
}
}
@Override
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == this.celButton) {
this.dispose();
} else if (arg0.getSource() == this.okButton) {
new Thread() {
@Override
public void run() {
try {
System.out.println("触发创建按钮!");
long time1 = System.nanoTime();
// KUtil.setByPass(true);
if(idField != null) {
String itemId = idField.getText();
//TODO 拼接id输入框和下拉框的id命名规则
String idRule = (String) idRulebox.getSelectedItem();
// itemId = itemId + idRule;
String type = tarRev.getType();
if("ProblemReportRevision".equals(type)) {
System.out.println("判断命名规范1");
// if(!ECR_PATTERN.matcher(itemId).matches()) {
// MessageBox.post("值为" + itemId + "不符合系统命名规则【ECR-'nnnnnnnn'】,请确认后重新填写",
// "提示", MessageBox.INFORMATION);
// return;
// }
}else {
System.out.println("判断命名规范2");
// if(!ECN_PATTERN.matcher(itemId).matches()) {
// MessageBox.post("值为" + itemId + "不符合系统命名规则【ECN-'nnnnnnnn'】,请确认后重新填写",
// "提示", MessageBox.INFORMATION);
// return;
// }
}
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(newType);
TCComponentItem findItem = itemType.find(itemId);
if(findItem != null) {
MessageBox.post("系统中已经存在id为" + itemId + "的对象,请检查后重新填写ID",
"提示", MessageBox.INFORMATION);
return;
}
}
TCComponentItemRevision rev = createItem("");
// KUtil.setByPass(false);
long time2 = System.nanoTime();
System.out.println("创建总用时(ms) " + (time2 - time1) / 1000000);
if(rev != null) {
MessageBox.post("创建成功,新对象在newstuff文件夹下", "提示", MessageBox.INFORMATION);
disposeDialog();
}
} catch (Exception e) {
MessageBox.post(e.getMessage(), "提示", MessageBox.INFORMATION);
e.printStackTrace();
}
}
}.start();
}else if (arg0.getSource() == this.assignButton) {
//指派id
updateLastUsedPref();
getAssignedIds();
}
}
public void getAssignedIds() {
TCComponentItemType tCComponentItemType = null;
boolean bl = true;
boolean bl2 = true;
try {
tCComponentItemType = (TCComponentItemType) this.session.getTypeComponent(ITEMTYPE);
DataManagementService dataManagementService = DataManagementService.getService((TCSession) this.session);
RevisionNamingRuleHelper.getInstance().loadRevNamingRuleDetails(this.session, ITEMTYPE, null);
int[] arrn = RevisionNamingRuleHelper.getInstance().getRevisionNamingRuleFormats();
int n = arrn[0];
int n2 = arrn[1];
if (this.idField.getText().length() == 0) {//如果id输入框中没有输入任何值
DataManagement.GenerateItemIdsAndInitialRevisionIdsProperties[] arrgenerateItemIdsAndInitialRevisionIdsProperties = new DataManagement.GenerateItemIdsAndInitialRevisionIdsProperties[] {
new DataManagement.GenerateItemIdsAndInitialRevisionIdsProperties() };
arrgenerateItemIdsAndInitialRevisionIdsProperties[0].item = null;
arrgenerateItemIdsAndInitialRevisionIdsProperties[0].itemType = ITEMTYPE;
arrgenerateItemIdsAndInitialRevisionIdsProperties[0].count = 1;
DataManagement.GenerateItemIdsAndInitialRevisionIdsResponse generateItemIdsAndInitialRevisionIdsResponse = dataManagementService
.generateItemIdsAndInitialRevisionIds(arrgenerateItemIdsAndInitialRevisionIdsProperties);
if (generateItemIdsAndInitialRevisionIdsResponse.serviceData.sizeOfPartialErrors() > 0) {
this.idField.setText("");
this.idField.requestFocusInWindow();
TCExceptionPartial tCExceptionPartial = SoaUtil.checkPartialErrorsNoThrow((com.teamcenter.soa.client.model.ServiceData) generateItemIdsAndInitialRevisionIdsResponse.serviceData);
MessageBox.post(this, (Throwable) tCExceptionPartial);
return;
}
String string = null;//最终生成的id
String zp_string = null;//指派生成的id
String string2 = null;
Map map = generateItemIdsAndInitialRevisionIdsResponse.outputItemIdsAndInitialRevisionIds;
Iterator iterator = map.entrySet().iterator();
if (iterator.hasNext()) {
Map.Entry entry = (Entry) iterator.next();
DataManagement.ItemIdsAndInitialRevisionIds[] arritemIdsAndInitialRevisionIds = (DataManagement.ItemIdsAndInitialRevisionIds[]) entry.getValue();
DataManagement.ItemIdsAndInitialRevisionIds itemIdsAndInitialRevisionIds = arritemIdsAndInitialRevisionIds[0];
zp_string = itemIdsAndInitialRevisionIds.newItemId;
if (n != 0) {
/*
* if (n2 == 0) { this.assignRevIdWithRevisionRule(); }
*/
} else {
string2 = itemIdsAndInitialRevisionIds.newRevId;
// this.revField.setText(string2);
}
bl = itemIdsAndInitialRevisionIds.isItemModify;
bl2 = itemIdsAndInitialRevisionIds.isRevModify;
}
// System.out.println("指派的id="+zp_string);
// String selectedItem = (String) this.idRulebox.getSelectedItem();
// System.out.println("选中的命名规则="+selectedItem);
// string = GenerateIdInput(zp_string,selectedItem);
this.idField.setText(zp_string);
if (!bl) {
this.idField.setEditable(false);
this.idRulebox.setEnabled(false);
}
// if (!bl2) {
// this.revField.setEditable(false);
// this.revisionIdCombobox.setEnabled(false);
// }
// this.nameField.requestFocusInWindow();
return;
}
// boolean bl3 = true;
// bl3 = this.validateId();
/*
* if (!bl3) { this.idField.setText(""); this.idField.requestFocusInWindow();
* return; }
*/
// if (n != 0) {
// if (n2 == 0) {
// this.assignRevIdWithRevisionRule();
// }
// } else {
// String string = tCComponentItemType.getNewRev(null);
// bl2 = tCComponentItemType.isNewRevModifiable(null, string);
// this.revField.setText(string);
// }
// if (!bl2) {
// this.revField.setEditable(false);
// }
// this.nameField.requestFocusInWindow();
} catch (TCException tCException) {
MessageBox.post((Window) this, (Throwable) tCException);
}
}
/**
*
* @param zp_string id
* @param selectedItem
* @return
*/
private String GenerateIdInput(String zp_string, String nameRule) {
String regex = "\"([^\"]*)\""; // 匹配第一个引号内的内容
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(regex);
java.util.regex.Matcher matcher = pattern.matcher(nameRule);
if (matcher.find()) {
String re = matcher.group(1)+zp_string;
return re;
}else {
System.out.println("处理命名规则异常!");
return null;
}
}
protected void updateLastUsedPref() {
try {
//选中的id命名规则
String string = (String) this.idRulebox.getSelectedItem();
String string2 = "";// (String) this.revisionIdCombobox.getSelectedItem();
boolean bl = false;
boolean bl2 = false;
String[] arrstring = new String[] { "item_id", "item_revision_id" };
String[] arrstring2 = new String[] { ITEMTYPE, ITEMTYPE };
NamingRule[] arrnamingRule = NamingRulesHelper.getInstance().getNamingRules(this.session, arrstring2, arrstring);
String string3 = arrnamingRule[0].getCondition();
String string4 = arrnamingRule[1].getCondition();
if (string3 == null) {
string3 = "";
}
if (string4 == null) {
string4 = "";
}
bl = arrnamingRule[0].patternPresent(string);
bl2 = arrnamingRule[1].patternPresent(string2);
string = bl ? (String) this.idRulebox.getSelectedItem() : "";
// string2 = bl2 ? (String) this.revisionIdCombobox.getSelectedItem() : "";
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(string3);
stringBuilder.append(":");
stringBuilder.append(ITEMTYPE);//新建的item类型
stringBuilder.append(":");
stringBuilder.append("item_id");
stringBuilder.append(":");
stringBuilder.append(string);
String string5 = stringBuilder.toString();
StringBuilder stringBuilder2 = new StringBuilder();
stringBuilder2.append(string4);
stringBuilder2.append(":");
stringBuilder2.append(ITEMTYPE);
stringBuilder2.append(":");
stringBuilder2.append("item_revision_id");
stringBuilder2.append(":");
stringBuilder2.append(string2);
String string6 = stringBuilder2.toString();
String[] arrstring3 = null;
if (string2.equals("") && !string.equals("")) {
arrstring3 = new String[] { string5 };
} else if (!string2.equals("") && string.equals("")) {
arrstring3 = new String[] { string6 };
} else if (!string2.equals("") && !string.equals("")) {
arrstring3 = new String[] { string5, string6 };
}
if (arrstring3 != null) {
// this.prefService = this.session.getPreferenceService();
String[] arrstring4 = session.getPreferenceService().getStringArray(1, "TC_LAST_USED_PATTERNS");
ArrayList<String> arrayList = new ArrayList<String>();
int n = 0;
int n2 = 0;
int n3 = 0;
int n4 = 0;
while (n4 < arrstring4.length) {
String string7 = arrstring4[n4];
if (!string7.equals("")) {
StringTokenizer stringTokenizer = new StringTokenizer(string7, ":");
stringTokenizer.nextToken();
String string8 = stringTokenizer.nextToken();
String string9 = stringTokenizer.nextToken();
if (ITEMTYPE.equals(string8)) {
++n;
if (string9.equals("item_id") && arrstring3[0] != null) {
arrayList.add(n4, arrstring3[0]);
++n2;
}
if (string9.equals("item_revision_id")) {
if (arrstring3.length == 1 && arrstring3[0] != null) {
arrayList.add(n4, arrstring3[0]);
++n3;
}
if (arrstring3.length > 1 && arrstring3[1] != null) {
arrayList.add(n4, arrstring3[1]);
++n3;
}
}
} else {
arrayList.add(n4, arrstring4[n4]);
}
}
++n4;
}
n4 = 0;
n4 = arrstring4.length == 1 && arrstring4[0].equals("") ? 0 : arrstring4.length;
int n5 = 0;
int n6 = 0;
int n7 = 0;
while (n7 < arrstring3.length) {
if (n < 1 && n2 < 1 && n3 < 1) {
arrayList.add(n4, arrstring3[n7]);
++n4;
}
if (n2 > 0 && n3 < 1 && !string2.equals("") && n5 == 0) {
arrayList.add(n4, arrstring3[1]);
++n5;
}
if (n3 > 0 && n2 < 1 && !string.equals("") && n6 == 0) {
arrayList.add(n4, arrstring3[0]);
++n6;
}
++n7;
}
String[] arrstring5 = arrayList.toArray(new String[arrayList.size()]);
session.getPreferenceService().setStringArray(1, "TC_LAST_USED_PATTERNS", arrstring5);
}
} catch (TCException tCException) {
}
}
/**
*
*
* @param errorBuffer
* @param valueMap
* @param objectDesc
* @param itemId
*/
private void judgeMust(StringBuffer errorBuffer, HashMap<String, String> valueMap) {
for (Entry<String, ControlBean> entry : beanMap.entrySet()) {
String name = entry.getKey();
ControlBean bean = entry.getValue();
System.out.println("当前字段为:" + name + "======当前是否必填为:" + bean.isIfMust());
if (bean.isIfMust()) {
String propValue = valueMap.get(name);
System.out.println("当前字段为:" + name + "======当前字段的值为:" + propValue);
if (propValue == null || propValue.isEmpty() || "未设置日期。".equals(propValue)) {
errorBuffer.append(bean.getPropName() + ",");
}
}
}
valueMap.remove("item_id");
valueMap.remove("object_desc");
}
/**
*
*
* @throws TCException
* @throws ServiceException
* @throws ParseException
* @throws NotLoadedException
*/
private TCComponentItemRevision createItem(String partNum)
throws TCException, ServiceException, ParseException {
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(newType);
HashMap<String, String> valueMap = new HashMap<String, String>();
int componentCount = centerPanel.getComponentCount();
// String itemId = null;
String objectDesc = "派生创建";
String objectName = "";
for (int i = 0; i < componentCount; i++) {
Component component = centerPanel.getComponent(i);
if (component instanceof JTextField) {
JTextField filed = (JTextField) component;
valueMap.put(filed.getName(), filed.getText());
} else if (component instanceof JComboBox) {
JComboBox<String> combox = (JComboBox<String>) component;
String boxName = combox.getName();
System.out.println("下拉框名称="+boxName);
String select = (String)combox.getSelectedItem();
valueMap.put(combox.getName(), select);
} else if (component instanceof DateButton) {
DateButton date = (DateButton) component;
valueMap.put(date.getName(), date.getText());
} else if (component instanceof JTextArea) {
JTextArea area = (JTextArea) component;
if (area.getName().equals("object_desc")) {
objectDesc = area.getText();
} else {
objectName = area.getText();
valueMap.put(area.getName(), area.getText());
}
}
}
StringBuffer errorBuffer = new StringBuffer();
System.out.println("idField:" + idField.getText());
if(idField != null && idField.getText() != null && !"".equals(idField.getText().trim())) {
System.out.println("写入属性item_id = " + idField.getText());
valueMap.put("item_id", idField.getText());
System.out.println("成功写入属性item_id = " + valueMap.get("item_id"));
}else {
String itemId = itemType.getNewID();
valueMap.put("item_id", itemId);
}
valueMap.put("object_desc", objectDesc);
judgeMust(errorBuffer, valueMap);
if (!errorBuffer.toString().isEmpty()) {
MessageBox.post(errorBuffer.toString() + " 这些必填项未填", "提示", MessageBox.INFORMATION);
return null;
}
Map<String, String> itemMaps = new HashMap<String, String>();
Map<String, String> revMaps = new HashMap<String, String>();
if(idField != null && idField.getText() != null && !"".equals(idField.getText().trim())) {
itemMaps.put("item_id", idField.getText());
}else {
itemMaps.put("item_id", valueMap.get("item_id"));
}
itemMaps.put("object_desc", objectDesc);
// revMaps.put("object_name", partNum + objectName);
// 修改3.7
revMaps.put("object_name", objectName);
//object_name ld6_partName
System.out.println("newType:" + newType);
System.out.println("createMaterialBySOA方法入参中itemID="+valueMap.get("item_id"));
TCComponent createMaterialBySOA = createMaterialBySOA(newType, itemMaps, revMaps,valueMap);
if (createMaterialBySOA == null) {
MessageBox.post("创建失败", "提示", MessageBox.INFORMATION);
return null;
}
TCComponentItem newItem = (TCComponentItem) createMaterialBySOA;
TCComponentItemRevision latestItemRevision = newItem.getLatestItemRevision();
// 放到newstuff
TCComponentFolder newStuffFolder = session.getUser().getNewStuffFolder();
newStuffFolder.add("contents", newItem);
try {
KUtil.setByPass(true);
tarRev.add("CMImplementedBy", latestItemRevision);
KUtil.setByPass(false);
} catch (TCException e) {
// TODO Auto-generated catch blocke
e.printStackTrace();
}finally {
KUtil.setByPass(false);
}
System.out.println("创建完成后再次打印一下beanMap=");
for (Entry<String, ControlBean> entry : beanMap.entrySet()) {
String key = entry.getKey();
ControlBean value = entry.getValue();
System.out.println("key=" + key + "\n value=" + value.toString());
}
// id版本类型名称描述
// 设置属性
for (Entry<String, String> entry : valueMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
ControlBean controlBean = beanMap.get(key);
if (controlBean == null){
System.out.println("无法通过["+key+"]在beanMap中获取到对应的ControlBean跳过");
continue;
}
TCComponent center = null;
if ("Item".equals(controlBean.getPropTo())) {
center = newItem;
} else if ("Rev".equals(controlBean.getPropTo())) {
center = latestItemRevision;
} else if ("Form".equals(controlBean.getPropTo())) {
center = latestItemRevision.getRelatedComponent("IMAN_master_form_rev");
}
if ("boolean".equals(controlBean.getPropType())) {
if ("是".equals(value)) {
center.setLogicalProperty(key, true);
} else if ("否".equals(value)) {
center.setLogicalProperty(key, false);
}
} else if ("date".equals(controlBean.getPropType())) {
if (!value.isEmpty() && !"未设置日期。".equals(value)) {
center.setDateProperty(key, sdf.parse(value));
}
} else if ("string".equals(controlBean.getPropType())) {
if (!value.isEmpty()) {
center.setStringProperty(key, value);
}
} else if ("lov".equals(controlBean.getPropType())) {
center.setStringProperty(key, controlBean.getLovMap().get(value));
}
}
System.out.println("开始转移关系文件夹下的对象");
TCComponent[] re1 = tarRev.getRelatedComponents("CMHasProblemItem");
if (re1 != null && re1.length > 0) {
latestItemRevision.add("CMHasProblemItem", re1);
}
TCComponent[] re2 = tarRev.getRelatedComponents("CMReferences");
if (re2 != null && re2.length > 0) {
latestItemRevision.add("CMReferences", re2);
}
String type = tarRev.getType();
if (!"ProblemReportRevision".equals(type)) {
TCComponent[] re4 = tarRev.getRelatedComponents("CMHasImpactedItem");
if (re4 != null && re4.length > 0) {
latestItemRevision.add("CMHasImpactedItem", re4);
}
}
if("ChangeRequestRevision".equals(type)) {
TCComponent[] re5 = tarRev.getRelatedComponents("IMAN_specification");
if(re5 != null && re5.length > 0) {
for (int i = 0; i < re5.length; i++) {
TCComponent dataset = re5[i];
if(dataset instanceof TCComponentDataset) {
TCComponentDataset newDataset = ((TCComponentDataset) dataset).saveAs(dataset.getStringProperty("object_name"));
if(newDataset != null) {
workflow(new String[] {newDataset.getUid()},"快速发布","TCM Release Process");
latestItemRevision.add("IMAN_specification", newDataset);
}
}
}
}
}
return latestItemRevision;
}
/**
*
* @param itemTypeCom
* @param itemPropMaps
* @param revMaps
* @return
* @throws TCException
* @throws ServiceException
* @throws ParseException
*/
private TCComponent createMaterialBySOA(String itemTypeCom, Map<String, String> itemPropMaps,
Map<String, String> revMaps,HashMap<String, String> valueMap) throws TCException, ServiceException, ParseException {
try {
System.out.println("begin通过SOA创建对象"+itemTypeCom);
Map<String, Boolean> itemboole = new HashMap<String, Boolean>();
Map<String,Calendar> itemdate = new HashMap<String, Calendar>();
Map<String, Boolean> revboole = new HashMap<String, Boolean>();
Map<String,Calendar> revdate = new HashMap<String, Calendar>();
Map<String, String> formMaps = new HashMap<String,String>();
Map<String, Boolean> formboole = new HashMap<String, Boolean>();
Map<String,Calendar> formdate = new HashMap<String, Calendar>();
for (Entry<String, String> entry : valueMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
ControlBean controlBean = beanMap.get(key);
if (controlBean == null) {
System.out.println("ERRO:在属性集合beanMap中无法通过valueMap中的key="+key+"获取具体的属性对象!");
continue;
}else {
System.out.println("处理属性>>"+controlBean.toString());
}
if ("Item".equals(controlBean.getPropTo())) {
if ("boolean".equals(controlBean.getPropType())) {
if ("是".equals(value)) {
itemboole.put(key, true);
} else if ("否".equals(value)) {
itemboole.put(key, false);
}
} else if ("date".equals(controlBean.getPropType())) {
if (!value.isEmpty() && !"未设置日期。".equals(value)) {
Date parse = sdf.parse(value);
Calendar cal = Calendar.getInstance();
cal.setTime(parse);
itemdate.put(key, cal);
}
} else if ("string".equals(controlBean.getPropType())) {
if (!value.isEmpty()) {
itemPropMaps.put(key, value);
}
} else if ("lov".equals(controlBean.getPropType())) {
String string = controlBean.getLovMap().get(value);
if(!"".equals(string.trim())) {
itemPropMaps.put(key, string);
}
}
} else if ("Rev".equals(controlBean.getPropTo())) {
if ("boolean".equals(controlBean.getPropType())) {
if ("是".equals(value)) {
revboole.put(key, true);
} else if ("否".equals(value)) {
revboole.put(key, false);
}
} else if ("date".equals(controlBean.getPropType())) {
if (!value.isEmpty() && !"未设置日期。".equals(value)) {
Date parse = sdf.parse(value);
Calendar cal = Calendar.getInstance();
cal.setTime(parse);
revdate.put(key, cal);
}
} else if ("string".equals(controlBean.getPropType())) {
if (!value.isEmpty()) {
revMaps.put(key, value);
}
} else if ("lov".equals(controlBean.getPropType())) {
String string = controlBean.getLovMap().get(value);
if(!"".equals(string.trim())) {
revMaps.put(key, string);
}
}
}else if("Form".equals(controlBean.getPropTo())) {
if ("boolean".equals(controlBean.getPropType())) {
if ("是".equals(value)) {
formboole.put(key, true);
} else if ("否".equals(value)) {
formboole.put(key, false);
}
} else if ("date".equals(controlBean.getPropType())) {
if (!value.isEmpty() && !"未设置日期。".equals(value)) {
Date parse = sdf.parse(value);
Calendar cal = Calendar.getInstance();
cal.setTime(parse);
formdate.put(key, cal);
}
} else if ("string".equals(controlBean.getPropType())) {
if (!value.isEmpty()) {
formMaps.put(key, value);
}
} else if ("lov".equals(controlBean.getPropType())) {
String string = controlBean.getLovMap().get(value);
System.out.println("key = ");
System.out.println("lovMapKey = "+value);
System.out.println("lovMapValue = "+string);
if(!"".equals(string.trim())) {
formMaps.put(key, string);
}
}
}
}
for (Map.Entry<String, String> entry : itemPropMaps.entrySet()) {
System.out.println("itemPropMaps: key = " + entry.getKey() + ", value = " + entry.getValue());
}
for (Map.Entry<String, String> entry : revMaps.entrySet()) {
System.out.println("revMaps: key = " + entry.getKey() + ", value = " + entry.getValue());
}
DataManagementService dmService = DataManagementService.getService(session);
CreateInput revInput = new CreateInput();
revInput.boName = itemTypeCom + "Revision";
revInput.stringProps = revMaps;
revInput.dateProps = revdate;
revInput.boolProps = revboole;
CreateInput[] formCompInputS = new CreateInput[1];
formCompInputS[0] = new CreateInput();
// formCompInputS[0].boName = itemTypeCom + "Revision Master";
formCompInputS[0].boName = itemTypeCom + "RevisionMaster";
formCompInputS[0].stringProps = formMaps;
formCompInputS[0].dateProps = formdate;
formCompInputS[0].boolProps = formboole;
Map<String, CreateInput[]> formCompMap = new HashMap();
formCompMap.put("IMAN_master_form_rev", formCompInputS);
revInput.compoundCreateInput = formCompMap;
//创建item对象时携带的数据
CreateInput itemInput = new CreateInput();
itemInput.boName = itemTypeCom;
itemInput.stringProps = itemPropMaps;
itemInput.dateProps = itemdate;
itemInput.boolProps = itemboole;
HashMap<String, CreateInput[]> revInfoMap = new HashMap<String, CreateInput[]>();
revInfoMap.put("revision", new CreateInput[] { revInput });
itemInput.compoundCreateInput = revInfoMap;
CreateIn createin = new CreateIn();
createin.clientId = "CreateItem";
createin.data = itemInput;
com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse createresponse;
createresponse = dmService.createObjects(new CreateIn[] { createin });
if (createresponse.serviceData.sizeOfPartialErrors() > 0) {
System.out.println("create item failed");
for (int i = 0; i < createresponse.serviceData.sizeOfPartialErrors(); i++) {
String[] messages = createresponse.serviceData.getPartialError(0).getMessages();
for(int j=0;j<messages.length;j++) {
System.out.println(createresponse.serviceData.getPartialError(0).getErrorValues()[j].getMessage());
}
System.out.println(createresponse.serviceData.getPartialError(0).getMessages());
System.out.println(createresponse.serviceData.getPartialError(0).getErrorValues()[0].getMessage());
}
return null;
}
TCComponent comp = null;
CreateOut cOs[] = createresponse.output;
if (cOs.length > 0) {
comp = cOs[0].objects[0];
System.out.println("创建的对象:" + comp);
return comp;
}
}catch (Exception e){
System.out.println("createMaterialBySOA创建对象失败:");
e.printStackTrace();
}
return null;
}
/**
*
*
*/
public void workflow(String[] uid,String workFlowName,String templateName) {
// String uid = rev.getUid();
//创建流程
WorkflowService wfService = WorkflowService.getService(session);
ContextData contextData = new ContextData();
String observerKey = "";
String name = workFlowName;
String subject = "";
String description = "";
contextData.processTemplate = templateName; // update with your own ProcessTemplate.
contextData.subscribeToEvents = false;
contextData.subscriptionEventCount = 0;
contextData.attachmentCount = uid.length;
contextData.attachments = uid ;
int [] types = new int[uid.length];
for(int i = 0;i <uid.length;i++) {
types[i] = 1;
}
contextData.attachmentTypes = types;
//创建流程
InstanceInfo instanceInfo = wfService.createInstance(true, observerKey, name, subject, description, contextData);
}
}

@ -0,0 +1,87 @@
package com.connor.plm.sb02;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import javafx.scene.control.TableColumn;
public class TableDemo extends JFrame{
static JTable table;
public TableDemo() {
setSize(600, 600);
setLocationRelativeTo(null);
/*创建表格*/
DefaultTableModel model = new DefaultTableModel();
model.addColumn("编号",new Vector<Integer>());
model.addColumn("书名", new Vector<String>());
model.addColumn("作者", new Vector<String>());
model.addColumn("是否选中", new Vector<String>());
table = new JTable(model);
JScrollPane jp = new JScrollPane(table);
for(int i = 0;i < 20 ;i ++) {
model.addRow(new Vector<String>());
}
JTableHeader head = table.getTableHeader();
//设置表头的大小
head.setPreferredSize(new Dimension(head.getWidth(),30));
//设置表头字体大小
head.setFont(new Font("宋体",Font.BOLD,16));
//设置表格的行宽
table.setRowHeight(30);
//设置表格行中字体大小
table.setFont(new Font("宋体",Font.ROMAN_BASELINE,13));
/*设置表格中的内容居中*/
DefaultTableCellRenderer renderer=new DefaultTableCellRenderer();
renderer.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
table.setDefaultRenderer(Object.class, renderer);
/*定义复选框*/
JCheckBox box = new JCheckBox();
/*getColumn()中数字填对应的第几行添加复选框*/
table.getColumnModel().getColumn(3).setCellRenderer(new TableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus,int row, int column) {
/*设置当复选框被选中整行被渲染*/
box.setSelected(isSelected);
/*设置复选框在单元格中居中*/
box.setHorizontalAlignment((int) 0.5f);
return box;
}
});
this.add(jp);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
TableDemo t = new TableDemo();
}
}

@ -0,0 +1,86 @@
package com.net.connor.ld.plm.ld06;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.util.Comparator;
import javax.swing.Icon;
import javax.swing.RowSorter;
import javax.swing.RowSorter.SortKey;
import javax.swing.SortOrder;
import javax.swing.table.TableRowSorter;
import antlr.collections.List;
public class ArrowIcon implements Icon {
private final SortOrder sortOrder;
private final int size;
private final boolean ascending;
public ArrowIcon(TableRowSorter<?> sorter, int column, boolean ascending) {
this.ascending = ascending;
this.size = 12;
java.util.List<? extends SortKey> sortKeys = sorter.getSortKeys();
if (sortKeys.size() > 0 && ((RowSorter.SortKey) sortKeys.get(0)).getColumn() == column) {
this.sortOrder = ((RowSorter.SortKey) sortKeys.get(0)).getSortOrder();
} else {
this.sortOrder = SortOrder.ASCENDING;
}
}
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g.create();
g2.translate(x, y);
if (ascending) {
g2.rotate(Math.PI, size / 2.0, size / 2.0);
}
if (sortOrder == SortOrder.ASCENDING) {
g2.draw(createUpTriangle(size));
} else {
g2.draw(createDownTriangle(size));
}
g2.dispose();
}
public int getIconWidth() {
return size;
}
public int getIconHeight() {
return size;
}
private Polygon createUpTriangle(int size) {
Polygon triangle = new Polygon();
triangle.addPoint(0, size);
triangle.addPoint(size / 2, 0);
triangle.addPoint(size, size);
return triangle;
}
private Polygon createDownTriangle(int size) {
Polygon triangle = new Polygon();
triangle.addPoint(0, 0);
triangle.addPoint(size, 0);
triangle.addPoint(size / 2, size);
return triangle;
}
}
//表格列排序类
class ColumnSorter implements Comparator<Object> {
private final int col;
private final boolean ascending;
public ColumnSorter(int col, boolean ascending) {
this.col = col;
this.ascending = ascending;
}
@Override
public int compare(Object a, Object b) {
if (a instanceof Comparable && b instanceof Comparable) {
if (ascending) {
return ((Comparable) a).compareTo((Comparable) b);
} else {
return ((Comparable) b).compareTo((Comparable) a);
}
} else {
return 0;
}
}
}

@ -0,0 +1,15 @@
package com.connor.plm;
import java.text.SimpleDateFormat;
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
String value = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm");
value = sdf.format("");
System.out.println(value);
}
}

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="GBK" ?>
<rules>
<rule id="B00" type="电动助力转向管柱带中间轴总成(管柱+中间轴+控制器)" ERP="3101" />
<rule id="B01" type="管柱+中间轴" ERP="null" />
<rule id="F00" type="转向器带拉杆总成" ERP="313203" />
<rule id="Z00" type="中间轴总成" ERP="313202" />
<rule id="K00" type="控制器总成" ERP="313204" />
<rule id="K01" type="控制器" ERP="313204" />
<rule id="M00" type="电机" ERP="1304" />
<rule id="C00" type="电动转向管柱带ECU总成管柱+控制器)" ERP="3102" />
<rule id="C01" type="EPS转向管柱总成管柱" ERP="313201" />
<rule id="C02" type="减速箱体及转向轴组件" ERP="220201" />
<rule id="C03" type="减速机构及传感器组件(机头)" ERP="220201" />
<rule id="C04" type="传感器外组件" ERP="220201" />
<rule id="C05" type="箱体组件" ERP="220201" />
<rule id="C06" type="蜗杆组件" ERP="220201" />
<rule id="C07" type="传感器内组件" ERP="220201" />
<rule id="C08" type="输入轴及扭杆组件" ERP="220201" />
<rule id="C09" type="输入轴B级扭杆组件" ERP="220201" />
<rule id="C10" type="输入轴B组件" ERP="220201" />
<rule id="C11" type="蜗轮轴组件" ERP="220201" />
<rule id="C12" type="蜗轮轴小组件" ERP="220202" />
<rule id="C13" type="管柱组件带转向轴组件" ERP="220202" />
<rule id="C14" type="转向轴组件" ERP="220101" />
<rule id="C15" type="管柱组件" ERP="220302" />
<rule id="C16" type="上管柱组件" ERP="220302" />
<rule id="C17" type="上管柱焊装组件" ERP="220302" />
<rule id="C18" type="上安装板焊接组件" ERP="220302" />
<rule id="C19" type="调节手柄组件" ERP="220302" />
<rule id="C20" type="下管柱组件" ERP="220302" />
<rule id="C21" type="下支架组件" ERP="220302" />
<rule id="C22" type="节叉组件" ERP="220103" />
<rule id="C23+" type="不在上述组件图号依次递加" ERP="null" />
<rule id="B00" type="电动助力转向器带拉杆总成" ERP="310300" />
<rule id="B01" type="电动转向器总成" ERP="220203" />
<rule id="C01" type="传动机构组件" ERP="220203" />
<rule id="C02" type="壳体组件" ERP="220203" />
<rule id="C03" type="传感器内组件" ERP="220101" />
<rule id="C04" type="传感器外组件" ERP="220101" />
<rule id="C05" type="齿轮组件" ERP="220101" />
<rule id="C06" type="蜗杆组件" ERP="220101" />
<rule id="C07" type="齿轮小组件" ERP="220101" />
<rule id="C08" type="输入轴组件" ERP="220202" />
<rule id="C09" type="传感器带护套组件" ERP="220202" />
<rule id="C09+" type="其他组件" ERP="null" />
<rule id="null" type="轴类" ERP="210100" />
<rule id="111" type="蜗轮轴" ERP="" />
<rule id="112" type="输入轴A输入轴" ERP="" />
<rule id="113" type="输入轴B" ERP="" />
<rule id="114" type="扭杆" ERP="" />
<rule id="115" type="转向轴" ERP="" />
<rule id="116" type="蜗杆" ERP="" />
<rule id="117" type="花键套" ERP="" />
<rule id="118" type="齿轮" ERP="" />
<rule id="119" type="齿条" ERP="" />
<rule id="11*" type="其余轴类" ERP="" />
<rule id="null" type="壳体类" ERP="210200" />
<rule id="211" type="减速箱体" ERP="" />
<rule id="212" type="端盖" ERP="" />
<rule id="213" type="壳体" ERP="" />
<rule id="214" type="壳体B" ERP="" />
<rule id="215" type="法兰盖" ERP="" />
<rule id="216" type="电机法兰" ERP="" />
<rule id="217" type="传感器壳体" ERP="" />
<rule id="21*" type="其余" ERP="" />
<rule id="null" type="钣金件及管柱类" ERP="110000" />
<rule id="311" type="上管柱" ERP="null" />
<rule id="312" type="下管柱" ERP="null" />
<rule id="321" type="组合开关支架" ERP="" />
<rule id="322" type="固定支架" ERP="" />
<rule id="323" type="上安装板" ERP="" />
<rule id="324" type="U型支架" ERP="" />
<rule id="325" type="调节手柄" ERP="" />
<rule id="326" type="固定板" ERP="" />
<rule id="327" type="下支架" ERP="" />
<rule id="328" type="控制器支架" ERP="" />
<rule id="32*" type="其余支架" ERP="" />
<rule id="" type="螺栓、螺母及螺柱类" ERP="130100" />
<rule id="41*" type="螺栓类" ERP="" />
<rule id="42*" type="螺母类" ERP="" />
<rule id="43*" type="螺柱类" ERP="" />
<rule id="44*" type="其余" ERP="" />
<rule id="" type="轴承类" ERP="130200" />
<rule id="51*" type="深沟球轴承" ERP="" />
<rule id="52*" type="滚针轴承" ERP="" />
<rule id="53*" type="滑动轴承" ERP="" />
<rule id="54*" type="其余轴承" ERP="" />
<rule id="61*" type="卡圈及挡圈类" ERP="130500" />
<rule id="71*" type="金属类" ERP="110000" />
<rule id="" type="橡胶及非金属类" ERP="130300" />
<rule id="81*" type="橡胶类" ERP="" />
<rule id="82*" type="拉脱块" ERP="" />
<rule id="83*" type="其余非金属类" ERP="" />
<rule id="" type="电子元器件类" ERP="130500" />
<rule id="911" type="导线" ERP="" />
<rule id="912" type="尼龙波纹管" ERP="" />
<rule id="913" type="接插件护套" ERP="" />
<rule id="914" type="接插件端子" ERP="" />
<rule id="915" type="集磁环屏蔽罩" ERP="" />
<rule id="91*" type="其余" ERP="" />
<rule id="S01" type="导磁环组件" ERP="" />
<rule id="S02" type="集磁环注塑件" ERP="" />
<rule id="S04" type="PCB板组件" ERP="" />
</rules>
Loading…
Cancel
Save