Browse Source

open

master
pioneer 2 years ago
commit
d348f539d5
  1. 6
      README.md
  2. BIN
      lib/accessors-smart-2.4.7.jar
  3. BIN
      lib/asm-9.1.jar
  4. BIN
      lib/finekit-10.0.jar
  5. BIN
      lib/json-path-2.7.0.jar
  6. BIN
      lib/json-smart-2.4.7.jar
  7. BIN
      lib/netty-all-4.1.17.jar
  8. 40
      plugin.xml
  9. 19
      src/main/java/com/fr/plugin/xx/submitjob/Constants.java
  10. 39
      src/main/java/com/fr/plugin/xx/submitjob/LocaleFinder.java
  11. 39
      src/main/java/com/fr/plugin/xx/submitjob/SubmitUIBridge.java
  12. 249
      src/main/java/com/fr/plugin/xx/submitjob/bean/JobBean.java
  13. 117
      src/main/java/com/fr/plugin/xx/submitjob/job/AbstractDataSubmitJob.java
  14. 415
      src/main/java/com/fr/plugin/xx/submitjob/job/AbstractDataSubmitTask.java
  15. 115
      src/main/java/com/fr/plugin/xx/submitjob/job/AbstractDataTotalSubmitJob.java
  16. 95
      src/main/java/com/fr/plugin/xx/submitjob/job/DataSubmitTask.java
  17. 41
      src/main/java/com/fr/plugin/xx/submitjob/job/GetSubmitJob.java
  18. 110
      src/main/java/com/fr/plugin/xx/submitjob/job/PostJsonSubmitJob.java
  19. 41
      src/main/java/com/fr/plugin/xx/submitjob/job/PostSubmitJob.java
  20. 62
      src/main/java/com/fr/plugin/xx/submitjob/job/PostTotalSubmitJob.java
  21. 88
      src/main/java/com/fr/plugin/xx/submitjob/job/SoapSubmitJob.java
  22. 81
      src/main/java/com/fr/plugin/xx/submitjob/job/SoapTotalSubmitJob.java
  23. 718
      src/main/java/com/fr/plugin/xx/submitjob/kit/HttpKit.java
  24. 28
      src/main/java/com/fr/plugin/xx/submitjob/request/SubmitControllerBridge.java
  25. 100
      src/main/java/com/fr/plugin/xx/submitjob/request/controller/SubmitJobController.java
  26. 197
      src/main/java/com/fr/plugin/xx/submitjob/ui/DataSubmitConfigPane.java
  27. 60
      src/main/java/com/fr/plugin/xx/submitjob/ui/DataSubmitItems.java
  28. 55
      src/main/java/com/fr/plugin/xx/submitjob/ui/StateItems.java
  29. 30
      src/main/resources/com/fr/plugin/xx/submitjob/locale/lang.properties
  30. 30
      src/main/resources/com/fr/plugin/xx/submitjob/locale/lang_en.properties
  31. 30
      src/main/resources/com/fr/plugin/xx/submitjob/locale/lang_zh_CN.properties

6
README.md

@ -0,0 +1,6 @@
# open-JSD-10036
JSD-10036 在填报提交时,能先完成身份验证\
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\
仅作为开发者学习参考使用!禁止用于任何商业用途!\
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。

BIN
lib/accessors-smart-2.4.7.jar

Binary file not shown.

BIN
lib/asm-9.1.jar

Binary file not shown.

BIN
lib/finekit-10.0.jar

Binary file not shown.

BIN
lib/json-path-2.7.0.jar

Binary file not shown.

BIN
lib/json-smart-2.4.7.jar

Binary file not shown.

BIN
lib/netty-all-4.1.17.jar

Binary file not shown.

40
plugin.xml

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<id>com.fr.plugin.xx.submitjob.ino</id>
<name><![CDATA[填报数据接口提交-INO]]></name>
<active>yes</active>
<version>1.1.12</version>
<env-version>10.0~11.0</env-version>
<jartime>2018-07-31</jartime>
<vendor>fr.open</vendor>
<description><![CDATA[报表填报属性中扩展提交类型,实现提交数据给HTTP接口功能。]]></description>
<change-notes><![CDATA[
[2022-03-21]POB-1658示例接口适配依赖;优化提交方式类加载和国际化处理<br/>
[2021-09-18]适配帆软11.0版本<br/>
[2021-06-03]单元格变更状态去掉修改删除、增加返回报错结果的测试接口。<br/>
[2021-05-21]增加返回结果的报错信息处理功能。<br/>
版本1.0主要功能:<br/>
提供接口参数配置页面,可配置 提交方式、单元格状态、接口url 参数值配置。<br/>
单行填报 HTTP GET 方式提交接口,可设置ur参数值功能。<br/>
单行填报 HTTP POST 方式提交接口,参数处理包括 表单 form-data形式、x-www-form-urlencodeed形式、json形式。<br/>
多行填报 HTTP POST 方式提交接口,参数处理为json形式。<br/>
单行、多行填报 WebService 方式提交接口。<br/>
自定义Body参数、Header参数属性数据支持单元格、函数公式、公式等。<br/>
调用接口返回结果保存到系统消息。<br/>
]]></change-notes>
<main-package>com.fr.plugin.xx.submitjob</main-package>
<prefer-packages>
<prefer-package>com.fanruan.api</prefer-package>
<prefer-package>com.jayway.jsonpath</prefer-package>
</prefer-packages>
<extra-core>
<LocaleFinder class="com.fr.plugin.xx.submitjob.LocaleFinder"/>
</extra-core>
<extra-decision>
<ControllerRegisterProvider class="com.fr.plugin.xx.submitjob.request.SubmitControllerBridge"/>
</extra-decision>
<extra-designer>
<SubmitProvider class="com.fr.plugin.xx.submitjob.SubmitUIBridge"/>
</extra-designer>
<function-recorder class="com.fr.plugin.xx.submitjob.LocaleFinder"/>
</plugin>

19
src/main/java/com/fr/plugin/xx/submitjob/Constants.java

@ -0,0 +1,19 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: Constants
* Author: xx
* Date: 2021/2/21 16:11
*/
package com.fr.plugin.xx.submitjob;
/**
* <Function Description><br>
* <Constants>
*
* @author xx
* @since 1.0.0
*/
public class Constants {
public static final String PLUGIN_ID = "com.fr.plugin.xx.submitjob.ino";
}

39
src/main/java/com/fr/plugin/xx/submitjob/LocaleFinder.java

@ -0,0 +1,39 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: LocaleFinder
* Author: xx
* Date: 2020/8/31 22:19
*/
package com.fr.plugin.xx.submitjob;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.stable.fun.Authorize;
import com.fr.stable.fun.impl.AbstractLocaleFinder;
import static com.fr.plugin.xx.submitjob.Constants.PLUGIN_ID;
/**
* <Function Description><br>
* <LocaleFinder>
*
* @author xx
* @since 1.0.0
*/
@EnableMetrics
@Authorize(callSignKey = PLUGIN_ID)
public class LocaleFinder extends AbstractLocaleFinder {
@Override
@Focus(id = PLUGIN_ID, text = "Plugin-submitjob", source = Original.PLUGIN)
public String find() {
return "com/fr/plugin/xx/submitjob/locale/lang";
}
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
}

39
src/main/java/com/fr/plugin/xx/submitjob/SubmitUIBridge.java

@ -0,0 +1,39 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: SubmitUIBridge
* Author: xx
* Date: 2020/8/31 21:50
*/
package com.fr.plugin.xx.submitjob;
import com.fanruan.api.i18n.I18nKit;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fun.impl.AbstractSubmitProvider;
import com.fr.plugin.xx.submitjob.ui.DataSubmitConfigPane;
/**
* <Function Description><br>
* <SubmitUIBridge>
*
* @author xx
* @since 1.0.0
*/
public class SubmitUIBridge extends AbstractSubmitProvider {
public static final String KEY = "DataSubmitJob";
@Override
public BasicBeanPane appearanceForSubmit() {
return new DataSubmitConfigPane();
}
@Override
public String dataForSubmit() {
return I18nKit.getLocText("Plugin-submitjob_Submit_Data");
}
@Override
public String keyForSubmit() {
return SubmitUIBridge.KEY;
}
}

249
src/main/java/com/fr/plugin/xx/submitjob/bean/JobBean.java

