diff --git a/JSD-8802需求确认书.docx b/JSD-8802需求确认书.docx
new file mode 100644
index 0000000..9698e77
Binary files /dev/null and b/JSD-8802需求确认书.docx differ
diff --git a/README.md b/README.md
index 6d7e03d..b05a2ef 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,6 @@
# open-JSD-8802
-JSD-8802 BMP集成
\ No newline at end of file
+JSD-8802 BMP集成\
+免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\
+仅作为开发者学习参考使用!禁止用于任何商业用途!\
+为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。
\ No newline at end of file
diff --git a/lib/finekit-10.0.jar b/lib/finekit-10.0.jar
new file mode 100644
index 0000000..611c8f5
Binary files /dev/null and b/lib/finekit-10.0.jar differ
diff --git a/plugin.xml b/plugin.xml
new file mode 100644
index 0000000..e6c6d60
--- /dev/null
+++ b/plugin.xml
@@ -0,0 +1,19 @@
+
+
+ com.fr.plugin.third.party.jsdiiac
+
+ yes
+ 0.7
+ 10.0
+ 2019-01-01
+ fr.open
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/fr/plugin/third/party/jsdiiac/BmpFlowUtils.java b/src/main/java/com/fr/plugin/third/party/jsdiiac/BmpFlowUtils.java
new file mode 100644
index 0000000..e49e977
--- /dev/null
+++ b/src/main/java/com/fr/plugin/third/party/jsdiiac/BmpFlowUtils.java
@@ -0,0 +1,270 @@
+package com.fr.plugin.third.party.jsdiiac;
+
+import com.fanruan.api.data.ConnectionKit;
+import com.fanruan.api.data.TableDataKit;
+import com.fanruan.api.log.LogKit;
+import com.fanruan.api.util.StringKit;
+import com.fr.base.ParameterMapNameSpace;
+import com.fr.base.TableData;
+import com.fr.general.data.DataModel;
+import com.fr.general.data.TableDataException;
+import com.fr.plugin.third.party.jsdiiac.config.CustomDataConfig;
+import com.fr.script.Calculator;
+import com.fr.stable.Primitive;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public class BmpFlowUtils {
+ public static int getFlowDataMainRowCount(String dataId) throws TableDataException {
+ DataModel dataModel = getFlowDataMainDataModel(dataId);
+ if (dataModel == null) {
+ return 0;
+ }
+ int rowCount = dataModel.getRowCount();
+ if (rowCount <= 0) {
+ return 0;
+ }
+ return rowCount;
+ }
+
+ public static DataModel getFlowDataMainDataModel(String dataId) {
+ String tableDataName = CustomDataConfig.getInstance().getDataSetName();
+ DataModel dataModel = getDataDataModel(dataId, tableDataName);
+ return dataModel;
+ }
+
+ /**
+ * 获取流程ID
+ *
+ * @param dataId
+ * @return
+ * @throws TableDataException
+ */
+ public static String getFlowId(String dataId) throws TableDataException {
+ DataModel dataModel = getFlowDataMainDataModel(dataId);
+ if (dataModel == null) {
+ return "";
+ }
+
+ int columnCount = dataModel.getColumnCount();
+ if (columnCount <= 0) {
+ return "";
+ }
+
+ int rowCount = dataModel.getRowCount();
+ if (rowCount <= 0) {
+ return "";
+ }
+ String value = getDataModelValueAt(dataModel, 0, 0);
+ return value;
+ }
+
+ /**
+ * 获取流程状态
+ *
+ * @param dataId
+ * @return
+ * @throws TableDataException
+ */
+ public static String getFlowStatus(String dataId) throws TableDataException {
+ DataModel dataModel = getFlowDataMainDataModel(dataId);
+ if (dataModel == null) {
+ return "";
+ }
+
+ int columnCount = dataModel.getColumnCount();
+ if (columnCount <= 2) {
+ return "";
+ }
+
+ int rowCount = dataModel.getRowCount();
+ if (rowCount <= 0) {
+ return "";
+ }
+ String value = getDataModelValueAt(dataModel, 0, 2);
+ return value;
+ }
+
+ public static String getDataModelValueAt(DataModel dataModel, int row, int col) throws TableDataException {
+ Object value = dataModel.getValueAt(row, col);
+ if (value == null) {
+ return "";
+ }
+ if (value instanceof Primitive) {
+ return "";
+ }
+ String tempValue = String.valueOf(value);
+ return tempValue;
+ }
+
+ public static String getDataModelValueAt(DataModel dataModel, int row, String colName) throws TableDataException {
+ if ((dataModel == null) || (row <= -1) || (StringKit.isEmpty(colName))) {
+ return "";
+ }
+
+ colName = colName.toUpperCase();
+ int col = dataModel.getColumnIndex(colName);
+ if (col <= -1) {
+ return "";
+ }
+
+ Object value = dataModel.getValueAt(row, col);
+ if (value == null) {
+ return "";
+ }
+ if (value instanceof Primitive) {
+ return "";
+ }
+ String tempValue = String.valueOf(value);
+ return tempValue;
+ }
+
+
+ public static String createFlowId(String dataId) throws Exception {
+ String id = getUuid();
+
+ String sql = "update IT_BJB_IN_REGISTER_MAIN set id = '" + id + "'\n" +
+ "where BHID = '" + dataId + "'";
+ com.fr.data.impl.Connection dbConnect = ConnectionKit.getConnection(CustomDataConfig.getInstance().getDataConnection());
+ Connection connection = dbConnect.createConnection();
+ connection.setAutoCommit(true);
+ Statement pstmt = connection.createStatement();
+ pstmt.execute(sql);
+ pstmt.close();
+ connection.close();
+ return id;
+ }
+
+
+ /**
+ * 更新流程状态
+ *
+ * @param flowId
+ * @param status
+ * @return
+ * @throws Exception
+ */
+ public static void updateFlowStatus(String flowId, String status) throws Exception {
+ String sql = "update IT_BJB_IN_REGISTER_MAIN set BPM_FLOW_STATUS = '" + status + "',\n" +
+ "BPM_STATUS_UPDATE_DATE= sysdate\n" +
+ "where ID = '" + flowId + "'";
+ com.fr.data.impl.Connection dbConnect = ConnectionKit.getConnection(CustomDataConfig.getInstance().getDataConnection());
+ Connection connection = dbConnect.createConnection();
+ connection.setAutoCommit(true);
+ Statement pstmt = connection.createStatement();
+ pstmt.execute(sql);
+ pstmt.close();
+ connection.close();
+ }
+
+
+ /**
+ * 更新流程状态
+ *
+ * @return
+ * @throws Exception
+ */
+ public static void updateUpload(String batch_id,
+ String upload,
+ String boid,
+ String bpmurl) throws Exception {
+ String sql = "update dbo.RL_ZP_XQQD " +
+ "set date_time = '" + now() + "',\n" +
+ " upload = '" + upload + "',\n" +
+ " url = '" + bpmurl + "',\n" +
+ " strBOID = '" + boid + "'\n" +
+ "where batch_id = '" + batch_id + "'";
+
+ LogKit.info("BMP集成,更新SQL:\n" + sql);
+ com.fr.data.impl.Connection dbConnect = ConnectionKit.getConnection(CustomDataConfig.getInstance().getDataConnection());
+ Connection connection = dbConnect.createConnection();
+ connection.setAutoCommit(true);
+ Statement pstmt = connection.createStatement();
+ pstmt.execute(sql);
+ pstmt.close();
+ connection.close();
+ }
+
+
+ public static String now() {
+ SimpleDateFormat sdf = new SimpleDateFormat();
+ sdf.applyPattern("yyyy-MM-dd HH:mm:ss");
+ return sdf.format(new java.util.Date());
+ }
+
+
+ public static String getUuid() {
+ String uuid = UUID.randomUUID().toString().replace("-", "");
+ return uuid;
+ }
+
+
+ public synchronized static String getSysTime() {
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
+ Date date = new Date();
+ String nowData = format.format(date);
+ return nowData;
+ }
+
+
+ public synchronized static String getTimestamp() {
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
+ Date date = new Date();
+ String nowData = format.format(date);
+ return nowData;
+ }
+
+ public synchronized static String getRandomValue() {
+ int value = (int) (1 + Math.random() * (9999 - 1 + 1));
+ String tempValue = String.valueOf(value);
+ int len = tempValue.length();
+ String tempStr = tempValue;
+ if (len == 1) {
+ tempStr = "000" + tempValue;
+ } else if (len == 2) {
+ tempStr = "00" + tempValue;
+ } else if (len == 3) {
+ tempStr = "0" + tempValue;
+ }
+ return tempStr;
+ }
+
+ public static String getBizTransactionId() {
+ String tempValue = "HZBITB_E855_" + getTimestamp() + "_" + getRandomValue();
+ return tempValue;
+ }
+
+
+ public static DataModel getFlowDataDataModel(String dataId) {
+ String tableDataName = CustomDataConfig.getInstance().getDataSetName();
+ DataModel dataModel = getDataDataModel(dataId, tableDataName);
+ return dataModel;
+ }
+
+ public static DataModel getDataDataModel(String dataId, String dataSetName) {
+ if (StringKit.isEmpty(dataId) || StringKit.isEmpty(dataSetName)) {
+ return null;
+ }
+ TableData tableData = TableDataKit.findTableData(dataSetName);
+ if (tableData == null) {
+ return null;
+ }
+ Calculator cal = Calculator.createCalculator();
+ Map map = new HashMap();
+ map.put("P_BHID", dataId);
+ ParameterMapNameSpace space = ParameterMapNameSpace.create(map);
+ cal.pushNameSpace(space);
+ DataModel dataModel = tableData.createDataModel(cal);
+ return dataModel;
+ }
+
+}
diff --git a/src/main/java/com/fr/plugin/third/party/jsdiiac/SqlUtils.java b/src/main/java/com/fr/plugin/third/party/jsdiiac/SqlUtils.java
new file mode 100644
index 0000000..b314565
--- /dev/null
+++ b/src/main/java/com/fr/plugin/third/party/jsdiiac/SqlUtils.java
@@ -0,0 +1,615 @@
+package com.fr.plugin.third.party.jsdiiac;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+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.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Random;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+import javax.servlet.http.HttpServletRequest;
+
+import com.fr.stable.StringUtils;
+import com.fr.third.alibaba.druid.support.json.JSONUtils;
+import com.fr.third.org.apache.http.auth.AuthScope;
+import com.fr.third.org.apache.http.auth.UsernamePasswordCredentials;
+import com.fr.third.org.apache.http.client.CredentialsProvider;
+import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse;
+import com.fr.third.org.apache.http.client.methods.HttpPost;
+import com.fr.third.org.apache.http.entity.StringEntity;
+import com.fr.third.org.apache.http.impl.client.BasicCredentialsProvider;
+import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
+import com.fr.third.org.apache.http.impl.client.HttpClients;
+import com.fr.third.org.apache.http.util.EntityUtils;
+
+public class SqlUtils {
+
+ public static synchronized Connection getConn(HttpServletRequest request) throws RuntimeException {
+ Properties prop = new Properties();
+ try {
+ // 读取jdbc连接配置文件
+ prop.load(request.getServletContext().getResourceAsStream("/WEB-INF/db.properties"));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ String driverClassName = prop.getProperty("jdbc.driverClassName");
+ String url = prop.getProperty("jdbc.url");
+ String username = prop.getProperty("jdbc.username");
+ String password = prop.getProperty("jdbc.password");
+
+ try {
+ Class.forName(driverClassName);
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+
+ Connection conn;
+ try {
+ conn = DriverManager.getConnection(url, username, password);
+ conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ return conn;
+ }
+
+ /**
+ * 更新状态为审批中
+ * @param connection
+ * @param xxzt 信息状态(0数据入库,1流程上传,2流程回退,3流程结束)
+ * @param strBOID 业务系统在接口传入的业务对象ID
+ * @param iProcInstID 该业务对象对应的创建的流程实例ID。如果创建失败,则该值无效,置0
+ * @param bSuccess 表示创建流程实例是否成功,1为成功,0为创建失败
+ * @param procURL 返回的BPM流程URL
+ * @param strMessage BPM接口提供的信息反馈
+ * @return
+ * @throws SQLException
+ * @throws IOException
+ */
+ public static int updateCreateResult(Connection connection,
+ String xxzt,
+ String strBOID,
+ String iProcInstID,
+ String bSuccess,
+ String procURL,
+ String strMessage
+ ) throws SQLException, IOException {
+ PreparedStatement ptmt = null;
+ try {
+ Map updateColumns = new HashMap<>();
+ updateColumns.put("date_time", now());
+ updateColumns.put("xxzt", xxzt);
+ updateColumns.put("iProcInstID", iProcInstID);
+ updateColumns.put("bSuccess", bSuccess);
+ updateColumns.put("procURL", procURL);
+// updateColumns.put("strMessage", strMessage); // 表里无strMessage字段
+
+ ptmt = updateDynamically(connection, "dbo.RL_ZP_XQQD", "strBOID", strBOID, updateColumns);
+ int affect = ptmt.executeUpdate();
+ return affect;
+ } catch (SQLException e) {
+ throw e;
+ } finally {
+ close(null, ptmt, null);
+ }
+ }
+
+ /**
+ * 更新状态为退回
+ * @param connection
+ * @param xxzt 信息状态(0数据入库,1流程上传,2流程回退,3流程结束)
+ * @param strBOID 业务系统在接口传入的业务对象ID
+ * @param iProcInstID 该业务对象对应的创建的流程实例ID。草稿步骤为0
+ * @param strStepName 审批时的步骤名称
+ * @param strApproverId 表示审批者用户ID
+ * @param eAction (审批过程中)退回发起人----2
+ * @param strComment 用户的审批意见备注
+ * @param dtTime 审批时间 yyyy-MM-dd hh:mm:ss
+ * @throws SQLException
+ * @throws IOException
+ */
+ public static int updateRework(Connection connection,
+ String xxzt,
+ String strBOID,
+ String iProcInstID,
+ String strStepName,
+ String strApproverId,
+ String eAction,
+ String strComment,
+ String dtTime
+ ) throws SQLException, IOException {
+ PreparedStatement ptmt = null;
+ try {
+ Map updateColumns = new HashMap<>();
+ updateColumns.put("date_time", now());
+ updateColumns.put("xxzt", xxzt);
+ updateColumns.put("iProcInstID", iProcInstID);
+ updateColumns.put("strStepName", strStepName);
+ updateColumns.put("strApproverId", strApproverId);
+ updateColumns.put("eAction", eAction);
+ updateColumns.put("strComment", strComment);
+ updateColumns.put("dtTime", dtTime);
+
+ ptmt = updateDynamically(connection, "dbo.RL_ZP_XQQD", "strBOID", strBOID, updateColumns);
+ int affect = ptmt.executeUpdate();
+ return affect;
+ } catch (SQLException e) {
+ throw e;
+ } finally {
+ close(null, ptmt, null);
+ }
+ }
+
+ /**
+ * 更新状态为审批结束(通过、作废)
+ * @param connection
+ * @param xxzt 信息状态(0数据入库,1流程上传,2流程回退,3流程结束)
+ * @param strBOID 业务系统在接口传入的业务对象ID
+ * @param iProcInstID 该业务对象对应的创建的流程实例ID
+ * @param eAction
+ * @param eProcessInstanceResult 1为审批通过;2 为作废
+ * @param strComment 备注信息,为BPM接口提供的信息反馈
+ * @param dtTime 审批时间 yyyy-MM-dd hh:mm:ss
+ * @throws SQLException
+ * @throws IOException
+ */
+ public static int updateApproveClose(Connection connection,
+ String xxzt,
+ String strBOID,
+ String iProcInstID,
+ String eProcessInstanceResult,
+ String strComment,
+ String dtTime
+ ) throws SQLException, IOException {
+ PreparedStatement ptmt = null;
+ try {
+ Map updateColumns = new HashMap<>();
+ updateColumns.put("date_time", now());
+ updateColumns.put("end_time", now());
+ updateColumns.put("xxzt", xxzt);
+ updateColumns.put("eProcessInstanceResult", eProcessInstanceResult);
+ updateColumns.put("iProcInstID", iProcInstID);
+ updateColumns.put("dtTime", dtTime);
+ updateColumns.put("strComment", strComment);
+
+ ptmt = updateDynamically(connection, "dbo.RL_ZP_XQQD", "strBOID", strBOID, updateColumns);
+ int affect = ptmt.executeUpdate();
+ return affect;
+ } catch (SQLException e) {
+ throw e;
+ } finally {
+ close(null, ptmt, null);
+ }
+ }
+
+
+ /**
+ * 上传后设置状态
+ * @param connection
+ * @param batch_id
+ * @param upload
+ * @return
+ * @throws SQLException
+ * @throws IOException
+ */
+ public static int updateUpload(Connection connection,
+ String batch_id,
+ String upload,
+ String boid,
+ String bpmurl
+ ) throws SQLException, IOException {
+ PreparedStatement ptmt = null;
+ try {
+ Map updateColumns = new HashMap<>();
+ updateColumns.put("date_time", now());
+ updateColumns.put("upload", upload);
+ updateColumns.put("strBOID", boid);
+ updateColumns.put("url", bpmurl);
+ ptmt = updateDynamically(connection, "dbo.RL_ZP_XQQD", "batch_id", batch_id, updateColumns);
+ int affect = ptmt.executeUpdate();
+ return affect;
+ } catch (SQLException e) {
+ throw e;
+ } finally {
+ close(null, ptmt, null);
+ }
+ }
+
+ public static synchronized void close(ResultSet rs, Statement ps, Connection connection) {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ try {
+ if (ps != null) {
+ ps.close();
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ try {
+ if (connection != null) {
+ connection.close();
+ }
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ public static String now() {
+ SimpleDateFormat sdf = new SimpleDateFormat();
+ sdf.applyPattern("yyyy-MM-dd HH:mm:ss");
+ return sdf.format(new java.util.Date());
+ }
+
+ public static String nowDate() {
+ SimpleDateFormat sdf = new SimpleDateFormat();
+ sdf.applyPattern("yyyyMMdd");
+ return sdf.format(new java.util.Date());
+ }
+
+ public static String nowContinuously() {
+ SimpleDateFormat sdf = new SimpleDateFormat();
+ sdf.applyPattern("yyyyMMddHHmmss");
+ return sdf.format(new java.util.Date());
+ }
+
+ /**
+ * 生成BIZTRANSACTIONID
+ * @param systemCode
+ * @return
+ */
+ public static String getBIZTRANSACTIONID(String systemCode) {
+ SimpleDateFormat sdf = new SimpleDateFormat();
+ sdf.applyPattern("yyyyMMddHHmmssSSS");
+ String format = sdf.format(new java.util.Date());
+
+ String StringBase = "0123456789";
+
+ Random random = new Random();
+ StringBuilder sb = new StringBuilder(4);
+ for (int i = 0; i < 4; i++) {
+ sb.append(StringBase.charAt(random.nextInt(StringBase.length())));
+ }
+
+ String randomString = sb.toString();
+
+ return systemCode + "_" + format + "_" + randomString;
+
+ }
+
+ /**
+ * 根据sql查询表数据
+ * @param connection
+ * @param sql
+ * @return
+ * @throws SQLException
+ */
+ public static List