diff --git a/JSD-7453-需求确认书V1.docx b/JSD-7453-需求确认书V1.docx
new file mode 100644
index 0000000..a28de86
Binary files /dev/null and b/JSD-7453-需求确认书V1.docx differ
diff --git a/README.md b/README.md
index 0e58c94..0aa8e30 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,6 @@
# open-JSD-7837
-JSD-7837开源任务材料
\ No newline at end of file
+JSD-7453 7837 开源任务代码\
+免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\
+仅作为开发者学习参考使用!禁止用于任何商业用途!\
+为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。
\ No newline at end of file
diff --git a/database.properties b/database.properties
new file mode 100644
index 0000000..9a19b3a
--- /dev/null
+++ b/database.properties
@@ -0,0 +1,3 @@
+url=jdbc:oracle:thin:@127.0.0.1:1521:databasename
+username=root
+psd=123
\ No newline at end of file
diff --git a/lib/ojdbc7.jar b/lib/ojdbc7.jar
new file mode 100644
index 0000000..fd38a6c
Binary files /dev/null and b/lib/ojdbc7.jar differ
diff --git a/plugin.xml b/plugin.xml
new file mode 100644
index 0000000..8073dbd
--- /dev/null
+++ b/plugin.xml
@@ -0,0 +1,31 @@
+
+ com.fr.plugin.sso
+
+ yes
+ 1.0.24
+ 10.0
+ 2018-07-31
+ author
+
+
+ com.fr.plugin.it
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/fr/plugin/it/api/FlowApi.java b/src/main/java/com/fr/plugin/it/api/FlowApi.java
new file mode 100644
index 0000000..cb4980a
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/api/FlowApi.java
@@ -0,0 +1,357 @@
+package com.fr.plugin.it.api;
+import com.fr.json.JSONArray;
+import com.fr.json.JSONObject;
+import com.fr.plugin.it.config.simple.account.PluginSimpleConfig;
+import com.fr.plugin.it.utils.*;
+
+import java.util.*;
+
+public class FlowApi {
+ //启动流程
+ public static String startFlow(Object[] object){
+ PluginSimpleConfig psc = PluginSimpleConfig.getInstance();
+ String startUrl = psc.getStart();
+
+ String workflowCode = String.valueOf(object[0]);
+ String userCode = String.valueOf(object[1]);
+ String finishStart = String.valueOf(object[2]);
+ String jsonDataItems = String.valueOf(object[3]);
+ String subJsonDataItems = "";
+// String.valueOf(object[4]);
+
+ String jsonDataItemsStr = getJSONDataStr(jsonDataItems);
+
+ if(Utils.isNullStr(jsonDataItemsStr)){
+ jsonDataItemsStr = "";
+ }
+
+ String subJsonDataItemsStr = getJSONDataStr(subJsonDataItems);
+
+ if(Utils.isNullStr(subJsonDataItemsStr)){
+ subJsonDataItemsStr = "";
+ }
+
+ Map param = new HashMap();
+
+ param.put("workflowCode",workflowCode);
+ param.put("userCode",userCode);
+ param.put("finishStart",finishStart);
+ param.put("jsonDataItems",jsonDataItemsStr);
+ param.put("subJsonDataItems",subJsonDataItemsStr);
+
+ String result = HttpUtils.HttpPostWWWForm(startUrl,null,param);
+ String re2 =XMLUtils.xmlToList(result);
+
+ Map param2 = new HashMap();
+
+ param2.put("workflowCode",workflowCode);
+ param2.put("userCode",userCode);
+ param2.put("finishStart",finishStart);
+ param2.put("jsonDataItems",jsonDataItems);
+ param2.put("subJsonDataItems",subJsonDataItems);
+
+ insertToDB(param2,"startWorkflow",re2);
+
+ return re2;
+ }
+
+ //驳回工作任务
+ public static String return1(Object[] object){
+ PluginSimpleConfig psc = PluginSimpleConfig.getInstance();
+ String startUrl = psc.getReturn1();
+
+ String userCode = String.valueOf(object[0]);
+ String workItemId = String.valueOf(object[1]);
+ String commentText = String.valueOf(object[2]);
+
+ Map param = new HashMap();
+
+ param.put("userCode",userCode);
+ param.put("workItemId",workItemId);
+ param.put("commentText",commentText);
+
+ String result = HttpUtils.HttpPostWWWForm(startUrl,null,param);
+
+ return XMLUtils.xmlToList(result);
+ }
+
+ //3、驳回工作任务到开始
+ public static String returnToStart(Object[] object){
+ PluginSimpleConfig psc = PluginSimpleConfig.getInstance();
+ String startUrl = psc.getReturnToStart();
+
+ String workItemId = String.valueOf(object[0]);
+ String commentText = String.valueOf(object[1]);
+
+ Map param = new HashMap();
+
+ param.put("workItemId",workItemId);
+ param.put("commentText",commentText);
+
+ String result = HttpUtils.HttpPostWWWForm(startUrl,null,param);
+
+ return XMLUtils.xmlToList(result);
+ }
+
+ //4、提交工作任务
+ public static String submit(Object[] object){
+ PluginSimpleConfig psc = PluginSimpleConfig.getInstance();
+ String startUrl = psc.getSubmit();
+
+ String userCode = String.valueOf(object[0]);
+ String workItemId = String.valueOf(object[1]);
+ String commentText = String.valueOf(object[2]);
+ String approval = String.valueOf(object[3]);
+
+ Map param = new HashMap();
+
+ param.put("userCode",userCode);
+ param.put("workItemId",workItemId);
+ param.put("commentText",commentText);
+ param.put("approval",approval);
+
+ String result = HttpUtils.HttpPostWWWForm(startUrl,null,param);
+ String result2 =XMLUtils.xmlToList(result);
+ insertToDB(param,"submitWorkItem",result2);
+
+ return result2;
+ }
+
+ //5、5、批量取消流程
+ public static String cancel(Object[] object){
+ PluginSimpleConfig psc = PluginSimpleConfig.getInstance();
+ String startUrl = psc.getCancel();
+
+ String userCode = String.valueOf(object[0]);
+ String sequenceNos = String.valueOf(object[1]);
+
+ Map param = new HashMap();
+
+ param.put("userCode",userCode);
+ param.put("instanceId",sequenceNos);
+
+ String result = HttpUtils.HttpPostWWWForm(startUrl,null,param);
+
+ return XMLUtils.xmlToList(result);
+ }
+
+ //6、取消流程
+ public static String cancelWithRemark(Object[] object){
+ PluginSimpleConfig psc = PluginSimpleConfig.getInstance();
+ String startUrl = psc.getCancelWithRemark();
+
+ String userCode = String.valueOf(object[0]);
+ String sequenceNos = String.valueOf(object[1]);
+ String remark = String.valueOf(object[2]);
+
+ Map param = new HashMap();
+
+ param.put("userCode",userCode);
+ param.put("instanceId",sequenceNos);
+ param.put("remark",remark);
+
+ String result = HttpUtils.HttpPostWWWForm(startUrl,null,param);
+ String result2 =XMLUtils.xmlToList(result);
+
+ insertToDB(param,"cancelInstanceWithRemark",result2);
+
+
+ return result2;
+ }
+
+ //7、重新激活流程
+ public static String restart(Object[] object){
+ PluginSimpleConfig psc = PluginSimpleConfig.getInstance();
+ String startUrl = psc.getReStart();
+
+ String instanceId = String.valueOf(object[0]);
+ String activityCode = String.valueOf(object[1]);
+
+ Map param = new HashMap();
+
+ param.put("instanceId",instanceId);
+ param.put("activityCode",activityCode);
+
+ String result = HttpUtils.HttpPostWWWForm(startUrl,null,param);
+ String result2 =XMLUtils.xmlToList2(result);
+ insertToDB(param,"reStartWorkflow",result2);
+
+ return result2;
+ }
+
+ private static String getJSONDataStr(String jsonDataItems) {
+ JSONArray itemsJsons = new JSONArray();
+
+ if(Utils.isNotNullStr(jsonDataItems)){
+ String[] items = jsonDataItems.split(";");
+
+ for(String item : items){
+ String[] keyValue = item.split(",");
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put(keyValue[0],keyValue[1]);
+ itemsJsons.add(jsonObject);
+ }
+
+ return itemsJsons.toString();
+ }
+
+ return "";
+ }
+
+ private static List getValues(String jsonDataItems) {
+ List result = new ArrayList();
+
+ if(Utils.isNotNullStr(jsonDataItems)){
+ String[] items = jsonDataItems.split(";");
+
+ for(String item : items){
+ String[] keyValue = item.split(",");
+ result.add(keyValue[1]);
+ }
+ }
+
+ return result;
+ }
+
+ private static void insertToDB(Map param,String flowName,String result){
+ String id = Utils.uuid();
+ Date date = new Date();
+ String yearMonth = DateUtilSelf.DateToString(date,"yyyyMM");
+ //是否成功调用
+ String isSuccess = "N";
+ String sql = "";
+
+ if("startWorkflow".equals(flowName)){
+ //请求参数
+ String workflowCode = param.get("workflowCode");
+ String userCode = param.get("userCode");
+ String finishStart = param.get("finishStart");
+ String jsonDataItems = param.get("jsonDataItems");
+ String subJsonDataItems = param.get("subJsonDataItems");
+
+ List values = getValues(jsonDataItems);
+ String field = getFileStr(values);
+ String value2 = getValueStr(values);
+
+ if(Utils.isNullStr(result)){
+ sql = "insert into FRSOURCEDATA10.RF_BPM_JYSGZ_TRIGGERLOG(ID,BPM_TYPE,YEARMONTH,STARTTIME,IS_SUCCESS,SUBMIT_DATA1,SUBMIT_DATA2,SUBMIT_DATA3"+field+")" +
+ " values('"+id+"','"+flowName+"','"+yearMonth+"',sysdate,'"+isSuccess+"','"+workflowCode+"','"+userCode+"','"+finishStart+"'"+value2+")";
+
+ JDBCUtil.update(sql);
+ return;
+ }
+
+ JSONObject resultJson = new JSONObject(result);
+ isSuccess = resultJson.getBoolean("Success") ? "Y" : "N";
+ //返回值
+ String success = resultJson.getString("Success");
+ String instanceID = resultJson.getString("InstanceID");
+ String message = resultJson.getString("Message");
+ String workItemID = resultJson.getString("WorkItemID");
+ String workItemUrl = resultJson.getString("WorkItemUrl");
+ String SequenceNO = resultJson.getString("SequenceNO");
+
+ sql = "insert into FRSOURCEDATA10.RF_BPM_JYSGZ_TRIGGERLOG(ID,BPM_TYPE,YEARMONTH,STARTTIME,IS_SUCCESS,SUBMIT_DATA1,SUBMIT_DATA2,SUBMIT_DATA3"+field+",BACK_DATA1,BACK_DATA2,BACK_DATA3,BACK_DATA4,BACK_DATA5,BACK_DATA6)" +
+ " values('"+id+"','"+flowName+"','"+yearMonth+"',sysdate,'"+isSuccess+"','"+workflowCode+"','"+userCode+"','"+finishStart+"'"+value2+",'"+success+"','"+instanceID+"','"+message+"','"+workItemID+"','"+workItemUrl+"','"+SequenceNO+"')";
+
+ FRUtils.FRLogInfo("sql:"+sql);
+ JDBCUtil.update(sql);
+ }else if("reStartWorkflow".equals(flowName)){
+ //请求参数
+ String instanceId = param.get("instanceId");
+ String activityCode = param.get("activityCode");
+
+ if(Utils.isNullStr(result)){
+ sql = "insert into FRSOURCEDATA10.RF_BPM_JYSGZ_TRIGGERLOG(ID,BPM_TYPE,YEARMONTH,STARTTIME,IS_SUCCESS,SUBMIT_DATA1,SUBMIT_DATA2)" +
+ " values('"+id+"','"+flowName+"','"+yearMonth+"',sysdate,'"+isSuccess+"','"+instanceId+"','"+activityCode+"')";
+
+ JDBCUtil.update(sql);
+
+ return;
+ }
+
+ JSONObject resultJson = new JSONObject(result);
+ isSuccess = resultJson.getBoolean("Success") ? "Y" : "N";
+ //返回值
+ String success = resultJson.getString("Success");
+ String sequenceNo = resultJson.getString("SequenceNo");
+ String instanceId2 = resultJson.getString("InstanceId");
+ String message = resultJson.getString("Message");
+ String jsonList = resultJson.getString("JsonList");
+
+ sql = "insert into FRSOURCEDATA10.RF_BPM_JYSGZ_TRIGGERLOG(ID,BPM_TYPE,YEARMONTH,STARTTIME,IS_SUCCESS,SUBMIT_DATA1,SUBMIT_DATA2,BACK_DATA1,BACK_DATA2,BACK_DATA3,BACK_DATA4,BACK_DATA5)" +
+ " values('"+id+"','"+flowName+"','"+yearMonth+"',sysdate,'"+isSuccess+"','"+instanceId+"','"+activityCode+"','"+success+"','"+sequenceNo+"','"+instanceId2+"','"+message+"','"+jsonList+"')";
+
+ FRUtils.FRLogInfo("sql:"+sql);
+ JDBCUtil.update(sql);
+ }else if("cancelInstanceWithRemark".equals(flowName)){
+ //请求参数
+ String userCode = param.get("userCode");
+ String sequenceNos = param.get("sequenceNos");
+ String remark = param.get("remark");
+
+ if(Utils.isNullStr(result)){
+ sql = "insert into FRSOURCEDATA10.RF_BPM_JYSGZ_TRIGGERLOG(ID,BPM_TYPE,YEARMONTH,STARTTIME,IS_SUCCESS,SUBMIT_DATA1,SUBMIT_DATA2,SUBMIT_DATA3)" +
+ " values('"+id+"','"+flowName+"','"+yearMonth+"',sysdate,'"+isSuccess+"','"+userCode+"','"+sequenceNos+"','"+remark+"')";
+
+ JDBCUtil.update(sql);
+ return;
+ }
+
+
+ isSuccess = result.equals("true") ? "Y" : "N";
+
+ sql = "insert into FRSOURCEDATA10.RF_BPM_JYSGZ_TRIGGERLOG(ID,BPM_TYPE,YEARMONTH,STARTTIME,IS_SUCCESS,SUBMIT_DATA1,SUBMIT_DATA2,SUBMIT_DATA3,BACK_DATA1)" +
+ " values('"+id+"','"+flowName+"','"+yearMonth+"',sysdate,'"+isSuccess+"','"+userCode+"','"+sequenceNos+"','"+remark+"','"+isSuccess+"')";
+
+ FRUtils.FRLogInfo("sql:"+sql);
+ JDBCUtil.update(sql);
+ }else if("submitWorkItem".equals(flowName)){
+ //请求参数
+ String userCode = param.get("userCode");
+ String workItemId = param.get("workItemId");
+ String commentText = param.get("commentText");
+ String approval = param.get("approval");
+
+ if(Utils.isNullStr(result)){
+ sql = "insert into FRSOURCEDATA10.RF_BPM_JYSGZ_TRIGGERLOG(ID,BPM_TYPE,YEARMONTH,STARTTIME,IS_SUCCESS,SUBMIT_DATA1,SUBMIT_DATA2,SUBMIT_DATA3,SUBMIT_DATA4)" +
+ " values('"+id+"','"+flowName+"','"+yearMonth+"',sysdate,'"+isSuccess+"','"+userCode+"','"+workItemId+"','"+commentText+"','"+approval+"')";
+
+ JDBCUtil.update(sql);
+ return;
+ }
+
+ isSuccess = result.equals("true") ? "Y" : "N";
+
+ sql = "insert into FRSOURCEDATA10.RF_BPM_JYSGZ_TRIGGERLOG(ID,BPM_TYPE,YEARMONTH,STARTTIME,IS_SUCCESS,SUBMIT_DATA1,SUBMIT_DATA2,SUBMIT_DATA3,SUBMIT_DATA4,BACK_DATA1)" +
+ " values('"+id+"','"+flowName+"','"+yearMonth+"',sysdate,'"+isSuccess+"','"+userCode+"','"+workItemId+"','"+commentText+"','"+approval+"','"+result+"')";
+
+ FRUtils.FRLogInfo("sql:"+sql);
+ JDBCUtil.update(sql);
+ }
+ }
+
+ private static String getFileStr(List values){
+ String field = "";
+ String fieldStr = "SUBMIT_DATA";
+ int count = 4;
+
+ for(String value : values){
+ field+= ","+fieldStr + count;
+
+ count ++;
+ }
+
+ return field;
+ }
+
+ private static String getValueStr(List values){
+ String result = "";
+
+ for(String value : values){
+ result +=",'"+value+"'";
+ }
+
+ return result;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/config/simple/DemoInitializeMonitor.java b/src/main/java/com/fr/plugin/it/config/simple/DemoInitializeMonitor.java
new file mode 100644
index 0000000..b542cfb
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/config/simple/DemoInitializeMonitor.java
@@ -0,0 +1,22 @@
+package com.fr.plugin.it.config.simple;
+
+import com.fr.plugin.context.PluginContext;
+import com.fr.plugin.it.config.simple.account.PluginSimpleConfig;
+import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor;
+
+/**
+ * @author richie
+ * @version 10.0
+ * Created by richie on 2018-12-04
+ */
+public class DemoInitializeMonitor extends AbstractPluginLifecycleMonitor {
+ @Override
+ public void afterRun(PluginContext pluginContext) {
+ PluginSimpleConfig.getInstance();
+ }
+
+ @Override
+ public void beforeStop(PluginContext pluginContext) {
+
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/config/simple/PluginInitializeFilterBridge.java b/src/main/java/com/fr/plugin/it/config/simple/PluginInitializeFilterBridge.java
new file mode 100644
index 0000000..6fee46a
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/config/simple/PluginInitializeFilterBridge.java
@@ -0,0 +1,23 @@
+package com.fr.plugin.it.config.simple;
+
+import com.fr.decision.fun.impl.AbstractEmbedRequestFilterProvider;
+import com.fr.plugin.it.config.simple.account.PluginSimpleConfig;
+
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class PluginInitializeFilterBridge extends AbstractEmbedRequestFilterProvider {
+
+ @Override
+ public void init(FilterConfig filterConfig) {
+ PluginSimpleConfig.getInstance();
+ }
+
+ @Override
+ public void filter(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException {
+
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/config/simple/PluginLocaleFinderBridge.java b/src/main/java/com/fr/plugin/it/config/simple/PluginLocaleFinderBridge.java
new file mode 100644
index 0000000..8134de6
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/config/simple/PluginLocaleFinderBridge.java
@@ -0,0 +1,10 @@
+package com.fr.plugin.it.config.simple;
+
+import com.fr.stable.fun.impl.AbstractLocaleFinder;
+
+public class PluginLocaleFinderBridge extends AbstractLocaleFinder {
+ @Override
+ public String find() {
+ return "conf";
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/config/simple/account/PluginSimpleConfig.java b/src/main/java/com/fr/plugin/it/config/simple/account/PluginSimpleConfig.java
new file mode 100644
index 0000000..702a5cf
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/config/simple/account/PluginSimpleConfig.java
@@ -0,0 +1,112 @@
+package com.fr.plugin.it.config.simple.account;
+
+import com.fr.config.*;
+import com.fr.config.holder.Conf;
+import com.fr.config.holder.factory.Holders;
+import com.fr.intelli.record.Focus;
+import com.fr.intelli.record.Original;
+import com.fr.record.analyzer.EnableMetrics;
+
+@Visualization(category = "流程接口配置")
+@EnableMetrics
+public class PluginSimpleConfig extends DefaultConfiguration {
+
+ private static volatile PluginSimpleConfig config = null;
+
+ @Focus(id="com.fr.plugin.it.config.simple", text = "流程接口配置", source = Original.PLUGIN)
+ public static PluginSimpleConfig getInstance() {
+ if (config == null) {
+ config = ConfigContext.getConfigInstance(PluginSimpleConfig.class);
+ }
+ return config;
+ }
+
+ @Identifier(value = "start", name = "启动流程接口", description = "StartWorkflow", status = Status.SHOW)
+ private Conf start = Holders.simple("http://192.168.18.71:8010/Portal/webServices/rfbpmservice.asmx/StartWorkflow");
+
+ @Identifier(value = "return1", name = "驳回工作任务接口", description = "ReturnWorkItem", status = Status.SHOW)
+ private Conf return1 = Holders.simple("http://192.168.18.71:8010/Portal/webServices/rfbpmservice.asmx/ReturnWorkItem");
+
+ @Identifier(value = "returnToStart", name = "驳回工作任务到开始接口", description = "ReturnWorkflowToStart", status = Status.SHOW)
+ private Conf returnToStart = Holders.simple("http://192.168.18.71:8010/Portal/webServices/rfbpmservice.asmx/ReturnWorkflowToStart");
+
+ @Identifier(value = "submit", name = "提交工作任务接口", description = "SubmitWorkItem", status = Status.SHOW)
+ private Conf submit = Holders.simple("http://192.168.18.71:8010/Portal/webServices/rfbpmservice.asmx/SubmitWorkItem");
+
+ @Identifier(value = "cancel", name = "批量取消流程接口", description = "CancelInstances", status = Status.SHOW)
+ private Conf cancel = Holders.simple("http://192.168.18.71:8010/Portal/webServices/rfbpmservice.asmx/CancelInstances");
+
+ @Identifier(value = "cancelWithRemark", name = "取消流程接口", description = "CancelInstanceWithRemark", status = Status.SHOW)
+ private Conf cancelWithRemark = Holders.simple("http://192.168.18.71:8010/Portal/webServices/rfbpmservice.asmx/CancelInstanceWithRemark");
+
+ @Identifier(value = "restart", name = "重新激活流程接口", description = "ReStartWorkflow", status = Status.SHOW)
+ private Conf restart = Holders.simple("http://192.168.18.71:8010/Portal/webServices/rfbpmservice.asmx/ReStartWorkflow");
+
+ public String getCancelWithRemark() {
+ return cancelWithRemark.get();
+ }
+
+ public void setCancelWithRemark(String url) {
+ this.cancelWithRemark.set(url);
+ }
+
+ public String getReStart() {
+ return restart.get();
+ }
+
+ public void setReStart(String url) {
+ this.restart.set(url);
+ }
+
+ public String getStart() {
+ return start.get();
+ }
+
+ public void setStart(String url) {
+ this.start.set(url);
+ }
+
+ public String getReturn1() {
+ return return1.get();
+ }
+
+ public void setReturn1(String url) {
+ this.return1.set(url);
+ }
+
+ public String getReturnToStart() {
+ return returnToStart.get();
+ }
+
+ public void setReturnToStart(String url) {
+ this.returnToStart.set(url);
+ }
+
+ public String getSubmit() {
+ return submit.get();
+ }
+
+ public void setSubmit(String url) {
+ this.submit.set(url);
+ }
+
+ public String getCancel() {
+ return cancel.get();
+ }
+
+ public void setCancel(String url) {
+ this.cancel.set(url);
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ PluginSimpleConfig cloned = (PluginSimpleConfig) super.clone();
+// cloned.text = (Conf) text.clone();
+// cloned.count = (Conf) count.clone();
+// cloned.price = (Conf) price.clone();
+// cloned.time = (Conf) time.clone();
+// cloned.student = (Conf) student.clone();
+ return cloned;
+ }
+
+}
diff --git a/src/main/java/com/fr/plugin/it/function/Cancel.java b/src/main/java/com/fr/plugin/it/function/Cancel.java
new file mode 100644
index 0000000..ac05b4a
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/function/Cancel.java
@@ -0,0 +1,14 @@
+package com.fr.plugin.it.function;
+
+import com.fr.plugin.it.api.FlowApi;
+import com.fr.script.AbstractFunction;
+import com.fr.stable.exception.FormulaException;
+
+public class Cancel extends AbstractFunction {
+ @Override
+ public Object run(Object[] objects) throws FormulaException {
+ String result = FlowApi.cancel(objects);
+
+ return "{\"code\":\""+result+"\",\"message\":\"\"}";
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/function/CancelWithRemark.java b/src/main/java/com/fr/plugin/it/function/CancelWithRemark.java
new file mode 100644
index 0000000..a2d5de9
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/function/CancelWithRemark.java
@@ -0,0 +1,14 @@
+package com.fr.plugin.it.function;
+
+import com.fr.plugin.it.api.FlowApi;
+import com.fr.script.AbstractFunction;
+import com.fr.stable.exception.FormulaException;
+
+public class CancelWithRemark extends AbstractFunction {
+ @Override
+ public Object run(Object[] objects) throws FormulaException {
+ String result = FlowApi.cancelWithRemark(objects);
+
+ return "{\"code\":\""+result+"\",\"message\":\"\"}";
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/function/Restart.java b/src/main/java/com/fr/plugin/it/function/Restart.java
new file mode 100644
index 0000000..28f6f4f
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/function/Restart.java
@@ -0,0 +1,14 @@
+package com.fr.plugin.it.function;
+
+import com.fr.plugin.it.api.FlowApi;
+import com.fr.script.AbstractFunction;
+import com.fr.stable.exception.FormulaException;
+
+public class Restart extends AbstractFunction {
+ @Override
+ public Object run(Object[] objects) throws FormulaException {
+ String result = FlowApi.restart(objects);
+
+ return "{\"code\":\""+result+"\",\"message\":\"\"}";
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/function/Return.java b/src/main/java/com/fr/plugin/it/function/Return.java
new file mode 100644
index 0000000..89542e3
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/function/Return.java
@@ -0,0 +1,15 @@
+package com.fr.plugin.it.function;
+
+import com.fr.json.JSONObject;
+import com.fr.plugin.it.api.FlowApi;
+import com.fr.script.AbstractFunction;
+import com.fr.stable.exception.FormulaException;
+
+public class Return extends AbstractFunction {
+ @Override
+ public Object run(Object[] objects) throws FormulaException {
+ String result = FlowApi.return1(objects);
+
+ return "{\"code\":\""+result+"\",\"message\":\"\"}";
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/function/ReturnToStart.java b/src/main/java/com/fr/plugin/it/function/ReturnToStart.java
new file mode 100644
index 0000000..f05485f
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/function/ReturnToStart.java
@@ -0,0 +1,14 @@
+package com.fr.plugin.it.function;
+
+import com.fr.plugin.it.api.FlowApi;
+import com.fr.script.AbstractFunction;
+import com.fr.stable.exception.FormulaException;
+
+public class ReturnToStart extends AbstractFunction {
+ @Override
+ public Object run(Object[] objects) throws FormulaException {
+ String result = FlowApi.returnToStart(objects);
+
+ return "{\"code\":\""+result+"\",\"message\":\"\"}";
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/function/StartFlow.java b/src/main/java/com/fr/plugin/it/function/StartFlow.java
new file mode 100644
index 0000000..3eb480b
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/function/StartFlow.java
@@ -0,0 +1,25 @@
+package com.fr.plugin.it.function;
+
+import com.fr.json.JSONObject;
+import com.fr.plugin.it.api.FlowApi;
+import com.fr.plugin.it.utils.ResponseUtils;
+import com.fr.plugin.it.utils.Utils;
+import com.fr.script.AbstractFunction;
+import com.fr.stable.exception.FormulaException;
+
+public class StartFlow extends AbstractFunction {
+ @Override
+ public Object run(Object[] objects) throws FormulaException {
+ String result = FlowApi.startFlow(objects);
+
+ if(Utils.isNullStr(result)){
+ return "{\"code\":\"false\",\"message\":\"开启流程失败\"}";
+ }
+
+ JSONObject resultJSON = new JSONObject(result);
+ boolean success = resultJSON.getBoolean("Success");
+ String msg = resultJSON.getString("Message");
+
+ return "{\"code\":\""+success+"\",\"message\":\""+msg+"\"}";
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/function/Submit.java b/src/main/java/com/fr/plugin/it/function/Submit.java
new file mode 100644
index 0000000..0bbf653
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/function/Submit.java
@@ -0,0 +1,14 @@
+package com.fr.plugin.it.function;
+
+import com.fr.plugin.it.api.FlowApi;
+import com.fr.script.AbstractFunction;
+import com.fr.stable.exception.FormulaException;
+
+public class Submit extends AbstractFunction {
+ @Override
+ public Object run(Object[] objects) throws FormulaException {
+ String result = FlowApi.submit(objects);
+
+ return "{\"code\":\""+result+"\",\"message\":\"\"}";
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/handler/ExtendAttrHandlerProvider.java b/src/main/java/com/fr/plugin/it/handler/ExtendAttrHandlerProvider.java
new file mode 100644
index 0000000..f45b66c
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/handler/ExtendAttrHandlerProvider.java
@@ -0,0 +1,13 @@
+package com.fr.plugin.it.handler;
+
+import com.fr.decision.fun.HttpHandler;
+import com.fr.decision.fun.impl.AbstractHttpHandlerProvider;
+
+public class ExtendAttrHandlerProvider extends AbstractHttpHandlerProvider {
+ @Override
+ public HttpHandler[] registerHandlers() {
+ return new HttpHandler[]{
+ new FlowOperate()
+ };
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/handler/FlowOperate.java b/src/main/java/com/fr/plugin/it/handler/FlowOperate.java
new file mode 100644
index 0000000..4a5b7a6
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/handler/FlowOperate.java
@@ -0,0 +1,176 @@
+package com.fr.plugin.it.handler;
+
+import com.fr.decision.fun.impl.BaseHttpHandler;
+import com.fr.json.JSONObject;
+import com.fr.plugin.it.api.FlowApi;
+import com.fr.plugin.it.utils.ResponseUtils;
+import com.fr.plugin.it.utils.Utils;
+import com.fr.plugin.transform.FunctionRecorder;
+import com.fr.third.springframework.web.bind.annotation.RequestMethod;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@FunctionRecorder
+public class FlowOperate extends BaseHttpHandler {
+
+
+ public FlowOperate() {
+ }
+
+ @Override
+ public RequestMethod getMethod() {
+ return RequestMethod.GET;
+ }
+
+ @Override
+ public String getPath() {
+ return "/flowOperate";
+ }
+
+ @Override
+ public boolean isPublic() {
+ return true;
+ }
+
+ @Override
+ public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception {
+ String operateName = req.getParameter("operateName");
+
+ if("startWorkflow".equals(operateName)){
+ Object[] param = new Object[5];
+ String workflowCode = req.getParameter("workflowCode");
+ String userCode = req.getParameter("userCode");
+ String finishStart = req.getParameter("finishStart");
+ String jsonDataItemsStr = req.getParameter("jsonDataItems");
+ String subJsonDataItems = req.getParameter("subJsonDataItems");
+
+
+ param[0] =workflowCode;
+ param[1] =userCode;
+ param[2] =finishStart;
+ param[3] =jsonDataItemsStr;
+ param[4] = subJsonDataItems;
+
+ String result = FlowApi.startFlow(param);
+
+ if(Utils.isNullStr(result)){
+ ResponseUtils.failedResponse(res,"流程操作失败(500)!");
+ return ;
+ }
+
+ JSONObject json = new JSONObject(result);
+ boolean success = json.getBoolean("Success");
+ String msg = json.getString("Message");
+
+ if(success){
+ ResponseUtils.successResponse(res,msg);
+ }else{
+ ResponseUtils.failedResponse(res,msg);
+ }
+
+ }
+ else if("returnWorkItem".equals(operateName)){
+ Object[] param = new Object[4];
+ String userCode = req.getParameter("userCode");
+ String workItemId = req.getParameter("workItemId");
+ String commentText = req.getParameter("commentText");
+
+ param[0] =userCode;
+ param[1] =workItemId;
+ param[2] =commentText;
+
+ String result = FlowApi.return1(param);
+ if(Utils.isNullStr(result)){
+ ResponseUtils.failedResponse(res,"流程操作失败(500)!");
+ return ;
+ }
+ ResponseUtils.successResponse(res,result);
+ }
+ else if("returnWorkflowToStart".equals(operateName)){
+ Object[] param = new Object[4];
+ String workItemId = req.getParameter("workItemId");
+ String commentText = req.getParameter("commentText");
+
+ param[0] =workItemId;
+ param[1] =commentText;
+
+ String result = FlowApi.returnToStart(param);
+ if(Utils.isNullStr(result)){
+ ResponseUtils.failedResponse(res,"流程操作失败(500)!");
+ return ;
+ }
+ ResponseUtils.successResponse(res,result);
+ }
+ else if("submitWorkItem".equals(operateName)){
+ Object[] param = new Object[4];
+ String userCode = req.getParameter("userCode");
+ String workItemId = req.getParameter("workItemId");
+ String commentText = req.getParameter("commentText");
+ String approval = req.getParameter("approval");
+
+ param[0] =userCode;
+ param[1] =workItemId;
+ param[2] =commentText;
+ param[3] =approval;
+
+ String result = FlowApi.submit(param);
+ if(Utils.isNullStr(result)){
+ ResponseUtils.failedResponse(res,"流程操作失败(500)!");
+ return ;
+ }
+ ResponseUtils.successResponse(res,result);
+ }
+ else if("cancelInstances".equals(operateName)){
+ Object[] param = new Object[4];
+ String userCode = req.getParameter("userCode");
+ String sequenceNos = req.getParameter("instanceId");
+
+ param[0] =userCode;
+ param[1] =sequenceNos;
+
+ String result = FlowApi.cancel(param);
+ if(Utils.isNullStr(result)){
+ ResponseUtils.failedResponse(res,"流程操作失败(500)!");
+ return ;
+ }
+ ResponseUtils.successResponse(res,result);
+ }
+ else if("cancelInstanceWithRemark".equals(operateName)){
+ Object[] param = new Object[3];
+ String userCode = req.getParameter("userCode");
+ String sequenceNos = req.getParameter("instanceId");
+ String remark = req.getParameter("remark");
+
+ param[0] =userCode;
+ param[1] =sequenceNos;
+ param[2] =remark;
+
+ String result = FlowApi.cancelWithRemark(param);
+ if(Utils.isNullStr(result)){
+ ResponseUtils.failedResponse(res,"流程操作失败(500)!");
+ return ;
+ }
+ ResponseUtils.successResponse(res,result);
+ }
+ else if("reStartWorkflow".equals(operateName)){
+ Object[] param = new Object[2];
+ String userCode = req.getParameter("instanceId");
+ String sequenceNos = req.getParameter("activityCode");
+
+ param[0] =userCode;
+ param[1] =sequenceNos;
+
+ String result = FlowApi.restart(param);
+ if(Utils.isNullStr(result)){
+ ResponseUtils.failedResponse(res,"流程操作失败(500)!");
+ return ;
+ }
+ ResponseUtils.successResponse(res,result);
+ }
+ }
+
+
+
+
+}
+
diff --git a/src/main/java/com/fr/plugin/it/handler/URLAliasProvide.java b/src/main/java/com/fr/plugin/it/handler/URLAliasProvide.java
new file mode 100644
index 0000000..99d327b
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/handler/URLAliasProvide.java
@@ -0,0 +1,14 @@
+package com.fr.plugin.it.handler;
+
+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 URLAliasProvide extends AbstractURLAliasProvider {
+ @Override
+ public URLAlias[] registerAlias() {
+ return new URLAlias[]{
+ URLAliasFactory.createPluginAlias("/flowOperate","/flowOperate",true),
+ };
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/test/Test.java b/src/main/java/com/fr/plugin/it/test/Test.java
new file mode 100644
index 0000000..3644f4b
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/test/Test.java
@@ -0,0 +1,80 @@
+package com.fr.plugin.it.test;
+
+import com.fr.json.JSONObject;
+import com.fr.plugin.it.utils.HttpUtils;
+import com.fr.plugin.it.utils.JDBCUtil;
+import com.fr.plugin.it.utils.XMLUtils;
+import com.sun.media.jfxmediaimpl.HostUtils;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class Test {
+ public static void main(String[] args) {
+// String xml = "\n" +
+// "\n" +
+// " true\n" +
+// " \n" +
+// " 3b61681d-f164-45d9-84f0-7b0e40bb21b9\n" +
+// " {\"InstanceId\":\"3b61681d-f164-45d9-84f0-7b0e40bb21b9\",\"WorkItemID\":\"\"}\n" +
+// " \n" +
+// "";
+//
+ String xml3 = "\n" +
+ "true";
+//
+// String a = XMLUtils.xmlToList2(xml3);
+// System.out.println(a);
+
+// String xml2 = "\n" +
+// "{\"Success\":true,\"InstanceID\":\"da7a73f8-be3c-4f62-9a7d-8307db321420\",\"Message\":\"流程实例启动成功!\",\"WorkItemID\":\"\",\"WorkItemUrl\":\"\",\"SequenceNO\":\"20210000919399\"}";
+
+ String result2 = XMLUtils.xmlToList(xml3);
+
+ System.out.println(result2);
+
+//
+// System.out.println(result2);
+// JSONObject json = new JSONObject(result2);
+// boolean success = json.getBoolean("Success");
+// String msg = json.getString("Message");
+//
+// System.out.println(msg);
+// String[] a = new String[]{"1","2","3","4"};
+// String field = "subMITData3";
+// String value = "'a'";
+// String fieldStr = "SUBMITDATA";
+// int count = 4;
+// for(String b : a){
+// field+= ","+fieldStr + count;
+// value +=",'"+b+"'";
+// count ++;
+// }
+//
+// System.out.println(field);
+// System.out.println(value);
+// String sql = "insert into RF_BPM_JYSGZ_TRIGGERLOG(ID,BPM_TYPE,YEARMONTH,STARTTIME,IS_SUCCESS,SUBMIT_DATA1,SUBMIT_DATA2,SUBMIT_DATA3,SUBMIT_DATA4,SUBMIT_DATA5,BACK_DATA1,BACK_DATA2,BACK_DATA3,BACK_DATA4,BACK_DATA5) values('578c2b8b-5c20-49ef-bffe-2bd0577e8a49','startWorkflow','202105',sysdate,'N','010101','erpex1','true','','','false','','流程启动失败,流程模板不存在,模板编码:010101。','','')";
+// JDBCUtil.update(sql);
+// String url = "http://192.168.18.71:8010/Portal/webServices/commonwebservice.asmx/StartWorkflow";
+// Map param = new HashMap();
+// param.put("workflowCode","workflowCode");
+// param.put("userCode","workflowCode");
+// param.put("finishStart","true");
+// param.put("jsonDataItems","workflowCode");
+// param.put("subJsonDataItems","workflowCode");
+//
+// String result = HttpUtils.HttpPostWWWForm(url,null,param);
+//
+// String a = XMLUtils.xmlToList(result);
+// JSONObject json = new JSONObject(a);
+// System.out.println(result);
+//
+// String xml = "\n" +
+// "false";
+//
+// System.out.println(XMLUtils.xmlToList(xml));
+// String a = "http://192.168.243.237:8075/webroot/decision";
+// System.out.println(a.contains("url/mobile"));
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/utils/DateUtilSelf.java b/src/main/java/com/fr/plugin/it/utils/DateUtilSelf.java
new file mode 100644
index 0000000..45e7ad3
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/utils/DateUtilSelf.java
@@ -0,0 +1,227 @@
+package com.fr.plugin.it.utils;
+
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+public class DateUtilSelf {
+
+ /**
+ * 日期转换为日期字符串
+ * @param date
+ * @param formatStr
+ * @return String
+ */
+ public static String DateToString(Date date,String formatStr) {
+ SimpleDateFormat sdf = new SimpleDateFormat(formatStr);
+ String dateStr = sdf.format(date).toString();
+
+ return dateStr;
+ }
+
+ /**
+ * 日期字符串转换日期
+ * @param dateStr
+ * @param formatStr
+ * @return Date
+ */
+ public static Date strToDate(String dateStr,String formatStr){
+ SimpleDateFormat sdf = new SimpleDateFormat(formatStr);
+ Date date = null;
+
+ try {
+ date = sdf.parse(dateStr);
+ }
+ catch(Exception e) {
+ }
+
+ return date;
+ }
+
+ /**
+ * Date转Timestamp
+ * @param date
+ * @return
+ */
+ public static Timestamp dateToTimestamp(Date date) {
+ Date transDate = DateUtilSelf.strToDate(DateUtilSelf.DateToString(date, "yyyy-MM-dd hh:mm:ss"),"yyyy-MM-dd hh:mm:ss");
+
+ Timestamp timestamp = new Timestamp(transDate.getTime());
+ return timestamp;
+ }
+
+ /**
+ * Date字符串转Timestamp
+ * @param dateStr
+ * @param format
+ * @return
+ */
+ public static Timestamp strToTimestamp(String dateStr,String format) {
+ Date date = strToDate(dateStr,format);
+ Timestamp timestamp = new Timestamp(date.getTime());
+ return timestamp;
+ }
+
+ /**
+ * 获取两个日期字符串之间的天数
+ * @param startDateStr
+ * @param endDateStr
+ * @param formatStr
+ * @return
+ */
+ public static int getDays(String startDateStr,String endDateStr,String formatStr) {
+
+ Date startDate = strToDate(startDateStr,formatStr);
+ Date endDate = strToDate(endDateStr,formatStr);
+
+ long startTime = startDate.getTime();
+ long endTime = endDate.getTime();
+
+ int days = (int) ((endTime - startTime)/(60*60*24*1000));
+
+ return days;
+ }
+
+ /**
+ * 获取给定时间之前之后的时间
+ * @param type
+ * @param dateStr
+ * @param count
+ * @param formatStr
+ * @return
+ */
+ public static String getAfterDateStr(int type,String dateStr,int count,String formatStr) {
+ Date startDate = strToDate(dateStr,formatStr);
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(startDate);
+
+ calendar.add(type, count);
+
+ String endDateStr = DateToString(calendar.getTime(),formatStr);
+
+ return endDateStr;
+ }
+
+ /**
+ * 获取给定时间之前之后的时间
+ * @param type
+ * @param date
+ * @param count
+ * @param formatStr
+ * @return
+ */
+ public static String getAfterDateStr(int type,Date date,int count,String formatStr) {
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+
+ calendar.add(type, count);
+
+ String endDateStr = DateToString(calendar.getTime(),formatStr);
+
+ return endDateStr;
+ }
+
+ /**
+ * 获取给定时间之前之后的时间
+ * @param type
+ * @param date
+ * @param count
+ * @return
+ */
+ public static Date getAfterDateStr(int type,Date date,int count) {
+ Calendar dateResult = Calendar.getInstance();
+ dateResult.setTime(date);
+ dateResult.add(type, count);
+ return dateResult.getTime();
+ }
+
+ /**
+ * 时间戳转日期
+ * @param timestamp
+ * @return
+ */
+ public static Date timestampToDate(Timestamp timestamp) {
+ Date date = new Date(timestamp.getTime());
+
+ return date;
+ }
+
+ /**
+ * 时间戳转时间字符串
+ * @param timestamp
+ * @param format 日期格式
+ * @return
+ */
+ public static String timestampToStr(Timestamp timestamp,String format) {
+ Date date = timestampToDate(timestamp);
+
+ String timeStr = DateToString(date, format);
+
+ return timeStr;
+ }
+
+ /**
+ * 获取所给日期length天内每一天的日期
+ * @param date 所给日期(yyyy-MM-dd)
+ * @param length 长度
+ * @return
+ */
+ public static List getDateList(String date,int length){
+ List dateList = new ArrayList();
+ String format = "yyyy-MM-dd";
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ //获取length天后的日期
+
+ String targetDate = getAfterDateStr(Calendar.DATE,date,length,format);
+
+ Date start = null;
+ Date end = null;
+
+ if(length >= 0) {
+ start = strToDate(date,format);
+ end = strToDate(targetDate,format);
+ }else {
+ start = strToDate(targetDate,format);
+ end = strToDate(date,format);
+ }
+
+ Calendar calBegin = Calendar.getInstance();
+ calBegin.setTime(start);
+ Calendar calEnd = Calendar.getInstance();
+ calEnd.setTime(end);
+
+ while (end.after(calBegin.getTime())) {
+ calBegin.add(Calendar.DATE, 1);
+ String dayStr = sdf.format(calBegin.getTime());
+ dateList.add(dayStr);
+ }
+
+ return dateList;
+ }
+
+ /**
+ * 比较startDate是否在endDate之前
+ * @param startDate
+ * @param endDate
+ * @param format
+ * @return 0 两个日期相等 <0 开始日期在结束日期之前 >0 开始日期在结束日期之后
+ */
+ public static int comparisonDate(String startDate,String endDate,String format) {
+ Date start = strToDate(startDate,format);
+ Date end = strToDate(endDate,format);
+
+ return start.compareTo(end);
+ }
+
+ //获取当前日期年、月、日、时、分、秒
+ public static int getCount(int type){
+ Calendar calendar = Calendar.getInstance();
+
+ return calendar.get(type);
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/utils/FRUtils.java b/src/main/java/com/fr/plugin/it/utils/FRUtils.java
new file mode 100644
index 0000000..79eb8e5
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/utils/FRUtils.java
@@ -0,0 +1,158 @@
+package com.fr.plugin.it.utils;
+
+import com.fr.decision.authority.AuthorityContext;
+import com.fr.decision.authority.data.User;
+import com.fr.decision.webservice.login.LogInOutResultInfo;
+import com.fr.decision.webservice.utils.DecisionServiceConstants;
+import com.fr.decision.webservice.v10.login.LoginService;
+import com.fr.decision.webservice.v10.login.event.LogInOutEvent;
+import com.fr.decision.webservice.v10.user.UserService;
+import com.fr.event.EventDispatcher;
+import com.fr.log.FineLoggerFactory;
+import com.fr.stable.StringUtils;
+import com.fr.stable.query.QueryFactory;
+import com.fr.stable.query.restriction.RestrictionFactory;
+import com.fr.web.utils.WebUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.util.List;
+
+public class FRUtils {
+ /**
+ * 判断用户是否存在
+ * @param userName
+ * @return
+ */
+ public static boolean isUserExist(String userName){
+ if (StringUtils.isEmpty(userName)) {
+ return false;
+ } else {
+ try {
+ List var1 = AuthorityContext.getInstance().getUserController().find(QueryFactory.create().addRestriction(RestrictionFactory.eq("userName", userName)));
+ return var1 != null && !var1.isEmpty();
+ } catch (Exception var2) {
+ FineLoggerFactory.getLogger().error(var2.getMessage());
+ return false;
+ }
+ }
+ }
+
+ /**
+ * 判断是否登录FR
+ * @param req
+ * @return
+ */
+ public static boolean isLogin(HttpServletRequest req){
+ return LoginService.getInstance().isLogged(req);
+ }
+
+ /**
+ * 帆软登录
+ * @param httpServletRequest
+ * @param httpServletResponse
+ * @param userName
+ * @param url
+ */
+ public static void login(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,String userName,String url){
+
+ FineLoggerFactory.getLogger().info("FRLOG:用户名:"+userName);
+ FineLoggerFactory.getLogger().info("FRLOG:跳转链接:"+url);
+
+
+ //判断用户名是否为空
+ if(!Utils.isNullStr(userName)){
+ if(isUserExist(userName)){
+ String FRToken = "";
+
+ try {
+ HttpSession session = httpServletRequest.getSession(true);
+
+ FRToken = LoginService.getInstance().login(httpServletRequest, httpServletResponse, userName);
+
+ httpServletRequest.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME,FRToken);
+
+ session.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME, FRToken);
+ EventDispatcher.fire(LogInOutEvent.LOGIN,new LogInOutResultInfo(httpServletRequest,httpServletResponse,userName,true));
+ FineLoggerFactory.getLogger().info("FRLOG:登陆成功!");
+
+ if(!Utils.isNullStr(url)){
+ httpServletResponse.sendRedirect(url);
+ }
+ } catch (Exception e) {
+ ResponseUtils.failedResponse(httpServletResponse,"登录异常,请联系管理员!");
+ FineLoggerFactory.getLogger().info("FRLOG:登录异常,请联系管理员!");
+ FineLoggerFactory.getLogger().info("FRLOGException:"+e.getMessage());
+ }
+ }else{
+ ResponseUtils.failedResponse(httpServletResponse,"用户在报表系统中不存在!");
+ FineLoggerFactory.getLogger().info("FRLOG:用户在报表系统中不存在!");
+ }
+ }else{
+ ResponseUtils.failedResponse(httpServletResponse,"用户名不能为空!");
+ FineLoggerFactory.getLogger().info("FRLOG:用户名不能为空!");
+ }
+ }
+
+ /**
+ *
+ * @param httpServletRequest
+ * @param httpServletResponse
+ */
+ public static void logout(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse)
+ {
+ if(!isLogin(httpServletRequest)){
+ return ;
+ }
+
+ try {
+ LoginService.getInstance().logout(httpServletRequest,httpServletResponse);
+ } catch (Exception e) {
+ ResponseUtils.failedResponse(httpServletResponse,"登出异常,请联系管理员!");
+ FineLoggerFactory.getLogger().info("FRLOG:登出异常,请联系管理员!");
+ FineLoggerFactory.getLogger().info("FRLOGException:"+e.getMessage());
+ }
+ }
+
+ /**
+ * 打印FR日志
+ * @param message
+ */
+ public static void FRLogInfo(String message){
+ FineLoggerFactory.getLogger().info("FRLOG:"+message);
+ }
+
+ /**
+ * 根据用户名获取用户信息
+ * @param userName
+ * @return
+ */
+ public static User getFRUserByUserName(String userName){
+ try {
+ return UserService.getInstance().getUserByUserName(userName);
+ } catch (Exception e) {
+ FRLogInfo("获取用户信息异常:"+e.getMessage());
+ }
+
+ return null;
+ }
+
+ /**
+ * 解密FR密码
+ * @param password
+ * @return
+ */
+// public static String decryptFRPsd(String password){
+// FRLogInfo("解密密码:"+password);
+// return TransmissionTool.decrypt(password);
+// }
+
+ /**
+ * 获取带参数的访问链接
+ * @return
+ */
+ public static String getAllUrl(HttpServletRequest httpServletRequest){
+ return WebUtils.getOriginalURL(httpServletRequest);
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/utils/HttpUtils.java b/src/main/java/com/fr/plugin/it/utils/HttpUtils.java
new file mode 100644
index 0000000..cd1ce09
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/utils/HttpUtils.java
@@ -0,0 +1,232 @@
+package com.fr.plugin.it.utils;
+
+import com.fr.log.FineLoggerFactory;
+import com.fr.third.org.apache.http.HttpEntity;
+import com.fr.third.org.apache.http.HttpResponse;
+import com.fr.third.org.apache.http.HttpStatus;
+import com.fr.third.org.apache.http.NameValuePair;
+import com.fr.third.org.apache.http.client.CookieStore;
+import com.fr.third.org.apache.http.client.entity.UrlEncodedFormEntity;
+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.entity.StringEntity;
+import com.fr.third.org.apache.http.impl.client.BasicCookieStore;
+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.impl.cookie.BasicClientCookie;
+import com.fr.third.org.apache.http.message.BasicNameValuePair;
+import com.fr.third.org.apache.http.ssl.SSLContexts;
+import com.fr.third.org.apache.http.ssl.TrustStrategy;
+import com.fr.third.org.apache.http.util.EntityUtils;
+
+import javax.net.ssl.SSLContext;
+import javax.servlet.http.Cookie;
+import java.io.UnsupportedEncodingException;
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class HttpUtils {
+ /**
+ * httpGet请求
+ * @param url
+ * @return
+ */
+ public static String get(String url,Cookie[] cookies){
+ FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--url:"+url);
+
+ //创建httpClient
+ CloseableHttpClient httpclient = createHttpClient(cookies);
+
+ HttpGet getMethod = new HttpGet(url);
+
+ try {
+ HttpResponse response = httpclient.execute(getMethod);
+
+ FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--status:"+response.getStatusLine().getStatusCode());
+
+ if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+ HttpEntity entity = response.getEntity();
+ String returnResult = EntityUtils.toString(entity, "utf-8");
+
+ FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--returnResult:"+returnResult);
+
+ return returnResult;
+ }
+ } catch (Exception e) {
+ FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--exception:"+e.getMessage());
+ }
+
+ return "";
+ }
+
+ /**
+ * HttpPost请求
+ * @param postMethod
+ * @return
+ */
+ private static String HttpPost(HttpPost postMethod){
+ CloseableHttpClient httpclient = createHttpClient(null);
+
+ try {
+ HttpResponse response = httpclient.execute(postMethod);
+
+ FineLoggerFactory.getLogger().info("FRLOG:HttpPost:status:"+response.getStatusLine().getStatusCode());
+
+ if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+ HttpEntity entity = response.getEntity();
+ String returnResult = EntityUtils.toString(entity, "utf-8");
+
+ FineLoggerFactory.getLogger().info("FRLOG:HttpPost:returnResult:"+returnResult);
+
+ return returnResult;
+ }
+ } catch (Exception e) {
+ FineLoggerFactory.getLogger().info("FRLOG:HttpPost:exception:"+e.getMessage());
+ }
+
+ return "";
+ }
+
+ public static String HttpPostXML(String url, String xmlParam){
+ FineLoggerFactory.getLogger().info("FRLOG:HttpPostXML:url:"+url);
+
+ HttpPost postMethod = new HttpPost(url);
+
+ postMethod.setHeader("Content-type", "text/html");
+ HttpEntity entity2 = null;
+ try {
+ entity2 = new StringEntity(xmlParam);
+ } catch (UnsupportedEncodingException e) {
+ FineLoggerFactory.getLogger().info("FRLOG:HttpPostXML:参数异常:"+e.getMessage());
+ return "";
+ }
+
+ postMethod.setEntity(entity2);
+
+ return HttpPost(postMethod);
+ }
+
+ public static String HttpPostJson(String url, String param,Map header){
+ FineLoggerFactory.getLogger().info("FRLOG:HttpPostJSON:url:"+url);
+
+ HttpPost postMethod = new HttpPost(url);
+
+ postMethod.setHeader("Content-Type","application/json");
+
+ if(header != null && header.size() > 0){
+ Set keySet = header.keySet();
+
+ for(String key : keySet){
+ postMethod.setHeader(key,header.get(key));
+ }
+ }
+
+ if(!Utils.isNullStr(param)){
+ HttpEntity entity2 = null;
+ try {
+ entity2 = new StringEntity(param);
+ } catch (UnsupportedEncodingException e) {
+ FineLoggerFactory.getLogger().info("FRLOG:HttpPostJSON:参数异常:"+e.getMessage());
+ return "";
+ }
+
+ postMethod.setEntity(entity2);
+ }
+
+ return HttpPost(postMethod);
+ }
+
+ public static String HttpPostWWWForm(String url, Map header,Map param){
+ FineLoggerFactory.getLogger().info("FRLOG:HttpWWWForm:url:"+url);
+
+ HttpPost postMethod = new HttpPost(url);
+
+ if(header != null && header.size() > 0){
+ FRUtils.FRLogInfo("header:"+header.toString());
+ Set keySet = header.keySet();
+
+ for(String key : keySet){
+ postMethod.setHeader(key,header.get(key));
+ }
+ }
+
+ if(param != null && param.size() > 0){
+ FRUtils.FRLogInfo("param:"+param.toString());
+
+ List params = new ArrayList(param.size());
+
+ for(Map.Entry map : param.entrySet()){
+ params.add(new BasicNameValuePair(map.getKey(), map.getValue()));
+ }
+
+ try {
+ postMethod.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ FineLoggerFactory.getLogger().info("FRLOG:HttpWWWForm:异常:"+e.getMessage());
+ return "";
+ }
+ }
+
+ return HttpPost(postMethod);
+ }
+
+ private static CloseableHttpClient createHttpClient(Cookie[] cookies){
+
+ SSLContext sslContext = null;
+ try {
+ sslContext = SSLContexts.custom().loadTrustMaterial(null, new TrustStrategy() {
+ @Override
+ public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
+ return true;
+ }
+ }).build();
+ } catch (NoSuchAlgorithmException e) {
+ FRUtils.FRLogInfo("createHttpClientException:"+e.getMessage());
+ } catch (KeyManagementException e) {
+ FRUtils.FRLogInfo("createHttpClientException:"+e.getMessage());
+ } catch (KeyStoreException e) {
+ FRUtils.FRLogInfo("createHttpClientException:"+e.getMessage());
+ }
+
+ CloseableHttpClient httpclient = null;
+
+ if(cookies != null && cookies.length > 0){
+ CookieStore cookieStore = cookieToCookieStore(cookies);
+
+ httpclient = HttpClients.custom().setSslcontext(sslContext).
+ setSSLHostnameVerifier(new NoopHostnameVerifier()).setDefaultCookieStore(cookieStore).build();
+ }
+ else{
+ httpclient = HttpClients.custom().setSslcontext(sslContext).
+ setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
+ }
+
+ return httpclient;
+ }
+
+ /**
+ * cookies转cookieStore
+ * @param cookies
+ * @return
+ */
+ public static CookieStore cookieToCookieStore(Cookie[] cookies){
+ CookieStore cookieStore = new BasicCookieStore();
+
+ if(cookies != null && cookies.length>0){
+ for(Cookie cookie : cookies){
+ BasicClientCookie cookie1 = new BasicClientCookie(cookie.getName(), cookie.getValue());
+ cookieStore.addCookie(cookie1);
+ }
+ }
+
+ return cookieStore;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/utils/IOUtils.java b/src/main/java/com/fr/plugin/it/utils/IOUtils.java
new file mode 100644
index 0000000..601ea21
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/utils/IOUtils.java
@@ -0,0 +1,65 @@
+package com.fr.plugin.it.utils;
+
+import java.io.*;
+
+public class IOUtils {
+
+ /**
+ * 将inputStream写入本地文件
+ * @param url
+ * @param inputStream
+ */
+ public static void writeFile(String url, InputStream inputStream){
+ int index;
+ byte[] bytes = new byte[1024];
+ FileOutputStream downloadFile = null ;
+ try {
+ downloadFile = new FileOutputStream(url);
+ while ((index = inputStream.read(bytes)) != -1) {
+ downloadFile.write(bytes, 0, index);
+ downloadFile.flush();
+ }
+ }catch(Exception e){
+ FRUtils.FRLogInfo("Exception:writeFile:"+e.getMessage());
+ }finally {
+ try {
+ inputStream.close();
+ downloadFile.close();
+ }
+ catch (Exception e){
+ FRUtils.FRLogInfo("Exception:writeFile:finally"+e.getMessage());
+ }
+ }
+
+ }
+
+ /**
+ * 字符串转输入流
+ * @param str
+ * @return
+ */
+ public static InputStream strToInputStream(String str){
+ try {
+ return new ByteArrayInputStream(str.getBytes("UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ FRUtils.FRLogInfo("IOUtils-strToInputStream:exception:"+e.getMessage());
+ }
+
+ return null;
+ }
+
+ public static String inputStreamToStr(InputStream inputStream) {
+ StringBuffer stringBuffer = new StringBuffer();
+ byte[] byt = new byte[4096];
+
+ try {
+ for (int i; (i = inputStream.read(byt)) != -1; ) {
+ stringBuffer.append(new String(byt, 0, i));
+ }
+ }catch(Exception e){
+ FRUtils.FRLogInfo("Exception:inputStreamToStr:"+e.getMessage());
+ }
+
+ return stringBuffer.toString();
+ }
+}
diff --git a/src/main/java/com/fr/plugin/it/utils/JDBCUtil.java b/src/main/java/com/fr/plugin/it/utils/JDBCUtil.java
new file mode 100644
index 0000000..2485bf6
--- /dev/null
+++ b/src/main/java/com/fr/plugin/it/utils/JDBCUtil.java
@@ -0,0 +1,143 @@
+package com.fr.plugin.it.utils;
+
+import oracle.jdbc.driver.OracleDriver;
+import java.sql.*;
+import java.util.*;
+
+public class JDBCUtil {
+ private static void release(Connection conn,Statement st,ResultSet rs) {
+ closeRs(rs);
+ closeSt(st);
+ closeConn(conn);
+ }
+
+ private static void closeRs(ResultSet rs) {
+ try {
+ if(rs!=null) {
+ rs.close();
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ rs=null;
+ }
+
+ }
+
+ private static void closeSt(Statement st) {
+ try {
+ if(st!=null) {
+ st.close();
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ st=null;
+ }
+
+ }
+
+ private static void closeConn(Connection conn) {
+ try {
+ if(conn!=null) {
+ conn.close();
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ conn=null;
+ }
+
+ }
+
+ /**
+ * 获取数据库连接
+ * @param url
+ * @param user
+ * @param password
+ * @return
+ */
+ private static Connection getConnection(String url,String user,String password){
+ Connection conn = null;
+
+ try{
+ //oracle
+ DriverManager.registerDriver(new OracleDriver());
+ //sqlService
+ //DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());
+ conn =DriverManager.getConnection(url,user , password);}
+ catch(Exception e){
+ FRUtils.FRLogInfo("获取数据库连接异常:"+e.getMessage());
+ }
+
+ return conn;
+ }
+
+ public static List