@ -0,0 +1,249 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: JobBean
* Author: xx
* Date: 2021/3/8 20:51
*/
package com.fr.plugin.xx.submitjob.bean;
import com.fr.base.Parameter;
import com.fr.data.DefinedSubmitJob;
import com.fr.data.JobValue;
import com.fr.general.ComparatorUtils;
import com.fr.general.DefaultValues;
import com.fr.general.GeneralContext;
import com.fr.plugin.xx.submitjob.job.AbstractDataSubmitTask;
import com.fr.plugin.xx.submitjob.ui.StateItems;
import com.fr.script.Calculator;
import com.fr.stable.Primitive;
import com.fr.stable.StableUtils;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* <Function Description><br>
* <任务参数JobBean>
*
* @author xx
* @since 1.0.0
*/
public class JobBean {
private Map<String, Object> headerMap;
private Map<String, Object> propertyMap;
private String url;
private String state;
private String bodyContent;
private String errorFlag;
private String successStatus;
private String errorMessageFlag;
public JobBean() {
}
public JobBean(Calculator calculator) {
this.headerMap = calculator.getAttribute(AbstractDataSubmitTask.HEADER_VALUE);
this.propertyMap = calculator.getAttribute(DefinedSubmitJob.PROPERTY_VALUE);
this.url = calculator.getAttribute(AbstractDataSubmitTask.API_URL);
this.state = calculator.getAttribute(AbstractDataSubmitTask.JOB_STATE);
this.bodyContent = calculator.getAttribute(AbstractDataSubmitTask.BODY_CONTENT);
this.errorFlag = calculator.getAttribute(AbstractDataSubmitTask.ERROR_FLAG);
this.successStatus = calculator.getAttribute(AbstractDataSubmitTask.SUCCESS_STATUS);
this.errorMessageFlag = calculator.getAttribute(AbstractDataSubmitTask.ERROR_MESSAGE_FLAG);
}
public JobBean(Calculator calculator, String type) {
this.headerMap = calculator.getAttribute(AbstractDataSubmitTask.HEADER_VALUE);
this.url = calculator.getAttribute(AbstractDataSubmitTask.API_URL);
this.state = calculator.getAttribute(AbstractDataSubmitTask.JOB_STATE);
this.bodyContent = calculator.getAttribute(AbstractDataSubmitTask.BODY_CONTENT);
this.errorFlag = calculator.getAttribute(AbstractDataSubmitTask.ERROR_FLAG);
this.successStatus = calculator.getAttribute(AbstractDataSubmitTask.SUCCESS_STATUS);
this.errorMessageFlag = calculator.getAttribute(AbstractDataSubmitTask.ERROR_MESSAGE_FLAG);
}
public Map<String, String> getHeaders() {
return getSubmitAttribute(this.headerMap);
}
public Map<String, String> getParams() {
return getSubmitAttribute(this.propertyMap);
}
/**
* 提取填报属性值
*/
private Map<String, String> getSubmitAttribute(Map<String, Object> propertyMap) {
Map<String, String> params = new HashMap<String, String>();
for (Map.Entry<String, Object> entry : propertyMap.entrySet()) {
if (entry.getValue() instanceof JobValue) {
JobValue ce = (JobValue) entry.getValue();
if (ce.getValue() instanceof Primitive) {
continue;
}
params.put(entry.getKey(), valueToString(ce.getValue()));
}
}
return params;
}
/**
* jobValue to String
*
* @return
*/
public static String valueToString(Object value) {
String result;
if (value instanceof Date) {
DefaultValues defaultValues = GeneralContext.getDefaultValues();
result = defaultValues.getDateTimeFormat().format(value);
} else if (value instanceof Parameter) {
result = ((Parameter) value).valueToString();
} else if (value instanceof Double) {
result = StableUtils.doubleToString((Double) value);
} else {
result = String.valueOf(value);
}
return result;
}
/**
* 填报属性状态判断
*
* @return
*/
public Boolean isOperationState() {
for (Map.Entry<String, Object> entry : propertyMap.entrySet()) {
if (entry.getValue() instanceof JobValue) {
JobValue ce = (JobValue) entry.getValue();
return isState(ce);
}
}
return false;
}
/**
* 填报属性状态判断
*
* @param jobValue
* @return
*/
public Boolean isState(JobValue jobValue) {
if (ComparatorUtils.equals(state, StateItems.CHANGED)
&& checkChange(jobValue.getState())) {
return true;
} else if (ComparatorUtils.equals(state, StateItems.INSERT)
&& (jobValue.getState().checkInsert() || jobValue.getState().checkDefault())) {
return true;
} else if (ComparatorUtils.equals(state, StateItems.DELETED)
&& (jobValue.getState().checkDeleted() || jobValue.getState().checkDefault())) {
return true;
} else if (ComparatorUtils.equals(state, StateItems.DEFAULT) && jobValue.getState().checkDefault()) {
return true;
}
return false;
}
/**
* 填报属性状态判断
*
* @param jobValue
* @return
*/
public Boolean isStateStrict(JobValue jobValue) {
if (ComparatorUtils.equals(state, StateItems.CHANGED)
&& (jobValue.getState().checkChanged() && !jobValue.getState().checkDeleted())) {
return true;
} else if (ComparatorUtils.equals(state, StateItems.INSERT)
&& jobValue.getState().checkInsert()) {
return true;
} else if (ComparatorUtils.equals(state, StateItems.DELETED)
&& jobValue.getState().checkDeleted()) {
return true;
} else if (ComparatorUtils.equals(state, StateItems.DEFAULT) && jobValue.getState().checkDefault()) {
return true;
}
return false;
}
/**
* 填报判断变更
*
* @return
*/
private boolean checkChange(JobValue.State state) {
if (state.checkChanged() && !state.checkDeleted()) {
return true;
}
if (state.checkDefault()) {
return true;
}
return false;
}
public Map<String, Object> getHeaderMap() {
return headerMap;
}
public void setHeaderMap(Map<String, Object> headerMap) {
this.headerMap = headerMap;
}
public Map<String, Object> getPropertyMap() {
return propertyMap;
}
public void setPropertyMap(Map<String, Object> propertyMap) {
this.propertyMap = propertyMap;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getBodyContent() {
return bodyContent;
}
public void setBodyContent(String bodyContent) {
this.bodyContent = bodyContent;
}
public String getErrorFlag() {
return errorFlag;
}
public void setErrorFlag(String errorFlag) {
this.errorFlag = errorFlag;
}
public String getSuccessStatus() {
return successStatus;
}
public void setSuccessStatus(String successStatus) {
this.successStatus = successStatus;
}
public String getErrorMessageFlag() {
return errorMessageFlag;
}
public void setErrorMessageFlag(String errorMessageFlag) {
this.errorMessageFlag = errorMessageFlag;
}
}

117
src/main/java/com/fr/plugin/xx/submitjob/job/AbstractDataSubmitJob.java

@ -0,0 +1,117 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: AbstractDataSubmitJob
* Author: xx
* Date: 2021/3/11 12:07
*/
package com.fr.plugin.xx.submitjob.job;
import com.fanruan.api.i18n.I18nKit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit;
import com.fr.data.DefinedSubmitJob;
import com.fr.decision.system.bean.message.MessageUrlType;
import com.fr.decision.webservice.v10.message.MessageService;
import com.fr.general.ComparatorUtils;
import com.fr.plugin.xx.submitjob.SubmitUIBridge;
import com.fr.plugin.xx.submitjob.bean.JobBean;
import com.fr.script.Calculator;
import com.fr.stable.StringUtils;
import com.jayway.jsonpath.JsonPath;
import java.util.Map;
/**
* <Function Description><br>
* <AbstractDataSubmitJob>
*
* @author xx
* @since 1.0.0
*/
public abstract class AbstractDataSubmitJob extends DefinedSubmitJob {
private static final long serialVersionUID = 225145504253862142L;
protected JobBean jobBean;
/**
* 接口返回结果发送消息
*
* @param response
*/
public static void throwErrorMessage(String response, String type, JobBean jobBean) throws Exception {
String errorFlag = jobBean.getErrorFlag();
String successStatus = jobBean.getSuccessStatus();
String errorMessageFlag = jobBean.getErrorMessageFlag();
if (StringKit.isBlank(errorFlag) || StringKit.isBlank(errorMessageFlag)) {
sendSystemMessage(type, response);
return;
}
String errorMessage = StringKit.EMPTY;
try {
Object errorCode = JsonPath.read(response, errorFlag);
LogKit.info("submitjob-AbstractDataSubmitJob-throwErrorMessage-errorCode:{}", errorCode);
if (StringKit.isNotBlank(successStatus) && ComparatorUtils.equalsIgnoreCase(String.valueOf(errorCode), successStatus)) {
return;
}
if (StringKit.isBlank(successStatus) && (errorCode == null || StringKit.isBlank(String.valueOf(errorCode)))) {
return;
}
errorMessage = JsonPath.read(response, errorMessageFlag);
} catch (Exception e) {
LogKit.error(e.getMessage(), e);
sendSystemMessage(type, response);
}
if (StringKit.isNotBlank(errorMessage)) {
throw new Exception(errorMessage);
}
}
/**
* 发送系统消息
*
* @param type
* @param response
*/
private static void sendSystemMessage(String type, String response) {
String content = I18nKit.getLocText("Plugin-submitjob") + "-" +
type + "-" +
I18nKit.getLocText("Plugin-submitjob_Result_Message") +
response;
MessageService.getInstance().sendMessage2SupperRole(content, StringUtils.EMPTY, MessageUrlType.NONE);
}
@Override
public String getJobType() {
return SubmitUIBridge.KEY;
}
@Override
public void doJob(Calculator calculator) throws Exception {
this.jobBean = new JobBean(calculator);
this.checkParams();
if (!this.jobBean.isOperationState()) {
return;
}
Map<String, String> params = this.jobBean.getParams();
if (params.isEmpty()) {
return;
}
Map<String, String> headers = this.jobBean.getHeaders();
checkHeader(headers);
operation(params, headers, calculator);
}
public void checkParams() throws Exception {
if (this.jobBean.getPropertyMap() == null || StringKit.isBlank(this.jobBean.getUrl())) {
throw new Exception(I18nKit.getLocText("Plugin-submitjob_Link_Valid"));
}
if (StringKit.isBlank(this.jobBean.getState())) {
throw new Exception(I18nKit.getLocText("Plugin-submitjob_State_Valid"));
}
}
public void checkHeader(Map<String, String> headers) throws Exception {
}
public abstract void operation(Map<String, String> params, Map<String, String> headers, Calculator calculator) throws Exception;
}

415
src/main/java/com/fr/plugin/xx/submitjob/job/AbstractDataSubmitTask.java

@ -0,0 +1,415 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: AbstractDataSubmitTask
* Author: xx
* Date: 2021/2/21 13:05
*/
package com.fr.plugin.xx.submitjob.job;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit;
import com.fr.data.AbstractSubmitTask;
import com.fr.data.FinishJob;
import com.fr.data.SubmitJob;
import com.fr.data.impl.SubmitJobValue;
import com.fr.general.ComparatorUtils;
import com.fr.general.DateUtils;
import com.fr.general.GeneralUtils;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.script.Calculator;
import com.fr.stable.*;
import com.fr.stable.script.CalculatorKey;
import com.fr.stable.xml.StableXMLUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLableReader;
import com.fr.write.DMLReport;
import com.fr.writex.assist.DmlAssist;
import com.fr.writex.cal.RowDataCalculator;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* <Function Description><br>
* <AbstractDataSubmitTask>
*
* @author xx
* @since 1.0.0
*/
public abstract class AbstractDataSubmitTask extends AbstractSubmitTask {
public static final CalculatorKey HEADER_VALUE = CalculatorKey.createKey("HEADER_VALUE");
public static final CalculatorKey API_URL = CalculatorKey.createKey("API_URL");
public static final CalculatorKey JOB_STATE = CalculatorKey.createKey("JOB_STATE");
public static final CalculatorKey BODY_CONTENT = CalculatorKey.createKey("BODY_CONTENT");
public static final CalculatorKey ERROR_FLAG = CalculatorKey.createKey("ERROR_FLAG");
public static final CalculatorKey SUCCESS_STATUS = CalculatorKey.createKey("SUCCESS_STATUS");
public static final CalculatorKey ERROR_MESSAGE_FLAG = CalculatorKey.createKey("ERROR_MESSAGE_FLAG");
public static final Map<String, SubmitJob> submitTypeMap = new LinkedHashMap<String, SubmitJob>() {
private static final long serialVersionUID = -7952964928237105471L;
{
put(GetSubmitJob.class.getName(), new GetSubmitJob());
put(PostSubmitJob.class.getName(), new PostSubmitJob());
put(PostJsonSubmitJob.class.getName(), new PostJsonSubmitJob());
put(PostTotalSubmitJob.class.getName(), new PostTotalSubmitJob());
put(SoapSubmitJob.class.getName(), new SoapSubmitJob());
put(SoapTotalSubmitJob.class.getName(), new SoapTotalSubmitJob());
}
};
private static final long serialVersionUID = -3454687937286690692L;
public FinishJob definedJob;
public String className;
public String state;
public String url;
public String bodyContent;
public ListMap<String, Object> headerMap = new ListMap<String, Object>();
public ListMap<String, Object> propertyMap = new ListMap<String, Object>();
public String errorFlag;
public String successStatus;
public String errorMessageFlag;
public AbstractDataSubmitTask() {
}
/**
* 行列值处理
*
* @param listMap
* @return
*/
protected ColumnRow[] calculateRelatedColumnRows(ListMap listMap) {
HashSet<ColumnRow> columnRowSet = new HashSet<ColumnRow>();
for (Object element : listMap.entrySet()) {
Object value = ((Map.Entry) element).getValue();
if (value instanceof ColumnRowRelated) {
ColumnRow[] relatedColumnRows = ((ColumnRowRelated) value).getRelatedColumnRows();
columnRowSet.addAll(Arrays.asList(relatedColumnRows));
}
}
return columnRowSet.toArray(new ColumnRow[0]);
}
@Override
public void doJob(Calculator calculator) throws Exception {
this.definedJob = this.createFinishJob();
if (CommonUtils.isNull(this.definedJob)) {
return;
}
RowDataCalculator rowDataCalculator = this.getRowDataCalculator();
DMLReport dmlReport = calculator.getAttribute(DMLReport.KEY);
if (dmlReport != null) {
ColumnRow[] columnRows = this.calculateRelatedColumnRows(this.propertyMap);
calculator.setAttribute(DmlAssist.RELATED_CR_ARRAY, columnRows);
dmlReport.getGroupRowDataCollector(calculator, rowDataCalculator).collectData();
} else {
rowDataCalculator.run(calculator);
}
this.doFinish(calculator);
}
protected abstract RowDataCalculator getRowDataCalculator();
@Override
public void doFinish(Calculator calculator) throws Exception {
}
protected FinishJob createFinishJob() {
if (StringUtils.isBlank(this.getClassName())) {
return null;
}
try {
return submitTypeMap.get(this.getClassName());
} catch (Exception e) {
LogKit.error(e.getMessage(), e);
return null;
}
}
/**
* 计算header属性值
*
* @param calculator
* @return
* @throws Exception
*/
protected ListMap<String, Object> getHeader4Action(Calculator calculator) throws Exception {
if (this.definedJob == null) {
return null;
}
ListMap<String, Object> listMap = new ListMap<String, Object>(this.headerMap.size());
for (Object element : this.headerMap.entrySet()) {
Map.Entry entry = (Map.Entry) element;
if (!listMap.containsKey((String) entry.getKey())) {
listMap.put((String) entry.getKey(), this.dealPropertyValue(calculator, entry.getValue(), null));
}
}
return listMap;
}
/**
* 计算body属性值
*
* @param calculator
* @return
* @throws Exception
*/
protected ListMap<String, Object> getValues4Action(Calculator calculator) throws Exception {
if (this.definedJob == null) {
return null;
}
ListMap<String, Object> listMap = new ListMap<String, Object>(this.propertyMap.size());
for (Object element : this.propertyMap.entrySet()) {
Map.Entry entry = (Map.Entry) element;
if (!listMap.containsKey((String) entry.getKey())) {
listMap.put((String) entry.getKey(), this.dealPropertyValue(calculator, entry.getValue(), null));
}
}
return listMap;
}
protected Object dealPropertyValue(Calculator calculator, Object propertyValueOld, Field field) throws Exception {
Object propertyValue = propertyValueOld;
int state = -1;
if (propertyValueOld instanceof ColumnRowRelated) {
if (this.needConvert(propertyValueOld, field)) {
ColumnRow[] relatedColumnRows = ((ColumnRowRelated) propertyValueOld).getRelatedColumnRows();
if (relatedColumnRows != null && relatedColumnRows.length == 1) {
state = GeneralUtils.objectToNumber(calculator.eval(relatedColumnRows[0].stateDescription()), false).intValue();
}
}
if (propertyValueOld instanceof ColumnRow) {
propertyValue = calculator.resolveVariable(propertyValueOld);
}
if (propertyValueOld instanceof FormulaProvider) {
propertyValue = calculator.evalValue((FormulaProvider) propertyValueOld);
}
}
if (!ComparatorUtils.equals(state, -1) || CommonUtils.isNull(field)) {
return new SubmitJobValue(propertyValue, state);
}
String fieldType = field.getType().getName();
if ("String".equals(fieldType)) {
return propertyValue.toString();
} else if ("Integer".equals(fieldType)) {
return new Integer(propertyValue.toString());
} else if ("Double".equals(fieldType)) {
return new Double(propertyValue.toString());
} else if ("Boolean".equals(fieldType)) {
return Boolean.valueOf(propertyValue.toString());
} else {
return "Date".equals(fieldType) ? DateUtils.object2Date(propertyValue, false) : propertyValue;
}
}
private boolean needConvert(Object value, Field field) {
return (value instanceof ColumnRow || value instanceof FormulaProvider && ((FormulaProvider) value).getContent().matches("^=[a-zA-Z]+\\d+$"))
&& (field == null || field.getType().getName().contains("JobValue"));
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isAttr()) {
this.headerMap.clear();
this.propertyMap.clear();
}
if (reader.isChildNode()) {
if (ComparatorUtils.equals(reader.getTagName(), "ClassAttr")) {
String className = reader.getAttrAsString("className", StringKit.EMPTY);
String state = reader.getAttrAsString("state", StringKit.EMPTY);
String url = reader.getAttrAsString("url", StringKit.EMPTY);
String bodyContent = reader.getAttrAsString("bodyContent", StringKit.EMPTY);
String errorFlag = reader.getAttrAsString("errorFlag", StringKit.EMPTY);
String successStatus = reader.getAttrAsString("successStatus", StringKit.EMPTY);
String errorMessageFlag = reader.getAttrAsString("errorMessageFlag", StringKit.EMPTY);
if (StringKit.isBlank(className) || StringKit.isBlank(url)) {
return;
}
this.setClassName(className);
this.setState(state);
this.setUrl(url);
this.setBodyContent(bodyContent);
this.setErrorFlag(errorFlag);
this.setSuccessStatus(successStatus);
this.setErrorMessageFlag(errorMessageFlag);
}
if (ComparatorUtils.equals(reader.getTagName(), "Header")) {
final String name = reader.getAttrAsString("name", StringKit.EMPTY);
if (StringKit.isBlank(name)) {
return;
}
reader.readXMLObject(new XMLReadable() {
public void readXML(XMLableReader xmLableReader) {
if (xmLableReader.isChildNode()) {
if (ComparatorUtils.equals(xmLableReader.getTagName(), "ColumnRow")) {
int column = xmLableReader.getAttrAsInt("column", 0);
int row = xmLableReader.getAttrAsInt("row", 0);
AbstractDataSubmitTask.this.headerMap.put(name, ColumnRow.valueOf(column, row));
}
if (ComparatorUtils.equals(xmLableReader.getTagName(), "O")) {
AbstractDataSubmitTask.this.headerMap.put(name, GeneralXMLTools.readObject(xmLableReader));
}
}
}
});
}
if (ComparatorUtils.equals(reader.getTagName(), "Property")) {
final String name = reader.getAttrAsString("name", StringKit.EMPTY);
if (StringKit.isBlank(name)) {
return;
}
reader.readXMLObject(new XMLReadable() {
public void readXML(XMLableReader xmLableReader) {
if (xmLableReader.isChildNode()) {
if (ComparatorUtils.equals(xmLableReader.getTagName(), "ColumnRow")) {
int column = xmLableReader.getAttrAsInt("column", 0);
int row = xmLableReader.getAttrAsInt("row", 0);
AbstractDataSubmitTask.this.propertyMap.put(name, ColumnRow.valueOf(column, row));
}
if (ComparatorUtils.equals(xmLableReader.getTagName(), "O")) {
AbstractDataSubmitTask.this.propertyMap.put(name, GeneralXMLTools.readObject(xmLableReader));
}
}
}
});
}
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
if (StringUtils.isNotBlank(this.getClassName())) {
writer.startTAG("ClassAttr")
.attr("className", this.getClassName())
.attr("state", this.getState())
.attr("url", this.getUrl())
.attr("bodyContent", this.getBodyContent())
.attr("errorFlag", this.getErrorFlag())
.attr("successStatus", this.getSuccessStatus())
.attr("errorMessageFlag", this.getErrorMessageFlag())
.end();
}
for (Object object : this.headerMap.entrySet()) {
Map.Entry entry = (Map.Entry) object;
Object value = entry.getValue();
writer.startTAG("Header").attr("name", (String) entry.getKey());
if (value instanceof ColumnRow) {
StableXMLUtils.writeColumnRow(writer, (ColumnRow) value);
} else {
GeneralXMLTools.writeObject(writer, value);
}
writer.end();
}
for (Object object : this.propertyMap.entrySet()) {
Map.Entry entry = (Map.Entry) object;
Object value = entry.getValue();
writer.startTAG("Property").attr("name", (String) entry.getKey());
if (value instanceof ColumnRow) {
StableXMLUtils.writeColumnRow(writer, (ColumnRow) value);
} else {
GeneralXMLTools.writeObject(writer, value);
}
writer.end();
}
}
public Object clone() throws CloneNotSupportedException {
AbstractDataSubmitTask dataSubmitTask = (AbstractDataSubmitTask) super.clone();
dataSubmitTask.headerMap = StableUtils.cloneListMap(this.headerMap);
dataSubmitTask.propertyMap = StableUtils.cloneListMap(this.propertyMap);
return dataSubmitTask;
}
public boolean equals(Object obj) {
return obj instanceof AbstractDataSubmitTask
&& ComparatorUtils.equals(((AbstractDataSubmitTask) obj).className, this.className)
&& ComparatorUtils.equals(((AbstractDataSubmitTask) obj).state, this.state)
&& ComparatorUtils.equals(((AbstractDataSubmitTask) obj).url, this.url)
&& ComparatorUtils.equals(((AbstractDataSubmitTask) obj).bodyContent, this.bodyContent)
&& ComparatorUtils.equals(((AbstractDataSubmitTask) obj).errorFlag, this.errorFlag)
&& ComparatorUtils.equals(((AbstractDataSubmitTask) obj).successStatus, this.successStatus)
&& ComparatorUtils.equals(((AbstractDataSubmitTask) obj).errorMessageFlag, this.errorMessageFlag)
&& ComparatorUtils.equals(((AbstractDataSubmitTask) obj).headerMap, this.headerMap)
&& ComparatorUtils.equals(((AbstractDataSubmitTask) obj).propertyMap, this.propertyMap);
}
public int hashCode() {
return AssistUtils.hashCode(new Object[]{this.className, this.state, this.url, this.bodyContent, this.errorFlag, this.successStatus, this.errorMessageFlag});
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public ListMap<String, Object> getHeaderMap() {
return headerMap;
}
public void setHeaderMap(ListMap<String, Object> headerMap) {
this.headerMap = headerMap;
}
public ListMap<String, Object> getPropertyMap() {
return propertyMap;
}
public void setPropertyMap(ListMap<String, Object> propertyMap) {
this.propertyMap = propertyMap;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getBodyContent() {
return bodyContent;
}
public void setBodyContent(String bodyContent) {
this.bodyContent = bodyContent;
}
public String getErrorFlag() {
return errorFlag;
}
public void setErrorFlag(String errorFlag) {
this.errorFlag = errorFlag;
}
public String getSuccessStatus() {
return successStatus;
}
public void setSuccessStatus(String successStatus) {
this.successStatus = successStatus;
}
public String getErrorMessageFlag() {
return errorMessageFlag;
}
public void setErrorMessageFlag(String errorMessageFlag) {
this.errorMessageFlag = errorMessageFlag;
}
}

115
src/main/java/com/fr/plugin/xx/submitjob/job/AbstractDataTotalSubmitJob.java

@ -0,0 +1,115 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: AbstractDataTotalSubmitJob
* Author: xx
* Date: 2021/3/11 12:11
*/
package com.fr.plugin.xx.submitjob.job;
import com.fanruan.api.i18n.I18nKit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit;
import com.fr.data.JobValue;
import com.fr.data.TotalSubmitJob;
import com.fr.plugin.xx.submitjob.SubmitUIBridge;
import com.fr.plugin.xx.submitjob.bean.JobBean;
import com.fr.plugin.xx.submitjob.kit.HttpKit;
import com.fr.script.Calculator;
import com.fr.stable.CommonUtils;
import com.fr.third.org.apache.http.entity.StringEntity;
import com.fr.third.springframework.web.util.HtmlUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.fr.plugin.xx.submitjob.bean.JobBean.valueToString;
import static com.fr.plugin.xx.submitjob.job.GetSubmitJob.throwErrorMessage;
/**
* <Function Description><br>
* <AbstractDataTotalSubmitJob>
*
* @author xx
* @since 1.0.0
*/
public abstract class AbstractDataTotalSubmitJob extends TotalSubmitJob {
private static final long serialVersionUID = 6348254394120760490L;
protected JobBean jobBean;
@Override
public String getJobType() {
return SubmitUIBridge.KEY;
}
@Override
public void doJob(Calculator calculator) throws Exception {
if (CommonUtils.isNull(jobBean)) {
jobBean = new JobBean(calculator, "total");
}
super.doJob(calculator);
}
@Override
protected void doTotalJob(Data data, Calculator calculator) throws Exception {
checkParams();
List<Map<String, String>> paramList = new ArrayList<Map<String, String>>();
boolean isRecordModify;
for (int row = 0; row < data.getRowCount(); row++) {
Map<String, String> params = new HashMap<String, String>();
isRecordModify = false;
for (int col = 0; col < data.getColumnCount(); col++) {
Object cellValue = data.getValueAt(row, col);
if (!(cellValue instanceof JobValue)) {
continue;
}
JobValue ce = (JobValue) cellValue;
if (!isRecordModify && this.jobBean.isStateStrict(ce)) {
isRecordModify = true;
}
params.put(data.getColumnName(col), valueToString(ce.getValue()));
}
if (isRecordModify) {
paramList.add(params);
}
}
if (paramList.isEmpty()) {
return;
}
Map<String, String> headers = jobBean.getHeaders();
checkHeader(headers);
String bodyContent = calculateContent(paramList, calculator);
operation(bodyContent, headers);
}
public void checkParams() throws Exception {
if (StringKit.isBlank(this.jobBean.getUrl())) {
throw new Exception(I18nKit.getLocText("Plugin-submitjob_Link_Valid"));
}
if (StringKit.isBlank(this.jobBean.getState())) {
throw new Exception(I18nKit.getLocText("Plugin-submitjob_State_Valid"));
}
}
public abstract String calculateContent(List<Map<String, String>> paramList, Calculator calculator) throws Exception;
public abstract void checkHeader(Map<String, String> headers) throws Exception;
/**
* 提交属性处理操作
*
* @param bodyContent
* @param headers
* @throws Exception
*/
private void operation(String bodyContent, Map<String, String> headers) throws Exception {
LogKit.info("submitjob-AbstractDataTotalSubmitJob-operation-bodyContent:{}, headers:{}", bodyContent, headers);
StringEntity stringEntity = new StringEntity(bodyContent, "UTF-8");
String response = HttpKit.executeAndParse(com.fanruan.api.net.http.rs.HttpRequest.custom()
.url(this.jobBean.getUrl()).post(stringEntity).headers(headers).build());
LogKit.info("submitjob-AbstractDataTotalSubmitJob-operation-response:{}", response);
throwErrorMessage(HtmlUtils.htmlUnescape(response), this.getJobType(), this.jobBean);
}
}

95
src/main/java/com/fr/plugin/xx/submitjob/job/DataSubmitTask.java

@ -0,0 +1,95 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: DataSubmitJob
* Author: xx
* Date: 2021/2/19 20:57
*/
package com.fr.plugin.xx.submitjob.job;
import com.fanruan.api.i18n.I18nKit;
import com.fanruan.api.log.LogKit;
import com.fr.data.DefinedSubmitJob;
import com.fr.data.TotalSubmitJob;
import com.fr.plugin.context.PluginContexts;
import com.fr.plugin.xx.submitjob.SubmitUIBridge;
import com.fr.script.Calculator;
import com.fr.stable.script.CalculatorProvider;
import com.fr.writex.cal.RowDataCalculator;
/**
* <Function Description><br>
* <DataSubmitJob>
*
* @author xx
* @since 1.0.0
*/
public class DataSubmitTask extends AbstractDataSubmitTask {
private static final long serialVersionUID = 2800082714711002017L;
public DataSubmitTask() {
}
public DataSubmitTask(String className) {
this.setClassName(className);
}
@Override
public String getJobType() {
return SubmitUIBridge.KEY;
}
@Override
public void doFinish(Calculator calculator) throws Exception {
if (this.definedJob instanceof TotalSubmitJob) {
this.definedJob.doFinish(calculator);
}
}
private void doJobByColumn(Calculator calculator) throws Exception {
if (!PluginContexts.currentContext().isAvailable()) {
LogKit.error(I18nKit.getLocText("Plugin-submitjob_licence_Expired"));
return;
}
calculator.setAttribute(AbstractDataSubmitTask.HEADER_VALUE, this.getHeader4Action(calculator));
calculator.setAttribute(DefinedSubmitJob.PROPERTY_VALUE, this.getValues4Action(calculator));
calculator.setAttribute(AbstractDataSubmitTask.API_URL, this.getUrl());
calculator.setAttribute(AbstractDataSubmitTask.JOB_STATE, this.getState());
calculator.setAttribute(AbstractDataSubmitTask.BODY_CONTENT, this.getBodyContent());
calculator.setAttribute(AbstractDataSubmitTask.ERROR_FLAG, this.getErrorFlag());
calculator.setAttribute(AbstractDataSubmitTask.SUCCESS_STATUS, this.getSuccessStatus());
calculator.setAttribute(AbstractDataSubmitTask.ERROR_MESSAGE_FLAG, this.getErrorMessageFlag());
try {
this.definedJob.doJob(calculator);
} finally {
calculator.removeAttribute(AbstractDataSubmitTask.HEADER_VALUE);
calculator.removeAttribute(DefinedSubmitJob.PROPERTY_VALUE);
calculator.removeAttribute(AbstractDataSubmitTask.API_URL);
calculator.removeAttribute(AbstractDataSubmitTask.JOB_STATE);
calculator.removeAttribute(AbstractDataSubmitTask.BODY_CONTENT);
calculator.removeAttribute(AbstractDataSubmitTask.ERROR_FLAG);
calculator.removeAttribute(AbstractDataSubmitTask.SUCCESS_STATUS);
calculator.removeAttribute(AbstractDataSubmitTask.ERROR_MESSAGE_FLAG);
}
}
protected RowDataCalculator getRowDataCalculator() {
return new RowDataCalculator() {
public void run(CalculatorProvider calculatorProvider) throws Exception {
DataSubmitTask.this.doJobByColumn((Calculator) calculatorProvider);
}
public boolean isDynamic() {
return true;
}
};
}
public boolean equals(Object obj) {
return obj instanceof DataSubmitTask && super.equals(obj);
}
public int hashCode() {
return super.hashCode();
}
}

41
src/main/java/com/fr/plugin/xx/submitjob/job/GetSubmitJob.java

@ -0,0 +1,41 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: GetSubmitJob
* Author: xx
* Date: 2020/8/28 17:01
*/
package com.fr.plugin.xx.submitjob.job;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.xx.submitjob.kit.HttpKit;
import com.fr.script.Calculator;
import com.fr.third.springframework.web.util.HtmlUtils;
import java.util.Map;
/**
* <Function Description><br>
* <GetSubmitJob>
*
* @author xx
* @since 1.0.0
*/
public class GetSubmitJob extends AbstractDataSubmitJob {
private static final long serialVersionUID = 9185266482517664080L;
public static final String KEY = "GetSubmitJob";
/**
* 提交属性处理操作
*
* @param params
* @throws Exception
*/
@Override
public void operation(Map<String, String> params, Map<String, String> headers, Calculator calculator) throws Exception {
LogKit.info("submitjob-GetSubmitJob-operation-params:{}, headers:{}", params, headers);
String response = HttpKit.get(this.jobBean.getUrl(), params, headers);
LogKit.info("submitjob-GetSubmitJob-operation-response:{}", response);
throwErrorMessage(HtmlUtils.htmlUnescape(response), GetSubmitJob.KEY, this.jobBean);
}
}

110
src/main/java/com/fr/plugin/xx/submitjob/job/PostJsonSubmitJob.java

@ -0,0 +1,110 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: PostSubmitJob
* Author: xx
* Date: 2020/8/28 17:01
*/
package com.fr.plugin.xx.submitjob.job;
import com.fanruan.api.i18n.I18nKit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.net.http.rs.HttpRequest;
import com.fr.base.TemplateUtils;
import com.fr.general.ComparatorUtils;
import com.fr.json.JSONObject;
import com.fr.plugin.xx.submitjob.kit.HttpKit;
import com.fr.script.Calculator;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse;
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.conn.ssl.TrustSelfSignedStrategy;
import com.fr.third.org.apache.http.cookie.Cookie;
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.ssl.SSLContexts;
import com.fr.third.org.apache.http.util.EntityUtils;
import com.fr.third.springframework.web.util.HtmlUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <Function Description><br>
* <PostSubmitJob>
*
* @author xx
* @since 1.0.0
*/
public class PostJsonSubmitJob extends AbstractDataSubmitJob {
public static final String KEY = "PostJsonSubmitJob";
private static final long serialVersionUID = -2439535244039859157L;
@Override
public void checkHeader(Map<String, String> headers) throws Exception {
if (!headers.containsKey("Content-Type")) {
headers.put("Content-Type", "application/json");
}
if (!ComparatorUtils.equalsIgnoreCase(headers.get("Content-Type"), "application/json")) {
throw new Exception(I18nKit.getLocText("Plugin-submitjob_Header_Content-Type_Valid"));
}
}
/**
* 提交属性处理操作
*
* @param params
* @throws Exception
*/
@Override
public void operation(Map<String, String> params, Map<String, String> headers, Calculator calculator) throws Exception {
setCookies(headers);
LogKit.info("submitjob-PostJsonSubmitJob-operation-params:{}, headers:{}", params, headers);
String bodyContent;
if (StringUtils.isNotBlank(this.jobBean.getBodyContent())) {
bodyContent = TemplateUtils.render(this.jobBean.getBodyContent(), params, calculator);
} else {
bodyContent = JSONObject.mapFrom(params).encode();
}
StringEntity stringEntity = new StringEntity(bodyContent, "UTF-8");
String response = HttpKit.executeAndParse(com.fanruan.api.net.http.rs.HttpRequest.custom()
.url(this.jobBean.getUrl()).post(stringEntity).headers(headers).build());
LogKit.info("submitjob-PostJsonSubmitJob-operation-response:{}", response);
throwErrorMessage(HtmlUtils.htmlUnescape(response), PostJsonSubmitJob.KEY, this.jobBean);
}
private void setCookies(Map<String, String> headers) {
if (!headers.containsKey("loginUrl") || !headers.containsKey("loginParams")) {
return;
}
List<Cookie> cookieList = getLoginCookies(headers.remove("loginUrl"), headers.remove("loginParams")).getCookies();
StringBuilder cookieBuilder = new StringBuilder();
for (Cookie cookie : cookieList) {
cookieBuilder.append(cookie.getName()).append("=").append(cookie.getValue()).append(";");
}
headers.put("Cookie", cookieBuilder.toString());
}
private BasicCookieStore getLoginCookies(String loginUrl, String bodyContent) {
BasicCookieStore loginCookie = new BasicCookieStore();
try {
SSLConnectionSocketFactory scsf = new SSLConnectionSocketFactory(SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(), NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(scsf).setDefaultCookieStore(loginCookie).build();
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
StringEntity stringEntity = new StringEntity(bodyContent, "UTF-8");
HttpRequest httpRequest = HttpRequest.custom()
.url(loginUrl).post(stringEntity).headers(headers).build();
CloseableHttpResponse response = HttpKit.execute(httpClient, httpRequest);
String result = EntityUtils.toString(response.getEntity());
LogKit.info("submitjob-PostJsonSubmitJob-getLoginCookies-result:{}", result);
} catch (Exception e) {
LogKit.error(e.getMessage(), e);
}
return loginCookie;
}
}

41
src/main/java/com/fr/plugin/xx/submitjob/job/PostSubmitJob.java

@ -0,0 +1,41 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: PostSubmitJob
* Author: xx
* Date: 2020/8/28 17:01
*/
package com.fr.plugin.xx.submitjob.job;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.xx.submitjob.kit.HttpKit;
import com.fr.script.Calculator;
import com.fr.third.springframework.web.util.HtmlUtils;
import java.util.Map;
/**
* <Function Description><br>
* <PostSubmitJob>
*
* @author xx
* @since 1.0.0
*/
public class PostSubmitJob extends AbstractDataSubmitJob {
private static final long serialVersionUID = -7229039666384758696L;
public static final String KEY = "PostSubmitJob";
/**
* 提交属性处理操作
*
* @param params
* @throws Exception
*/
@Override
public void operation(Map<String, String> params, Map<String, String> headers, Calculator calculator) throws Exception {
LogKit.info("submitjob-PostSubmitJob-operation-params:{}, headers:{}", params, headers);
String response = HttpKit.post(this.jobBean.getUrl(), params, headers);
LogKit.info("submitjob-PostSubmitJob-operation-response:{}", response);
throwErrorMessage(HtmlUtils.htmlUnescape(response), PostSubmitJob.KEY, this.jobBean);
}
}

62
src/main/java/com/fr/plugin/xx/submitjob/job/PostTotalSubmitJob.java

@ -0,0 +1,62 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: GetTotalSubmitJob
* Author: xx
* Date: 2021/2/22 10:46
*/
package com.fr.plugin.xx.submitjob.job;
import com.fanruan.api.i18n.I18nKit;
import com.fr.base.TemplateUtils;
import com.fr.general.ComparatorUtils;
import com.fr.json.JSONArray;
import com.fr.script.Calculator;
import com.fr.stable.StringUtils;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* <Function Description><br>
* <GetTotalSubmitJob>
*
* @author xx
* @since 1.0.0
*/
public class PostTotalSubmitJob extends AbstractDataTotalSubmitJob {
private static final long serialVersionUID = 3323384848317314231L;
public static final String KEY = "PostTotalSubmitJob";
public static final String PARAMS_DATA = "paramsData";
@Override
public String getJobType() {
return PostTotalSubmitJob.KEY;
}
/**
* 处理body内容
*
* @param paramList
* @return
* @throws IOException
*/
@Override
public String calculateContent(List<Map<String, String>> paramList, Calculator calculator) throws Exception {
if (StringUtils.isBlank(this.jobBean.getBodyContent())) {
return JSONArray.create(paramList).encode();
}
return TemplateUtils.render(this.jobBean.getBodyContent(), PARAMS_DATA, JSONArray.create(paramList).encode());
}
@Override
public void checkHeader(Map<String, String> headers) throws Exception {
if (!headers.containsKey("Content-Type")){
headers.put("Content-Type", "application/json");
}
if (!ComparatorUtils.equalsIgnoreCase(headers.get("Content-Type"), "application/json")){
throw new Exception(I18nKit.getLocText("Plugin-submitjob_Header_Content-Type_Valid"));
}
}
}

88
src/main/java/com/fr/plugin/xx/submitjob/job/SoapSubmitJob.java

@ -0,0 +1,88 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: SoapSubmitJob
* Author: xx
* Date: 2021/3/2 16:56
*/
package com.fr.plugin.xx.submitjob.job;
import com.fanruan.api.i18n.I18nKit;
import com.fanruan.api.log.LogKit;
import com.fr.plugin.xx.submitjob.kit.HttpKit;
import com.fanruan.api.util.StringKit;
import com.fr.base.TemplateUtils;
import com.fr.general.ComparatorUtils;
import com.fr.script.Calculator;
import com.fr.third.org.apache.http.entity.StringEntity;
import com.fr.third.springframework.web.util.HtmlUtils;
import java.io.IOException;
import java.util.Map;
/**
* <Function Description><br>
* <SoapSubmitJob>
*
* @author xx
* @since 1.0.0
*/
public class SoapSubmitJob extends AbstractDataSubmitJob {
private static final long serialVersionUID = -1927219126342645238L;
public static final String KEY = "SoapSubmitJob";
@Override
public void checkParams() throws Exception {
super.checkParams();
if (StringKit.isBlank(this.jobBean.getBodyContent())) {
throw new Exception(I18nKit.getLocText("Plugin-submitjob_Body_Content_Valid"));
}
}
@Override
public void checkHeader(Map<String, String> headers) throws Exception {
checkSoapHeader(headers);
}
/**
* 提交属性处理操作
*
* @param params
* @param headers
* @param calculator
* @throws Exception
*/
@Override
public void operation(Map<String, String> params, Map<String, String> headers, Calculator calculator) throws Exception {
String soapXml = calculateXML(params, calculator);
LogKit.info("submitjob-SoapSubmitJob-operation-soapXml:{}, headers:{}", soapXml, headers);
StringEntity stringEntity = new StringEntity(soapXml, "UTF-8");
String response = HttpKit.executeAndParse(com.fanruan.api.net.http.rs.HttpRequest.custom().url(this.jobBean.getUrl()).post(stringEntity).headers(headers).build());
LogKit.info("submitjob-SoapSubmitJob-operation-response:{}", HtmlUtils.htmlUnescape(response));
throwErrorMessage(HtmlUtils.htmlUnescape(response), SoapSubmitJob.KEY, this.jobBean);
}
/**
* 处理body内容
*
* @param params
* @return
* @throws IOException
*/
private String calculateXML(Map<String, String> params, Calculator calculator) throws Exception {
return TemplateUtils.render(this.jobBean.getBodyContent(), params, calculator);
}
public static void checkSoapHeader(Map<String, String> headers) throws Exception {
if (!headers.containsKey("Content-Type")) {
headers.put("Content-Type", "text/xml;charset=UTF-8");
}
if (!ComparatorUtils.equalsIgnoreCase(headers.get("Content-Type"), "application/soap+xml;charset=UTF-8")
&& !ComparatorUtils.equalsIgnoreCase(headers.get("Content-Type"), "text/xml;charset=UTF-8")) {
throw new Exception(I18nKit.getLocText("Plugin-submitjob_Header_Content-Type_Valid"));
}
if (StringKit.isBlank(headers.get("SOAPAction"))) {
throw new Exception(I18nKit.getLocText("Plugin-submitjob_Header_SOAPAction_Valid"));
}
}
}

81
src/main/java/com/fr/plugin/xx/submitjob/job/SoapTotalSubmitJob.java

@ -0,0 +1,81 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: SoapTotalSubmitJob
* Author: xx
* Date: 2021/2/22 10:46
*/
package com.fr.plugin.xx.submitjob.job;
import com.fanruan.api.i18n.I18nKit;
import com.fanruan.api.util.StringKit;
import com.fr.base.TemplateUtils;
import com.fr.general.ComparatorUtils;
import com.fr.json.JSONArray;
import com.fr.script.Calculator;
import com.fr.stable.StringUtils;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* <Function Description><br>
* <SoapTotalSubmitJob>
*
* @author xx
* @since 1.0.0
*/
public class SoapTotalSubmitJob extends AbstractDataTotalSubmitJob {
private static final long serialVersionUID = 3323384848317314231L;
public static final String KEY = "SoapTotalSubmitJob";
public static final String TEMPLATE_SEPERATE = "##LOOP##";
@Override
public String getJobType() {
return SoapTotalSubmitJob.KEY;
}
/**
* 检查参数值
*
* @throws Exception
*/
@Override
public void checkParams() throws Exception {
super.checkParams();
if (StringKit.isBlank(this.jobBean.getBodyContent())) {
throw new Exception(I18nKit.getLocText("Plugin-submitjob_Body_Content_Valid"));
}
if (!ComparatorUtils.equals(this.jobBean.getBodyContent().split(TEMPLATE_SEPERATE).length, 3)) {
throw new Exception(I18nKit.getLocText("Plugin-submitjob_Body_Content_Format_Valid"));
}
}
/**
* 处理body内容
*
* @param paramList
* @return
* @throws IOException
*/
@Override
public String calculateContent(List<Map<String, String>> paramList, Calculator calculator) throws Exception {
if (StringUtils.isBlank(this.jobBean.getBodyContent())) {
return JSONArray.create(paramList).encode();
}
String[] templateArray = this.jobBean.getBodyContent().split(TEMPLATE_SEPERATE);
StringBuilder bodyContent = new StringBuilder();
bodyContent.append(TemplateUtils.render(templateArray[0], calculator));
for (Map<String, String> params : paramList) {
bodyContent.append(TemplateUtils.render(templateArray[1], params, calculator));
}
bodyContent.append(TemplateUtils.render(templateArray[2], calculator));
return bodyContent.toString();
}
@Override
public void checkHeader(Map<String, String> headers) throws Exception {
SoapSubmitJob.checkSoapHeader(headers);
}
}

718
src/main/java/com/fr/plugin/xx/submitjob/kit/HttpKit.java

@ -0,0 +1,718 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: HttpKit
* Author: xx
* Date: 2021/3/17 14:19
*/
package com.fr.plugin.xx.submitjob.kit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.macro.EncodeConstants;
import com.fanruan.api.net.http.rs.HttpRequest;
import com.fanruan.api.net.http.rs.*;
import com.fr.third.guava.collect.Maps;
import com.fr.third.org.apache.http.*;
import com.fr.third.org.apache.http.client.HttpRequestRetryHandler;
import com.fr.third.org.apache.http.client.config.RequestConfig;
import com.fr.third.org.apache.http.client.entity.UrlEncodedFormEntity;
import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse;
import com.fr.third.org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import com.fr.third.org.apache.http.client.methods.HttpRequestBase;
import com.fr.third.org.apache.http.client.protocol.HttpClientContext;
import com.fr.third.org.apache.http.client.utils.URIBuilder;
import com.fr.third.org.apache.http.config.Registry;
import com.fr.third.org.apache.http.config.RegistryBuilder;
import com.fr.third.org.apache.http.conn.routing.HttpRoute;
import com.fr.third.org.apache.http.conn.socket.ConnectionSocketFactory;
import com.fr.third.org.apache.http.conn.socket.LayeredConnectionSocketFactory;
import com.fr.third.org.apache.http.conn.socket.PlainConnectionSocketFactory;
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.conn.ssl.TrustSelfSignedStrategy;
import com.fr.third.org.apache.http.entity.FileEntity;
import com.fr.third.org.apache.http.entity.mime.HttpMultipartMode;
import com.fr.third.org.apache.http.entity.mime.MultipartEntityBuilder;
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.conn.PoolingHttpClientConnectionManager;
import com.fr.third.org.apache.http.message.BasicNameValuePair;
import com.fr.third.org.apache.http.protocol.HttpContext;
import com.fr.third.org.apache.http.ssl.SSLContexts;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.net.ssl.*;
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import static com.fanruan.api.net.http.rs.HttpRequestType.POST;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-29
* <p>
* http请求工具类封装了用于http请求的各种方法
* 新增https忽略证书功能 Update By xx on 2021-03-17
* </p>
*/
public class HttpKit {
private static final int RETRY_TIMES = 5;
private final static Object SYNC_LOCK = new Object();
private static CloseableHttpClient httpClient = null;
/**
* 根据请求地址创建HttpClient对象
*
* @param url 请求地址
* @return HttpClient对象
*/
public static CloseableHttpClient getHttpClient(String url) {
String hostname = url.split("/")[2];
int port = 80;
if (hostname.contains(":")) {
String[] arr = hostname.split(":");
hostname = arr[0];
port = Integer.parseInt(arr[1]);
}
if (httpClient == null) {
synchronized (SYNC_LOCK) {
if (httpClient == null) {
try {
httpClient = createHttpClient(hostname, port, createIgnoreVerifySSL());
} catch (NoSuchAlgorithmException e) {
LogKit.error(e.getMessage(), e);
} catch (KeyManagementException e) {
LogKit.error(e.getMessage(), e);
}
}
}
}
return httpClient;
}
/**
* 新增了https 请求绕过证书认证
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
SSLContext sc = SSLContext.getInstance("SSLv3");
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
X509TrustManager trustManager = new X509TrustManager() {
@Override
public void checkClientTrusted(
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
String paramString) throws CertificateException {
}
@Override
public void checkServerTrusted(
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
String paramString) throws CertificateException {
}
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
};
sc.init(null, new TrustManager[]{trustManager}, null);
return sc;
}
public static CloseableHttpClient createHttpClient(String hostname, int port, SSLContext sslContext) {
return createHttpClient(200, 40, 100, hostname, port, sslContext);
}
private static CloseableHttpClient createHttpClient(int maxTotal,
int maxPerRoute,
int maxRoute,
String hostname,
int port,
SSLContext sslContext) {
ConnectionSocketFactory socketFactory = PlainConnectionSocketFactory.getSocketFactory();
LayeredConnectionSocketFactory sslConnectionSocketFactory;
try {
sslConnectionSocketFactory = new SSLConnectionSocketFactory(SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(), NoopHostnameVerifier.INSTANCE);
} catch (Exception e) {
LogKit.error(e.getMessage(), e);
sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
}
Registry<ConnectionSocketFactory> registry = RegistryBuilder
.<ConnectionSocketFactory>create()
.register("http", socketFactory)
.register("https", sslConnectionSocketFactory)
.build();
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry);
// 将最大连接数增加
cm.setMaxTotal(maxTotal);
// 将每个路由基础的连接增加
cm.setDefaultMaxPerRoute(maxPerRoute);
HttpHost httpHost = new HttpHost(hostname, port);
// 将目标主机的最大连接数增加
cm.setMaxPerRoute(new HttpRoute(httpHost), maxRoute);
// 请求重试处理
HttpRequestRetryHandler httpRequestRetryHandler = new HttpRequestRetryHandler() {
@Override
public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
if (executionCount >= RETRY_TIMES) {// 如果已经重试了5次,就放弃
return false;
}
if (exception instanceof NoHttpResponseException) {// 如果服务器丢掉了连接,那么就重试
return true;
}
if (exception instanceof SSLHandshakeException) {// 不要重试SSL握手异常
return false;
}
if (exception instanceof InterruptedIOException) {// 超时
return false;
}
if (exception instanceof UnknownHostException) {// 目标服务器不可达
return false;
}
if (exception instanceof SSLException) {// SSL握手异常
return false;
}
HttpClientContext clientContext = HttpClientContext.adapt(context);
com.fr.third.org.apache.http.HttpRequest request = clientContext.getRequest();
// 如果请求是幂等的,就再次尝试
return !(request instanceof HttpEntityEnclosingRequest);
}
};
return HttpClients.custom()
.setConnectionManager(cm)
.setRetryHandler(httpRequestRetryHandler)
.build();
}
/**
* 设置 httpEntity
*
* @param requestBase 请求体
* @param httpRequest 请求
*/
private static void setHttpEntity(@NotNull HttpEntityEnclosingRequestBase requestBase, @NotNull HttpRequest httpRequest) {
HttpEntity httpEntity = httpRequest.getHttpEntity();
if (httpEntity != null) {
// 如果存在 httpEntity 直接设置
requestBase.setEntity(httpEntity);
return;
}
Map<String, String> params = httpRequest.getParams();
if (params == null || params.isEmpty()) {
return;
}
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
for (Map.Entry<String, String> entry : params.entrySet()) {
pairs.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
try {
requestBase.setEntity(new UrlEncodedFormEntity(pairs, httpRequest.getEncoding()));
} catch (UnsupportedEncodingException e) {
LogKit.error(e.getMessage(), e);
}
}
private static <V> Map<String, String> transformMap(Map<String, V> oldMap) {
if (oldMap == null) {
return null;
}
return Maps.transformEntries(oldMap, new Maps.EntryTransformer<String, V, String>() {
@Override
public String transformEntry(@Nullable String key, @Nullable V value) {
return value == null ? null : value.toString();
}
});
}
/**
* 发起POST请求并获取返回的文本
*
* @param url 响应请求的的服务器地址
* @param params POST请求的参数
* @return 服务器返回的文本内容
*/
public static <V> String post(String url, Map<String, V> params) throws IOException {
return executeAndParse(HttpRequest
.custom()
.url(url)
.post(transformMap(params))
.build());
}
/**
* 发起POST请求并获取返回的文本
*
* @param url 响应请求的的服务器地址
* @param params POST请求的参数
* @param responseType 返回类型
* @return 服务器返回的文本内容
* @see com.fanruan.api.net.http.HttpKit#execute(HttpRequest)
*/
@Deprecated
public static <T, V> T post(String url, Map<String, V> params, HttpResponseType<T> responseType) throws IOException {
CloseableHttpResponse response = execute(HttpRequest
.custom()
.url(url)
.post(transformMap(params))
.build());
return responseType.result(response, null);
}
/**
* 发起POST请求并获取返回的文本
*
* @param url 响应请求的的服务器地址
* @param params POST请求的参数
* @param headers 请求头
* @return 服务器返回的文本内容
* @see com.fanruan.api.net.http.HttpKit#executeAndParse(HttpRequest)
*/
@Deprecated
public static <V> String post(String url, Map<String, V> params, Map<String, String> headers) throws IOException {
return executeAndParse(HttpRequest
.custom()
.url(url)
.post(transformMap(params))
.headers(headers)
.build());
}
/**
* 发起POST请求并获取返回的文本
*
* @param url 响应请求的的服务器地址
* @param params POST请求的参数
* @param headers 请求头
* @param responseType 返回类型
* @return 服务器返回的文本内容
* @see com.fanruan.api.net.http.HttpKit#execute(HttpRequest)
*/
@Deprecated
public static <T, V> T post(String url, Map<String, V> params, Map<String, String> headers, HttpResponseType<T> responseType) throws IOException {
CloseableHttpResponse response = execute(HttpRequest
.custom()
.url(url)
.post(transformMap(params))
.headers(headers)
.build());
return responseType.result(response, null);
}
/**
* 发起POST请求并获取返回的文本
*
* @param url 响应请求的的服务器地址
* @param params POST请求的参数
* @param responseEncoding 响应的文本的编码
* @return 服务器返回的文本内容
* @see com.fanruan.api.net.http.HttpKit#executeAndParse(HttpRequest, BaseHttpResponseHandle)
*/
@Deprecated
public static <V> String post(String url, Map<String, V> params, String responseEncoding) throws IOException {
return executeAndParse(HttpRequest
.custom()
.url(url)
.post(transformMap(params))
.build(),
new TextResponseHandle(responseEncoding));
}
/**
* 发起POST请求并获取返回的文本
*
* @param url 响应请求的的服务器地址
* @param params POST请求的参数
* @param responseEncoding 响应的文本的编码
* @param headers 请求头
* @return 服务器返回的文本内容
* @see com.fanruan.api.net.http.HttpKit#executeAndParse(HttpRequest, BaseHttpResponseHandle)
*/
@Deprecated
public static <V> String post(String url, Map<String, V> params, String responseEncoding, Map<String, String> headers) throws IOException {
return executeAndParse(HttpRequest
.custom()
.url(url)
.post(transformMap(params))
.headers(headers)
.build(),
new TextResponseHandle(responseEncoding));
}
/**
* 发起POST请求并获取返回的文本
*
* @param url 响应请求的的服务器地址
* @param params POST请求的参数
* @param responseEncoding 响应的文本的编码
* @param paramsEncoding 参数编码
* @param headers 请求头
* @return 服务器返回的文本内容
* @see com.fanruan.api.net.http.HttpKit#executeAndParse(HttpRequest, BaseHttpResponseHandle)
*/
public static <V> String post(String url, Map<String, V> params, String responseEncoding, String paramsEncoding, Map<String, String> headers) throws IOException {
return executeAndParse(HttpRequest
.custom()
.url(url)
.post(transformMap(params))
.encoding(paramsEncoding)
.headers(headers)
.build(),
new TextResponseHandle(responseEncoding));
}
/**
* 发起POST请求并获取返回的文本
*
* @param url 响应请求的的服务器地址
* @param params POST请求的参数
* @param responseEncoding 响应的文本的编码
* @param paramsEncoding 参数编码
* @param headers 请求头
* @param responseType 返回值类型
* @return 服务器返回的文本内容
* @see com.fanruan.api.net.http.HttpKit#execute(HttpRequest)
*/
public static <T, V> T post(String url, Map<String, V> params, String responseEncoding, String paramsEncoding, Map<String, String> headers, HttpResponseType<T> responseType) throws IOException {
CloseableHttpResponse response = execute(HttpRequest
.custom()
.url(url)
.post(transformMap(params))
.encoding(paramsEncoding)
.headers(headers)
.build());
return responseType.result(response, responseEncoding);
}
/**
* 发起GET请求并获取返回的文本
*
* @param url 响应请求的的服务器地址
* @return 服务器返回的文本内容
*/
public static String get(String url) throws IOException {
return executeAndParse(HttpRequest.custom().url(url).build());
}
/**
* 发起GET请求并获取返回的文本
*
* @param url 响应请求的的服务器地址
* @param params 参数
* @return 服务器返回的文本内容
*/
public static String get(String url, Map<String, String> params) throws IOException {
return executeAndParse(HttpRequest.custom().url(url).params(params).build());
}
/**
* 发起GET请求并获取返回的文本
*
* @param url 响应请求的的服务器地址
* @param params 参数
* @param headers 请求头
* @return 服务器返回的文本内容
* @see com.fanruan.api.net.http.HttpKit#executeAndParse(HttpRequest, BaseHttpResponseHandle)
*/
public static String get(String url, Map<String, String> params, Map<String, String> headers) throws IOException {
return executeAndParse(HttpRequest.custom().url(url).params(params).headers(headers).build());
}
/**
* 发起GET请求并获取返回的文本
*
* @param url 响应请求的的服务器地址
* @param params 参数
* @param responseEncoding 返回的文本的编码
* @return 服务器返回的文本内容
* @see com.fanruan.api.net.http.HttpKit#executeAndParse(HttpRequest, BaseHttpResponseHandle)
*/
public static String get(String url, Map<String, String> params, String responseEncoding) throws IOException {
return executeAndParse(HttpRequest
.custom()
.url(url)
.params(params)
.build(),
new TextResponseHandle(responseEncoding));
}
/**
* 发起GET请求并获取返回的文本
*
* @param url 响应请求的的服务器地址
* @param params 参数
* @param responseEncoding 返回的文本的编码
* @return 服务器返回的文本内容
* @see com.fanruan.api.net.http.HttpKit#executeAndParse(HttpRequest, BaseHttpResponseHandle)
*/
public static String get(String url, Map<String, String> params, String responseEncoding, Map<String, String> headers) throws IOException {
return executeAndParse(HttpRequest
.custom()
.url(url)
.params(params)
.headers(headers)
.build(),
new TextResponseHandle(responseEncoding));
}
/**
* 从指定的地址下载文件
*
* @param url 文件下载地址
* @return 文件的字节流
* @throws IOException 下载过程中出现错误则抛出此异常
*/
public static ByteArrayInputStream download(String url) throws IOException {
return executeAndParse(HttpRequest.custom().url(url).build(), StreamResponseHandle.DEFAULT);
}
/**
* 从指定的地址下载文件
*
* @param url 文件下载地址
* @param params 参数对
* @param responseEncoding 响应的文件编码
* @param headers 请求头
* @return 文件的字节流
* @throws IOException 下载过程中出现错误则抛出此异常
*/
public static ByteArrayInputStream download(String url, Map<String, String> params, String responseEncoding, Map<String, String> headers) throws IOException {
return executeAndParse(HttpRequest
.custom()
.url(url)
.params(params)
.headers(headers)
.build(),
new StreamResponseHandle(responseEncoding));
}
/**
* 上传文件到指定的服务器
*
* @param url 接收文件的服务器地址
* @param file 要上传的文件默认的文件编码为utf-8
* @throws IOException 上传中出现错误则抛出此异常
*/
public static void upload(String url, File file) throws IOException {
upload(url, file, Charset.forName("utf-8"));
}
/**
* 上传文件到指定的服务器
*
* @param url 接收文件的服务器地址
* @param file 要上传的文件
* @param charset 文件的编码
* @throws IOException 上传中出现错误则抛出此异常
*/
public static void upload(String url, File file, Charset charset) throws IOException {
upload(url, new FileEntity(file), charset);
}
/**
* 上传文件到指定的服务器
*
* @param url 接收文件的服务器地址
* @param builder 附件构造器
* @param charset 文件的编码
* @throws IOException 上传中出现错误则抛出此异常
*/
public static void upload(String url, MultipartEntityBuilder builder, Charset charset) throws IOException {
upload(url, builder, charset, Collections.<String, String>emptyMap(), POST);
}
/**
* 上传文件到指定的服务器
*
* @param url 接收文件的服务器地址
* @param fileEntity 文件实体
* @param charset 文件的编码
* @throws IOException 上传中出现错误则抛出此异常
*/
public static void upload(String url, FileEntity fileEntity, Charset charset) throws IOException {
upload(url, fileEntity, charset, Collections.<String, String>emptyMap(), POST);
}
/**
* 上传多文件到指定的服务器
*
* @param url 接收文件的服务器地址
* @param builder 附件构造器
* @param charset 文件的编码
* @param headers 请求头
* @param httpRequestType 请求类型
* @throws IOException 上传中出现错误则抛出此异常
*/
public static void upload(String url, MultipartEntityBuilder builder, Charset charset, Map<String, String> headers, HttpRequestType httpRequestType) throws IOException {
// richie:采用浏览器模式,防止出现乱码
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
HttpEntity reqEntity = builder.setCharset(charset).build();
upload(url, reqEntity, charset, headers, httpRequestType);
}
/**
* 上传文件到指定的服务器
*
* @param url 接收文件的服务器地址
* @param reqEntity 请求实体
* @param charset 文件的编码
* @param headers 请求头
* @param httpRequestType 请求类型
* @throws IOException 上传中出现错误则抛出此异常
*/
public static void upload(String url, HttpEntity reqEntity, Charset charset, Map<String, String> headers, HttpRequestType httpRequestType) throws IOException {
executeAndParse(HttpRequest
.custom()
.url(url)
.headers(headers)
.method(httpRequestType)
.httpEntity(reqEntity)
.encoding(charset.toString())
.build(),
UploadResponseHandle.DEFAULT);
}
/**
* 请求资源或服务使用默认文本http解析器UTF-8编码
*
* @param httpRequest httpRequest
* @return 返回处理结果
*/
public static String executeAndParse(HttpRequest httpRequest) throws IOException {
return executeAndParse(httpRequest, TextResponseHandle.DEFAULT);
}
/**
* 请求资源或服务自请求参数并指定 http 响应处理器
*
* <pre>
* String res = HttpToolbox.executeAndParse(HttpRequest
* .custom()
* .url("")
* .build(),
* TextResponseHandle.DEFAULT);
* </pre>
*
* @param httpRequest httpRequest
* @param handle http 解析器
* @return 返回处理结果
*/
public static <T> T executeAndParse(HttpRequest httpRequest, BaseHttpResponseHandle<T> handle) throws IOException {
return handle.parse(execute(httpRequest));
}
/**
* 请求资源或服务传入请求参数
*
* @param httpRequest httpRequest
* @return 返回处理结果
*/
public static CloseableHttpResponse execute(HttpRequest httpRequest) throws IOException {
return execute(getHttpClient(httpRequest.getUrl()), httpRequest);
}
/**
* 请求资源或服务自定义client对象传入请求参数
*
* @param httpClient http客户端
* @param httpRequest httpRequest
* @return 返回处理结果
*/
public static CloseableHttpResponse execute(CloseableHttpClient httpClient, HttpRequest httpRequest) throws IOException {
String url = httpRequest.getUrl();
// 创建请求对象
HttpRequestBase httpRequestBase = httpRequest.getMethod().createHttpRequest(url);
// 设置header信息
httpRequestBase.setHeader("User-Agent", "Mozilla/5.0");
Map<String, String> headers = httpRequest.getHeaders();
if (headers != null && !headers.isEmpty()) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
httpRequestBase.setHeader(entry.getKey(), entry.getValue());
}
}
// 配置请求的设置
RequestConfig requestConfig = httpRequest.getConfig();
if (requestConfig != null) {
httpRequestBase.setConfig(requestConfig);
}
// 判断是否支持设置entity(仅HttpPost、HttpPut、HttpPatch支持)
if (HttpEntityEnclosingRequestBase.class.isAssignableFrom(httpRequestBase.getClass())) {
setHttpEntity((HttpEntityEnclosingRequestBase) httpRequestBase, httpRequest);
} else {
Map<String, String> params = httpRequest.getParams();
if (params != null && !params.isEmpty()) {
// 注意get等不支持设置entity需要更新拼接之后的URL,但是url变量没有更新
httpRequestBase.setURI(URI.create(buildUrl(url, params, httpRequest.getEncoding())));
}
}
return httpClient.execute(httpRequestBase);
}
/**
* 构建 Url
*
* @param url 请求地址
* @param params 参数
* @return 拼接之后的地址
*/
public static String buildUrl(String url, Map<String, String> params) {
try {
return buildUrl(url, params, EncodeConstants.ENCODING_UTF_8);
} catch (UnsupportedEncodingException ignore) {
}
return url;
}
/**
* 构建 Url
*
* @param url 请求地址
* @param params 参数
* @return 拼接之后的地址
* @throws UnsupportedEncodingException 不支持的编码
*/
private static String buildUrl(String url, Map<String, String> params, String paramsEncoding) throws UnsupportedEncodingException {
if (params == null || params.isEmpty()) {
return url;
}
URIBuilder builder;
try {
builder = new URIBuilder(url);
for (Map.Entry<String, String> entry : params.entrySet()) {
String key = URLEncoder.encode(entry.getKey(), paramsEncoding);
String value = URLEncoder.encode(entry.getValue(), paramsEncoding);
builder.setParameter(key, value);
}
return builder.build().toString();
} catch (URISyntaxException e) {
LogKit.debug("Error to build url, please check the arguments.");
}
return url;
}
}

28
src/main/java/com/fr/plugin/xx/submitjob/request/SubmitControllerBridge.java

@ -0,0 +1,28 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: SubmitControllerBridge
* Author: xx
* Date: 2021/3/4 16:45
*/
package com.fr.plugin.xx.submitjob.request;
import com.fr.decision.fun.impl.AbstractControllerRegisterProvider;
import com.fr.plugin.xx.submitjob.request.controller.SubmitJobController;
/**
* <Function Description><br>
* <接口测试用途SubmitControllerBridge>
*
* @author xx
* @since 1.0.0
*/
public class SubmitControllerBridge extends AbstractControllerRegisterProvider {
@Override
public Class[] getControllers() {
return new Class[]{
SubmitJobController.class
};
}
}

100
src/main/java/com/fr/plugin/xx/submitjob/request/controller/SubmitJobController.java

@ -0,0 +1,100 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: SubmitJobController
* Author: xx
* Date: 2021/3/4 16:51
*/
package com.fr.plugin.xx.submitjob.request.controller;
import com.fanruan.api.log.LogKit;
import com.fr.decision.webservice.annotation.LoginStatusChecker;
import com.fr.third.springframework.stereotype.Controller;
import com.fr.third.springframework.web.bind.annotation.*;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
/**
* <Function Description><br>
* <测试接口SubmitJobController>
*
* @author xx
* @since 1.0.0
*/
@Controller
@RequestMapping("submitjob")
public class SubmitJobController {
// submitjob
@RequestMapping(value = "get", method = RequestMethod.GET)
@ResponseBody
@LoginStatusChecker(required = false)
public String submitjobGet(@RequestParam(value = "documentCode", required = true) String documentCode,
@RequestHeader(value = "token", required = true) String token,
@RequestParam(value = "VENDOR_CODE", required = true) String vendorCode) throws UnsupportedEncodingException {
LogKit.info("submitjob-测试接口-get, documentCode:" + URLDecoder.decode(documentCode, "UTF-8").replace("+", " ")
+ ", vendorCode:" + URLDecoder.decode(vendorCode, "UTF-8").replace("+", " ")
+ ", token:" + URLDecoder.decode(token, "UTF-8").replace("+", " "));
return "{\"code\":0,\"message\":\"\",\"status\":\"OK\"}";
}
@RequestMapping(value = "post", method = RequestMethod.POST)
@ResponseBody
@LoginStatusChecker(required = false)
public String submitjobPost(@RequestParam(value = "documentCode", required = true) String documentCode,
// @RequestHeader(value = "token", required = true) String token,
@RequestParam(value = "VENDOR_CODE", required = true) String vendorCode) {
LogKit.info("submitjob-测试接口-post, documentCode:" + documentCode + ", vendorCode:" + vendorCode);
return "{\"code\":0,\"message\":\"\",\"status\":\"OK\"}";
}
@RequestMapping(value = "post-json", method = RequestMethod.POST)
@ResponseBody
@LoginStatusChecker(required = false)
public String submitjobPostJson(@RequestBody String paramBody) {
LogKit.info("submitjob-测试接口-post, paramBody:" + paramBody);
return "{\"code\":0,\"message\":\"\",\"status\":\"OK\"}";
}
@RequestMapping(value = "post-total", method = RequestMethod.POST)
@ResponseBody
@LoginStatusChecker(required = false)
public String submitjobPostTotal(@RequestBody String paramBody) {
LogKit.info("submitjob-测试接口-post-total, paramBody:" + paramBody);
return "{\"code\":0,\"message\":\"\",\"status\":\"OK\"}";
}
@RequestMapping(value = "soap", method = RequestMethod.POST)
@ResponseBody
@LoginStatusChecker(required = false)
public String submitjobSoap(@RequestHeader(value = "Content-Type", required = true) String ContentType,
@RequestHeader(value = "SOAPAction", required = true) String SOAPAction,
@RequestBody String bodyContent) {
LogKit.info("submitjob-测试接口-soap, bodyContent:" + bodyContent + ", ContentType:" + ContentType + ", SOAPAction:" + SOAPAction);
return "{\"code\":0,\"message\":\"\",\"status\":\"OK\"}";
}
@RequestMapping(value = "soap-total", method = RequestMethod.POST)
@ResponseBody
@LoginStatusChecker(required = false)
public String submitjobSoapTotal(@RequestHeader(value = "Content-Type", required = true) String ContentType,
@RequestHeader(value = "SOAPAction", required = true) String SOAPAction,
@RequestBody String bodyContent) {
LogKit.info("submitjob-测试接口-soap-total, bodyContent:" + bodyContent + ", ContentType:" + ContentType + ", SOAPAction:" + SOAPAction);
return "{\"code\":0,\"message\":\"\",\"status\":\"OK\"}";
}
// submitjob
@RequestMapping(value = "getError", method = RequestMethod.GET)
@ResponseBody
@LoginStatusChecker(required = false)
public String submitjobGetError(@RequestParam(value = "documentCode", required = true) String documentCode,
@RequestHeader(value = "token", required = true) String token,
@RequestParam(value = "VENDOR_CODE", required = true) String vendorCode) throws UnsupportedEncodingException {
LogKit.info("submitjob-测试接口-getError, documentCode:" + URLDecoder.decode(documentCode, "UTF-8").replace("+", " ")
+ ", vendorCode:" + URLDecoder.decode(vendorCode, "UTF-8").replace("+", " ")
+ ", token:" + URLDecoder.decode(token, "UTF-8").replace("+", " "));
return "{\"code\":1,\"message\":\"运行错误异常\",\"status\":\"OK\"}";
}
}

197
src/main/java/com/fr/plugin/xx/submitjob/ui/DataSubmitConfigPane.java

@ -0,0 +1,197 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: DataSubmitConfigPane
* Author: xx
* Date: 2020/8/31 21:59
*/
package com.fr.plugin.xx.submitjob.ui;
import com.fanruan.api.design.ui.component.UILabel;
import com.fanruan.api.design.ui.component.UITextArea;
import com.fanruan.api.design.ui.component.UITextField;
import com.fanruan.api.design.ui.container.UIScrollPane;
import com.fanruan.api.design.ui.layout.TableLayoutKit;
import com.fanruan.api.i18n.I18nKit;
import com.fanruan.api.util.StringKit;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.gui.frpane.ObjectProperiesPane;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.itextfield.PlaceholderTextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.plugin.xx.submitjob.SubmitUIBridge;
import com.fr.plugin.xx.submitjob.job.DataSubmitTask;
import com.fr.plugin.xx.submitjob.job.GetSubmitJob;
import com.fr.plugin.xx.submitjob.job.PostSubmitJob;
import com.fr.stable.CommonUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.List;
/**
* <Function Description><br>
* <数据提交配置DataSubmitConfigPane>
*
* @author xx
* @since 1.0.0
*/
public class DataSubmitConfigPane extends BasicBeanPane<DataSubmitTask> {
public static final int CONTENT_PANE_INDEX = 2;
private static final int CONTENT_PANE_COLUMNS = 30;
private static String WATER_MARK = "decision/view/report";
protected UIComboBox classNameComboBox;
protected ObjectProperiesPane headerProperiesPane;
protected ObjectProperiesPane objectProperiesPane;
private UIComboBox stateComboBox;
private JTabbedPane tabbedPane;
private PlaceholderTextField linkField;
private UITextArea bodyContent;
private UITextField errorFlagTextField;
private UITextField successStatusTextField;
private UITextField errorMessageFlagTextField;
public DataSubmitConfigPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel classPathPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane();
this.classNameComboBox = initUIComboBox(DataSubmitItems.LIST_ITEMS);
this.classNameComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (!ComparatorUtils.equals(e.getStateChange(), ItemEvent.SELECTED)) {
return;
}
if (ComparatorUtils.equals(e.getItem().toString(), I18nKit.getLocText("Plugin-submitjob_ClassName_Get_Submit")) ||
ComparatorUtils.equals(e.getItem().toString(), I18nKit.getLocText("Plugin-submitjob_ClassName_Post_Submit"))) {
DataSubmitConfigPane.this.tabbedPane.setEnabledAt(CONTENT_PANE_INDEX, false);
} else {
DataSubmitConfigPane.this.tabbedPane.setEnabledAt(CONTENT_PANE_INDEX, true);
}
}
});
this.stateComboBox = initUIComboBox(StateItems.LIST_ITEMS);
this.linkField = this.createHolderTextField();
classPathPane.add(this.classNameComboBox);
classPathPane.add(this.stateComboBox);
classPathPane.add(this.linkField);
classPathPane.setBorder(GUICoreUtils.createTitledBorder(I18nKit.getLocText("Plugin-submitjob_ClassPath_Title"), null));
this.add(classPathPane, BorderLayout.NORTH);
this.headerProperiesPane = new ObjectProperiesPane();
this.objectProperiesPane = new ObjectProperiesPane();
UIScrollPane bodyContentPane = new UIScrollPane(this.bodyContent = new UITextArea(5, CONTENT_PANE_COLUMNS));
bodyContentPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
UIScrollPane uiScrollPane = new UIScrollPane(bodyContentPane);
uiScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
errorFlagTextField = new UITextField();
successStatusTextField = new UITextField();
errorMessageFlagTextField = new UITextField();
double p = TableLayoutKit.PREFERRED;
double f = TableLayoutKit.FILL;
double[] rowSize = new double[]{p, p, p};
double[] columnSize = new double[]{p, f};
JComponent[][] comps = new JComponent[][]{
{new UILabel(I18nKit.getLocText("Plugin-submitjob_Result_Error_Flag") + ":"), errorFlagTextField},
{new UILabel(I18nKit.getLocText("Plugin-submitjob_Result_Success_Status") + ":"), successStatusTextField},
{new UILabel(I18nKit.getLocText("Plugin-submitjob_Result_Error_Message_Flag") + ":"), errorMessageFlagTextField}
};
JPanel resultContentPane = TableLayoutKit.createTableLayoutPane(comps, rowSize, columnSize);
this.tabbedPane = new UITabbedPane();
this.tabbedPane.add(I18nKit.getLocText("Plugin-submitjob_Body_Property"), this.objectProperiesPane);
this.tabbedPane.add(I18nKit.getLocText("Plugin-submitjob_Header_Property"), this.headerProperiesPane);
this.tabbedPane.add(I18nKit.getLocText("Plugin-submitjob_Body_Content"), uiScrollPane);
this.tabbedPane.add(I18nKit.getLocText("Plugin-submitjob_Result_Content"), resultContentPane);
this.add(this.tabbedPane, BorderLayout.CENTER);
UITextArea description = new UITextArea(2, 1);
description.setText(I18nKit.getLocText("Plugin-submitjob_Basic_Extend_Class", "com.fr.data.AbstractSubmitTask"));
JPanel descriptionPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
descriptionPane.add(description);
descriptionPane.setBorder(GUICoreUtils.createTitledBorder(I18nKit.getLocText("Plugin-submitjob_Basic_Custom_Job_Description"), null));
this.add(descriptionPane, BorderLayout.SOUTH);
this.checkAddButtonEnable();
}
@Override
protected String title4PopupWindow() {
return SubmitUIBridge.KEY;
}
@Override
public void populateBean(DataSubmitTask submitJob) {
if (CommonUtils.isNull(submitJob)) {
return;
}
this.classNameComboBox.setSelectedIndex(DataSubmitItems.classNameList.indexOf(submitJob.getClassName()));
if (ComparatorUtils.equals(submitJob.getClassName(), GetSubmitJob.class.getName())
|| ComparatorUtils.equals(submitJob.getClassName(), PostSubmitJob.class.getName())) {
this.tabbedPane.setEnabledAt(CONTENT_PANE_INDEX, false);
}
this.stateComboBox.setSelectedIndex(StateItems.stateList.indexOf(submitJob.getState()));
this.linkField.setText(submitJob.getUrl());
this.bodyContent.setText(submitJob.getBodyContent());
this.errorFlagTextField.setText(submitJob.getErrorFlag());
this.successStatusTextField.setText(submitJob.getSuccessStatus());
this.errorMessageFlagTextField.setText(submitJob.getErrorMessageFlag());
this.headerProperiesPane.populateBean(submitJob.getHeaderMap());
this.objectProperiesPane.populateBean(submitJob.getPropertyMap());
this.checkAddButtonEnable();
}
@Override
public DataSubmitTask updateBean() {
DataSubmitTask submitJob = new DataSubmitTask(DataSubmitItems.classNameList.get(this.classNameComboBox.getSelectedIndex()));
submitJob.setState(StateItems.stateList.get(this.stateComboBox.getSelectedIndex()));
submitJob.setUrl(this.linkField.getText());
submitJob.setBodyContent(this.bodyContent.getText());
submitJob.setErrorFlag(this.errorFlagTextField.getText());
submitJob.setSuccessStatus(this.successStatusTextField.getText());
submitJob.setErrorMessageFlag(this.errorMessageFlagTextField.getText());
submitJob.setPropertyMap(this.objectProperiesPane.updateBean());
submitJob.setHeaderMap(this.headerProperiesPane.updateBean());
this.checkAddButtonEnable();
return submitJob;
}
@Override
public void checkValid() throws Exception {
if (StringKit.isBlank(this.linkField.getText())) {
throw new Exception(I18nKit.getLocText("Plugin-submitjob_Link_Valid"));
}
}
public void checkAddButtonEnable() {
this.headerProperiesPane.enableAddButton(true);
this.objectProperiesPane.enableAddButton(true);
}
private PlaceholderTextField createHolderTextField() {
PlaceholderTextField placeholderTextField = new PlaceholderTextField(CONTENT_PANE_COLUMNS);
placeholderTextField.setPlaceholder(WATER_MARK);
return placeholderTextField;
}
/**
* 初始化类名下拉框
*
* @param items
* @return
*/
private UIComboBox initUIComboBox(List<Item> items) {
DefaultComboBoxModel model = new DefaultComboBoxModel();
for (Item item : items) {
model.addElement(item);
}
return new UIComboBox(model);
}
}

