commit c48739e9b384a4b6c4ca01750dcde53cd0889607
Author: ChenZichaoczc <2974997276@qq.com>
Date: Tue Jun 3 16:17:38 2025 +0800
first commit
diff --git a/SubstMacros-MSExcel.wsf b/SubstMacros-MSExcel.wsf
new file mode 100644
index 0000000..c2b4a6f
--- /dev/null
+++ b/SubstMacros-MSExcel.wsf
@@ -0,0 +1,168 @@
+
+
+
diff --git a/SubstMacros-MSWord.wsf b/SubstMacros-MSWord.wsf
new file mode 100644
index 0000000..43a70f5
--- /dev/null
+++ b/SubstMacros-MSWord.wsf
@@ -0,0 +1,221 @@
+
+
+
+
diff --git a/cn.net.connor.designtopart.zip b/cn.net.connor.designtopart.zip
new file mode 100644
index 0000000..8e14972
Binary files /dev/null and b/cn.net.connor.designtopart.zip differ
diff --git a/cn.net.connor.designtopart/.classpath b/cn.net.connor.designtopart/.classpath
new file mode 100644
index 0000000..8a7b5a7
--- /dev/null
+++ b/cn.net.connor.designtopart/.classpath
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cn.net.connor.designtopart/.gitignore b/cn.net.connor.designtopart/.gitignore
new file mode 100644
index 0000000..ae3c172
--- /dev/null
+++ b/cn.net.connor.designtopart/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/cn.net.connor.designtopart/.project b/cn.net.connor.designtopart/.project
new file mode 100644
index 0000000..b036b3e
--- /dev/null
+++ b/cn.net.connor.designtopart/.project
@@ -0,0 +1,28 @@
+
+
+ cn.net.connor.designtopart
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/cn.net.connor.designtopart/.settings/org.eclipse.core.resources.prefs b/cn.net.connor.designtopart/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..618525c
--- /dev/null
+++ b/cn.net.connor.designtopart/.settings/org.eclipse.core.resources.prefs
@@ -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
diff --git a/cn.net.connor.designtopart/.settings/org.eclipse.jdt.core.prefs b/cn.net.connor.designtopart/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..0c68a61
--- /dev/null
+++ b/cn.net.connor.designtopart/.settings/org.eclipse.jdt.core.prefs
@@ -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
diff --git a/cn.net.connor.designtopart/META-INF/MANIFEST.MF b/cn.net.connor.designtopart/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..1a846b8
--- /dev/null
+++ b/cn.net.connor.designtopart/META-INF/MANIFEST.MF
@@ -0,0 +1,73 @@
+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"
+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
diff --git a/cn.net.connor.designtopart/README.MD b/cn.net.connor.designtopart/README.MD
new file mode 100644
index 0000000..e802225
--- /dev/null
+++ b/cn.net.connor.designtopart/README.MD
@@ -0,0 +1,17 @@
+## 鍥剧焊杞墿鏂
+
+> 閰嶇疆棣栭夐」锛欳onnor_Design_To_Part
+
+```text
+闇瑕佽浆鎹esign瀵硅薄绫诲瀷=[-]鍏崇郴鍚嶇О=杞崲鍚庡璞$被鍨+鈥渱鈥濆垎闅旓紝鍚庤竟涓哄睘鎬х户鎵垮搴斿叧绯伙紝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
+```
\ No newline at end of file
diff --git a/cn.net.connor.designtopart/build.properties b/cn.net.connor.designtopart/build.properties
new file mode 100644
index 0000000..e86059d
--- /dev/null
+++ b/cn.net.connor.designtopart/build.properties
@@ -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/
diff --git a/cn.net.connor.designtopart/icons/ojdbc7.jar b/cn.net.connor.designtopart/icons/ojdbc7.jar
new file mode 100644
index 0000000..811da0f
Binary files /dev/null and b/cn.net.connor.designtopart/icons/ojdbc7.jar differ
diff --git a/cn.net.connor.designtopart/icons/sample.png b/cn.net.connor.designtopart/icons/sample.png
new file mode 100644
index 0000000..02c4b79
Binary files /dev/null and b/cn.net.connor.designtopart/icons/sample.png differ
diff --git a/cn.net.connor.designtopart/icons/sample@2x.png b/cn.net.connor.designtopart/icons/sample@2x.png
new file mode 100644
index 0000000..c1224d1
Binary files /dev/null and b/cn.net.connor.designtopart/icons/sample@2x.png differ
diff --git a/cn.net.connor.designtopart/lib/core-renderer.jar b/cn.net.connor.designtopart/lib/core-renderer.jar
new file mode 100644
index 0000000..871fabf
Binary files /dev/null and b/cn.net.connor.designtopart/lib/core-renderer.jar differ
diff --git a/cn.net.connor.designtopart/lib/iTextAsian.jar b/cn.net.connor.designtopart/lib/iTextAsian.jar
new file mode 100644
index 0000000..3fa2157
Binary files /dev/null and b/cn.net.connor.designtopart/lib/iTextAsian.jar differ
diff --git a/cn.net.connor.designtopart/lib/iTextAsianCmaps.jar b/cn.net.connor.designtopart/lib/iTextAsianCmaps.jar
new file mode 100644
index 0000000..aa2b429
Binary files /dev/null and b/cn.net.connor.designtopart/lib/iTextAsianCmaps.jar differ
diff --git a/cn.net.connor.designtopart/lib/itextpdf-5.0.6.jar b/cn.net.connor.designtopart/lib/itextpdf-5.0.6.jar
new file mode 100644
index 0000000..d716b4e
Binary files /dev/null and b/cn.net.connor.designtopart/lib/itextpdf-5.0.6.jar differ
diff --git a/cn.net.connor.designtopart/lib/ojdbc7.jar b/cn.net.connor.designtopart/lib/ojdbc7.jar
new file mode 100644
index 0000000..811da0f
Binary files /dev/null and b/cn.net.connor.designtopart/lib/ojdbc7.jar differ
diff --git a/cn.net.connor.designtopart/plugin.xml b/cn.net.connor.designtopart/plugin.xml
new file mode 100644
index 0000000..a8e8b57
--- /dev/null
+++ b/cn.net.connor.designtopart/plugin.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/designtopart/Activator.java b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/Activator.java
new file mode 100644
index 0000000..cdcb7a7
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/Activator.java
@@ -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;
+ }
+
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/designtopart/DesigntopartLocale.java b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/DesigntopartLocale.java
new file mode 100644
index 0000000..1642fe0
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/DesigntopartLocale.java
@@ -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());
+ }
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/designtopart/commands/DesignToPartCommand.java b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/commands/DesignToPartCommand.java
new file mode 100644
index 0000000..73b4147
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/commands/DesignToPartCommand.java
@@ -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)));
+ }
+
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/DesignToPartDialog.java b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/DesignToPartDialog.java
new file mode 100644
index 0000000..bcb263d
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/DesignToPartDialog.java
@@ -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);
+ }
+
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/DesignToPartDialogController.java b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/DesignToPartDialogController.java
new file mode 100644
index 0000000..defba3b
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/DesignToPartDialogController.java
@@ -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 tableBuilders = new ArrayList();
+
+ public DesignToPartDialogController(AbstractAIFApplication app) {
+ super(app);
+ }
+
+ @Override
+ public boolean init() throws Exception {
+ InterfaceAIFComponent[] targets = app.getTargetComponents();
+ Map> 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 list;
+ if (selectedRevMap.containsKey(type)) {
+ list = selectedRevMap.get(type);
+ } else {
+ list = new ArrayList();
+ 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;
+ }
+
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/DesignToPartPanel.fxml b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/DesignToPartPanel.fxml
new file mode 100644
index 0000000..f2185a1
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/DesignToPartPanel.fxml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/DesignToPartPanel.java b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/DesignToPartPanel.java
new file mode 100644
index 0000000..b53081e
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/DesignToPartPanel.java
@@ -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();
+ }
+
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/DesignToPartPanelController.java b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/DesignToPartPanelController.java
new file mode 100644
index 0000000..38a8b6c
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/DesignToPartPanelController.java
@@ -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 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 table = tableBuilder.build();
+ if (table == null) {
+ continue;
+ }
+ table.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler() {
+ @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();
+ }
+ }
+ }
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/TableBuilder.java b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/TableBuilder.java
new file mode 100644
index 0000000..263891b
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/TableBuilder.java
@@ -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 colConfigs = new ArrayList();
+ protected List fromRevList;
+ protected TableView 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 xinMap = new HashMap<>();
+ private Map laoMap = new HashMap<>();
+ private String[] xinValues = null, laoValues = null;
+
+ protected List 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 list2 = Arrays
+ .asList(new String[] { "SB6_CatiaAssDLRevision", "SB6_CatiaSDLRevision", "SB6_CatiaDesignLRevision" });
+ protected List list3 = Arrays.asList(new String[] { "SB6_CatiaDesignLRevision", "SB6_CatiaAssDLRevision",
+ "SB6_CatiaSDLRevision", "SB6_AutocadAssDLRevision", "SB6_AutocadDLRevision", "SB6_AutocadSDLRevision" });
+
+ protected Map uomMap = new HashMap<>();
+ protected ObservableList uomList = FXCollections.observableArrayList();
+
+ protected Map khflMap = new HashMap<>();
+ protected Map tzMap = new HashMap<>();
+ protected ObservableList khflList = FXCollections.observableArrayList();
+ protected ObservableList tzList = FXCollections.observableArrayList();
+
+ protected Map khfl2Map = new HashMap<>();
+ protected Map tz2Map = new HashMap<>();
+ protected ObservableList khfl2List = FXCollections.observableArrayList();
+ protected ObservableList tz2List = FXCollections.observableArrayList();
+
+ protected Map khfl3Map = new HashMap<>();
+ protected Map cgqlxMap = new HashMap<>();
+ protected Map tz3Map = new HashMap<>();
+ protected ObservableList khfl3List = FXCollections.observableArrayList();
+ protected ObservableList cgqlxList = FXCollections.observableArrayList();
+ protected ObservableList tz3List = FXCollections.observableArrayList();
+
+ protected String formName = "";
+ protected boolean isHave = false;
+ protected String sb6_PartRM14 = "";
+
+ public TableBuilder(TCSession session, String config, Map> selectedRevMap)
+ throws Exception {
+ this.session = session;
+ initData();
+ parseConfig(config, selectedRevMap);
+ }
+
+ protected void parseConfig(String config, Map> 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 dataMap = new HashMap<>();
+ public Map> refDataMap = new HashMap<>();
+ public TCComponentItemRevision fromRev;
+
+ public RowData(TCComponentItemRevision rev, List 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(value));
+ } else {
+ String value = comp.getProperty(colConfig.fromPropName);
+ dataMap.put(colConfig, new SimpleStringProperty(value));
+ }
+ }
+ }
+
+ public void checkCanCreate() throws Exception {
+ if (table == null) {
+ return;
+ }
+ ObservableList 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 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 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 itemProps = new HashMap<>();
+ Map revProps = new HashMap<>();
+ Map revMasterProps = new HashMap<>();
+ Map itemRefProps = new HashMap<>();
+ Map revRefProps = new HashMap<>();
+ Map 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 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 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 build() throws Exception {
+ if (fromRevList == null || fromRevList.size() == 0) {
+ return null;
+ }
+ this.table = new TableView();
+ 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 col = new TableColumn(
+ colConfig.colName);
+ col.setCellValueFactory(p -> p.getValue().refDataMap.get(colConfig));
+ this.table.getColumns().add(col);
+ continue;
+ }
+ TableColumn 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, TableCell>() {
+ @Override
+ public TableCell call(TableColumn param) {
+ return new KFXEditableStringTableCell() {
+ 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, TableCell>() {
+ @Override
+ public TableCell call(TableColumn param) {
+ return new TableCell() {
+ 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 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 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 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 map) {
+ String[] values = session.getPreferenceService().getStringValues(str);
+ for (String val : values) {
+ String[] split = val.split("-");
+ map.put(val, split[1]);
+ }
+ }
+
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/style.css b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/style.css
new file mode 100644
index 0000000..65b4060
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart/style.css
@@ -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;
+}
\ No newline at end of file
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart_locale.properties b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart_locale.properties
new file mode 100644
index 0000000..1de0944
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart_locale.properties
@@ -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
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart_locale_zh_CN.properties b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart_locale_zh_CN.properties
new file mode 100644
index 0000000..b98a5b6
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/designtopart/designtopart_locale_zh_CN.properties
@@ -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
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/plm/dialogs/DataAllocationHandlerDialog.java b/cn.net.connor.designtopart/src/cn/net/connor/plm/dialogs/DataAllocationHandlerDialog.java
new file mode 100644
index 0000000..137a84b
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/plm/dialogs/DataAllocationHandlerDialog.java
@@ -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 propList1;
+ private List propList2;
+ private List propList3;
+ private List relationRevs;
+
+ public DataAllocationHandlerDialog(AbstractAIFUIApplication app, List propList1, List propList2,
+ List propList3, List 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 filePaths = new ArrayList();
+ 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();
+ }
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/plm/entity/Prop.java b/cn.net.connor.designtopart/src/cn/net/connor/plm/entity/Prop.java
new file mode 100644
index 0000000..24dad69
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/plm/entity/Prop.java
@@ -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 + '\'' +
+ '}';
+ }
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/plm/handlers/DataAllocationHandler.java b/cn.net.connor.designtopart/src/cn/net/connor/plm/handlers/DataAllocationHandler.java
new file mode 100644
index 0000000..7fc6787
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/plm/handlers/DataAllocationHandler.java
@@ -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 propList1 = new ArrayList<>();
+ List propList2 = new ArrayList<>();
+ List propList3 = new ArrayList<>();
+
+ List relationRevs = new ArrayList();
+ 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();
+ }
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/plm/util/ExcelWriteTable1.java b/cn.net.connor.designtopart/src/cn/net/connor/plm/util/ExcelWriteTable1.java
new file mode 100644
index 0000000..97d5496
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/plm/util/ExcelWriteTable1.java
@@ -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 props = new ArrayList<>();
+ props.add(new Prop("鍥剧焊", "鍑忛熺澹充綋", "123",
+ "姝e紡", "A", "test1", "2024.4.18", "TCN_1", "TCN_2"));
+ props.add(new Prop("鍥剧焊", "鍑忛熺澹充綋", "123",
+ "姝e紡", "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 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);
+
+ // 搴忓彿锛圓鍒楋級
+ 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);
+ }
+ }
+ }
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/plm/util/ExcelWriteTable2.java b/cn.net.connor.designtopart/src/cn/net/connor/plm/util/ExcelWriteTable2.java
new file mode 100644
index 0000000..f40ee4b
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/plm/util/ExcelWriteTable2.java
@@ -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 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);
+
+ // 搴忓彿锛圓鍒楋級
+ 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);
+ }
+ }
+ }
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/plm/util/ExcelWriteTable3.java b/cn.net.connor.designtopart/src/cn/net/connor/plm/util/ExcelWriteTable3.java
new file mode 100644
index 0000000..6722bd9
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/plm/util/ExcelWriteTable3.java
@@ -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 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);
+
+ // 搴忓彿锛圓鍒楋級
+ 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);
+ }
+ }
+ }
+
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/plm/util/SignPDF.java b/cn.net.connor.designtopart/src/cn/net/connor/plm/util/SignPDF.java
new file mode 100644
index 0000000..fd62692
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/plm/util/SignPDF.java
@@ -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;
+ }
+}
\ No newline at end of file
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/test/Colconfig.java b/cn.net.connor.designtopart/src/cn/net/connor/test/Colconfig.java
new file mode 100644
index 0000000..61fcbcc
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/test/Colconfig.java
@@ -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;
+ }
+
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/test/Data.java b/cn.net.connor.designtopart/src/cn/net/connor/test/Data.java
new file mode 100644
index 0000000..2a0f04b
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/test/Data.java
@@ -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;
+ }
+
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/test/Main.java b/cn.net.connor.designtopart/src/cn/net/connor/test/Main.java
new file mode 100644
index 0000000..6a8ea09
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/test/Main.java
@@ -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 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("name"));
+ name.setCellFactory(ComboBoxTableCell.forTableColumn(list));
+
+ age.setCellValueFactory(new PropertyValueFactory("age"));
+ age.setCellFactory(TextFieldTableCell.forTableColumn());
+
+ code.setCellValueFactory(new PropertyValueFactory("code"));
+ code.setCellFactory(TextFieldTableCell.forTableColumn());
+
+ name.setOnEditCommit(new EventHandler() {
+ @Override
+ public void handle(Event arg0) {
+ }
+ });
+
+ ObservableList 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();
+ }
+
+
+
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/test/Main2.java b/cn.net.connor.designtopart/src/cn/net/connor/test/Main2.java
new file mode 100644
index 0000000..eddaac8
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/test/Main2.java
@@ -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 list = FXCollections.observableArrayList();
+ list.add("One");
+ list.add("Two");
+ list.add("Three");
+ list.add("Four");
+
+ for (int i = 0; i < 3; i++) {
+ ObservableList 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 name = new TableColumn<>("Name");
+ TableColumn age = new TableColumn<>("Age");
+ TableColumn code = new TableColumn<>("Code");
+
+ name.setCellValueFactory(new PropertyValueFactory("name"));
+ name.setCellFactory(ComboBoxTableCell.forTableColumn(list));
+
+ age.setCellValueFactory(new PropertyValueFactory("age"));
+ age.setCellFactory(TextFieldTableCell.forTableColumn());
+
+ code.setCellValueFactory(new PropertyValueFactory("code"));
+ code.setCellFactory(TextFieldTableCell.forTableColumn());
+
+ TableView 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();
+ }
+
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/test/PartBean.java b/cn.net.connor.designtopart/src/cn/net/connor/test/PartBean.java
new file mode 100644
index 0000000..1b2a580
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/test/PartBean.java
@@ -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;
+ }
+
+}
diff --git a/cn.net.connor.designtopart/src/cn/net/connor/test/Test.java b/cn.net.connor.designtopart/src/cn/net/connor/test/Test.java
new file mode 100644
index 0000000..f62fb6d
--- /dev/null
+++ b/cn.net.connor.designtopart/src/cn/net/connor/test/Test.java
@@ -0,0 +1,37 @@
+package cn.net.connor.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Test {
+ public List inners;
+
+ public Test() {
+ inners = new ArrayList();
+ 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();
+ }
+
+}
diff --git a/cn.net.connor.designtopart/src/com/connor/dfl/plm/util/DataBaseControl.java b/cn.net.connor.designtopart/src/com/connor/dfl/plm/util/DataBaseControl.java
new file mode 100644
index 0000000..fc0b4ab
--- /dev/null
+++ b/cn.net.connor.designtopart/src/com/connor/dfl/plm/util/DataBaseControl.java
@@ -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();
+ }
+ }
+
+}
diff --git a/cn.net.connor.designtopart/src/xinShiBao.xml b/cn.net.connor.designtopart/src/xinShiBao.xml
new file mode 100644
index 0000000..00598f9
--- /dev/null
+++ b/cn.net.connor.designtopart/src/xinShiBao.xml
@@ -0,0 +1,114 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cn.net.connor.pdf.lao.image/.classpath b/cn.net.connor.pdf.lao.image/.classpath
new file mode 100644
index 0000000..12e0d55
--- /dev/null
+++ b/cn.net.connor.pdf.lao.image/.classpath
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/cn.net.connor.pdf.lao.image/.project b/cn.net.connor.pdf.lao.image/.project
new file mode 100644
index 0000000..2f471d5
--- /dev/null
+++ b/cn.net.connor.pdf.lao.image/.project
@@ -0,0 +1,17 @@
+
+
+ cn.net.connor.pdf.lao.image
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/cn.net.connor.pdf.lao.image/.settings/org.eclipse.jdt.core.prefs b/cn.net.connor.pdf.lao.image/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..ec1937b
--- /dev/null
+++ b/cn.net.connor.pdf.lao.image/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+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.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/cn.net.connor.pdf.lao.image/bin/com/sgcc/test/SignPdfLao.java--- b/cn.net.connor.pdf.lao.image/bin/com/sgcc/test/SignPdfLao.java---
new file mode 100644
index 0000000..551eb1b
--- /dev/null
+++ b/cn.net.connor.pdf.lao.image/bin/com/sgcc/test/SignPdfLao.java---
@@ -0,0 +1,435 @@
+package com.connor.pdf;
+
+import java.awt.Color;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.lowagie.text.DocumentException;
+import com.lowagie.text.Rectangle;
+import com.lowagie.text.pdf.BaseFont;
+import com.lowagie.text.pdf.PdfContentByte;
+import com.lowagie.text.pdf.PdfReader;
+import com.lowagie.text.pdf.PdfStamper;
+
+public class SignPdfLao {
+ public static void main(String[] args) {
+ int pageCount = 1;
+ SignPdfLao signPdf = new SignPdfLao();
+
+ String dataPath = args[0];
+ String pdfPath = args[1];
+ String outs = args[2];
+
+// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
+// String pdfPath = "C:\\Users\\infodba\\Desktop\\老世宝PDF\\A4图纸模板.PDF";
+// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\A4图纸模板.PDF";
+
+// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
+// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\SHIBAO_A4_页_1.PDF";
+// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\SHIBAO_A4_页_1.PDF";
+
+// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
+// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\SHIBAO_SO_A4_页_1.PDF";
+// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\SHIBAO_SO_A4_页_1.PDF";
+
+// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
+// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\AA.PDF";
+// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\AA.PDF";
+
+// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
+// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\A4图纸模板.PDF";
+// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\A4图纸模板.PDF";
+
+ Map dataMap = signPdf.getData(dataPath);
+ try {
+ System.out.println("=====开始签字=====");
+
+ PdfReader reader = new PdfReader(pdfPath);
+ PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outs));
+ Rectangle rectangle = reader.getPageSize(1);
+ Float[] fposition = signPdf.getSize(rectangle);
+ BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", true);
+ float x1 = 0.0F;
+ float x2 = 0.0F;
+ float x3 = 0.0F;
+ float x4 = 0.0F;
+ float y1 = 0.0F;
+ float y2 = 0.0F;
+ float y3 = 0.0F;
+ float y4 = 0.0F;
+ if (fposition[0] == 2384.0F && fposition[1] == 3370.0F) { // A0
+ x1 = 2870.0F;
+ y1 = 62.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 2900.0F;
+ x3 = 2971.0F;
+ x4 = 3003.0F;
+ } else if (fposition[0] == 2384.0F && fposition[1] == 1684.0F) { // A1
+ x1 = 1885.0F;
+ y1 = 62.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 1913.0F;
+ x3 = 1985.0F;
+ x4 = 2016.0F;
+ } else if (fposition[0] == 1684.0F && fposition[1] == 1191.0F) { // A2
+ x1 = 1183.0F;
+ y1 = 62.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 1214.0F;
+ x3 = 1285.0F;
+ x4 = 1316.0F;
+ } else if (fposition[0] == 1191.0F && fposition[1] == 842.0F) { // A3
+ x1 = 703.0F;
+ y1 = 48.0F;
+ y2 = 34.0F;
+ y3 = 20.0F;
+ y4 = 6.0F;
+ x2 = 735.0F;
+ x3 = 805.0F;
+ x4 = 837.0F;
+ } else if (fposition[0] == 842.0F && fposition[1] == 595.0F) { // A4
+ x1 = 110.0F;
+ y1 = 48.0F;
+ y2 = 34.0F;
+ y3 = 20.0F;
+ y4 = 6.0F;
+ x2 = 142.0F;
+ x3 = 213.0F;
+ x4 = 243.0F;
+ } else if (fposition[0] == 3370.4F && fposition[1] == 2383.94F) { // CATIA A0
+ x1 = 2870.0F;
+ y1 = 62.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 2902.0F;
+ x3 = 2971.0F;
+ x4 = 3003.0F;
+ } else if (fposition[0] == 2383.94F && fposition[1] == 1683.78F) { // CATIA A1
+ x1 = 1885.0F;
+ y1 = 62.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 1914.0F;
+ x3 = 1986.0F;
+ x4 = 2017.0F;
+ } else if (fposition[0] == 1683.78F && fposition[1] == 1190.56F) { // CATIA A2
+ x1 = 1183.0F;
+ y1 = 62.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 1214.0F;
+ x3 = 1285.0F;
+ x4 = 1316.0F;
+ } else if (fposition[0] == 1190.56F && fposition[1] == 841.89F) { // CATIA A3
+ x1 = 703.0F;
+ y1 = 48.0F;
+ y2 = 34.0F;
+ y3 = 20.0F;
+ y4 = 6.0F;
+ x2 = 735.0F;
+ x3 = 805.0F;
+ x4 = 837.0F;
+ } else if (fposition[0] == 595.28F && fposition[1] == 841.89F) { // CATIA A4
+ x1 = 110.0F;
+ y1 = 48.0F;
+ y2 = 34.0F;
+ y3 = 20.0F;
+ y4 = 6.0F;
+ x2 = 142.0F;
+ x3 = 213.0F;
+ x4 = 243.0F;
+ } else if (fposition[0] == 5054.18F && fposition[1] == 2383.94F) { // CATIA S0 A0
+ x1 = 4554.0F;
+ y1 = 61.0F;
+ y2 = 47.0F;
+ y3 = 33.0F;
+ y4 = 19.0F;
+ x2 = 4585.5F;
+ x3 = 4585.5F;
+ x4 = 4585.5F;
+ } else if (fposition[0] == 6740.79F && fposition[1] == 2383.94F) { // CATIA S0 A1
+ x1 = 6240.0F;
+ y1 = 61.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 6272.0F;
+ x3 = 6272.0F;
+ x4 = 6272.0F;
+ } else if (fposition[0] == 8424.57F && fposition[1] == 2383.94F) { // CATIA S0 A2
+ x1 = 7925.0F;
+ y1 = 60.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 7957.0F;
+ x3 = 7957.0F;
+ x4 = 7957.0F;
+ } else if (fposition[0] == 10111.19F && fposition[1] == 2383.94F) { // CATIA S0 A3
+ x1 = 9614.0F;
+ y1 = 60.0F;
+ y2 = 46.0F;
+ y3 = 32.0F;
+ y4 = 18.0F;
+ x2 = 9643.0F;
+ x3 = 9643.0F;
+ x4 = 9643.0F;
+ } else if (fposition[0] == 11794.97F && fposition[1] == 2383.94F) { // CATIA S0 A4
+ x1 = 11295.0F;
+ y1 = 60.0F;
+ y2 = 46.0F;
+ y3 = 32.0F;
+ y4 = 18.0F;
+ x2 = 11327.0F;
+ x3 = 11327.0F;
+ x4 = 11327.0F;
+ } else if (fposition[0] == 1684.0F && fposition[1] == 2384.0F) { // A1
+ x1 = 1885.0F;
+ y1 = 62.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 1913.0F;
+ x3 = 1985.0F;
+ x4 = 2016.0F;
+ } else if (fposition[0] == 1191.0F && fposition[1] == 1684.0F) { // A2
+ x1 = 1183.0F;
+ y1 = 62.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 1214.0F;
+ x3 = 1285.0F;
+ x4 = 1316.0F;
+ } else if (fposition[0] == 842.0F && fposition[1] == 1191.0F) { // A3
+ x1 = 703.0F;
+ y1 = 48.0F;
+ y2 = 34.0F;
+ y3 = 20.0F;
+ y4 = 6.0F;
+ x2 = 735.0F;
+ x3 = 805.0F;
+ x4 = 837.0F;
+ } else if (fposition[0] == 595.0F && fposition[1] == 842.0F) { // A4
+ x1 = 110.0F;
+ y1 = 48.0F;
+ y2 = 34.0F;
+ y3 = 20.0F;
+ y4 = 6.0F;
+ x2 = 142.0F;
+ x3 = 213.0F;
+ x4 = 243.0F;
+ }
+
+ if (dataMap.containsKey("编制")) {
+ String value = (String) dataMap.get("编制");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 9.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y1).floatValue());
+ content.showText(value);
+ content.endText();
+// signPdf.signBZ(pageCount, value, content, reader, stamper, Integer.valueOf(275));
+ }
+ if (dataMap.containsKey("校对")) {
+ String value = (String) dataMap.get("校对");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 9.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y2).floatValue());
+ content.showText(value);
+ content.endText();
+// signPdf.signBZ(pageCount, value, content, reader, stamper, Integer.valueOf(476));
+ }
+ if (dataMap.containsKey("会签")) {
+ String value = (String) dataMap.get("会签");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 9.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y3).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("批准")) {
+ String value = (String) dataMap.get("批准");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 9.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y4).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+
+ if (dataMap.containsKey("编制日期")) {
+ String value = (String) dataMap.get("编制日期");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 6.2F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y1).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("校对日期")) {
+ String value = (String) dataMap.get("校对日期");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 6.2F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y2).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("会签日期")) {
+ String value = (String) dataMap.get("会签日期");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 6.2F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y3).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("批准日期")) {
+ String value = (String) dataMap.get("批准日期");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 6.2F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y4).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+
+ stamper.close();
+ reader.close();
+ System.out.println("=====签字结束=====");
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public Map getData(String filePath) {
+ String lineTxt = "";
+ Map dataMap = new HashMap<>();
+ try {
+ String encoding = "GBK";
+ File file = new File(filePath);
+ if ((file.isFile()) && (file.exists())) {
+ InputStreamReader read = new InputStreamReader(new FileInputStream(file), encoding);
+ BufferedReader bufferedReader = new BufferedReader(read);
+ lineTxt = bufferedReader.readLine();
+ System.out.println("linttxt=======" + lineTxt);
+
+ read.close();
+ } else {
+ System.out.println("找不到指定的文件");
+ }
+ } catch (Exception e) {
+ System.out.println("读取文件内容出错");
+ e.printStackTrace();
+ }
+ String[] dataList = null;
+ if ((lineTxt != null) && (lineTxt.length() > 0) && (lineTxt.split("\\|") != null))
+ dataList = lineTxt.split("\\|");
+ else {
+ dataList[0] = "";
+ }
+ for (int i = 0; i < dataList.length; i++) {
+ System.out.println("dataList=======" + dataList[i]);
+ String[] datas = null;
+ datas = dataList[i].split("=");
+ if ((datas != null) && (datas.length > 1)) {
+ dataMap.put(datas[0], datas[1]);
+ }
+ }
+
+ return dataMap;
+ }
+
+ public 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();
+
+ JFomPdfBean bean = new JFomPdfBean();
+ bean.setH(Float.valueOf(toright - toleft));
+ bean.setW(Float.valueOf(totop - tobottom));
+ sizef[0] = bean.getH();
+ sizef[1] = bean.getW();
+ System.out.println("bean.getH------------>................." + bean.getH());
+ System.out.println("bean.getW------------>................." + bean.getW());
+
+ return sizef;
+ }
+
+ public void signBZ(int pageCount, String value, PdfContentByte content, PdfReader reader, PdfStamper stamper,
+ Integer x) {
+ for (int i = 2; i <= pageCount; i++) {
+ int width = x.intValue();
+ SignPdfLao pdf = new SignPdfLao();
+ Rectangle rectangle = reader.getPageSize(i);
+ System.out.println("=========第" + i + "页=========");
+ Float[] fposition = pdf.getSize(rectangle);
+ try {
+ BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", true);
+ String[] values = value.split(" ");
+ if (values != null)
+ for (int j = 0; j < values.length; j++) {
+ content = stamper.getUnderContent(i);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 11.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(width).floatValue(), Float.valueOf(30.0F).floatValue());
+ content.showText(values[j]);
+ content.endText();
+ width += 63;
+ }
+ } catch (DocumentException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/cn.net.connor.pdf.lao.image/bin/com/sgcc/test/StamperLao.class b/cn.net.connor.pdf.lao.image/bin/com/sgcc/test/StamperLao.class
new file mode 100644
index 0000000..98d42d0
Binary files /dev/null and b/cn.net.connor.pdf.lao.image/bin/com/sgcc/test/StamperLao.class differ
diff --git a/cn.net.connor.pdf.lao.image/bin/com/sgcc/test/Test.class b/cn.net.connor.pdf.lao.image/bin/com/sgcc/test/Test.class
new file mode 100644
index 0000000..be485c6
Binary files /dev/null and b/cn.net.connor.pdf.lao.image/bin/com/sgcc/test/Test.class differ
diff --git a/cn.net.connor.pdf.lao.image/bin/com/sgcc/test/鑰佺増鍧愭爣.txt b/cn.net.connor.pdf.lao.image/bin/com/sgcc/test/鑰佺増鍧愭爣.txt
new file mode 100644
index 0000000..02149d0
--- /dev/null
+++ b/cn.net.connor.pdf.lao.image/bin/com/sgcc/test/鑰佺増鍧愭爣.txt
@@ -0,0 +1,58 @@
+if (fposition[0] == 2384.0 && fposition[1] == 3370.0F) { // A0
+ x1 = 3010.0F;
+ y1 = 220.0F;
+ } else if (fposition[0] == 2384.0F && fposition[1] == 1684.0F) { // A1
+ x1 = 2020.0F;
+ y1 = 220.0F;
+ } else if (fposition[0] == 1684.0F && fposition[1] == 1191.0F) { // A2
+ x1 = 1310.0F;
+ y1 = 220.0F;
+ } else if (fposition[0] == 1191.0F && fposition[1] == 842.0F) { // A3
+ x1 = 850.0F;
+ y1 = 200.0F;
+ } else if (fposition[0] == 842.0F && fposition[1] == 595.0F) { // A4
+ x1 = 250.0F;
+ y1 = 200.0F;
+ }else if (fposition[0] == 3370.4F && fposition[1] == 2383.94F) { // CATIA A0
+ x1 = 2870.0F;
+ y1 = 162.0F;
+ } else if (fposition[0] == 2383.94F && fposition[1] == 1683.78F) { // CATIA A1
+ x1 = 1885.0F;
+ y1 = 162.0F;
+ } else if (fposition[0] == 1683.78F && fposition[1] == 1190.56F) { // CATIA A2
+ x1 = 1183.0F;
+ y1 = 162.0F;
+ } else if (fposition[0] == 1190.56F && fposition[1] == 841.89F) { // CATIA A3
+ x1 = 703.0F;
+ y1 = 148.0F;
+ } else if (fposition[0] == 595.28F && fposition[1] == 841.89F) { // CATIA A4
+ x1 = 110.0F;
+ y1 = 148.0F;
+ } else if (fposition[0] == 5054.18F && fposition[1] == 2383.94F) { // CATIA S0 A0
+ x1 = 4554.0F;
+ y1 = 161.0F;
+ } else if (fposition[0] == 6740.79F && fposition[1] == 2383.94F) { // CATIA S0 A1
+ x1 = 6240.0F;
+ y1 = 161.0F;
+ } else if (fposition[0] == 8424.57F && fposition[1] == 2383.94F) { // CATIA S0 A2
+ x1 = 7925.0F;
+ y1 = 160.0F;
+ } else if (fposition[0] == 10111.19F && fposition[1] == 2383.94F) { // CATIA S0 A3
+ x1 = 9614.0F;
+ y1 = 160.0F;
+ } else if (fposition[0] == 11794.97F && fposition[1] == 2383.94F) { // CATIA S0 A4
+ x1 = 11295.0F;
+ y1 = 160.0F;
+ }else if (fposition[0] == 1684.0F && fposition[1] == 2384.0F) { // A1
+ x1 = 1885.0F;
+ y1 = 210.0F;
+ } else if (fposition[0] == 1191.0F && fposition[1] == 1684.0F) { // A2
+ x1 = 1183.0F;
+ y1 = 210.0F;
+ } else if (fposition[0] == 842.0F && fposition[1] == 1191.0F) { // A3
+ x1 = 703.0F;
+ y1 = 190.0F;
+ } else if (fposition[0] == 595.0F && fposition[1] == 842.0F) { // A4
+ x1 = 110.0F;
+ y1 = 190.0F;
+ }
diff --git a/cn.net.connor.pdf.lao.image/lib/core-renderer.jar b/cn.net.connor.pdf.lao.image/lib/core-renderer.jar
new file mode 100644
index 0000000..871fabf
Binary files /dev/null and b/cn.net.connor.pdf.lao.image/lib/core-renderer.jar differ
diff --git a/cn.net.connor.pdf.lao.image/lib/iTextAsian.jar b/cn.net.connor.pdf.lao.image/lib/iTextAsian.jar
new file mode 100644
index 0000000..3fa2157
Binary files /dev/null and b/cn.net.connor.pdf.lao.image/lib/iTextAsian.jar differ
diff --git a/cn.net.connor.pdf.lao.image/lib/iTextAsianCmaps.jar b/cn.net.connor.pdf.lao.image/lib/iTextAsianCmaps.jar
new file mode 100644
index 0000000..aa2b429
Binary files /dev/null and b/cn.net.connor.pdf.lao.image/lib/iTextAsianCmaps.jar differ
diff --git a/cn.net.connor.pdf.lao.image/lib/itextpdf-5.0.6.jar b/cn.net.connor.pdf.lao.image/lib/itextpdf-5.0.6.jar
new file mode 100644
index 0000000..d716b4e
Binary files /dev/null and b/cn.net.connor.pdf.lao.image/lib/itextpdf-5.0.6.jar differ
diff --git a/cn.net.connor.pdf.lao.image/src/com/sgcc/test/SignPdfLao.java--- b/cn.net.connor.pdf.lao.image/src/com/sgcc/test/SignPdfLao.java---
new file mode 100644
index 0000000..551eb1b
--- /dev/null
+++ b/cn.net.connor.pdf.lao.image/src/com/sgcc/test/SignPdfLao.java---
@@ -0,0 +1,435 @@
+package com.connor.pdf;
+
+import java.awt.Color;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.lowagie.text.DocumentException;
+import com.lowagie.text.Rectangle;
+import com.lowagie.text.pdf.BaseFont;
+import com.lowagie.text.pdf.PdfContentByte;
+import com.lowagie.text.pdf.PdfReader;
+import com.lowagie.text.pdf.PdfStamper;
+
+public class SignPdfLao {
+ public static void main(String[] args) {
+ int pageCount = 1;
+ SignPdfLao signPdf = new SignPdfLao();
+
+ String dataPath = args[0];
+ String pdfPath = args[1];
+ String outs = args[2];
+
+// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
+// String pdfPath = "C:\\Users\\infodba\\Desktop\\老世宝PDF\\A4图纸模板.PDF";
+// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\A4图纸模板.PDF";
+
+// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
+// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\SHIBAO_A4_页_1.PDF";
+// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\SHIBAO_A4_页_1.PDF";
+
+// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
+// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\SHIBAO_SO_A4_页_1.PDF";
+// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\SHIBAO_SO_A4_页_1.PDF";
+
+// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
+// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\AA.PDF";
+// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\AA.PDF";
+
+// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
+// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\A4图纸模板.PDF";
+// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\A4图纸模板.PDF";
+
+ Map dataMap = signPdf.getData(dataPath);
+ try {
+ System.out.println("=====开始签字=====");
+
+ PdfReader reader = new PdfReader(pdfPath);
+ PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outs));
+ Rectangle rectangle = reader.getPageSize(1);
+ Float[] fposition = signPdf.getSize(rectangle);
+ BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", true);
+ float x1 = 0.0F;
+ float x2 = 0.0F;
+ float x3 = 0.0F;
+ float x4 = 0.0F;
+ float y1 = 0.0F;
+ float y2 = 0.0F;
+ float y3 = 0.0F;
+ float y4 = 0.0F;
+ if (fposition[0] == 2384.0F && fposition[1] == 3370.0F) { // A0
+ x1 = 2870.0F;
+ y1 = 62.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 2900.0F;
+ x3 = 2971.0F;
+ x4 = 3003.0F;
+ } else if (fposition[0] == 2384.0F && fposition[1] == 1684.0F) { // A1
+ x1 = 1885.0F;
+ y1 = 62.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 1913.0F;
+ x3 = 1985.0F;
+ x4 = 2016.0F;
+ } else if (fposition[0] == 1684.0F && fposition[1] == 1191.0F) { // A2
+ x1 = 1183.0F;
+ y1 = 62.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 1214.0F;
+ x3 = 1285.0F;
+ x4 = 1316.0F;
+ } else if (fposition[0] == 1191.0F && fposition[1] == 842.0F) { // A3
+ x1 = 703.0F;
+ y1 = 48.0F;
+ y2 = 34.0F;
+ y3 = 20.0F;
+ y4 = 6.0F;
+ x2 = 735.0F;
+ x3 = 805.0F;
+ x4 = 837.0F;
+ } else if (fposition[0] == 842.0F && fposition[1] == 595.0F) { // A4
+ x1 = 110.0F;
+ y1 = 48.0F;
+ y2 = 34.0F;
+ y3 = 20.0F;
+ y4 = 6.0F;
+ x2 = 142.0F;
+ x3 = 213.0F;
+ x4 = 243.0F;
+ } else if (fposition[0] == 3370.4F && fposition[1] == 2383.94F) { // CATIA A0
+ x1 = 2870.0F;
+ y1 = 62.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 2902.0F;
+ x3 = 2971.0F;
+ x4 = 3003.0F;
+ } else if (fposition[0] == 2383.94F && fposition[1] == 1683.78F) { // CATIA A1
+ x1 = 1885.0F;
+ y1 = 62.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 1914.0F;
+ x3 = 1986.0F;
+ x4 = 2017.0F;
+ } else if (fposition[0] == 1683.78F && fposition[1] == 1190.56F) { // CATIA A2
+ x1 = 1183.0F;
+ y1 = 62.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 1214.0F;
+ x3 = 1285.0F;
+ x4 = 1316.0F;
+ } else if (fposition[0] == 1190.56F && fposition[1] == 841.89F) { // CATIA A3
+ x1 = 703.0F;
+ y1 = 48.0F;
+ y2 = 34.0F;
+ y3 = 20.0F;
+ y4 = 6.0F;
+ x2 = 735.0F;
+ x3 = 805.0F;
+ x4 = 837.0F;
+ } else if (fposition[0] == 595.28F && fposition[1] == 841.89F) { // CATIA A4
+ x1 = 110.0F;
+ y1 = 48.0F;
+ y2 = 34.0F;
+ y3 = 20.0F;
+ y4 = 6.0F;
+ x2 = 142.0F;
+ x3 = 213.0F;
+ x4 = 243.0F;
+ } else if (fposition[0] == 5054.18F && fposition[1] == 2383.94F) { // CATIA S0 A0
+ x1 = 4554.0F;
+ y1 = 61.0F;
+ y2 = 47.0F;
+ y3 = 33.0F;
+ y4 = 19.0F;
+ x2 = 4585.5F;
+ x3 = 4585.5F;
+ x4 = 4585.5F;
+ } else if (fposition[0] == 6740.79F && fposition[1] == 2383.94F) { // CATIA S0 A1
+ x1 = 6240.0F;
+ y1 = 61.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 6272.0F;
+ x3 = 6272.0F;
+ x4 = 6272.0F;
+ } else if (fposition[0] == 8424.57F && fposition[1] == 2383.94F) { // CATIA S0 A2
+ x1 = 7925.0F;
+ y1 = 60.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 7957.0F;
+ x3 = 7957.0F;
+ x4 = 7957.0F;
+ } else if (fposition[0] == 10111.19F && fposition[1] == 2383.94F) { // CATIA S0 A3
+ x1 = 9614.0F;
+ y1 = 60.0F;
+ y2 = 46.0F;
+ y3 = 32.0F;
+ y4 = 18.0F;
+ x2 = 9643.0F;
+ x3 = 9643.0F;
+ x4 = 9643.0F;
+ } else if (fposition[0] == 11794.97F && fposition[1] == 2383.94F) { // CATIA S0 A4
+ x1 = 11295.0F;
+ y1 = 60.0F;
+ y2 = 46.0F;
+ y3 = 32.0F;
+ y4 = 18.0F;
+ x2 = 11327.0F;
+ x3 = 11327.0F;
+ x4 = 11327.0F;
+ } else if (fposition[0] == 1684.0F && fposition[1] == 2384.0F) { // A1
+ x1 = 1885.0F;
+ y1 = 62.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 1913.0F;
+ x3 = 1985.0F;
+ x4 = 2016.0F;
+ } else if (fposition[0] == 1191.0F && fposition[1] == 1684.0F) { // A2
+ x1 = 1183.0F;
+ y1 = 62.0F;
+ y2 = 48.0F;
+ y3 = 34.0F;
+ y4 = 20.0F;
+ x2 = 1214.0F;
+ x3 = 1285.0F;
+ x4 = 1316.0F;
+ } else if (fposition[0] == 842.0F && fposition[1] == 1191.0F) { // A3
+ x1 = 703.0F;
+ y1 = 48.0F;
+ y2 = 34.0F;
+ y3 = 20.0F;
+ y4 = 6.0F;
+ x2 = 735.0F;
+ x3 = 805.0F;
+ x4 = 837.0F;
+ } else if (fposition[0] == 595.0F && fposition[1] == 842.0F) { // A4
+ x1 = 110.0F;
+ y1 = 48.0F;
+ y2 = 34.0F;
+ y3 = 20.0F;
+ y4 = 6.0F;
+ x2 = 142.0F;
+ x3 = 213.0F;
+ x4 = 243.0F;
+ }
+
+ if (dataMap.containsKey("编制")) {
+ String value = (String) dataMap.get("编制");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 9.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y1).floatValue());
+ content.showText(value);
+ content.endText();
+// signPdf.signBZ(pageCount, value, content, reader, stamper, Integer.valueOf(275));
+ }
+ if (dataMap.containsKey("校对")) {
+ String value = (String) dataMap.get("校对");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 9.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y2).floatValue());
+ content.showText(value);
+ content.endText();
+// signPdf.signBZ(pageCount, value, content, reader, stamper, Integer.valueOf(476));
+ }
+ if (dataMap.containsKey("会签")) {
+ String value = (String) dataMap.get("会签");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 9.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y3).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("批准")) {
+ String value = (String) dataMap.get("批准");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 9.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y4).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+
+ if (dataMap.containsKey("编制日期")) {
+ String value = (String) dataMap.get("编制日期");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 6.2F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y1).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("校对日期")) {
+ String value = (String) dataMap.get("校对日期");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 6.2F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y2).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("会签日期")) {
+ String value = (String) dataMap.get("会签日期");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 6.2F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y3).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("批准日期")) {
+ String value = (String) dataMap.get("批准日期");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 6.2F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y4).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+
+ stamper.close();
+ reader.close();
+ System.out.println("=====签字结束=====");
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public Map getData(String filePath) {
+ String lineTxt = "";
+ Map dataMap = new HashMap<>();
+ try {
+ String encoding = "GBK";
+ File file = new File(filePath);
+ if ((file.isFile()) && (file.exists())) {
+ InputStreamReader read = new InputStreamReader(new FileInputStream(file), encoding);
+ BufferedReader bufferedReader = new BufferedReader(read);
+ lineTxt = bufferedReader.readLine();
+ System.out.println("linttxt=======" + lineTxt);
+
+ read.close();
+ } else {
+ System.out.println("找不到指定的文件");
+ }
+ } catch (Exception e) {
+ System.out.println("读取文件内容出错");
+ e.printStackTrace();
+ }
+ String[] dataList = null;
+ if ((lineTxt != null) && (lineTxt.length() > 0) && (lineTxt.split("\\|") != null))
+ dataList = lineTxt.split("\\|");
+ else {
+ dataList[0] = "";
+ }
+ for (int i = 0; i < dataList.length; i++) {
+ System.out.println("dataList=======" + dataList[i]);
+ String[] datas = null;
+ datas = dataList[i].split("=");
+ if ((datas != null) && (datas.length > 1)) {
+ dataMap.put(datas[0], datas[1]);
+ }
+ }
+
+ return dataMap;
+ }
+
+ public 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();
+
+ JFomPdfBean bean = new JFomPdfBean();
+ bean.setH(Float.valueOf(toright - toleft));
+ bean.setW(Float.valueOf(totop - tobottom));
+ sizef[0] = bean.getH();
+ sizef[1] = bean.getW();
+ System.out.println("bean.getH------------>................." + bean.getH());
+ System.out.println("bean.getW------------>................." + bean.getW());
+
+ return sizef;
+ }
+
+ public void signBZ(int pageCount, String value, PdfContentByte content, PdfReader reader, PdfStamper stamper,
+ Integer x) {
+ for (int i = 2; i <= pageCount; i++) {
+ int width = x.intValue();
+ SignPdfLao pdf = new SignPdfLao();
+ Rectangle rectangle = reader.getPageSize(i);
+ System.out.println("=========第" + i + "页=========");
+ Float[] fposition = pdf.getSize(rectangle);
+ try {
+ BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", true);
+ String[] values = value.split(" ");
+ if (values != null)
+ for (int j = 0; j < values.length; j++) {
+ content = stamper.getUnderContent(i);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 11.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(width).floatValue(), Float.valueOf(30.0F).floatValue());
+ content.showText(values[j]);
+ content.endText();
+ width += 63;
+ }
+ } catch (DocumentException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/cn.net.connor.pdf.lao.image/src/com/sgcc/test/StamperLao.java b/cn.net.connor.pdf.lao.image/src/com/sgcc/test/StamperLao.java
new file mode 100644
index 0000000..6d8c2aa
--- /dev/null
+++ b/cn.net.connor.pdf.lao.image/src/com/sgcc/test/StamperLao.java
@@ -0,0 +1,314 @@
+package com.sgcc.test;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+import com.itextpdf.text.BaseColor;
+import com.itextpdf.text.Image;
+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;
+
+/**
+ * 签字盖章 多个盖章签字测试
+ *
+ * @author wang
+ * @version 1.0.0
+ */
+public class StamperLao {
+ public static void main(String[] args) {
+ String pdfUrl = "C:\\测试用例\\A3图纸模板V4.0.PDF";
+ String newPdfUrl = "C:\\测试用例\\A3图纸模板V4.02.PDF";
+ String imageFile = "C:\\测试用例\\configsk.txt";
+ String dateSign = "2025-4-23";
+ String method = "sk".toLowerCase();
+ String isSignDate = "Y";
+
+
+// String pdfUrl = args[0];
+// String newPdfUrl = args[1];
+// String imageFile = args[2];
+// String dateSign = args[3];
+// String method = args[4].toLowerCase();
+// String isSignDate = args[5];
+ sign(pdfUrl, newPdfUrl, imageFile,dateSign, method, isSignDate);
+ }
+
+ public static void sign(String pdfUrl, String newPdfUrl, String imageFile, String dateSign,String method,String isSignDate) {
+ try {
+
+ String imageUrl = "";
+ FileReader fReader = new FileReader(imageFile);
+ char[] buf = new char[128];
+ int len;
+ while ((len = fReader.read(buf)) != -1) {
+ imageUrl= new String(buf, 0, len);
+ }
+ imageUrl = imageUrl.split("=")[1];
+ System.out.println(imageUrl);
+
+ System.out.println("imageUrl : " + imageUrl);
+ System.out.println("method : " + method);
+
+ 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");
+ if (method.equals("sk")) {
+ x1 = 2718.42F;
+ y1 = 28.3F;
+ } else{
+ x1 = 2718.42F;
+ y1 = 170.0F;
+ }
+ } else if (fposition[0] == 2384.0F && fposition[1] == 1684.0F) { // A1
+ System.out.println("A1");
+ if (method.equals("sk")) {
+ x1 = 1731.9F;
+ y1 = 28.3F;
+ } else {
+ x1 = 1731.9F;
+ y1 = 170.0F;
+ }
+ } else if (fposition[0] == 1684.0F && fposition[1] == 1191.0F) { // A2
+ System.out.println("A2");
+ if (method.equals("sk")) {
+ x1 = 1031.8F;
+ y1 = 28.3F;
+ } else {
+ x1 = 1031.8F;
+ y1 = 170.0F;
+ }
+ } else if (fposition[0] == 1191.0F && fposition[1] == 842.0F) { // A3
+ System.out.println("A3");
+ if (method.equals("sk")) {
+ x1 = 552.7F;
+ y1 = 14.1F;
+ } else {
+ x1 = 552.7F;
+ y1 = 155.9F;
+ }
+ } else if (fposition[0] == 842.0F && fposition[1] == 595.0F) { // A4
+ System.out.println("A4");
+ if (method.equals("sk")) {
+ x1 = 714.3F;
+ y1 = 467.7F;
+ } else {
+ x1 = 629.2F;
+ y1 = 467.7F;
+ }
+ } else if (fposition[0] == 3370.4F && fposition[1] == 2383.94F) { // CATIA A0
+ System.out.println("CATIA A0");
+ if (method.equals("sk")) {
+ x1 = 2718.4F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 2718.4F;
+ y1 = 170.0F;
+ }else {
+ x1 = 1628.5F;
+ y1 = 1163.6F;
+ }
+ } else if (fposition[0] == 2383.94F && fposition[1] == 1683.78F) { // CATIA A1
+ System.out.println("CATIA A1");
+ if (method.equals("sk")) {
+ x1 = 1731.9F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 1731.9F;
+ y1 = 170.0F;
+ }else {
+ x1 = 629.2F;
+ y1 = 813.5F;
+ }
+ } else if (fposition[0] == 1683.78F && fposition[1] == 1190.56F) { // CATIA A2
+ System.out.println("CATIA A2");
+ if (method.equals("sk")) {
+ x1 = 1031.8F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 1031.8F;
+ y1 = 170.0F;
+ }else {
+ x1 = 629.2F;
+ y1 = 566.9F;
+ }
+ } else if (fposition[0] == 1190.56F && fposition[1] == 841.89F) { // CATIA A3
+ System.out.println("CATIA A3");
+ if (method.equals("sk")) {
+ x1 = 552.7F;
+ y1 = 14.1F;
+ } else if(method.equals("ls")){
+ x1 = 552.7F;
+ y1 = 155.9F;
+ }else {
+ x1 = 538.6F;
+ y1 = 392.5F;
+ }
+ } else if (fposition[0] == 595.28F && fposition[1] == 841.89F) { // CATIA A4
+ System.out.println("CATIA A4");
+ if (method.equals("sk")) {
+ x1 = 467.7F;
+ y1 = 714.3F;
+ } else if(method.equals("ls")){
+ x1 = 467.7F;
+ y1 = 629.2F;
+ }else {
+ x1 = 240.9F;
+ y1 = 392.5F;
+ }
+ } else if (fposition[0] == 5054.18F && fposition[1] == 2383.94F) { // CATIA S0 A0
+ System.out.println("CATIA S0 A0");
+ if (method.equals("sk")) {
+ x1 = 4402.2F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 4402.2F;
+ y1 = 170.1F;
+ }else {
+ x1 = 2470.4F;
+ y1 = 1163.6F;
+ }
+ } else if (fposition[0] == 6740.79F && fposition[1] == 2383.94F) { // CATIA S0 A1
+ System.out.println("CATIA S0 A1");
+ if (method.equals("sk")) {
+ x1 = 6088.8F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 6088.8F;
+ y1 = 170.1F;
+ }else {
+ x1 = 3313.7F;
+ y1 = 1163.6F;
+ }
+ } else if (fposition[0] == 8424.57F && fposition[1] == 2383.94F) { // CATIA S0 A2
+ System.out.println("CATIA S0 A2");
+ if (method.equals("sk")) {
+ x1 = 7772.6F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 7772.6F;
+ y1 = 170.1F;
+ }else {
+ x1 = 4155.6F;
+ y1 = 1163.6F;
+ }
+ } else if (fposition[0] == 10111.19F && fposition[1] == 2383.94F) { // CATIA S0 A3
+ System.out.println("CATIA S0 A3");
+ if (method.equals("sk")) {
+ x1 = 9459.2F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 9459.2F;
+ y1 = 170.1F;
+ }else {
+ x1 = 4998.9F;
+ y1 = 1163.6F;
+ }
+ } else if (fposition[0] == 11794.97F && fposition[1] == 2383.94F) { // CATIA S0 A4
+ System.out.println("CATIA S0 A4");
+ if (method.equals("sk")) {
+ x1 = 11143F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 11143F;
+ y1 = 170.1F;
+ }else {
+ x1 = 5840.8F;
+ y1 = 1163.6F;
+ }
+ } else if (fposition[0] == 1684.0F && fposition[1] == 2384.0F) { // A1
+ System.out.println("-A1");
+ x1 = 1885.0F;
+ y1 = 210.0F;
+ } else if (fposition[0] == 1191.0F && fposition[1] == 1684.0F) { // A2
+ System.out.println("-A2");
+ x1 = 1183.0F;
+ y1 = 210.0F;
+ } else if (fposition[0] == 842.0F && fposition[1] == 1191.0F) { // A3
+ System.out.println("-A3");
+ x1 = 703.0F;
+ y1 = 190.0F;
+ } else if (fposition[0] == 595.0F && fposition[1] == 842.0F) { // A4
+ System.out.println("-A4");
+ if (method.equals("sk")) {
+ x1 = 467.7F;
+ y1 = 714.3F;
+ } else {
+ x1 = 467.7F;
+ y1 = 629.2F;
+ }
+ }
+
+ System.out.println("当前盖章x1坐标:" + x1);
+ System.out.println("当前盖章y1坐标:" + y1);
+
+ Image img = Image.getInstance(imageUrl);
+ img.setAbsolutePosition(x1, y1);
+ if(method.equals("zf")) {
+ img.scalePercent(41);
+ }else {
+ img.scalePercent(46);
+ }
+ PdfContentByte under = stamper.getOverContent(1);
+
+ // 1. 插入图片(带透明度)
+ PdfGState imgState = new PdfGState();
+ imgState.setFillOpacity(0.9f);
+ // 应用透明度状态
+ under.setGState(imgState);
+ under.saveState();
+ under.addImage(img);
+
+ PdfGState fontState = new PdfGState();
+ under.setGState(fontState);
+ under.saveState();
+ // 2. 插入时间字符串(formattedTime2)
+ // 定义字体(Times New Roman,常规,小四,红色)
+ if (method.equals("ls") && isSignDate.equals("Y")) {
+ BaseFont baseFont = BaseFont.createFont("c:/windows/fonts/times.ttf", // Times New Roman 字体文件路径
+ BaseFont.WINANSI, BaseFont.EMBEDDED);
+ under.beginText();
+ under.setFontAndSize(baseFont, 12);
+ under.setColorFill(new BaseColor(225, 0, 0));
+// under.setTextMatrix(x1+161, y1 + 60);
+ under.setTextMatrix(x1 + 50, y1 + 6);
+ under.showText(dateSign);
+ under.endText();
+ }
+
+ under.restoreState();
+ fReader.close();
+ 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;
+ }
+}
diff --git a/cn.net.connor.pdf.lao.image/src/com/sgcc/test/Test.java b/cn.net.connor.pdf.lao.image/src/com/sgcc/test/Test.java
new file mode 100644
index 0000000..9e49070
--- /dev/null
+++ b/cn.net.connor.pdf.lao.image/src/com/sgcc/test/Test.java
@@ -0,0 +1,337 @@
+package com.sgcc.test;
+
+import java.io.FileOutputStream;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+import com.itextpdf.text.BaseColor;
+import com.itextpdf.text.Image;
+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 Test {
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ LocalDateTime now = LocalDateTime.now();
+ String formattedTime1 = now.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
+ String formattedTime2 = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ float opacity = Float.parseFloat("0.9"); // 范围0.0~1.0(1.0为不透明)
+
+ String[] pdfNames = new String[] {"A3图纸模板V4.0"};
+ int count = 0;
+ String[] pdfUrls = new String[] { "C:\\测试用例\\" + pdfNames[count++] + ".PDF"};
+
+// String[] imageNames = new String[] {"ls","skjs","skgy"};
+ String[] imageNames = new String[] { "sk" };
+ int cnt = 0;
+// String[] imageUrls = new String[] {"C:\\测试用例\\"+imageNames[cnt++]+".png","C:\\测试用例\\"+imageNames[cnt++]+".png"
+// ,"C:\\测试用例\\"+imageNames[cnt++]+".png"};
+ String[] imageUrls = new String[] { "C:\\测试用例\\" + imageNames[cnt++] + ".png"};
+
+ for (int i = 0; i < pdfUrls.length; i++) {
+// for (int j = 0; j < imageUrls.length; j++) {
+// System.out.println("========>Begin : "+ pdfUrls[i]);
+// String tempTime = now.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
+// String newPdfUrl = "C:\\测试用例\\盖章\\" + pdfNames[i] + "_"+ imageNames[j] + "_" + tempTime +".PDF";
+// String method = imageNames[j];
+// System.out.println("pngName : "+ method);
+// sign(pdfUrls[i],newPdfUrl,imageUrls[j],"",method,opacity);
+// System.out.println("========>End : "+ newPdfUrl);
+// System.out.println();
+// }
+ System.out.println("========>Begin : " + pdfUrls[i]);
+ String tempTime = now.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
+ String newPdfUrl = "C:\\测试用例\\盖章\\" + pdfNames[i] + "_" + imageNames[0] + "_" + tempTime + ".PDF";
+ System.out.println("pngName : " + imageNames[0]);
+ sign(pdfUrls[i], newPdfUrl, imageUrls[0], formattedTime2, imageNames[0], opacity);
+ System.out.println("========>End : " + newPdfUrl);
+ System.out.println();
+
+ sign(newPdfUrl, "C:\\测试用例\\盖章\\" + pdfNames[i] + "_" + imageNames[1] + "_" + tempTime + ".PDF",
+ imageUrls[1], formattedTime2, imageNames[1], opacity);
+ }
+
+ }
+
+
+ public static void sign(String pdfUrl, String newPdfUrl, String imageUrl, String dateSign, String method,
+ float opacity) {
+// try(FileInputStream fis = new FileInputStream(imageFile);
+// InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8)) {
+ try {
+
+// String imageUrl = "";
+// FileReader fReader = new FileReader(imageFile);
+// char[] buf = new char[128];
+// int len;
+// while ((len = fReader.read(buf)) != -1) {
+// imageUrl= new String(buf, 0, len);
+// }
+// imageUrl = imageUrl.split("=")[1];
+// System.out.println(imageUrl);
+
+// String imageUrl = "";
+// StringBuilder content = new StringBuilder();
+// char[] buffer = new char[1024];
+// int len;
+// while ((len = isr.read(buffer)) != -1) {
+// content.append(buffer, 0, len);
+// }
+// imageUrl = content.toString().split("=")[1];
+// System.out.println(imageUrl);
+
+ 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");
+ if (method.equals("sk")) {
+ x1 = 2718.42F;
+ y1 = 28.3F;
+ } else{
+ x1 = 2718.42F;
+ y1 = 170.0F;
+ }
+ } else if (fposition[0] == 2384.0F && fposition[1] == 1684.0F) { // A1
+ System.out.println("A1");
+ if (method.equals("sk")) {
+ x1 = 1731.9F;
+ y1 = 28.3F;
+ } else {
+ x1 = 1731.9F;
+ y1 = 170.0F;
+ }
+ } else if (fposition[0] == 1684.0F && fposition[1] == 1191.0F) { // A2
+ System.out.println("A2");
+ if (method.equals("sk")) {
+ x1 = 1031.8F;
+ y1 = 28.3F;
+ } else {
+ x1 = 1031.8F;
+ y1 = 170.0F;
+ }
+ } else if (fposition[0] == 1191.0F && fposition[1] == 842.0F) { // A3
+ System.out.println("A3");
+ if (method.equals("sk")) {
+ x1 = 552.7F;
+ y1 = 14.1F;
+ } else {
+ x1 = 552.7F;
+ y1 = 155.9F;
+ }
+ } else if (fposition[0] == 842.0F && fposition[1] == 595.0F) { // A4
+ System.out.println("A4");
+ if (method.equals("sk")) {
+ x1 = 714.3F;
+ y1 = 467.7F;
+ } else {
+ x1 = 629.2F;
+ y1 = 467.7F;
+ }
+ } else if (fposition[0] == 3370.4F && fposition[1] == 2383.94F) { // CATIA A0
+ System.out.println("CATIA A0");
+ if (method.equals("sk")) {
+ x1 = 2718.4F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 2718.4F;
+ y1 = 170.0F;
+ }else {
+ x1 = 1628.5F;
+ y1 = 1163.6F;
+ }
+ } else if (fposition[0] == 2383.94F && fposition[1] == 1683.78F) { // CATIA A1
+ System.out.println("CATIA A1");
+ if (method.equals("sk")) {
+ x1 = 1731.9F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 1731.9F;
+ y1 = 170.0F;
+ }else {
+ x1 = 629.2F;
+ y1 = 813.5F;
+ }
+ } else if (fposition[0] == 1683.78F && fposition[1] == 1190.56F) { // CATIA A2
+ System.out.println("CATIA A2");
+ if (method.equals("sk")) {
+ x1 = 1031.8F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 1031.8F;
+ y1 = 170.0F;
+ }else {
+ x1 = 629.2F;
+ y1 = 566.9F;
+ }
+ } else if (fposition[0] == 1190.56F && fposition[1] == 841.89F) { // CATIA A3
+ System.out.println("CATIA A3");
+ if (method.equals("sk")) {
+ x1 = 552.7F;
+ y1 = 14.1F;
+ } else if(method.equals("ls")){
+ x1 = 552.7F;
+ y1 = 155.9F;
+ }else {
+ x1 = 538.6F;
+ y1 = 392.5F;
+ }
+ } else if (fposition[0] == 595.28F && fposition[1] == 841.89F) { // CATIA A4
+ System.out.println("CATIA A4");
+ if (method.equals("sk")) {
+ x1 = 467.7F;
+ y1 = 714.3F;
+ } else if(method.equals("ls")){
+ x1 = 467.7F;
+ y1 = 629.2F;
+ }else {
+ x1 = 240.9F;
+ y1 = 392.5F;
+ }
+ } else if (fposition[0] == 5054.18F && fposition[1] == 2383.94F) { // CATIA S0 A0
+ System.out.println("CATIA S0 A0");
+ if (method.equals("sk")) {
+ x1 = 4402.2F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 4402.2F;
+ y1 = 170.1F;
+ }else {
+ x1 = 2470.4F;
+ y1 = 1163.6F;
+ }
+ } else if (fposition[0] == 6740.79F && fposition[1] == 2383.94F) { // CATIA S0 A1
+ System.out.println("CATIA S0 A1");
+ if (method.equals("sk")) {
+ x1 = 6088.8F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 6088.8F;
+ y1 = 170.1F;
+ }else {
+ x1 = 3313.7F;
+ y1 = 1163.6F;
+ }
+ } else if (fposition[0] == 8424.57F && fposition[1] == 2383.94F) { // CATIA S0 A2
+ System.out.println("CATIA S0 A2");
+ if (method.equals("sk")) {
+ x1 = 7772.6F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 7772.6F;
+ y1 = 170.1F;
+ }else {
+ x1 = 4155.6F;
+ y1 = 1163.6F;
+ }
+ } else if (fposition[0] == 10111.19F && fposition[1] == 2383.94F) { // CATIA S0 A3
+ System.out.println("CATIA S0 A3");
+ if (method.equals("sk")) {
+ x1 = 9459.2F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 9459.2F;
+ y1 = 170.1F;
+ }else {
+ x1 = 4998.9F;
+ y1 = 1163.6F;
+ }
+ } else if (fposition[0] == 11794.97F && fposition[1] == 2383.94F) { // CATIA S0 A4
+ System.out.println("CATIA S0 A4");
+ if (method.equals("sk")) {
+ x1 = 11143F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 11143F;
+ y1 = 170.1F;
+ }else {
+ x1 = 5840.8F;
+ y1 = 1163.6F;
+ }
+ } else if (fposition[0] == 1684.0F && fposition[1] == 2384.0F) { // A1
+ System.out.println("-A1");
+ x1 = 1885.0F;
+ y1 = 210.0F;
+ } else if (fposition[0] == 1191.0F && fposition[1] == 1684.0F) { // A2
+ System.out.println("-A2");
+ x1 = 1183.0F;
+ y1 = 210.0F;
+ } else if (fposition[0] == 842.0F && fposition[1] == 1191.0F) { // A3
+ System.out.println("-A3");
+ x1 = 703.0F;
+ y1 = 190.0F;
+ } else if (fposition[0] == 595.0F && fposition[1] == 842.0F) { // A4
+ System.out.println("-A4");
+ if (method.equals("sk")) {
+ x1 = 467.7F;
+ y1 = 714.3F;
+ } else {
+ x1 = 467.7F;
+ y1 = 629.2F;
+ }
+ }
+
+ System.out.println("当前盖章x1坐标:" + x1);
+ System.out.println("当前盖章y1坐标:" + y1);
+
+ Image img = Image.getInstance(imageUrl);
+ img.setAbsolutePosition(x1, y1);
+ PdfContentByte under = stamper.getOverContent(1);
+
+ // 1. 插入图片(带透明度)
+ PdfGState imgState = new PdfGState();
+ imgState.setFillOpacity(opacity);
+ // 应用透明度状态
+ under.setGState(imgState);
+ under.saveState();
+ under.addImage(img);
+
+ PdfGState fontState = new PdfGState();
+ under.setGState(fontState);
+ under.saveState();
+ // 2. 插入时间字符串(formattedTime2)
+ // 定义字体(Times New Roman,常规,小四,红色)
+ if (method.equals("ls")) {
+ BaseFont baseFont = BaseFont.createFont("c:/windows/fonts/times.ttf", // Times New Roman 字体文件路径
+ BaseFont.WINANSI, BaseFont.EMBEDDED);
+ under.beginText();
+ under.setFontAndSize(baseFont, 12);
+ under.setColorFill(new BaseColor(225, 0, 0));
+// under.setTextMatrix(x1+161, y1 + 60);
+ under.setTextMatrix(x1 + 50, y1 + 8);
+ under.showText(dateSign);
+ under.endText();
+ }
+
+ under.restoreState();
+
+ stamper.close();
+// fReader.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;
+ }
+}
\ No newline at end of file
diff --git a/cn.net.connor.pdf.lao.image/src/com/sgcc/test/鑰佺増鍧愭爣.txt b/cn.net.connor.pdf.lao.image/src/com/sgcc/test/鑰佺増鍧愭爣.txt
new file mode 100644
index 0000000..02149d0
--- /dev/null
+++ b/cn.net.connor.pdf.lao.image/src/com/sgcc/test/鑰佺増鍧愭爣.txt
@@ -0,0 +1,58 @@
+if (fposition[0] == 2384.0 && fposition[1] == 3370.0F) { // A0
+ x1 = 3010.0F;
+ y1 = 220.0F;
+ } else if (fposition[0] == 2384.0F && fposition[1] == 1684.0F) { // A1
+ x1 = 2020.0F;
+ y1 = 220.0F;
+ } else if (fposition[0] == 1684.0F && fposition[1] == 1191.0F) { // A2
+ x1 = 1310.0F;
+ y1 = 220.0F;
+ } else if (fposition[0] == 1191.0F && fposition[1] == 842.0F) { // A3
+ x1 = 850.0F;
+ y1 = 200.0F;
+ } else if (fposition[0] == 842.0F && fposition[1] == 595.0F) { // A4
+ x1 = 250.0F;
+ y1 = 200.0F;
+ }else if (fposition[0] == 3370.4F && fposition[1] == 2383.94F) { // CATIA A0
+ x1 = 2870.0F;
+ y1 = 162.0F;
+ } else if (fposition[0] == 2383.94F && fposition[1] == 1683.78F) { // CATIA A1
+ x1 = 1885.0F;
+ y1 = 162.0F;
+ } else if (fposition[0] == 1683.78F && fposition[1] == 1190.56F) { // CATIA A2
+ x1 = 1183.0F;
+ y1 = 162.0F;
+ } else if (fposition[0] == 1190.56F && fposition[1] == 841.89F) { // CATIA A3
+ x1 = 703.0F;
+ y1 = 148.0F;
+ } else if (fposition[0] == 595.28F && fposition[1] == 841.89F) { // CATIA A4
+ x1 = 110.0F;
+ y1 = 148.0F;
+ } else if (fposition[0] == 5054.18F && fposition[1] == 2383.94F) { // CATIA S0 A0
+ x1 = 4554.0F;
+ y1 = 161.0F;
+ } else if (fposition[0] == 6740.79F && fposition[1] == 2383.94F) { // CATIA S0 A1
+ x1 = 6240.0F;
+ y1 = 161.0F;
+ } else if (fposition[0] == 8424.57F && fposition[1] == 2383.94F) { // CATIA S0 A2
+ x1 = 7925.0F;
+ y1 = 160.0F;
+ } else if (fposition[0] == 10111.19F && fposition[1] == 2383.94F) { // CATIA S0 A3
+ x1 = 9614.0F;
+ y1 = 160.0F;
+ } else if (fposition[0] == 11794.97F && fposition[1] == 2383.94F) { // CATIA S0 A4
+ x1 = 11295.0F;
+ y1 = 160.0F;
+ }else if (fposition[0] == 1684.0F && fposition[1] == 2384.0F) { // A1
+ x1 = 1885.0F;
+ y1 = 210.0F;
+ } else if (fposition[0] == 1191.0F && fposition[1] == 1684.0F) { // A2
+ x1 = 1183.0F;
+ y1 = 210.0F;
+ } else if (fposition[0] == 842.0F && fposition[1] == 1191.0F) { // A3
+ x1 = 703.0F;
+ y1 = 190.0F;
+ } else if (fposition[0] == 595.0F && fposition[1] == 842.0F) { // A4
+ x1 = 110.0F;
+ y1 = 190.0F;
+ }
diff --git a/cn.net.connor.pdf.xin.image/.classpath b/cn.net.connor.pdf.xin.image/.classpath
new file mode 100644
index 0000000..1e608f5
--- /dev/null
+++ b/cn.net.connor.pdf.xin.image/.classpath
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/cn.net.connor.pdf.xin.image/.project b/cn.net.connor.pdf.xin.image/.project
new file mode 100644
index 0000000..89114b4
--- /dev/null
+++ b/cn.net.connor.pdf.xin.image/.project
@@ -0,0 +1,17 @@
+
+
+ cn.net.connor.pdf.xin.image
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/cn.net.connor.pdf.xin.image/.settings/org.eclipse.jdt.core.prefs b/cn.net.connor.pdf.xin.image/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..ec1937b
--- /dev/null
+++ b/cn.net.connor.pdf.xin.image/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+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.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/cn.net.connor.pdf.xin.image/bin/com/sgcc/test/StamperXin.class b/cn.net.connor.pdf.xin.image/bin/com/sgcc/test/StamperXin.class
new file mode 100644
index 0000000..22055fb
Binary files /dev/null and b/cn.net.connor.pdf.xin.image/bin/com/sgcc/test/StamperXin.class differ
diff --git a/cn.net.connor.pdf.xin.image/llib/core-renderer.jar b/cn.net.connor.pdf.xin.image/llib/core-renderer.jar
new file mode 100644
index 0000000..871fabf
Binary files /dev/null and b/cn.net.connor.pdf.xin.image/llib/core-renderer.jar differ
diff --git a/cn.net.connor.pdf.xin.image/llib/iTextAsian.jar b/cn.net.connor.pdf.xin.image/llib/iTextAsian.jar
new file mode 100644
index 0000000..3fa2157
Binary files /dev/null and b/cn.net.connor.pdf.xin.image/llib/iTextAsian.jar differ
diff --git a/cn.net.connor.pdf.xin.image/llib/iTextAsianCmaps.jar b/cn.net.connor.pdf.xin.image/llib/iTextAsianCmaps.jar
new file mode 100644
index 0000000..aa2b429
Binary files /dev/null and b/cn.net.connor.pdf.xin.image/llib/iTextAsianCmaps.jar differ
diff --git a/cn.net.connor.pdf.xin.image/llib/itextpdf-5.0.6.jar b/cn.net.connor.pdf.xin.image/llib/itextpdf-5.0.6.jar
new file mode 100644
index 0000000..d716b4e
Binary files /dev/null and b/cn.net.connor.pdf.xin.image/llib/itextpdf-5.0.6.jar differ
diff --git a/cn.net.connor.pdf.xin.image/src/com/sgcc/test/StamperXin.java b/cn.net.connor.pdf.xin.image/src/com/sgcc/test/StamperXin.java
new file mode 100644
index 0000000..8a921a6
--- /dev/null
+++ b/cn.net.connor.pdf.xin.image/src/com/sgcc/test/StamperXin.java
@@ -0,0 +1,218 @@
+package com.sgcc.test;
+
+import java.io.FileOutputStream;
+import java.io.FileReader;
+
+import com.itextpdf.text.BaseColor;
+import com.itextpdf.text.Image;
+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;
+import com.itextpdf.text.Rectangle;
+
+/**
+ * 签字盖章
+ *
+ * @author wang
+ * @version 1.0.0
+ */
+public class StamperXin {
+ public static void main(String[] args) {
+ String pdfUrl = args[0];
+ String newPdfUrl = args[1];
+ String imageFile = args[2];
+ String dateSign = args[3];
+ String method = args[4].toLowerCase();
+ String isSignDate = args[5];
+ sign(pdfUrl, newPdfUrl, imageFile,dateSign, method, isSignDate);
+ }
+
+ public static void sign(String pdfUrl, String newPdfUrl, String imageFile, String dateSign,String method,String isSignDate) {
+ try {
+
+ String imageUrl = "";
+ FileReader fReader = new FileReader(imageFile);
+ char[] buf = new char[128];
+ int len;
+ while ((len = fReader.read(buf)) != -1) {
+ imageUrl= new String(buf, 0, len);
+ }
+ imageUrl = imageUrl.split("=")[1];
+ System.out.println(imageUrl);
+
+ System.out.println("imageUrl : " + imageUrl);
+ System.out.println("method : " + method);
+
+ 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].floatValue() == 2384.0F && fposition[1].floatValue() == 3370.0F) {// A0-HENGBAN
+ System.out.println("A0-HENGBAN");
+ if (method.equals("sk")) {
+ x1 = 2690.1F;
+ y1 = 56.7F;
+ } else if(method.equals("ls")){
+ x1 = 2690.1F;
+ y1 = 198.4F;
+ }else {
+ x1 = 1628.5F;
+ y1 = 1163.6F;
+ }
+ } else if (fposition[0].floatValue() == 2384.0F && fposition[1].floatValue() == 1684.0F) {// A1-HENGBAN
+ System.out.println("A1-HENGBAN");
+ if (method.equals("sk")) {
+ x1 = 1732F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 1732F;
+ y1 = 170.1F;
+ }else {
+ x1 = 1131F;
+ y1 = 817.8F;
+ }
+ } else if (fposition[0].floatValue() == 1684.0F && fposition[1].floatValue() == 1191.0F) {// A2-HENGBAN
+ System.out.println("A2-HENGBAN");
+ if (method.equals("sk")) {
+ x1 = 1695.1F;
+ y1 = 56.7F;
+ } else if(method.equals("ls")){
+ x1 = 1695.1F;
+ y1 = 198.4F;
+ }else {
+ x1 = 785.2F;
+ y1 = 566.9F;
+ }
+ } else if (fposition[0].floatValue() == 1191.0F && fposition[1].floatValue() == 842.0F) {// A3-HENGBAN
+ System.out.println("A3-HENGBAN");
+ if (method.equals("sk")) {
+ x1 = 538.6F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 538.6F;
+ y1 = 170.1F;
+ }else {
+ x1 = 538.6F;
+ y1 = 392.6F;
+ }
+ } else if (fposition[0].floatValue() == 842.0F && fposition[1].floatValue() == 595.0F) {// A4-HENGBAN
+ System.out.println("A4-HENGBAN");
+ if (method.equals("sk")) {
+ x1 = 189.9F;
+ y1 = 28.3F;
+ } else if(method.equals("ls")){
+ x1 = 189.9F;
+ y1 = 170.1F;
+ }else {
+ x1 = 364.3F;
+ y1 = 269.3F;
+ }
+ } else if (fposition[0].floatValue() == 595.0F && fposition[1].floatValue() == 842.0F) {// A4-SHUBANG
+ System.out.println("A4-SHUBANG");
+ if (method.equals("sk")) {
+ x1 = 453.6F;
+ y1 = 700.1F;
+ } else if(method.equals("ls")){
+ x1 = 453.6F;
+ y1 = 615F;
+ }else {
+ x1 = 240.9F;
+ y1 = 392.6F;
+ }
+ } else if (fposition[0] == 2384.0F && fposition[1] == 5056.0F) {// 1.5A0
+ x1 = 4550.0F;
+ y1 = 260.0F;
+ }else if (fposition[0] == 3370.4F && fposition[1] == 2383.94F) {//A0
+
+ } else if (fposition[0] == 5055.6F && fposition[1] == 2383.94F) {//A01.5
+ System.out.println("A01.5");
+ if (method.equals("sk")) {
+ x1 = 4373.9F;
+ y1 = 56.7F;
+ } else if(method.equals("ls")){
+ x1 = 4373.9F;
+ y1 = 198.4F;
+ }else {
+ x1 = 2470.4F;
+ y1 = 1163.6F;
+ }
+ } else if (fposition[0] == 2383.94F && fposition[1] == 1683.78F) {// A1
+ x1 = 1848.0F;
+ y1 = 260.0F;
+ } else if (fposition[0] == 1683.78F && fposition[1] == 1190.56F) {// A2
+ x1 = 1178.0F;
+ y1 = 230.0F;
+ } else if (fposition[0] == 1190.56F && fposition[1] == 841.89F) {// A3
+ x1 = 686.0F;
+ y1 = 230.0F;
+ } else if (fposition[0] == 595.28F && fposition[1] == 841.89F) {// A4
+ x1 = 91.0F;
+ y1 = 230.0F;
+ } else if (fposition[0] == 841.89F && fposition[1] == 595.28F) {// A4HEN
+
+ }
+
+ System.out.println("当前盖章x1坐标:" + x1);
+ System.out.println("当前盖章y1坐标:" + y1);
+
+ Image img = Image.getInstance(imageUrl);
+ img.setAbsolutePosition(x1, y1);
+ if(method.equals("zf")) {
+ img.scalePercent(41);
+ }else {
+ img.scalePercent(46);
+ }
+ PdfContentByte under = stamper.getOverContent(1);
+
+ // 1. 插入图片(带透明度)
+ PdfGState imgState = new PdfGState();
+ imgState.setFillOpacity(0.9f);
+ // 应用透明度状态
+ under.setGState(imgState);
+ under.saveState();
+ under.addImage(img);
+
+ PdfGState fontState = new PdfGState();
+ under.setGState(fontState);
+ under.saveState();
+ // 2. 插入时间字符串(formattedTime2)
+ // 定义字体(Times New Roman,常规,小四,红色)
+ if (method.equals("ls") && isSignDate.equals("Y")) {
+ BaseFont baseFont = BaseFont.createFont("c:/windows/fonts/times.ttf", // Times New Roman 字体文件路径
+ BaseFont.WINANSI, BaseFont.EMBEDDED);
+ under.beginText();
+ under.setFontAndSize(baseFont, 12);
+ under.setColorFill(new BaseColor(225, 0, 0));
+// under.setTextMatrix(x1+161, y1 + 60);
+ under.setTextMatrix(x1 + 50, y1 + 6);
+ under.showText(dateSign);
+ under.endText();
+ }
+
+ under.restoreState();
+ fReader.close();
+ 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;
+ }
+}
diff --git a/com.connor.pdf/.classpath b/com.connor.pdf/.classpath
new file mode 100644
index 0000000..9138bb8
--- /dev/null
+++ b/com.connor.pdf/.classpath
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.connor.pdf/.project b/com.connor.pdf/.project
new file mode 100644
index 0000000..381d4a1
--- /dev/null
+++ b/com.connor.pdf/.project
@@ -0,0 +1,17 @@
+
+
+ com.connor.pdf
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/com.connor.pdf/.settings/org.eclipse.jdt.core.prefs b/com.connor.pdf/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..8000cd6
--- /dev/null
+++ b/com.connor.pdf/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/com.connor.pdf/bin/com/connor/pdf/JFomPdfBean.class b/com.connor.pdf/bin/com/connor/pdf/JFomPdfBean.class
new file mode 100644
index 0000000..624551b
Binary files /dev/null and b/com.connor.pdf/bin/com/connor/pdf/JFomPdfBean.class differ
diff --git a/com.connor.pdf/bin/com/connor/pdf/SignPdfXin.class b/com.connor.pdf/bin/com/connor/pdf/SignPdfXin.class
new file mode 100644
index 0000000..a7a0a18
Binary files /dev/null and b/com.connor.pdf/bin/com/connor/pdf/SignPdfXin.class differ
diff --git a/com.connor.pdf/lib/core-renderer.jar b/com.connor.pdf/lib/core-renderer.jar
new file mode 100644
index 0000000..871fabf
Binary files /dev/null and b/com.connor.pdf/lib/core-renderer.jar differ
diff --git a/com.connor.pdf/lib/iText-5.0.2.jar b/com.connor.pdf/lib/iText-5.0.2.jar
new file mode 100644
index 0000000..ed95653
Binary files /dev/null and b/com.connor.pdf/lib/iText-5.0.2.jar differ
diff --git a/com.connor.pdf/lib/iTextAsian.jar b/com.connor.pdf/lib/iTextAsian.jar
new file mode 100644
index 0000000..3fa2157
Binary files /dev/null and b/com.connor.pdf/lib/iTextAsian.jar differ
diff --git a/com.connor.pdf/lib/iTextAsianCmaps.jar b/com.connor.pdf/lib/iTextAsianCmaps.jar
new file mode 100644
index 0000000..aa2b429
Binary files /dev/null and b/com.connor.pdf/lib/iTextAsianCmaps.jar differ
diff --git a/com.connor.pdf/lib/itext-2.0.3.jar b/com.connor.pdf/lib/itext-2.0.3.jar
new file mode 100644
index 0000000..3c0f688
Binary files /dev/null and b/com.connor.pdf/lib/itext-2.0.3.jar differ
diff --git a/com.connor.pdf/src/com/connor/pdf/JFomPdfBean.java b/com.connor.pdf/src/com/connor/pdf/JFomPdfBean.java
new file mode 100644
index 0000000..8646898
--- /dev/null
+++ b/com.connor.pdf/src/com/connor/pdf/JFomPdfBean.java
@@ -0,0 +1,41 @@
+package com.connor.pdf;
+
+public class JFomPdfBean {
+ private Float w = 0.0f;
+ private Float h = 0.0f;
+ private Float wi = 0.0f;
+ private Float hi = 0.0f;
+
+ public Float getW() {
+ return w;
+ }
+
+ public void setW(Float w) {
+ this.w = w;
+ }
+
+ public Float getH() {
+ return h;
+ }
+
+ public void setH(Float h) {
+ this.h = h;
+ }
+
+ public Float getWi() {
+ return wi;
+ }
+
+ public void setWi(Float wi) {
+ this.wi = wi;
+ }
+
+ public Float getHi() {
+ return hi;
+ }
+
+ public void setHi(Float hi) {
+ this.hi = hi;
+ }
+
+}
diff --git a/com.connor.pdf/src/com/connor/pdf/SignPdfXin.java b/com.connor.pdf/src/com/connor/pdf/SignPdfXin.java
new file mode 100644
index 0000000..44709b9
--- /dev/null
+++ b/com.connor.pdf/src/com/connor/pdf/SignPdfXin.java
@@ -0,0 +1,431 @@
+package com.connor.pdf;
+
+import com.lowagie.text.DocumentException;
+import com.lowagie.text.Rectangle;
+import com.lowagie.text.pdf.BaseFont;
+import com.lowagie.text.pdf.PdfContentByte;
+import com.lowagie.text.pdf.PdfReader;
+import com.lowagie.text.pdf.PdfStamper;
+import java.awt.Color;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.Map;
+
+public class SignPdfXin {
+ public static void main(String[] args) {
+ int pageCount = 1;
+ SignPdfXin signPdf = new SignPdfXin();
+
+ String dataPath = args[0];
+ String pdfPath = args[1];
+ String outs = args[2];
+
+// String dataPath = "C:\\Users\\infodba\\Desktop\\新世宝签字.txt";
+// String pdfPath = "C:\\Users\\infodba\\Desktop\\新世宝PDF\\A4-SHUBANG.PDF";
+// String outs = "C:\\Users\\infodba\\Desktop\\新世宝CAD输出\\A4-SHUBANG.PDF";
+
+// String dataPath = "C:\\Users\\infodba\\Desktop\\新世宝签字.txt";
+// String pdfPath = "C:\\Users\\infodba\\Desktop\\新世宝CAD\\1.5A0.PDF";
+// String outs = "C:\\Users\\infodba\\Desktop\\新世宝CAD输出\\1.5A0.PDF";
+
+// String dataPath = "C:\\Users\\infodba\\Desktop\\新世宝签字.txt";
+// String pdfPath = "C:\\Users\\infodba\\Desktop\\新世宝CAD\\A4-SHUBANG.PDF";//A0-HENGBAN A4-SHUBANG
+// String outs = "C:\\Users\\infodba\\Desktop\\新世宝CAD输出\\A4-SHUBANG.PDF";
+
+// String dataPath = "C:\\Users\\infodba\\Desktop\\新世宝签字.txt";
+// String pdfPath = "C:\\Users\\infodba\\Desktop\\新建文件夹 (4)\\新世宝\\A4HENG.PDF";
+// String outs = "C:\\Users\\infodba\\Desktop\\新世宝CAD输出\\A4HENG.PDF";
+
+ Map dataMap = signPdf.getData(dataPath);
+ try {
+ PdfReader reader = new PdfReader(pdfPath);
+ PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outs));
+ Rectangle rectangle = reader.getPageSize(1);
+ Float[] fposition = signPdf.getSize(rectangle);
+ BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", true);
+ float x1 = 0.0F;
+ float x2 = 0.0F;
+ float x3 = 0.0F;
+ float x4 = 0.0F;
+ float y1 = 0.0F;
+ float y2 = 0.0F;
+ float y3 = 0.0F;
+ float y4 = 0.0F;
+ if (fposition[0] == 2384.0F && fposition[1] == 3370.0F) {// A0-HENGBAN
+ x1 = 2834.0F;
+ y1 = 110.0F;
+ y2 = 90.0F;
+ y3 = 70.0F;
+ y4 = 52.0F;
+ x2 = 2871.0F;
+ x3 = 2950.0F;
+ x4 = 2980.0F;
+ System.out.println("aaaaa");
+ } else if (fposition[0] == 2384.0F && fposition[1] == 1684.0F) {// A1-HENGBAN
+ x1 = 1837.0F;
+ y1 = 110.0F;
+ y2 = 90.0F;
+ y3 = 70.0F;
+ y4 = 50.0F;
+ x2 = 1870.0F;
+ x3 = 1950.0F;
+ x4 = 1985.0F;
+ } else if (fposition[0] == 1684.0F && fposition[1] == 1191.0F) {// A2-HENGBAN
+ x1 = 1176.0F;
+ y1 = 83.0F;
+ y2 = 62.0F;
+ y3 = 43.0F;
+ y4 = 23.0F;
+ x2 = 1210.0F;
+ x3 = 1288.0F;
+ x4 = 1324.0F;
+ } else if (fposition[0] == 1191.0F && fposition[1] == 842.0F) {// A3-HENGBAN
+ x1 = 686.0F;
+ y1 = 82.0F;
+ y2 = 60.0F;
+ y3 = 40.0F;
+ y4 = 21.0F;
+ x2 = 719.0F;
+ x3 = 800.0F;
+ x4 = 833.0F;
+ } else if (fposition[0] == 842.0F && fposition[1] == 595.0F) {// A4-HENGBAN
+ x1 = 338.0F;
+ y1 = 80.0F;
+ y2 = 61.0F;
+ y3 = 42.0F;
+ y4 = 24.0F;
+ x2 = 370.0F;
+ x3 = 450.0F;
+ x4 = 483.0F;
+ } else if (fposition[0] == 595.0F && fposition[1] == 842.0F) {// A4-SHUBANG
+ x1 = 93.0F;
+ y1 = 80.0F;
+ y2 = 61.0F;
+ y3 = 42.0F;
+ y4 = 24.0F;
+ x2 = 127.0F;
+ x3 = 205.0F;
+ x4 = 238.0F;
+ } else if (fposition[0] == 2384.0F && fposition[1] == 5056.0F) {// 1.5A0
+ x1 = 4520.0F;
+ y1 = 108.0F;
+ y2 = 90.0F;
+ y3 = 70.0F;
+ y4 = 52.0F;
+ x2 = 4555.0F;
+ x3 = 4635.0F;
+ x4 = 4670.0F;
+ }else if (fposition[0] == 3370.4F && fposition[1] == 2383.94F) {//A0
+ x1 = 2837.0F;
+ y1 = 110.0F;
+ y2 = 90.0F;
+ y3 = 70.0F;
+ y4 = 50.0F;
+ x2 = 2870.0F;
+ x3 = 2950.0F;
+ x4 = 2985.0F;
+ } else if (fposition[0] == 5055.6F && fposition[1] == 2383.94F) {//A01.5
+ x1 = 4520.0F;
+ y1 = 110.0F;
+ y2 = 90.0F;
+ y3 = 70.0F;
+ y4 = 50.0F;
+ x2 = 4555.0F;
+ x3 = 4635.0F;
+ x4 = 4670.0F;
+ } else if (fposition[0] == 2383.94F && fposition[1] == 1683.78F) {// A1
+ x1 = 1848.0F;
+ y1 = 110.0F;
+ y2 = 90.0F;
+ y3 = 70.0F;
+ y4 = 50.0F;
+ x2 = 1883.0F;
+ x3 = 1963.0F;
+ x4 = 1998.0F;
+ } else if (fposition[0] == 1683.78F && fposition[1] == 1190.56F) {// A2
+ x1 = 1178.0F;
+ y1 = 83.0F;
+ y2 = 62.0F;
+ y3 = 43.0F;
+ y4 = 23.0F;
+ x2 = 1212.0F;
+ x3 = 1290.0F;
+ x4 = 1326.0F;
+ } else if (fposition[0] == 1190.56F && fposition[1] == 841.89F) {// A3
+ x1 = 686.0F;
+ y1 = 82.0F;
+ y2 = 60.0F;
+ y3 = 40.0F;
+ y4 = 21.0F;
+ x2 = 719.0F;
+ x3 = 800.0F;
+ x4 = 833.0F;
+ } else if (fposition[0] == 595.28F && fposition[1] == 841.89F) {// A4
+ x1 = 91.0F;
+ y1 = 80.0F;
+ y2 = 61.0F;
+ y3 = 42.0F;
+ y4 = 24.0F;
+ x2 = 125.0F;
+ x3 = 203.0F;
+ x4 = 236.0F;
+ } else if (fposition[0] == 841.89F && fposition[1] == 595.28F) {// A4HEN
+ x1 = 338.0F;
+ y1 = 80.0F;
+ y2 = 61.0F;
+ y3 = 42.0F;
+ y4 = 24.0F;
+ x2 = 370.0F;
+ x3 = 450.0F;
+ x4 = 483.0F;
+ }
+
+
+ if (dataMap.containsKey("设计")) {
+ String value = dataMap.get("设计");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 9.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y1).floatValue());
+ content.showText(value);
+ content.endText();
+// signPdf.signBZ(pageCount, value, content, reader, stamper, Integer.valueOf(275));
+ }
+ if (dataMap.containsKey("校对")) {
+ String value = dataMap.get("校对");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 9.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y2).floatValue());
+ content.showText(value);
+ content.endText();
+// signPdf.signBZ(pageCount, value, content, reader, stamper, Integer.valueOf(476));
+ }
+ if (dataMap.containsKey("审核")) {
+ String value = dataMap.get("审核");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 9.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y3).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("工艺")) {
+ String value = dataMap.get("工艺");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 9.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y4).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("标准化")) {
+ String value = dataMap.get("标准化");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 9.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x3).floatValue(), Float.valueOf(y1).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("会签")) {
+ String value = dataMap.get("会签");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 9.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x3).floatValue(), Float.valueOf(y3).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("批准")) {
+ String value = dataMap.get("批准");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 9.0F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x3).floatValue(), Float.valueOf(y4).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("设计日期")) {
+ String value = dataMap.get("设计日期");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 7.5F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y1).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("校对日期")) {
+ String value = dataMap.get("校对日期");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 7.5F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y2).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("审核日期")) {
+ String value = dataMap.get("审核日期");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 7.5F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y3).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("工艺日期")) {
+ String value = dataMap.get("工艺日期");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 7.5F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y4).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("标准化日期")) {
+ String value = dataMap.get("标准化日期");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 7.5F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x4).floatValue(), Float.valueOf(y1).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("会签日期")) {
+ String value = dataMap.get("会签日期");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 7.5F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x4).floatValue(), Float.valueOf(y3).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ if (dataMap.containsKey("批准日期")) {
+ String value = dataMap.get("批准日期");
+ PdfContentByte content = stamper.getUnderContent(1);
+ content.beginText();
+ content.setColorFill(Color.BLACK);
+ content.setFontAndSize(base, 7.5F);
+ content.setTextRise(14.0F);
+ content.setTextMatrix(Float.valueOf(x4).floatValue(), Float.valueOf(y4).floatValue());
+ content.showText(value);
+ content.endText();
+ }
+ stamper.close();
+ reader.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public Map getData(String filePath) {
+ String lineTxt = "";
+ Map