LAPTOP-SB56SG4Q\86185
3 years ago
16 changed files with 1853 additions and 1 deletions
Binary file not shown.
@ -1,3 +1,6 @@
|
||||
# open-JSD-8802 |
||||
|
||||
JSD-8802 BMP集成 |
||||
JSD-8802 BMP集成\ |
||||
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。 |
Binary file not shown.
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
<plugin> |
||||
<id>com.fr.plugin.third.party.jsdiiac</id> |
||||
<name><![CDATA[BMP集成]]></name> |
||||
<active>yes</active> |
||||
<version>0.7</version> |
||||
<env-version>10.0</env-version> |
||||
<jartime>2019-01-01</jartime> |
||||
<vendor>fr.open</vendor> |
||||
<description><![CDATA[]]></description> |
||||
<change-notes><![CDATA[]]></change-notes> |
||||
<extra-decision> |
||||
<HttpHandlerProvider class="com.fr.plugin.third.party.jsdiiac.http.CustomHttpHandlerProvider"/> |
||||
<URLAliasProvider class="com.fr.plugin.third.party.jsdiiac.http.CustomURLAliasProvider"/> |
||||
<GlobalRequestFilterProvider class="com.fr.plugin.third.party.jsdiiac.http.SessionGlobalRequestFilterProvider"/> |
||||
</extra-decision> |
||||
<function-recorder class="com.fr.plugin.third.party.jsdiiac.config.DataConfigInitializeMonitor"/> |
||||
<lifecycle-monitor class="com.fr.plugin.third.party.jsdiiac.config.DataConfigInitializeMonitor"/> |
||||
</plugin> |
@ -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; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,192 @@
|
||||
package com.fr.plugin.third.party.jsdiiac; |
||||
|
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.third.org.apache.http.HttpEntity; |
||||
import com.fr.third.org.apache.http.HttpStatus; |
||||
import com.fr.third.org.apache.http.client.config.RequestConfig; |
||||
import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse; |
||||
import com.fr.third.org.apache.http.client.methods.HttpGet; |
||||
import com.fr.third.org.apache.http.client.methods.HttpPost; |
||||
import com.fr.third.org.apache.http.conn.ssl.NoopHostnameVerifier; |
||||
import com.fr.third.org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
||||
import com.fr.third.org.apache.http.entity.StringEntity; |
||||
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.ssl.SSLContextBuilder; |
||||
import com.fr.third.org.apache.http.ssl.TrustStrategy; |
||||
import com.fr.third.org.apache.http.util.EntityUtils; |
||||
|
||||
import javax.net.ssl.HostnameVerifier; |
||||
import javax.net.ssl.SSLContext; |
||||
import javax.servlet.ServletInputStream; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.IOException; |
||||
import java.security.cert.CertificateException; |
||||
import java.security.cert.X509Certificate; |
||||
|
||||
public class Utils { |
||||
|
||||
/** |
||||
* 获取请求主体内容 |
||||
* @param req |
||||
* @return |
||||
* @throws IOException |
||||
*/ |
||||
public static String getHttpRequestBody(HttpServletRequest req) throws IOException { |
||||
if (req == null) { |
||||
return ""; |
||||
} |
||||
ServletInputStream inputStream = req.getInputStream(); |
||||
if (inputStream == null) { |
||||
return ""; |
||||
} |
||||
String content = IOUtils.inputStream2String(inputStream); |
||||
if (StringKit.isEmpty(content)) { |
||||
return ""; |
||||
} |
||||
return content; |
||||
} |
||||
|
||||
|
||||
public static String DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36"; |
||||
public static RequestConfig REQUEST_CONFIG = RequestConfig.custom() |
||||
.setConnectionRequestTimeout(30000) |
||||
.setSocketTimeout(30000) // 服务端相应超时
|
||||
.setConnectTimeout(30000) // 建立socket链接超时时间
|
||||
.build(); |
||||
|
||||
public static CloseableHttpClient createSSLClientDefault() { |
||||
try { |
||||
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { |
||||
|
||||
@Override |
||||
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { |
||||
return true; |
||||
} |
||||
}).build(); |
||||
HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE; |
||||
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, hostnameVerifier); |
||||
return HttpClients.custom().setSSLSocketFactory(sslsf).build(); |
||||
} catch (Exception e) { |
||||
LogKit.error(e.getMessage(), e); |
||||
} |
||||
return HttpClients.createDefault(); |
||||
} |
||||
|
||||
public static synchronized CloseableHttpClient createHttpClient(String url) { |
||||
CloseableHttpClient httpClient = null; |
||||
if (StringKit.isEmpty(url)) { |
||||
httpClient = HttpClients.createDefault(); |
||||
return httpClient; |
||||
} |
||||
|
||||
if (url.startsWith("https://")) { |
||||
httpClient = createSSLClientDefault(); |
||||
return httpClient; |
||||
} |
||||
httpClient = HttpClients.createDefault(); |
||||
return httpClient; |
||||
} |
||||
|
||||
public static synchronized String createHttpGetContent(CloseableHttpClient httpClient, String url) throws IOException { |
||||
if ((httpClient == null) || (StringKit.isEmpty(url))) { |
||||
return ""; |
||||
} |
||||
|
||||
HttpGet httpGet = new HttpGet(url); |
||||
httpGet.addHeader("User-Agent", Utils.DEFAULT_USER_AGENT); |
||||
httpGet.setConfig(Utils.REQUEST_CONFIG); |
||||
CloseableHttpResponse response = httpClient.execute(httpGet); |
||||
int statusCode = response.getStatusLine().getStatusCode(); |
||||
if (statusCode != HttpStatus.SC_OK) { |
||||
response.close(); |
||||
LogKit.info("http请求出错,http status:" + statusCode); |
||||
return ""; |
||||
} |
||||
|
||||
HttpEntity httpEntity = response.getEntity(); |
||||
if (httpEntity == null) { |
||||
response.close(); |
||||
LogKit.info("http请求出错,http响应内容为空"); |
||||
return ""; |
||||
} |
||||
String responseContent = EntityUtils.toString(httpEntity, "UTF-8"); |
||||
response.close(); |
||||
if (StringKit.isEmpty(responseContent)) { |
||||
LogKit.info("http请求出错,http响应内容为空1"); |
||||
return ""; |
||||
} |
||||
return responseContent; |
||||
} |
||||
|
||||
public static synchronized String createHttpPostContent(CloseableHttpClient httpClient, String url, String bodyContent) throws IOException { |
||||
if ((httpClient == null) || (StringKit.isEmpty(url)) || (StringKit.isEmpty(bodyContent))) { |
||||
return ""; |
||||
} |
||||
|
||||
HttpPost httpPost = new HttpPost(url); |
||||
httpPost.addHeader("User-Agent", Utils.DEFAULT_USER_AGENT); |
||||
httpPost.setConfig(Utils.REQUEST_CONFIG); |
||||
StringEntity bodyEntity = new StringEntity(bodyContent, "UTF-8"); |
||||
httpPost.setEntity(bodyEntity); |
||||
CloseableHttpResponse response = httpClient.execute(httpPost); |
||||
int statusCode = response.getStatusLine().getStatusCode(); |
||||
if (statusCode != HttpStatus.SC_OK) { |
||||
response.close(); |
||||
LogKit.info("http请求出错,http status:" + statusCode); |
||||
return ""; |
||||
} |
||||
|
||||
HttpEntity httpEntity = response.getEntity(); |
||||
if (httpEntity == null) { |
||||
response.close(); |
||||
LogKit.info("http请求出错,http响应内容为空"); |
||||
return ""; |
||||
} |
||||
String responseContent = EntityUtils.toString(httpEntity, "UTF-8"); |
||||
response.close(); |
||||
if (StringKit.isEmpty(responseContent)) { |
||||
LogKit.info("http请求出错,http响应内容为空1"); |
||||
return ""; |
||||
} |
||||
return responseContent; |
||||
} |
||||
|
||||
/** |
||||
* 重定向 |
||||
* @param res |
||||
* @param url |
||||
*/ |
||||
public static void sendRedirect(HttpServletResponse res, String url) { |
||||
if ((res == null) || (StringKit.isEmpty(url))) { |
||||
return; |
||||
} |
||||
res.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY); |
||||
res.setHeader("Location", url); |
||||
} |
||||
|
||||
/** |
||||
* 获取完整请求链接 |
||||
* |
||||
* @param req 请求 |
||||
* @return |
||||
*/ |
||||
public static String getFullRequestUrl(HttpServletRequest req) { |
||||
if (req == null) { |
||||
return ""; |
||||
} |
||||
String url = req.getRequestURL().toString(); |
||||
String queryUrl = req.getQueryString(); |
||||
if ((queryUrl == null) || "null".equalsIgnoreCase(queryUrl)) { |
||||
queryUrl = ""; |
||||
} else { |
||||
queryUrl = "?" + queryUrl; |
||||
} |
||||
String fullUrl = url + queryUrl; |
||||
return fullUrl; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,167 @@
|
||||
package com.fr.plugin.third.party.jsdiiac.config; |
||||
|
||||
|
||||
import com.fr.config.*; |
||||
import com.fr.config.holder.Conf; |
||||
import com.fr.config.holder.factory.Holders; |
||||
|
||||
import java.util.concurrent.ConcurrentHashMap; |
||||
|
||||
/** |
||||
* 配置数据保存 |
||||
*/ |
||||
@Visualization(category = "BMP集成配置") |
||||
public class CustomDataConfig extends DefaultConfiguration { |
||||
public String getNameSpace() { |
||||
return this.getClass().getName(); |
||||
} |
||||
|
||||
private static volatile CustomDataConfig config = null; |
||||
|
||||
public static CustomDataConfig getInstance() { |
||||
if (config == null) { |
||||
config = ConfigContext.getConfigInstance(CustomDataConfig.class); |
||||
} |
||||
return config; |
||||
} |
||||
|
||||
@Identifier(value = "esbUrl", name = "ESB发送链接", description = "", status = Status.SHOW) |
||||
private Conf<String> esbUrl = Holders.simple(""); |
||||
|
||||
@Identifier(value = "reqSrcSys", name = "发送方系统标识(REQ_SRC_SYS)", description = "", status = Status.SHOW) |
||||
private Conf<String> reqSrcSys = Holders.simple(""); |
||||
|
||||
@Identifier(value = "reqTarSys", name = "接收方系统标识(REQ_TAR_SYS)", description = "", status = Status.SHOW) |
||||
private Conf<String> reqTarSys = Holders.simple(""); |
||||
|
||||
@Identifier(value = "reqServerName", name = "服务方名称(REQ_SERVER_NAME)", description = "", status = Status.SHOW) |
||||
private Conf<String> reqServerName = Holders.simple(""); |
||||
|
||||
|
||||
@Identifier(value = "esbUsername", name = "ESB用户名", description = "", status = Status.SHOW) |
||||
private Conf<String> esbUsername = Holders.simple(""); |
||||
|
||||
@Identifier(value = "esbPassword", name = "ESB密码", description = "", status = Status.SHOW) |
||||
private Conf<String> esbPassword = Holders.simple(""); |
||||
|
||||
|
||||
@Identifier(value = "dataConnection", name = "数据库连接名称", description = "", status = Status.SHOW) |
||||
private Conf<String> dataConnection = Holders.simple(""); |
||||
|
||||
|
||||
@Identifier(value = "dataSetName", name = "内容数据集名称", description = "", status = Status.SHOW) |
||||
private Conf<String> dataSetName = Holders.simple(""); |
||||
|
||||
@Identifier(value = "bmpUrl", name = "BMP服务器地址", description = "", status = Status.SHOW) |
||||
private Conf<String> bmpUrl = Holders.simple(""); |
||||
|
||||
|
||||
@Identifier(value = "frUrl", name = "报表平台地址", description = "", status = Status.SHOW) |
||||
private Conf<String> frUrl = Holders.simple(""); |
||||
|
||||
@Identifier(value = "bmpFrUrl", name = "BMP跳转报表地址", description = "", status = Status.SHOW) |
||||
private Conf<String> bmpFrUrl = Holders.simple(""); |
||||
|
||||
public String getFrUrl() { |
||||
return frUrl.get(); |
||||
} |
||||
|
||||
public void setFrUrl(String frUrl) { |
||||
this.frUrl.set(frUrl); |
||||
} |
||||
|
||||
public String getBmpFrUrl() { |
||||
return bmpFrUrl.get(); |
||||
} |
||||
|
||||
public void setBmpFrUrl(String bmpFrUrl) { |
||||
this.bmpFrUrl.set(bmpFrUrl); |
||||
} |
||||
|
||||
public String getBmpUrl() { |
||||
return bmpUrl.get(); |
||||
} |
||||
|
||||
public void setBmpUrl(String bmpUrl) { |
||||
this.bmpUrl.set(bmpUrl); |
||||
} |
||||
|
||||
public String getEsbUrl() { |
||||
return esbUrl.get(); |
||||
} |
||||
|
||||
public void setEsbUrl(String esbUrl) { |
||||
this.esbUrl.set(esbUrl); |
||||
} |
||||
|
||||
public String getReqSrcSys() { |
||||
return reqSrcSys.get(); |
||||
} |
||||
|
||||
public void setReqSrcSys(String reqSrcSys) { |
||||
this.reqSrcSys.set(reqSrcSys); |
||||
} |
||||
|
||||
public String getReqTarSys() { |
||||
return reqTarSys.get(); |
||||
} |
||||
|
||||
public void setReqTarSys(String reqTarSys) { |
||||
this.reqTarSys.set(reqTarSys); |
||||
} |
||||
|
||||
public String getReqServerName() { |
||||
return reqServerName.get(); |
||||
} |
||||
|
||||
public void setReqServerName(String reqServerName) { |
||||
this.reqServerName.set(reqServerName); |
||||
} |
||||
|
||||
public String getEsbUsername() { |
||||
return esbUsername.get(); |
||||
} |
||||
|
||||
public void setEsbUsername(String esbUsername) { |
||||
this.esbUsername.set(esbUsername); |
||||
} |
||||
|
||||
public String getEsbPassword() { |
||||
return esbPassword.get(); |
||||
} |
||||
|
||||
public void setEsbPassword(String esbPassword) { |
||||
this.esbPassword.set(esbPassword); |
||||
} |
||||
|
||||
public String getDataConnection() { |
||||
return dataConnection.get(); |
||||
} |
||||
|
||||
public void setDataConnection(String dataConnection) { |
||||
this.dataConnection.set(dataConnection); |
||||
} |
||||
|
||||
public String getDataSetName() { |
||||
return dataSetName.get(); |
||||
} |
||||
|
||||
public void setDataSetName(String dataSetName) { |
||||
this.dataSetName.set(dataSetName); |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
CustomDataConfig cloned = (CustomDataConfig) super.clone(); |
||||
cloned.esbUrl = (Conf<String>) esbUrl.clone(); |
||||
cloned.reqSrcSys = (Conf<String>) reqSrcSys.clone(); |
||||
cloned.reqTarSys = (Conf<String>) reqTarSys.clone(); |
||||
cloned.reqServerName = (Conf<String>) reqServerName.clone(); |
||||
cloned.esbUsername = (Conf<String>) esbUsername.clone(); |
||||
cloned.esbPassword = (Conf<String>) esbPassword.clone(); |
||||
cloned.dataConnection = (Conf<String>) dataConnection.clone(); |
||||
cloned.dataSetName = (Conf<String>) dataSetName.clone(); |
||||
cloned.bmpUrl = (Conf<String>) bmpUrl.clone(); |
||||
return cloned; |
||||
} |
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.fr.plugin.third.party.jsdiiac.config; |
||||
|
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.intelli.record.Original; |
||||
import com.fr.plugin.context.PluginContext; |
||||
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
|
||||
/** |
||||
* 配置信息初始化 |
||||
*/ |
||||
@EnableMetrics |
||||
public class DataConfigInitializeMonitor extends AbstractPluginLifecycleMonitor { |
||||
@Override |
||||
@Focus(id = "com.fr.plugin.third.party.jsdiiac", text = "plugin-jsdiiac", source = Original.PLUGIN) |
||||
public void afterRun(PluginContext pluginContext) { |
||||
CustomDataConfig.getInstance(); |
||||
} |
||||
|
||||
@Override |
||||
public void beforeStop(PluginContext pluginContext) { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,13 @@
|
||||
package com.fr.plugin.third.party.jsdiiac.http; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractHttpHandlerProvider; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
|
||||
public class CustomHttpHandlerProvider extends AbstractHttpHandlerProvider { |
||||
@Override |
||||
public BaseHttpHandler[] registerHandlers() { |
||||
return new BaseHttpHandler[]{ |
||||
new SendEsbMessageHttpHandler() |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.fr.plugin.third.party.jsdiiac.http; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractURLAliasProvider; |
||||
import com.fr.decision.webservice.url.alias.URLAlias; |
||||
import com.fr.decision.webservice.url.alias.URLAliasFactory; |
||||
|
||||
public class CustomURLAliasProvider extends AbstractURLAliasProvider { |
||||
@Override |
||||
public URLAlias[] registerAlias() { |
||||
return new URLAlias[]{ |
||||
URLAliasFactory.createPluginAlias("/jsdiiac/sendesbmessage", "/jsdiiac/sendesbmessage", true) |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,364 @@
|
||||
package com.fr.plugin.third.party.jsdiiac.http; |
||||
|
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.general.data.DataModel; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.third.party.jsdiiac.BmpFlowUtils; |
||||
import com.fr.plugin.third.party.jsdiiac.SqlUtils; |
||||
import com.fr.plugin.third.party.jsdiiac.Utils; |
||||
import com.fr.plugin.third.party.jsdiiac.config.CustomDataConfig; |
||||
import com.fr.third.alibaba.druid.support.json.JSONUtils; |
||||
import com.fr.third.alibaba.druid.util.StringUtils; |
||||
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; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.IOException; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
import java.util.UUID; |
||||
|
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
public class SendEsbMessageHttpHandler extends BaseHttpHandler { |
||||
|
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.POST; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/jsdiiac/sendesbmessage"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception { |
||||
res.setContentType("application/json; charset=utf-8"); |
||||
String reqContent = Utils.getHttpRequestBody(req); |
||||
reqContent = StringKit.trim(reqContent); |
||||
if (StringKit.isEmpty(reqContent)) { |
||||
WebUtils.printAsString(res, "batch_id不能为空"); |
||||
} |
||||
|
||||
JSONObject reqJson = new JSONObject(reqContent); |
||||
String batchId = reqJson.getString("batch_id"); |
||||
if (StringKit.isEmpty(batchId)) { |
||||
WebUtils.printAsString(res, "batch_id不能为空1"); |
||||
} |
||||
|
||||
LogKit.info("BMP集成,batch_id:" + batchId); |
||||
String BTID = "recruit_code"; |
||||
String BSID = "HBFR"; |
||||
|
||||
DataModel dataModel = BmpFlowUtils.getFlowDataDataModel(batchId); |
||||
if (dataModel == null) { |
||||
LogKit.error("BPM流程业务数据提交,获取数据为空"); |
||||
return; |
||||
} |
||||
|
||||
int columnCount = dataModel.getColumnCount(); |
||||
if (columnCount <= 0) { |
||||
LogKit.error("BPM流程业务数据提交,获取数据为空1"); |
||||
return; |
||||
} |
||||
|
||||
String xxzt = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "XXZT"); |
||||
String iProcInstID = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "IPROCINSTID"); |
||||
String strBOID = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "IPROCINSTID"); |
||||
|
||||
String boid = ""; |
||||
if (StringUtils.isEmpty(strBOID)) { |
||||
boid = UUID.randomUUID().toString(); |
||||
LogKit.info("BPM流程业务数据提交,生成新的boid:" + boid); |
||||
} else { |
||||
boid = strBOID; |
||||
LogKit.info("BPM流程业务数据提交,使用旧的boid: " + boid); |
||||
} |
||||
|
||||
String rzzz = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "rzzz"); |
||||
String zgs = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "zgs"); |
||||
String bzs = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "bzs"); |
||||
String zts = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "zts"); |
||||
String zw = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "zw"); |
||||
String zprs = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "zprs"); |
||||
String yxzj = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "yxzj"); |
||||
String tx = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "tx"); |
||||
String jj = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "jj"); |
||||
String dg_date = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "dg_date"); |
||||
String zdxl = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "zdxl"); |
||||
String sfgjg = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "sfgjg"); |
||||
String gjgwlx = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "gjgwlx"); |
||||
String xb = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "xb"); |
||||
String yxfy = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "yxfy"); |
||||
String zgnl = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "zgnl"); |
||||
String zwms = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "zwms"); |
||||
String gzzz = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "gzzz"); |
||||
String zryq = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "zryq"); |
||||
String gzdd = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "gzdd"); |
||||
String sfcb = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "sfcb"); |
||||
|
||||
String fsubject = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "fsubject"); |
||||
String applicantname = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "applicantname"); |
||||
String applyorg = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "applyorg"); |
||||
String applydept = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "applydept"); |
||||
String applypost = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "applypost"); |
||||
String switchorg = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "switchorg"); |
||||
String create_time = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "create_time"); |
||||
|
||||
String zaizhi_url = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "zaizhi_url"); |
||||
if (StringKit.isNotEmpty(zaizhi_url)) { |
||||
zaizhi_url = CustomDataConfig.getInstance().getFrUrl() + "?bmpFrUrlValue=" + zaizhi_url; |
||||
} |
||||
|
||||
String cbrs = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "cbrs"); |
||||
String zpsy = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "zpsy"); |
||||
String zpsysm = BmpFlowUtils.getDataModelValueAt(dataModel, 0, "zpsysm"); |
||||
|
||||
String reqSrcSys = CustomDataConfig.getInstance().getReqSrcSys(); |
||||
String reqTarSys = CustomDataConfig.getInstance().getReqTarSys(); |
||||
String reqServerName = CustomDataConfig.getInstance().getReqServerName(); |
||||
|
||||
String sendEsbMessage = getSendEsbMessage(iProcInstID, boid, reqSrcSys, reqTarSys, reqServerName, batchId, rzzz, zgs, bzs, zts, zw, zprs, yxzj, tx, jj, dg_date, zdxl, sfgjg, gjgwlx, xb, yxfy, zgnl, zwms, gzzz, zryq, gzdd, sfcb, |
||||
fsubject, applicantname, applyorg, applydept, applypost, switchorg, create_time, zaizhi_url, cbrs, zpsy, zpsysm); |
||||
|
||||
String returnMessage = ""; |
||||
String esbUrl = CustomDataConfig.getInstance().getEsbUrl(); |
||||
String esbReturnMessage = sendJson(sendEsbMessage, esbUrl); |
||||
if (StringKit.isEmpty(esbReturnMessage)) { |
||||
returnMessage = getSimpleReturnMessage(BTID, BSID, "500", "", ""); |
||||
WebUtils.printAsString(res, returnMessage); |
||||
return; |
||||
} |
||||
Object esbReturnMessageObj = JSONUtils.parse(esbReturnMessage); |
||||
Map<String, String> esbReturnData = parseJsonMessage(esbReturnMessageObj); |
||||
|
||||
if ("0".equals(esbReturnData.get("RESULT"))) { |
||||
// 拼出bpmurl入库,防止页面关闭无法找回
|
||||
String bpmurl_server = CustomDataConfig.getInstance().getBmpUrl(); |
||||
String bpmurl = bpmurl_server + "?BSID=" + BSID + "&BTID=" + BTID + "&BOID=" + boid; |
||||
BmpFlowUtils.updateUpload(batchId, "1", boid, bpmurl); |
||||
returnMessage = getSimpleReturnMessage(BTID, BSID, "200", "发送esb成功", boid); |
||||
} else { |
||||
returnMessage = getSimpleReturnMessage(BTID, BSID, "500", "", ""); |
||||
} |
||||
LogKit.info("BMP集成," + returnMessage); |
||||
WebUtils.printAsString(res, returnMessage); |
||||
} |
||||
|
||||
public static Map<String, String> parseJsonMessage(Object o) { |
||||
Map<String, String> result = new HashMap<>(); |
||||
result.put("RESULT", SqlUtils.<String>objToMap(o, "E_RESPONSE", "RSP_BASEINFO", "RESULT")); |
||||
result.put("RSP_STATUS_CODE", SqlUtils.<String>objToMap(o, "E_RESPONSE", "RSP_BASEINFO", "RSP_STATUS_CODE")); |
||||
result.put("RSP_STATUS_MSG", SqlUtils.<String>objToMap(o, "E_RESPONSE", "RSP_BASEINFO", "RSP_STATUS_MSG")); |
||||
result.put("STATUSCODE", SqlUtils.<String>objToMap(o, "E_RESPONSE", "MESSAGE", "RSP_ITEM", "PI_RES_DATA", "STATUSCODE")); |
||||
result.put("STATUSMESSAGE", SqlUtils.<String>objToMap(o, "E_RESPONSE", "MESSAGE", "RSP_ITEM", "PI_RES_DATA", "STATUSMESSAGE")); |
||||
return result; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* post调接口给esb发送数据 |
||||
* |
||||
* @param json |
||||
* @param url |
||||
* @return |
||||
* @throws IOException |
||||
*/ |
||||
public static synchronized String sendJson(String json, String url) throws IOException { |
||||
String user = "ESB_Q_PUBLIC"; |
||||
String password = "publictest@esb"; |
||||
user = CustomDataConfig.getInstance().getEsbUsername(); |
||||
password = CustomDataConfig.getInstance().getEsbPassword(); |
||||
// 创建用户信息
|
||||
CredentialsProvider provider = new BasicCredentialsProvider(); |
||||
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(user, password); |
||||
provider.setCredentials(AuthScope.ANY, credentials); |
||||
|
||||
CloseableHttpClient client = null; |
||||
LogKit.info("BMP集成,请求BMP地址:" + url); |
||||
LogKit.info("BMP集成,ESB验证用户名:" + user + ",密码:" + password); |
||||
client = HttpClients.custom().setDefaultCredentialsProvider(provider).build(); |
||||
HttpPost httpPost = new HttpPost(url); |
||||
/* |
||||
String authorizationStr = user + ":" + password; |
||||
String authorizationBase64 = new String(Base64.getEncoder().encode(authorizationStr.getBytes())); |
||||
httpPost.addHeader("Authorization", "Basic " + authorizationBase64);*/ |
||||
|
||||
|
||||
httpPost.setHeader("Content-Type", "application/json;charset=UTF-8"); |
||||
LogKit.info("BMP集成,发送数据:\n" + json); |
||||
StringEntity se = new StringEntity(json, "utf-8"); |
||||
se.setContentEncoding("UTF-8"); |
||||
se.setContentType("application/json"); |
||||
httpPost.setEntity(se); |
||||
CloseableHttpResponse response = client.execute(httpPost); |
||||
LogKit.info("BMP集成,接口返回状态码:" + response.getStatusLine().getStatusCode()); |
||||
if (response.getStatusLine().getStatusCode() != 200) { |
||||
LogKit.info("BMP集成,接口返回状态码错误"); |
||||
client.close(); |
||||
return ""; |
||||
} |
||||
String resData = EntityUtils.toString(response.getEntity()); |
||||
LogKit.info("BMP集成,接口返回:\n" + resData); |
||||
client.close(); |
||||
return resData; |
||||
} |
||||
|
||||
public static String getSendEsbMessage(String iProcInstID, String boid, String REQ_SRC_SYS, String REQ_TAR_SYS, String REQ_SERVER_NAME |
||||
, String batch_id |
||||
, String rzzz |
||||
, String zgs |
||||
, String bzs |
||||
, String zts |
||||
, String zw |
||||
, String zprs |
||||
, String yxzj |
||||
, String tx |
||||
, String jj |
||||
, String dg_date |
||||
, String zdxl |
||||
, String sfgjg |
||||
, String gjgwlx |
||||
, String xb |
||||
, String yxfy |
||||
, String zgnl |
||||
, String zwms |
||||
, String gzzz |
||||
, String zryq |
||||
, String gzdd |
||||
, String sfcb |
||||
|
||||
, String FSubject |
||||
, String APPLICANTNAME |
||||
, String APPLYORG |
||||
, String APPLYDEPT |
||||
, String APPLYPOST |
||||
, String SWITCHORG |
||||
, String APPLYDATETIME |
||||
, String zaizhi_url |
||||
, String cbrs |
||||
, String zpsy |
||||
, String zpsysm |
||||
|
||||
) { |
||||
|
||||
Map<String, Object> REQ_BASEINFO = new HashMap<>(); |
||||
REQ_BASEINFO.put("REQ_TRACE_ID", UUID.randomUUID().toString().replace("-", "")); |
||||
REQ_BASEINFO.put("REQ_SEND_TIME", SqlUtils.nowContinuously()); |
||||
REQ_BASEINFO.put("REQ_SRC_SYS", REQ_SRC_SYS); |
||||
REQ_BASEINFO.put("REQ_TAR_SYS", REQ_TAR_SYS); |
||||
REQ_BASEINFO.put("REQ_SERVER_NAME", REQ_SERVER_NAME); |
||||
REQ_BASEINFO.put("REQ_SYN_FLAG", "S"); |
||||
REQ_BASEINFO.put("BIZTRANSACTIONID", SqlUtils.getBIZTRANSACTIONID("HBBITB_E902")); // 接口编号,可能需要改
|
||||
REQ_BASEINFO.put("REQ_SERVER_NAME", REQ_SERVER_NAME); |
||||
|
||||
REQ_BASEINFO.put("REQ_BSN_ID", ""); |
||||
REQ_BASEINFO.put("REQ_RETRY_TIMES", ""); |
||||
REQ_BASEINFO.put("REQ_REPEAT_FLAG", ""); |
||||
REQ_BASEINFO.put("REQ_REPEAT_CYCLE", ""); |
||||
REQ_BASEINFO.put("COUNT", "1"); |
||||
|
||||
Map<String, Object> DATA = new HashMap<>(); |
||||
DATA.put("batch_id", batch_id); |
||||
DATA.put("rzzz", rzzz); |
||||
DATA.put("zgs", zgs); |
||||
DATA.put("bzs", bzs); |
||||
DATA.put("zts", zts); |
||||
DATA.put("zw", zw); |
||||
DATA.put("zprs", zprs); |
||||
DATA.put("yxzj", yxzj); |
||||
DATA.put("tx", tx); |
||||
DATA.put("jj", jj); |
||||
DATA.put("dg_date", dg_date); |
||||
DATA.put("zdxl", zdxl); |
||||
DATA.put("sfgjg", sfgjg); |
||||
DATA.put("gjgwlx", gjgwlx); |
||||
DATA.put("xb", xb); |
||||
DATA.put("yxfy", yxfy); |
||||
DATA.put("zgnl", zgnl); |
||||
DATA.put("zwms", zwms); |
||||
DATA.put("gzzz", gzzz); |
||||
DATA.put("zryq", zryq); |
||||
DATA.put("gzdd", gzdd); |
||||
DATA.put("sfcb", sfcb); |
||||
|
||||
DATA.put("zaizhi_url", zaizhi_url); |
||||
DATA.put("cbrs", cbrs); |
||||
DATA.put("zpsy", zpsy); |
||||
DATA.put("zpsysm", zpsysm); |
||||
|
||||
DATA.put("FSubject", FSubject); |
||||
DATA.put("APPLICANTNAME", APPLICANTNAME); |
||||
DATA.put("APPLYORG", APPLYORG); |
||||
DATA.put("APPLYDEPT", APPLYDEPT); |
||||
DATA.put("APPLYPOST", APPLYPOST); |
||||
DATA.put("SWITCHORG", SWITCHORG); |
||||
DATA.put("APPLYDATETIME", APPLYDATETIME); |
||||
|
||||
Map<String, Object> BSXML = new HashMap<>(); |
||||
BSXML.put("DATA", DATA); |
||||
|
||||
Map<String, Object> REQ_ITEM = new HashMap<>(); |
||||
REQ_ITEM.put("BSXML", BSXML); |
||||
|
||||
// 暂为固定值,可能要改
|
||||
REQ_ITEM.put("BTID", "recruit_code"); |
||||
REQ_ITEM.put("BSID", "HBFR"); |
||||
REQ_ITEM.put("PROCINSTID", iProcInstID); |
||||
REQ_ITEM.put("BOID", boid); |
||||
REQ_ITEM.put("USERID", "xiechen"); |
||||
|
||||
|
||||
Map<String, Object> MESSAGE = new HashMap<>(); |
||||
MESSAGE.put("REQ_ITEM", REQ_ITEM); |
||||
|
||||
Map<String, Object> I_REQUEST = new HashMap<>(); |
||||
I_REQUEST.put("REQ_BASEINFO", REQ_BASEINFO); |
||||
I_REQUEST.put("MESSAGE", MESSAGE); |
||||
|
||||
Map<String, Object> result = new HashMap<>(); |
||||
result.put("I_REQUEST", I_REQUEST); |
||||
|
||||
return JSONUtils.toJSONString(result); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 获取简单返回json |
||||
* |
||||
* @param code |
||||
* @param message |
||||
* @return |
||||
*/ |
||||
public static String getSimpleReturnMessage(String BTID, String BSID, String code, String message, String boid) { |
||||
Map<String, Object> a = new HashMap<>(); |
||||
a.put("code", code); |
||||
a.put("message", message); |
||||
a.put("BOID", boid); |
||||
a.put("BTID", BTID); |
||||
a.put("BSID", BSID); |
||||
return JSONUtils.toJSONString(a); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,90 @@
|
||||
package com.fr.plugin.third.party.jsdiiac.http; |
||||
|
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.decision.fun.impl.AbstractGlobalRequestFilterProvider; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.plugin.third.party.jsdiiac.Utils; |
||||
import com.fr.plugin.third.party.jsdiiac.config.CustomDataConfig; |
||||
import com.fr.third.springframework.web.util.UriUtils; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.FilterChain; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
|
||||
public class SessionGlobalRequestFilterProvider extends AbstractGlobalRequestFilterProvider { |
||||
private static String DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36"; |
||||
|
||||
@Override |
||||
public String filterName() { |
||||
return "com.fr.plugin.third.party.jsdiiac"; |
||||
} |
||||
|
||||
@Override |
||||
public String[] urlPatterns() { |
||||
return new String[]{"/decision", "/decision/*"}; |
||||
} |
||||
|
||||
@Override |
||||
public void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain filterChain) { |
||||
try { |
||||
if (!PluginContexts.currentContext().isAvailable()) { |
||||
LogKit.info("BMP集成,许可证过期"); |
||||
filterChain.doFilter(req, res); |
||||
return; |
||||
} |
||||
|
||||
String reqUrl = req.getRequestURL().toString(); |
||||
String fullUrl = Utils.getFullRequestUrl(req); |
||||
String method = req.getMethod(); |
||||
LogKit.info("BMP集成,记录访问地址:" + method + " " + fullUrl); |
||||
|
||||
if (!"GET".equalsIgnoreCase(method)) { |
||||
filterChain.doFilter(req, res); |
||||
return; |
||||
} |
||||
|
||||
if (reqUrl.indexOf("/remote/") >= 0) { |
||||
filterChain.doFilter(req, res); |
||||
return; |
||||
} |
||||
|
||||
if (reqUrl.indexOf("/decision/login") >= 0) { |
||||
filterChain.doFilter(req, res); |
||||
return; |
||||
} |
||||
|
||||
if (fullUrl.indexOf("/weixin/") >= 0) { |
||||
filterChain.doFilter(req, res); |
||||
return; |
||||
} |
||||
|
||||
|
||||
if (fullUrl.indexOf("/dingtalk/") >= 0) { |
||||
filterChain.doFilter(req, res); |
||||
return; |
||||
} |
||||
|
||||
String bmpFrUrlValue = WebUtils.getHTTPRequestParameter(req, "bmpFrUrlValue"); |
||||
|
||||
if (StringKit.isNotEmpty(bmpFrUrlValue)) { |
||||
LogKit.info("BMP集成,bmpFrUrlValue:" + bmpFrUrlValue); |
||||
String tempValue = bmpFrUrlValue; |
||||
if (bmpFrUrlValue.indexOf("%") < 0) { |
||||
tempValue = UriUtils.encodeQueryParam(bmpFrUrlValue, "UTF-8"); |
||||
} |
||||
String realUrl = CustomDataConfig.getInstance().getBmpFrUrl() + "&rzzz=" + tempValue; |
||||
LogKit.info("BMP集成,真实跳转地址:" + realUrl); |
||||
Utils.sendRedirect(res, realUrl); |
||||
return; |
||||
} |
||||
filterChain.doFilter(req, res); |
||||
} catch (Exception e) { |
||||
LogKit.error("BMP集成出错," + e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,46 @@
|
||||
package com.fr.plugin.third.party.jsdiiac.web; |
||||
|
||||
import com.fr.web.struct.Component; |
||||
import com.fr.web.struct.Filter; |
||||
import com.fr.web.struct.browser.RequestClient; |
||||
import com.fr.web.struct.category.ScriptPath; |
||||
import com.fr.web.struct.category.StylePath; |
||||
|
||||
public class MainFilesComponent extends Component { |
||||
public static final MainFilesComponent KEY = new MainFilesComponent(); |
||||
private MainFilesComponent(){} |
||||
/** |
||||
* 返回需要引入的JS脚本路径 |
||||
* @param client 请求客户端描述 |
||||
* @return JS脚本路径 |
||||
*/ |
||||
public ScriptPath script(RequestClient client ) { |
||||
//如果不需要就直接返回 ScriptPath.EMPTY
|
||||
return ScriptPath.build("com/fr/plugin/third/party/jsdiagb/web/main.js"); |
||||
} |
||||
|
||||
/** |
||||
* 返回需要引入的CSS样式路径 |
||||
* @param client 请求客户端描述 |
||||
* @return CSS样式路径 |
||||
*/ |
||||
public StylePath style(RequestClient client ) { |
||||
//如果不需要就直接返回 StylePath.EMPTY;
|
||||
//return StylePath.build("com/fr/plugin/jscssinput/demo/demo.css");
|
||||
return StylePath.EMPTY; |
||||
} |
||||
|
||||
/** |
||||
* 通过给定的资源过滤器控制是否加载这个资源 |
||||
* @return 资源过滤器 |
||||
*/ |
||||
public Filter filter() { |
||||
return new Filter(){ |
||||
@Override |
||||
public boolean accept() { |
||||
//任何情况下我们都在平台组件加载时加载我们的组件
|
||||
return true; |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,19 @@
|
||||
package com.fr.plugin.third.party.jsdiiac.web; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractWebResourceProvider; |
||||
import com.fr.decision.web.MainComponent; |
||||
import com.fr.web.struct.Atom; |
||||
|
||||
public class MainWebResourceProvider extends AbstractWebResourceProvider { |
||||
@Override |
||||
public Atom attach() { |
||||
//在平台主组件加载时添加我们自己的组件
|
||||
return MainComponent.KEY; |
||||
} |
||||
|
||||
@Override |
||||
public Atom client() { |
||||
//我们自己要引入的组件
|
||||
return MainFilesComponent.KEY; |
||||
} |
||||
} |
@ -0,0 +1,16 @@
|
||||
$(function () { |
||||
var url = Dec.fineServletURL + "/url/jsd8061/oauth/config"; |
||||
$.post(url, |
||||
function (data, status) { |
||||
if (status == "success") { |
||||
debugger; |
||||
var a = Dec.Logout; |
||||
var logoutUrl = data.loginUrl; |
||||
Dec.Logout = function () { |
||||
a(); |
||||
//$.get(logoutUrl);
|
||||
window.location.href = logoutUrl; |
||||
} |
||||
} |
||||
}, "json"); |
||||
}); |
Loading…
Reference in new issue