60
src/main/java/com/fr/plugin/xx/submitjob/ui/DataSubmitItems.java

@ -0,0 +1,60 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: DataSubmitItems
* Author: xx
* Date: 2020/9/1 8:47
*/
package com.fr.plugin.xx.submitjob.ui;
import com.fanruan.api.i18n.I18nKit;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.designer.properties.items.ItemProvider;
import com.fr.plugin.xx.submitjob.job.*;
import java.util.ArrayList;
import java.util.List;
/**
* <Function Description><br>
* <DataSubmitItems>
*
* @author xx
* @since 1.0.0
*/
public class DataSubmitItems implements ItemProvider {
public static List<Item> LIST_ITEMS = new ArrayList<Item>() {
private static final long serialVersionUID = 4517273885238014305L;
{
add(new Item(I18nKit.getLocText("Plugin-submitjob_ClassName_Get_Submit"), GetSubmitJob.class.getName()));
add(new Item(I18nKit.getLocText("Plugin-submitjob_ClassName_Post_Submit"), PostSubmitJob.class.getName()));
add(new Item(I18nKit.getLocText("Plugin-submitjob_ClassName_Post_Json_Submit"), PostJsonSubmitJob.class.getName()));
add(new Item(I18nKit.getLocText("Plugin-submitjob_ClassName_Post_Total_Submit"), PostTotalSubmitJob.class.getName()));
add(new Item(I18nKit.getLocText("Plugin-submitjob_ClassName_Soap_Submit"), SoapSubmitJob.class.getName()));
add(new Item(I18nKit.getLocText("Plugin-submitjob_ClassName_Soap_Total_Submit"), SoapTotalSubmitJob.class.getName()));
}
};
public static List<String> classNameList = new ArrayList<String>() {
private static final long serialVersionUID = 1815958019785941089L;
{
add(GetSubmitJob.class.getName());
add(PostSubmitJob.class.getName());
add(PostJsonSubmitJob.class.getName());
add(PostTotalSubmitJob.class.getName());
add(SoapSubmitJob.class.getName());
add(SoapTotalSubmitJob.class.getName());
}
};
public DataSubmitItems() {
}
@Override
public Item[] getItems() {
return LIST_ITEMS.toArray(new Item[0]);
}
}

55
src/main/java/com/fr/plugin/xx/submitjob/ui/StateItems.java

@ -0,0 +1,55 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: StateItems
* Author: xx
* Date: 2021/2/22 16:56
*/
package com.fr.plugin.xx.submitjob.ui;
import com.fanruan.api.i18n.I18nKit;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.designer.properties.items.ItemProvider;
import java.util.ArrayList;
import java.util.List;
/**
* <Function Description><br>
* <StateItems>
*
* @author xx
* @since 1.0.0
*/
public class StateItems implements ItemProvider {
public static final String CHANGED = "Changed";
public static final String INSERT = "Insert";
public static final String DELETED = "Deleted";
public static final String DEFAULT = "Default";
public static List<Item> LIST_ITEMS = new ArrayList<Item>() {
private static final long serialVersionUID = 6046814757149293673L;
{
add(new Item(I18nKit.getLocText("Plugin-submitjob_State_Changed"), CHANGED));
add(new Item(I18nKit.getLocText("Plugin-submitjob_State_Insert"), INSERT));
add(new Item(I18nKit.getLocText("Plugin-submitjob_State_Deleted"), DELETED));
add(new Item(I18nKit.getLocText("Plugin-submitjob_State_Default"), DEFAULT));
}
};
public static List<String> stateList = new ArrayList<String>() {
private static final long serialVersionUID = 4772266674754035741L;
{
add("Changed");
add("Insert");
add("Deleted");
add("Default");
}
};
@Override
public Item[] getItems() {
return LIST_ITEMS.toArray(new Item[0]);
}
}

30
src/main/resources/com/fr/plugin/xx/submitjob/locale/lang.properties

@ -0,0 +1,30 @@
Plugin-submitjob=Data Submit Job
Plugin-submitjob_Submit_Data=API Data Submit
Plugin-submitjob_ClassPath_Title=Submit Method & Cell State & Url
Plugin-submitjob_Header_Property=Header Property
Plugin-submitjob_Body_Property=Body Property
Plugin-submitjob_Body_Content=Body Content
Plugin-submitjob_Result_Content=Result Content
Plugin-submitjob_Result_Error_Flag=Error Flag
Plugin-submitjob_Result_Success_Status=Success Status
Plugin-submitjob_Result_Error_Message_Flag=Error Message Flag
Plugin-submitjob_ClassName_Get_Submit=Get
Plugin-submitjob_ClassName_Post_Submit=Post
Plugin-submitjob_ClassName_Post_Json_Submit=PostJson
Plugin-submitjob_ClassName_Post_Total_Submit=PostTotal
Plugin-submitjob_ClassName_Soap_Submit=Soap
Plugin-submitjob_ClassName_Soap_Total_Submit=SoapTotal
Plugin-submitjob_State_Changed=Changed
Plugin-submitjob_State_Insert=Insert
Plugin-submitjob_State_Deleted=Deleted
Plugin-submitjob_State_Default=Default
Plugin-submitjob_Link_Valid=URL is not empty
Plugin-submitjob_State_Valid=State is not empty
Plugin-submitjob_Body_Content_Valid=Body Template is not empty
Plugin-submitjob_Body_Content_Format_Valid=body Template Error
Plugin-submitjob_Header_Content-Type_Valid=Header Content-Type Error
Plugin-submitjob_Header_SOAPAction_Valid=Header SOAPAction Error
Plugin-submitjob_Result_Message=Result:
Plugin-submitjob_Licence_Expired=Submitjob Plugin Licence Expired
Plugin-submitjob_Basic_Extend_Class=Extend Class:{}.
Plugin-submitjob_Basic_Custom_Job_Description=Description

30
src/main/resources/com/fr/plugin/xx/submitjob/locale/lang_en.properties

@ -0,0 +1,30 @@
Plugin-submitjob=Data Submit Job
Plugin-submitjob_Submit_Data=API Data Submit
Plugin-submitjob_ClassPath_Title=Submit Method & Cell State & Url
Plugin-submitjob_Header_Property=Header Property
Plugin-submitjob_Body_Property=Body Property
Plugin-submitjob_Body_Content=Body Content
Plugin-submitjob_Result_Content=Result Content
Plugin-submitjob_Result_Error_Flag=Error Flag
Plugin-submitjob_Result_Success_Status=Success Status
Plugin-submitjob_Result_Error_Message_Flag=Error Message Flag
Plugin-submitjob_ClassName_Get_Submit=Get
Plugin-submitjob_ClassName_Post_Submit=Post
Plugin-submitjob_ClassName_Post_Json_Submit=PostJson
Plugin-submitjob_ClassName_Post_Total_Submit=PostTotal
Plugin-submitjob_ClassName_Soap_Submit=Soap
Plugin-submitjob_ClassName_Soap_Total_Submit=SoapTotal
Plugin-submitjob_State_Changed=Changed
Plugin-submitjob_State_Insert=Insert
Plugin-submitjob_State_Deleted=Deleted
Plugin-submitjob_State_Default=Default
Plugin-submitjob_Link_Valid=URL is not empty
Plugin-submitjob_State_Valid=State is not empty
Plugin-submitjob_Body_Content_Valid=Body Template is not empty
Plugin-submitjob_Body_Content_Format_Valid=body Template Error
Plugin-submitjob_Header_Content-Type_Valid=Header Content-Type Error
Plugin-submitjob_Header_SOAPAction_Valid=Header SOAPAction Error
Plugin-submitjob_Result_Message=Result:
Plugin-submitjob_Licence_Expired=Submitjob Plugin Licence Expired
Plugin-submitjob_Basic_Extend_Class=Extend Class:{}.
Plugin-submitjob_Basic_Custom_Job_Description=Description

30
src/main/resources/com/fr/plugin/xx/submitjob/locale/lang_zh_CN.properties

@ -0,0 +1,30 @@
Plugin-submitjob=\u586B\u62A5\u6570\u636E\u63A5\u53E3\u63D0\u4EA4
Plugin-submitjob_Submit_Data=\u63A5\u53E3\u6570\u636E\u63D0\u4EA4
Plugin-submitjob_ClassPath_Title=\u63D0\u4EA4\u65B9\u5F0F & \u5355\u5143\u683C\u72B6\u6001 & \u94FE\u63A5
Plugin-submitjob_Header_Property=Header\u53C2\u6570
Plugin-submitjob_Body_Property=Body\u53C2\u6570
Plugin-submitjob_Body_Content=Body\u5185\u5BB9
Plugin-submitjob_Result_Content=\u8FD4\u56DE\u7ED3\u679C
Plugin-submitjob_Result_Error_Flag=\u9519\u8BEF\u6807\u8BC6
Plugin-submitjob_Result_Success_Status=\u6210\u529F\u72B6\u6001\u503C
Plugin-submitjob_Result_Error_Message_Flag=\u9519\u8BEF\u4FE1\u606F\u6807\u8BC6
Plugin-submitjob_ClassName_Get_Submit=Get
Plugin-submitjob_ClassName_Post_Submit=Post
Plugin-submitjob_ClassName_Post_Json_Submit=PostJson
Plugin-submitjob_ClassName_Post_Total_Submit=PostTotal
Plugin-submitjob_ClassName_Soap_Submit=Soap
Plugin-submitjob_ClassName_Soap_Total_Submit=SoapTotal
Plugin-submitjob_State_Changed=\u53D8\u66F4
Plugin-submitjob_State_Insert=\u65B0\u589E
Plugin-submitjob_State_Deleted=\u5220\u9664
Plugin-submitjob_State_Default=\u9ED8\u8BA4
Plugin-submitjob_Link_Valid=\u94FE\u63A5\u4E0D\u80FD\u4E3A\u7A7A
Plugin-submitjob_State_Valid=\u72B6\u6001\u4E0D\u80FD\u4E3A\u7A7A
Plugin-submitjob_Body_Content_Valid=body\u6A21\u677F\u4E0D\u80FD\u4E3A\u7A7A
Plugin-submitjob_Body_Content_Format_Valid=body\u6A21\u677F\u683C\u5F0F\u9519\u8BEF
Plugin-submitjob_Header_Content-Type_Valid=Header\u53C2\u6570Content-Type\u4E3A\u7A7A\u6216\u9519\u8BEF
Plugin-submitjob_Header_SOAPAction_Valid=Header\u53C2\u6570SOAPAction\u4E3A\u7A7A\u6216\u9519\u8BEF
Plugin-submitjob_Result_Message=\u7ED3\u679C:
Plugin-submitjob_licence_Expired=\u586B\u62A5\u6570\u636E\u63A5\u53E3\u63D0\u4EA4\u63D2\u4EF6\u6388\u6743\u8BB8\u53EF\u8FC7\u671F
Plugin-submitjob_Basic_Extend_Class=\u7EE7\u627F\u7C7B:{}\u3002
Plugin-submitjob_Basic_Custom_Job_Description=\u63CF\u8FF0
Loading…
Cancel
Save