LAPTOP-SB56SG4Q\86185
3 years ago
18 changed files with 1403 additions and 1 deletions
Binary file not shown.
@ -1,3 +1,6 @@ |
|||||||
# open-JSD-8658 |
# open-JSD-8658 |
||||||
|
|
||||||
JSD-8658 泛微E9消息推送 |
JSD-8658 泛微E9消息推送\ |
||||||
|
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||||
|
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||||
|
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。 |
@ -0,0 +1,34 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||||
|
<plugin> |
||||||
|
<id>com.fr.plugin.xxxx.swyy.message</id> |
||||||
|
<main-package>com.fr.plugin.xxxx.swyy.message</main-package> |
||||||
|
<name><![CDATA[泛微OA消息推送]]></name> |
||||||
|
<active>yes</active> |
||||||
|
<version>1.9</version> |
||||||
|
<env-version>10.0</env-version> |
||||||
|
<jartime>2018-07-31</jartime> |
||||||
|
<vendor>fr.open</vendor> |
||||||
|
<description><![CDATA[泛微OA消息推送]]></description> |
||||||
|
<change-notes><![CDATA[ |
||||||
|
[2021-12-14]【1.0】初始化插件。<br/> |
||||||
|
[2021-12-17]【1.1】修改传递字段。<br/> |
||||||
|
[2021-12-17]【1.2】代码修改。<br/> |
||||||
|
[2021-12-17]【1.3】代码修改。<br/> |
||||||
|
[2021-01-10]【1.4】乱码修改。<br/> |
||||||
|
[2021-01-11]【1.5】接口传输修改。<br/> |
||||||
|
[2021-01-11]【1.6】公式支持。<br/> |
||||||
|
[2021-01-13]【1.7】公式支持。<br/> |
||||||
|
[2022-02-22]【1.8】链接乱码解决。<br/> |
||||||
|
[2022-02-25]【1.9】链接乱码解决。<br/> |
||||||
|
]]></change-notes> |
||||||
|
<extra-decision> |
||||||
|
<WebResourceProvider class="com.fr.plugin.xxxx.swyy.message.js.JSCSSBridge"/> |
||||||
|
<DecisionDBAccessProvider class="com.fr.plugin.xxxx.swyy.message.ScheduleOutputDBAccess"/> |
||||||
|
<!--插件注入提取公式的类--> |
||||||
|
<OutputFormulaExtractorProvider class="com.fr.plugin.xxxx.swyy.message.OutputFormulaCalculator"/> |
||||||
|
<!--插件注入处理公式的类--> |
||||||
|
<OutputFormulaProvider class="com.fr.plugin.xxxx.swyy.message.MessageFormula"/> |
||||||
|
</extra-decision> |
||||||
|
<function-recorder class="com.fr.plugin.xxxx.swyy.message.js.JSCSSBridge"/> |
||||||
|
<lifecycle-monitor class="com.fr.plugin.xxxx.swyy.message.LRGT"/> |
||||||
|
</plugin> |
@ -0,0 +1,37 @@ |
|||||||
|
package com.fr.plugin.xxxx.swyy.message; |
||||||
|
|
||||||
|
import com.fr.plugin.context.PluginContext; |
||||||
|
import com.fr.plugin.xxxx.swyy.message.conf.MessageConfig; |
||||||
|
import com.fr.plugin.xxxx.swyy.message.entity.EarlyMessageAction; |
||||||
|
import com.fr.plugin.xxxx.swyy.message.entity.EarlyMessageEntity; |
||||||
|
import com.fr.plugin.xxxx.swyy.message.handle.EarlyMessageHandle; |
||||||
|
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; |
||||||
|
import com.fr.schedule.feature.ScheduleOutputActionEntityRegister; |
||||||
|
import com.fr.schedule.feature.output.OutputActionHandler; |
||||||
|
|
||||||
|
/** |
||||||
|
* 配置信息初始化 |
||||||
|
*/ |
||||||
|
|
||||||
|
public class LRGT extends AbstractPluginLifecycleMonitor { |
||||||
|
@Override |
||||||
|
public void afterRun(PluginContext pluginContext) { |
||||||
|
MessageConfig.getInstance(); |
||||||
|
OutputActionHandler.registerHandler(new EarlyMessageHandle(), EarlyMessageAction.class.getName()); |
||||||
|
ScheduleOutputActionEntityRegister.getInstance().addClass(EarlyMessageEntity.class); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void beforeStop(PluginContext pluginContext) { |
||||||
|
OutputActionHandler.removeOutputHandler(EarlyMessageAction.class.getName()); |
||||||
|
ScheduleOutputActionEntityRegister.getInstance().removeClass(EarlyMessageEntity.class); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void beforeUninstall(PluginContext pluginContext) { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void afterInstall(PluginContext var1) { |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
package com.fr.plugin.xxxx.swyy.message; |
||||||
|
|
||||||
|
import com.fr.main.workbook.ResultWorkBook; |
||||||
|
import com.fr.plugin.xxxx.swyy.message.entity.EarlyMessageAction; |
||||||
|
import com.fr.schedule.base.provider.impl.AbstractOutputFormulaProvider; |
||||||
|
import com.fr.schedule.extension.report.util.ScheduleParameterUtils; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author fr.open |
||||||
|
* @Date 2021/3/24 |
||||||
|
* @Description |
||||||
|
**/ |
||||||
|
public class MessageFormula extends AbstractOutputFormulaProvider<EarlyMessageAction, ResultWorkBook> { |
||||||
|
@Override |
||||||
|
public void dealWithFormulaParam(EarlyMessageAction outputSms, ResultWorkBook resultWorkBook, List<Map<String, Object>> map) throws Exception { |
||||||
|
outputSms.setSubject(ScheduleParameterUtils.dealWithParameter(outputSms.getSubject(), map.get(0), resultWorkBook)); |
||||||
|
outputSms.setContent(ScheduleParameterUtils.dealWithParameter(outputSms.getContent(), map.get(0), resultWorkBook)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getActionClassName() { |
||||||
|
return EarlyMessageAction.class.getName(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
package com.fr.plugin.xxxx.swyy.message; |
||||||
|
|
||||||
|
import com.fr.plugin.xxxx.swyy.message.entity.EarlyMessageAction; |
||||||
|
import com.fr.schedule.extension.report.job.output.formula.extract.impl.AbstractOutputFormulaExtractorProvider; |
||||||
|
import com.fr.schedule.extension.report.util.ScheduleParameterUtils; |
||||||
|
|
||||||
|
import java.util.Map; |
||||||
|
import java.util.regex.Pattern; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author fr.open |
||||||
|
* @Date 2021/3/24 |
||||||
|
* @Description |
||||||
|
**/ |
||||||
|
public class OutputFormulaCalculator extends AbstractOutputFormulaExtractorProvider<EarlyMessageAction> { |
||||||
|
@Override |
||||||
|
public String getActionClassName() { |
||||||
|
return EarlyMessageAction.class.getName(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void addFormulaToMap(EarlyMessageAction outputSms, Pattern pattern, Map<String, Object> map) { |
||||||
|
ScheduleParameterUtils.addFormulaToMap(outputSms.getSubject(), pattern, map); |
||||||
|
ScheduleParameterUtils.addFormulaToMap(outputSms.getContent(), pattern, map); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,14 @@ |
|||||||
|
package com.fr.plugin.xxxx.swyy.message; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author fr.open |
||||||
|
* @Date 2020/12/05 |
||||||
|
* @Description |
||||||
|
**/ |
||||||
|
public class PluginConstants { |
||||||
|
public static final String PLUGIN_ID = "com.fr.plugin.xxxx.swyy.message"; |
||||||
|
|
||||||
|
public static final String PLUGIN_NAME = "泛微E9消息推送"; |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,44 @@ |
|||||||
|
package com.fr.plugin.xxxx.swyy.message; |
||||||
|
|
||||||
|
import com.fr.decision.plugin.db.AbstractDecisionDBAccessProvider; |
||||||
|
import com.fr.plugin.xxxx.swyy.message.dao.EarlyMessageDao; |
||||||
|
import com.fr.plugin.xxxx.swyy.message.entity.EarlyMessageEntity; |
||||||
|
import com.fr.stable.db.accessor.DBAccessor; |
||||||
|
import com.fr.stable.db.dao.BaseDAO; |
||||||
|
import com.fr.stable.db.dao.DAOProvider; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author fr.open |
||||||
|
* @Date 2020/12/05 |
||||||
|
* @Description |
||||||
|
**/ |
||||||
|
public class ScheduleOutputDBAccess extends AbstractDecisionDBAccessProvider { |
||||||
|
|
||||||
|
private static DBAccessor dbAccessor; |
||||||
|
|
||||||
|
public DBAccessor getDbAccessor() { |
||||||
|
return dbAccessor; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DAOProvider[] registerDAO() { |
||||||
|
return new DAOProvider[]{ |
||||||
|
new DAOProvider() { |
||||||
|
@Override |
||||||
|
public Class getEntityClass() { |
||||||
|
return EarlyMessageEntity.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends BaseDAO> getDAOClass() { |
||||||
|
return EarlyMessageDao.class; |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onDBAvailable(DBAccessor dbAccessor) { |
||||||
|
ScheduleOutputDBAccess.dbAccessor = dbAccessor; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,91 @@ |
|||||||
|
package com.fr.plugin.xxxx.swyy.message.conf; |
||||||
|
|
||||||
|
import com.fr.config.*; |
||||||
|
import com.fr.config.holder.Conf; |
||||||
|
import com.fr.config.holder.factory.Holders; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @author fr.open |
||||||
|
* @since 2021/12/04 |
||||||
|
*/ |
||||||
|
@Visualization(category = "待办推送配置") |
||||||
|
public class MessageConfig extends DefaultConfiguration { |
||||||
|
|
||||||
|
private static volatile MessageConfig config = null; |
||||||
|
|
||||||
|
public static MessageConfig getInstance() { |
||||||
|
if (config == null) { |
||||||
|
config = ConfigContext.getConfigInstance(MessageConfig.class); |
||||||
|
} |
||||||
|
return config; |
||||||
|
} |
||||||
|
|
||||||
|
@Identifier(value = "debugSwitch", name = "插件调试开关", description = "日志调试模式", status = Status.SHOW) |
||||||
|
private Conf<Boolean> debugSwitch = Holders.simple(true); |
||||||
|
|
||||||
|
public Boolean getDebugSwitch() { |
||||||
|
return this.debugSwitch.get(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setDebugSwitch(Boolean debugSwitch) { |
||||||
|
this.debugSwitch.set(debugSwitch); |
||||||
|
} |
||||||
|
|
||||||
|
@Identifier(value = "sendNotify", name = "推送地址", description = "推送待办地址", status = Status.SHOW) |
||||||
|
private Conf<String> sendNotify = Holders.simple(""); |
||||||
|
|
||||||
|
public String getSendNotify() { |
||||||
|
return sendNotify.get(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setSendNotify(String sendNotify) { |
||||||
|
this.sendNotify.set(sendNotify); |
||||||
|
} |
||||||
|
|
||||||
|
@Identifier(value = "code", name = "消息来源", description = "消息来源", status = Status.SHOW) |
||||||
|
private Conf<String> code = Holders.simple("xxxx"); |
||||||
|
|
||||||
|
public String getCode() { |
||||||
|
return code.get(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setCode(String code) { |
||||||
|
this.code.set(code);; |
||||||
|
} |
||||||
|
|
||||||
|
@Identifier(value = "authUser", name = "鉴权用户名", description = "鉴权用户名", status = Status.SHOW) |
||||||
|
private Conf<String> authUser = Holders.simple(""); |
||||||
|
|
||||||
|
public String getAuthUser() { |
||||||
|
return authUser.get(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setAuthUser(String code) { |
||||||
|
this.authUser.set(code);; |
||||||
|
} |
||||||
|
|
||||||
|
@Identifier(value = "authPass", name = "鉴权密码", description = "鉴权密码", status = Status.SHOW) |
||||||
|
private Conf<String> authPass = Holders.simple(""); |
||||||
|
|
||||||
|
public String getAuthPass() { |
||||||
|
return authPass.get(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setAuthPass(String code) { |
||||||
|
this.authPass.set(code);; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object clone() throws CloneNotSupportedException { |
||||||
|
MessageConfig cloned = (MessageConfig) super.clone(); |
||||||
|
cloned.debugSwitch = (Conf<Boolean>) debugSwitch.clone(); |
||||||
|
cloned.sendNotify = (Conf<String>) sendNotify.clone(); |
||||||
|
cloned.code = (Conf<String>) code.clone(); |
||||||
|
cloned.authUser = (Conf<String>) authUser.clone(); |
||||||
|
cloned.authPass = (Conf<String>) authPass.clone(); |
||||||
|
return cloned; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
package com.fr.plugin.xxxx.swyy.message.dao; |
||||||
|
|
||||||
|
import com.fr.plugin.xxxx.swyy.message.entity.EarlyMessageEntity; |
||||||
|
import com.fr.stable.db.dao.BaseDAO; |
||||||
|
import com.fr.stable.db.session.DAOSession; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author fr.open |
||||||
|
* @Date 2020/12/05 |
||||||
|
* @Description |
||||||
|
**/ |
||||||
|
public class EarlyMessageDao extends BaseDAO<EarlyMessageEntity> { |
||||||
|
|
||||||
|
public EarlyMessageDao(DAOSession daoSession) { |
||||||
|
super(daoSession); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected Class<EarlyMessageEntity> getEntityClass() { |
||||||
|
return EarlyMessageEntity.class; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,127 @@ |
|||||||
|
package com.fr.plugin.xxxx.swyy.message.entity; |
||||||
|
|
||||||
|
import com.fr.schedule.base.bean.output.BaseOutputAction; |
||||||
|
import com.fr.schedule.base.entity.AbstractScheduleEntity; |
||||||
|
import com.fr.schedule.base.type.RunType; |
||||||
|
import com.fr.third.fasterxml.jackson.annotation.JsonSubTypes; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author fr.open |
||||||
|
* @Date 2020/12/05 |
||||||
|
* @Description |
||||||
|
**/ |
||||||
|
@JsonSubTypes.Type(value = EarlyMessageAction.class, name = "EarlyMessageAction") |
||||||
|
public class EarlyMessageAction extends BaseOutputAction { |
||||||
|
|
||||||
|
private static final long serialVersionUID = -7083270486682938571L; |
||||||
|
|
||||||
|
private int terminal = 32; |
||||||
|
|
||||||
|
private String subject; |
||||||
|
|
||||||
|
private String content; |
||||||
|
|
||||||
|
private int type; |
||||||
|
|
||||||
|
private int linkOpenType = -1; |
||||||
|
|
||||||
|
private String mediaId; |
||||||
|
|
||||||
|
private String customizeLink; |
||||||
|
|
||||||
|
private int runType = RunType.CLIENT_NOTIFICATION.getValue(); |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean willExecuteByUser() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public RunType runType() { |
||||||
|
return RunType.CLIENT_NOTIFICATION; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends AbstractScheduleEntity> outputActionEntityClass() { |
||||||
|
return EarlyMessageEntity.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public EarlyMessageEntity createOutputActionEntity() { |
||||||
|
EarlyMessageEntity entity = new EarlyMessageEntity(); |
||||||
|
entity.setId(this.getId()); |
||||||
|
entity.setContent(this.getContent()); |
||||||
|
entity.setSubject(this.getSubject()); |
||||||
|
entity.setTerminal(this.getTerminal()); |
||||||
|
entity.setType(this.getType()); |
||||||
|
entity.setLinkOpenType(this.getLinkOpenType()); |
||||||
|
entity.setCustomizeLink(this.getCustomizeLink()); |
||||||
|
entity.setMediaId(this.getMediaId()); |
||||||
|
return entity; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public int getTerminal() { |
||||||
|
return terminal; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTerminal(int terminal) { |
||||||
|
this.terminal = terminal; |
||||||
|
} |
||||||
|
|
||||||
|
public String getSubject() { |
||||||
|
return subject; |
||||||
|
} |
||||||
|
|
||||||
|
public void setSubject(String subject) { |
||||||
|
this.subject = subject; |
||||||
|
} |
||||||
|
|
||||||
|
public String getContent() { |
||||||
|
return content; |
||||||
|
} |
||||||
|
|
||||||
|
public void setContent(String content) { |
||||||
|
this.content = content; |
||||||
|
} |
||||||
|
|
||||||
|
public int getType() { |
||||||
|
return type; |
||||||
|
} |
||||||
|
|
||||||
|
public void setType(int type) { |
||||||
|
this.type = type; |
||||||
|
} |
||||||
|
|
||||||
|
public int getLinkOpenType() { |
||||||
|
return linkOpenType; |
||||||
|
} |
||||||
|
|
||||||
|
public void setLinkOpenType(int linkOpenType) { |
||||||
|
this.linkOpenType = linkOpenType; |
||||||
|
} |
||||||
|
|
||||||
|
public String getCustomizeLink() { |
||||||
|
return customizeLink; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCustomizeLink(String customizeLink) { |
||||||
|
this.customizeLink = customizeLink; |
||||||
|
} |
||||||
|
|
||||||
|
public String getMediaId() { |
||||||
|
return mediaId; |
||||||
|
} |
||||||
|
|
||||||
|
public void setMediaId(String mediaId) { |
||||||
|
this.mediaId = mediaId; |
||||||
|
} |
||||||
|
|
||||||
|
public int getRunType() { |
||||||
|
return runType; |
||||||
|
} |
||||||
|
|
||||||
|
public void setRunType(int runType) { |
||||||
|
this.runType = runType; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,153 @@ |
|||||||
|
package com.fr.plugin.xxxx.swyy.message.entity; |
||||||
|
|
||||||
|
import com.fr.schedule.base.entity.AbstractScheduleEntity; |
||||||
|
import com.fr.stable.db.constant.EntityConstant; |
||||||
|
import com.fr.stable.db.entity.TableAssociation; |
||||||
|
import com.fr.third.javax.persistence.Column; |
||||||
|
import com.fr.third.javax.persistence.Entity; |
||||||
|
import com.fr.third.javax.persistence.Table; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author fr.open |
||||||
|
* @Date 2020/12/05 |
||||||
|
* @Description |
||||||
|
**/ |
||||||
|
@Entity |
||||||
|
@Table(name = "fine_early_message") //表名
|
||||||
|
@TableAssociation(associated = true) |
||||||
|
public class EarlyMessageEntity extends AbstractScheduleEntity { |
||||||
|
private static final String COLUMN_TERMINAL = "terminal"; |
||||||
|
private static final String COLUMN_AGENTID = "agentId"; |
||||||
|
private static final String COLUMN_SUBJECT = "subject"; |
||||||
|
private static final String COLUMN_CONTENT = "content"; |
||||||
|
private static final String COLUMN_LINK_OPEN_TYPE = "linkOpenType"; |
||||||
|
private static final String COLUMN_CUSTOMIZE_LINK = "customizeLink"; |
||||||
|
private static final String COLUMN_TYPE = "type"; |
||||||
|
private static final String COLUMN_MEDIA_ID = "mediaId"; |
||||||
|
private static final String COLUMN_ADDRESSEE = "addressee"; |
||||||
|
private static final String COLUMN_CHAT_GROUPS = "chatGroups"; |
||||||
|
|
||||||
|
@Column(name = COLUMN_TERMINAL) |
||||||
|
private int terminal = 32; |
||||||
|
|
||||||
|
@Column(name = COLUMN_AGENTID) |
||||||
|
private String agentId = null; |
||||||
|
|
||||||
|
@Column(name = COLUMN_SUBJECT, length = EntityConstant.STRING_LONG_SIZE) |
||||||
|
private String subject; |
||||||
|
|
||||||
|
@Column(name = COLUMN_CONTENT, length = EntityConstant.STRING_LONG_SIZE) |
||||||
|
private String content; |
||||||
|
|
||||||
|
@Column(name = COLUMN_LINK_OPEN_TYPE) |
||||||
|
private int linkOpenType = -1; |
||||||
|
|
||||||
|
@Column(name = COLUMN_CUSTOMIZE_LINK, length = EntityConstant.STRING_LONG_SIZE) |
||||||
|
private String customizeLink; |
||||||
|
|
||||||
|
@Column(name = COLUMN_TYPE) |
||||||
|
private int type; |
||||||
|
|
||||||
|
@Column(name = COLUMN_MEDIA_ID) |
||||||
|
private String mediaId; |
||||||
|
|
||||||
|
@Column(name = COLUMN_ADDRESSEE) |
||||||
|
private int[] addressee; |
||||||
|
|
||||||
|
@Column(name = COLUMN_CHAT_GROUPS, length = EntityConstant.STRING_LONG_SIZE) |
||||||
|
private String[] chatGroups; |
||||||
|
|
||||||
|
@Override |
||||||
|
public EarlyMessageAction createBean() { |
||||||
|
EarlyMessageAction bean = new EarlyMessageAction(); |
||||||
|
bean.setId(this.getId()); |
||||||
|
bean.setTerminal(this.getTerminal()); |
||||||
|
bean.setSubject(this.getSubject()); |
||||||
|
bean.setContent(this.getContent()); |
||||||
|
bean.setLinkOpenType(this.getLinkOpenType()); |
||||||
|
bean.setCustomizeLink(this.getCustomizeLink()); |
||||||
|
bean.setType(this.getType()); |
||||||
|
bean.setMediaId(this.getMediaId()); |
||||||
|
return bean; |
||||||
|
} |
||||||
|
|
||||||
|
public String getAgentId() { |
||||||
|
return agentId; |
||||||
|
} |
||||||
|
|
||||||
|
public void setAgentId(String agentId) { |
||||||
|
this.agentId = agentId; |
||||||
|
} |
||||||
|
|
||||||
|
public int getTerminal() { |
||||||
|
return terminal; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTerminal(int terminal) { |
||||||
|
this.terminal = terminal; |
||||||
|
} |
||||||
|
|
||||||
|
public String getSubject() { |
||||||
|
return subject; |
||||||
|
} |
||||||
|
|
||||||
|
public void setSubject(String subject) { |
||||||
|
this.subject = subject; |
||||||
|
} |
||||||
|
|
||||||
|
public String getContent() { |
||||||
|
return content; |
||||||
|
} |
||||||
|
|
||||||
|
public void setContent(String content) { |
||||||
|
this.content = content; |
||||||
|
} |
||||||
|
|
||||||
|
public int getLinkOpenType() { |
||||||
|
return linkOpenType; |
||||||
|
} |
||||||
|
|
||||||
|
public void setLinkOpenType(int linkOpenType) { |
||||||
|
this.linkOpenType = linkOpenType; |
||||||
|
} |
||||||
|
|
||||||
|
public String getCustomizeLink() { |
||||||
|
return customizeLink; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCustomizeLink(String customizeLink) { |
||||||
|
this.customizeLink = customizeLink; |
||||||
|
} |
||||||
|
|
||||||
|
public int getType() { |
||||||
|
return type; |
||||||
|
} |
||||||
|
|
||||||
|
public void setType(int type) { |
||||||
|
this.type = type; |
||||||
|
} |
||||||
|
|
||||||
|
public String getMediaId() { |
||||||
|
return mediaId; |
||||||
|
} |
||||||
|
|
||||||
|
public void setMediaId(String mediaId) { |
||||||
|
this.mediaId = mediaId; |
||||||
|
} |
||||||
|
|
||||||
|
public int[] getAddressee() { |
||||||
|
return addressee; |
||||||
|
} |
||||||
|
|
||||||
|
public void setAddressee(int[] addressee) { |
||||||
|
this.addressee = addressee; |
||||||
|
} |
||||||
|
|
||||||
|
public String[] getChatGroups() { |
||||||
|
return chatGroups; |
||||||
|
} |
||||||
|
|
||||||
|
public void setChatGroups(String[] chatGroups) { |
||||||
|
this.chatGroups = chatGroups; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,85 @@ |
|||||||
|
package com.fr.plugin.xxxx.swyy.message.handle; |
||||||
|
|
||||||
|
import com.fr.base.Formula; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.plugin.xxxx.swyy.message.conf.MessageConfig; |
||||||
|
import com.fr.plugin.xxxx.swyy.message.entity.EarlyMessageAction; |
||||||
|
import com.fr.plugin.xxxx.swyy.message.util.HttpUtil; |
||||||
|
import com.fr.plugin.xxxx.swyy.message.util.LogUtils; |
||||||
|
import com.fr.schedule.base.constant.ScheduleConstants; |
||||||
|
import com.fr.schedule.feature.output.OutputActionHandler; |
||||||
|
import com.fr.stable.CodeUtils; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import java.nio.charset.Charset; |
||||||
|
import java.util.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author fr.open |
||||||
|
* @Date 2020/12/05 |
||||||
|
* @Description |
||||||
|
**/ |
||||||
|
public class EarlyMessageHandle extends OutputActionHandler<EarlyMessageAction> { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void doAction(EarlyMessageAction output, Map<String, Object> map) throws Exception { |
||||||
|
String[] users = (String[]) map.get(ScheduleConstants.USERNAMES); |
||||||
|
String taskName = CodeUtils.encodeURIComponent((String) map.get(ScheduleConstants.TASK_NAME)); |
||||||
|
String path = CodeUtils.encodeURIComponent((String) map.get(ScheduleConstants.SAVE_DIRECTORY)); |
||||||
|
path = path.replaceAll("\\+", "%20"); |
||||||
|
String showType = (String) map.get(ScheduleConstants.SHOW_TYPE); |
||||||
|
int taskType = (Integer) map.get(ScheduleConstants.TASK_TYPE); |
||||||
|
String scheduleUsername = (String) map.get(ScheduleConstants.USERNAME); |
||||||
|
Set<String> userSet = new HashSet(); |
||||||
|
if (StringUtils.isNotBlank(scheduleUsername)) { |
||||||
|
userSet.add(scheduleUsername); |
||||||
|
} else { |
||||||
|
userSet.addAll(Arrays.asList(users)); |
||||||
|
} |
||||||
|
LogUtils.debug4plugin("send schedule user is {}", userSet); |
||||||
|
String pcUrl = output.getResultURL() + "/schedule/result?taskName=" + taskName + "&username=" + scheduleUsername + "&path=" + path + "&showType=" + showType + "&taskType=" + taskType; |
||||||
|
LogUtils.debug4plugin("get pc result is {}", pcUrl); |
||||||
|
String mobileUrl = output.getResultURL() + "/schedule/result?taskName=" + taskName + "&username=" + scheduleUsername + "&path=" + path + "&showType=" + showType + "&taskType=" + taskType; |
||||||
|
LogUtils.debug4plugin("get mobile url is {}", mobileUrl); |
||||||
|
String title = output.getSubject(); |
||||||
|
LogUtils.debug4plugin("cover subject is {}",title); |
||||||
|
String content = output.getContent(); |
||||||
|
LogUtils.debug4plugin("cover content is {}", content); |
||||||
|
JSONObject body = JSONObject.create(); |
||||||
|
body.put("code", MessageConfig.getInstance().getCode()); |
||||||
|
body.put("loginIdList", com.fr.third.org.apache.commons.lang3.StringUtils.join(userSet, ",")); |
||||||
|
//body.put("creater", map.get(ScheduleConstants.TASK_CREATOR));
|
||||||
|
body.put("title", title); |
||||||
|
body.put("context", content); |
||||||
|
body.put("linkUrl", pcUrl); |
||||||
|
body.put("linkMobileUrl", mobileUrl); |
||||||
|
Map<String, Object> header = new HashMap<>(); |
||||||
|
header.put("Authorization", getHeader(MessageConfig.getInstance().getAuthUser(), MessageConfig.getInstance().getAuthPass())); |
||||||
|
String url = MessageConfig.getInstance().getSendNotify(); |
||||||
|
LogUtils.debug4plugin("send url {} header is {} data is {}", url, header, body); |
||||||
|
String res = HttpUtil.doJSONPost(url, header, body,null,null); |
||||||
|
LogUtils.debug4plugin("send to res is {}", res); |
||||||
|
} |
||||||
|
|
||||||
|
private String getParam(Map<String, Object> map, String p) { |
||||||
|
List<Map> list = (List) map.get(ScheduleConstants.RECORD_LIST); |
||||||
|
Object title = StringUtils.EMPTY; |
||||||
|
Object param = list.get(0).get(p); |
||||||
|
if (param instanceof Formula) { |
||||||
|
Formula formula = (Formula) param; |
||||||
|
title = formula.getResult(); |
||||||
|
} else { |
||||||
|
if (param != null) { |
||||||
|
title = param.toString(); |
||||||
|
} |
||||||
|
} |
||||||
|
return title.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
private String getHeader(String user, String pass) { |
||||||
|
String auth = user + ":" + pass; |
||||||
|
byte[] encodedAuth = Base64.getEncoder().encode(auth.getBytes(Charset.forName("US-ASCII"))); |
||||||
|
String authHeader = "Basic " + new String(encodedAuth); |
||||||
|
return authHeader; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,55 @@ |
|||||||
|
package com.fr.plugin.xxxx.swyy.message.js; |
||||||
|
|
||||||
|
import com.fr.plugin.transform.ExecuteFunctionRecord; |
||||||
|
import com.fr.web.struct.Component; |
||||||
|
import com.fr.web.struct.Filter; |
||||||
|
import com.fr.web.struct.browser.RequestClient; |
||||||
|
import com.fr.web.struct.category.ScriptPath; |
||||||
|
import com.fr.web.struct.category.StylePath; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author fr.open |
||||||
|
* @Date 2020/12/05 |
||||||
|
* @Description |
||||||
|
**/ |
||||||
|
public class FileDef extends Component { |
||||||
|
public static final FileDef KEY = new FileDef(); |
||||||
|
private FileDef(){} |
||||||
|
/** |
||||||
|
* 返回需要引入的JS脚本路径 |
||||||
|
* @param client 请求客户端描述 |
||||||
|
* @return JS脚本路径 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public ScriptPath script(RequestClient client ) { |
||||||
|
//如果不需要就直接返回 ScriptPath.EMPTY
|
||||||
|
return ScriptPath.build("com/fr/plugin/xxxx/swyy/message/theme.js"); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 返回需要引入的CSS样式路径 |
||||||
|
* @param client 请求客户端描述 |
||||||
|
* @return CSS样式路径 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public StylePath style(RequestClient client ) { |
||||||
|
//如果不需要就直接返回 StylePath.EMPTY;
|
||||||
|
return StylePath.EMPTY; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 通过给定的资源过滤器控制是否加载这个资源 |
||||||
|
* @return 资源过滤器 |
||||||
|
*/ |
||||||
|
@ExecuteFunctionRecord |
||||||
|
@Override |
||||||
|
public Filter filter() { |
||||||
|
return new Filter(){ |
||||||
|
@Override |
||||||
|
public boolean accept() { |
||||||
|
//任何情况下我们都在平台组件加载时加载我们的组件
|
||||||
|
return true; |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
package com.fr.plugin.xxxx.swyy.message.js; |
||||||
|
|
||||||
|
import com.fr.decision.fun.impl.AbstractWebResourceProvider; |
||||||
|
import com.fr.decision.web.MainComponent; |
||||||
|
import com.fr.plugin.transform.FunctionRecorder; |
||||||
|
import com.fr.web.struct.Atom; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author hujian |
||||||
|
* @Date 2020/12/05 |
||||||
|
* @Description |
||||||
|
**/ |
||||||
|
@FunctionRecorder |
||||||
|
public class JSCSSBridge extends AbstractWebResourceProvider { |
||||||
|
@Override |
||||||
|
public Atom attach() { |
||||||
|
//在平台主组件加载时添加我们自己的组件
|
||||||
|
return MainComponent.KEY; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Atom client() { |
||||||
|
//我们自己要引入的组件
|
||||||
|
return FileDef.KEY; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,479 @@ |
|||||||
|
package com.fr.plugin.xxxx.swyy.message.util; |
||||||
|
|
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
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.HttpClient; |
||||||
|
import com.fr.third.org.apache.http.client.entity.UrlEncodedFormEntity; |
||||||
|
import com.fr.third.org.apache.http.client.methods.HttpPost; |
||||||
|
import com.fr.third.org.apache.http.client.methods.HttpPut; |
||||||
|
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.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.SSLConnectionSocketFactory; |
||||||
|
import com.fr.third.org.apache.http.conn.ssl.SSLContexts; |
||||||
|
import com.fr.third.org.apache.http.conn.ssl.TrustStrategy; |
||||||
|
import com.fr.third.org.apache.http.entity.StringEntity; |
||||||
|
import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; |
||||||
|
import com.fr.third.org.apache.http.impl.client.HttpClientBuilder; |
||||||
|
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.util.EntityUtils; |
||||||
|
|
||||||
|
import javax.net.ssl.*; |
||||||
|
import java.io.*; |
||||||
|
import java.net.HttpURLConnection; |
||||||
|
import java.net.URL; |
||||||
|
import java.net.URLEncoder; |
||||||
|
import java.security.KeyManagementException; |
||||||
|
import java.security.KeyStore; |
||||||
|
import java.security.KeyStoreException; |
||||||
|
import java.security.NoSuchAlgorithmException; |
||||||
|
import java.security.cert.CertificateException; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Iterator; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author fr.open |
||||||
|
* @Date 2021/7/27 |
||||||
|
*/ |
||||||
|
public class HttpUtil { |
||||||
|
|
||||||
|
private static HostnameVerifier hv = new HostnameVerifier() { |
||||||
|
@Override |
||||||
|
public boolean verify(String urlHostName, SSLSession session) { |
||||||
|
System.out.println("Warning: URL Host: " + urlHostName + " vs. " |
||||||
|
+ session.getPeerHost()); |
||||||
|
return true; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* 发送get请求 |
||||||
|
* |
||||||
|
* @param url |
||||||
|
* @param param |
||||||
|
* @param header |
||||||
|
* @return |
||||||
|
* @throws IOException |
||||||
|
*/ |
||||||
|
public static String sendGet(String url, Map<String, Object> param, Map<String, Object> header, String charset) { |
||||||
|
String result = ""; |
||||||
|
BufferedReader in = null; |
||||||
|
String urlNameString = url; |
||||||
|
try { |
||||||
|
if (param != null && !param.isEmpty()) { |
||||||
|
urlNameString += "?"; |
||||||
|
urlNameString += param.entrySet() |
||||||
|
.stream() |
||||||
|
.map(entry -> entry.getKey() + "=" + entry.getValue()) |
||||||
|
.collect(Collectors.joining("&")); |
||||||
|
} |
||||||
|
|
||||||
|
URL realUrl = new URL(urlNameString); |
||||||
|
// 打开和URL之间的连接
|
||||||
|
HttpURLConnection connection; |
||||||
|
if (url.startsWith("https")) { |
||||||
|
trustAllHttpsCertificates(); |
||||||
|
HttpsURLConnection.setDefaultHostnameVerifier(hv); |
||||||
|
connection = (HttpURLConnection) realUrl.openConnection(); |
||||||
|
} else { |
||||||
|
connection = (HttpURLConnection) realUrl.openConnection(); |
||||||
|
} |
||||||
|
//设置超时时间
|
||||||
|
connection.setDoInput(true); |
||||||
|
connection.setRequestMethod("GET"); |
||||||
|
connection.setConnectTimeout(5000); |
||||||
|
connection.setReadTimeout(15000); |
||||||
|
// 设置通用的请求属性
|
||||||
|
if (header != null) { |
||||||
|
Iterator<Map.Entry<String, Object>> it = header.entrySet().iterator(); |
||||||
|
while (it.hasNext()) { |
||||||
|
Map.Entry<String, Object> entry = it.next(); |
||||||
|
System.out.println(entry.getKey() + ":::" + entry.getValue()); |
||||||
|
connection.setRequestProperty(entry.getKey(), entry.getValue().toString()); |
||||||
|
} |
||||||
|
} |
||||||
|
connection.setRequestProperty("accept", "*/*"); |
||||||
|
connection.setRequestProperty("connection", "Keep-Alive"); |
||||||
|
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); |
||||||
|
// 建立实际的连接
|
||||||
|
connection.connect(); |
||||||
|
if(connection.getResponseCode() == 200){ |
||||||
|
// 定义 BufferedReader输入流来读取URL的响应,设置utf8防止中文乱码
|
||||||
|
in = new BufferedReader(new InputStreamReader(connection.getInputStream(), charset == null ? "utf-8" : charset)); |
||||||
|
String line; |
||||||
|
while ((line = in.readLine()) != null) { |
||||||
|
result += line; |
||||||
|
} |
||||||
|
if (in != null) { |
||||||
|
in.close(); |
||||||
|
} |
||||||
|
}else { |
||||||
|
in = new BufferedReader(new InputStreamReader(connection.getErrorStream(), charset == null ? "utf-8" : charset)); |
||||||
|
String line; |
||||||
|
while ((line = in.readLine()) != null) { |
||||||
|
result += line; |
||||||
|
} |
||||||
|
if (in != null) { |
||||||
|
in.close(); |
||||||
|
} |
||||||
|
FineLoggerFactory.getLogger().error("Http post form code is {},message is {}",connection.getResponseCode(),result); |
||||||
|
return StringUtils.EMPTY; |
||||||
|
} |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e, "get url error ,url is:{},error is {}", urlNameString, e.getMessage()); |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
public static String sendPost(String url, Map<String, Object> header, JSONObject body) { |
||||||
|
PrintWriter out = null; |
||||||
|
BufferedReader in = null; |
||||||
|
String result = null; |
||||||
|
String res = null; |
||||||
|
try { |
||||||
|
String urlNameString = url; |
||||||
|
|
||||||
|
URL realUrl = new URL(urlNameString); |
||||||
|
// 打开和URL之间的连接
|
||||||
|
HttpURLConnection conn; |
||||||
|
if (url.startsWith("https")) { |
||||||
|
trustAllHttpsCertificates(); |
||||||
|
HttpsURLConnection.setDefaultHostnameVerifier(hv); |
||||||
|
conn = (HttpURLConnection) realUrl.openConnection(); |
||||||
|
} else { |
||||||
|
conn = (HttpURLConnection) realUrl.openConnection(); |
||||||
|
} |
||||||
|
// 设置通用的请求属性
|
||||||
|
conn.setRequestProperty("accept", "*/*"); |
||||||
|
conn.setRequestProperty("connection", "Keep-Alive"); |
||||||
|
// conn.setRequestProperty("user-agent",
|
||||||
|
// "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
||||||
|
conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); |
||||||
|
if (header != null) { |
||||||
|
header.forEach((k, v) -> { |
||||||
|
conn.setRequestProperty(k, String.valueOf(v)); |
||||||
|
}); |
||||||
|
} |
||||||
|
// 发送POST请求必须设置如下两行
|
||||||
|
conn.setDoOutput(true); |
||||||
|
conn.setDoInput(true); |
||||||
|
//获取请求头
|
||||||
|
|
||||||
|
// 获取URLConnection对象对应的输出流
|
||||||
|
out = new PrintWriter(conn.getOutputStream()); |
||||||
|
// 发送请求参数
|
||||||
|
if (body != null) { |
||||||
|
FineLoggerFactory.getLogger().error("content data: {}", body.toString()); |
||||||
|
FineLoggerFactory.getLogger().error("content cover data: {}", new String(body.toString().getBytes("UTF-8"), "UTF-8")); |
||||||
|
out.print(new String(body.toString().getBytes("UTF-8"), "UTF-8")); |
||||||
|
} |
||||||
|
// flush输出流的缓冲
|
||||||
|
out.flush(); |
||||||
|
// 定义BufferedReader输入流来读取URL的响应
|
||||||
|
in = new BufferedReader( |
||||||
|
new InputStreamReader(conn.getInputStream())); |
||||||
|
String line; |
||||||
|
while ((line = in.readLine()) != null) { |
||||||
|
result += line; |
||||||
|
} |
||||||
|
res = result; |
||||||
|
if (res.startsWith("null")) { |
||||||
|
res = res.replace("null", ""); |
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
//使用finally块来关闭输出流、输入流
|
||||||
|
finally { |
||||||
|
try { |
||||||
|
if (out != null) { |
||||||
|
out.close(); |
||||||
|
} |
||||||
|
if (in != null) { |
||||||
|
in.close(); |
||||||
|
} |
||||||
|
} catch (IOException e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} |
||||||
|
return res; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public static String doJSONPost(String url, Map<String, Object> header, JSONObject json, Map<String, Object> param, String chartset) { |
||||||
|
HttpClient client = getHttpsClient(); |
||||||
|
/*if (url.startsWith("https")) { |
||||||
|
SSLContext sslcontext = createIgnoreVerifySSL(); |
||||||
|
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create() |
||||||
|
.register("http", PlainConnectionSocketFactory.INSTANCE) |
||||||
|
.register("https", new SSLConnectionSocketFactory(sslcontext)) |
||||||
|
.build(); |
||||||
|
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry); |
||||||
|
HttpClients.custom().setConnectionManager(connManager); |
||||||
|
client = HttpClients.custom().setConnectionManager(connManager).build(); |
||||||
|
}*/ |
||||||
|
if (param != null && !param.isEmpty()) { |
||||||
|
url += "?"; |
||||||
|
url += param.entrySet() |
||||||
|
.stream() |
||||||
|
.map(entry -> entry.getKey() + "=" + entry.getValue()) |
||||||
|
.collect(Collectors.joining("&")); |
||||||
|
} |
||||||
|
HttpPost post = new HttpPost(url); |
||||||
|
post.setHeader("accept", "*/*"); |
||||||
|
post.setHeader("connection", "Keep-Alive"); |
||||||
|
post.setHeader("Content-Type", "application/json"); |
||||||
|
if (header != null) { |
||||||
|
header.forEach((k, v) -> { |
||||||
|
post.setHeader(k, v.toString()); |
||||||
|
}); |
||||||
|
} |
||||||
|
try { |
||||||
|
StringEntity s = new StringEntity(json.toString(), chartset == null ? "UTF-8" : chartset); |
||||||
|
s.setContentEncoding("UTF-8"); |
||||||
|
s.setContentType("application/json; charset=UTF-8");//发送json数据需要设置contentType
|
||||||
|
post.setEntity(s); |
||||||
|
HttpResponse res = client.execute(post); |
||||||
|
if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { |
||||||
|
String result = EntityUtils.toString(res.getEntity());// 返回json格式:
|
||||||
|
return result; |
||||||
|
} else { |
||||||
|
FineLoggerFactory.getLogger().error("Http post form code is {},message is {}", res.getStatusLine().getStatusCode(), EntityUtils.toString(res.getEntity())); |
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public static String doJSONPut(String url, Map<String, Object> header, JSONObject json, Map<String, Object> param, String chartset) { |
||||||
|
HttpClient client = getHttpsClient(); |
||||||
|
/*if (url.startsWith("https")) { |
||||||
|
SSLContext sslcontext = createIgnoreVerifySSL(); |
||||||
|
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create() |
||||||
|
.register("http", PlainConnectionSocketFactory.INSTANCE) |
||||||
|
.register("https", new SSLConnectionSocketFactory(sslcontext)) |
||||||
|
.build(); |
||||||
|
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry); |
||||||
|
HttpClients.custom().setConnectionManager(connManager); |
||||||
|
client = HttpClients.custom().setConnectionManager(connManager).build(); |
||||||
|
}*/ |
||||||
|
if (param != null && !param.isEmpty()) { |
||||||
|
url += "?"; |
||||||
|
url += param.entrySet() |
||||||
|
.stream() |
||||||
|
.map(entry -> entry.getKey() + "=" + entry.getValue()) |
||||||
|
.collect(Collectors.joining("&")); |
||||||
|
} |
||||||
|
HttpPut post = new HttpPut(url); |
||||||
|
post.setHeader("accept", "*/*"); |
||||||
|
post.setHeader("connection", "Keep-Alive"); |
||||||
|
post.setHeader("Content-Type", "application/json"); |
||||||
|
if (header != null) { |
||||||
|
header.forEach((k, v) -> { |
||||||
|
post.setHeader(k, v.toString()); |
||||||
|
}); |
||||||
|
} |
||||||
|
try { |
||||||
|
StringEntity s = new StringEntity(json.toString(), chartset == null ? "UTF-8" : chartset); |
||||||
|
s.setContentEncoding("UTF-8"); |
||||||
|
s.setContentType("application/json; charset=UTF-8");//发送json数据需要设置contentType
|
||||||
|
post.setEntity(s); |
||||||
|
HttpResponse res = client.execute(post); |
||||||
|
if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { |
||||||
|
String result = EntityUtils.toString(res.getEntity());// 返回json格式:
|
||||||
|
return result; |
||||||
|
} else { |
||||||
|
FineLoggerFactory.getLogger().error("Http post form code is {},message is {}", res.getStatusLine().getStatusCode(), EntityUtils.toString(res.getEntity())); |
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public static String doFormPost(String url,Map<String, Object> header, Map<String, Object> map, String chartset) { |
||||||
|
//声明返回结果
|
||||||
|
String result = ""; |
||||||
|
UrlEncodedFormEntity entity = null; |
||||||
|
HttpResponse httpResponse = null; |
||||||
|
HttpClient httpClient = null; |
||||||
|
try { |
||||||
|
// 创建连接
|
||||||
|
httpClient = getHttpsClient(); |
||||||
|
; |
||||||
|
/*if (url.startsWith("https")) { |
||||||
|
SSLContext sslcontext = createIgnoreVerifySSL(); |
||||||
|
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create() |
||||||
|
.register("http", PlainConnectionSocketFactory.INSTANCE) |
||||||
|
.register("https", new SSLConnectionSocketFactory(sslcontext)) |
||||||
|
.build(); |
||||||
|
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry); |
||||||
|
HttpClients.custom().setConnectionManager(connManager); |
||||||
|
httpClient = HttpClients.custom().setConnectionManager(connManager).build(); |
||||||
|
}*/ |
||||||
|
// 设置请求头和报文
|
||||||
|
HttpPost httpPost = new HttpPost(url); |
||||||
|
if (header != null) { |
||||||
|
header.forEach((k, v) -> { |
||||||
|
httpPost.setHeader(k, v.toString()); |
||||||
|
}); |
||||||
|
} |
||||||
|
//设置参数
|
||||||
|
List<NameValuePair> list = new ArrayList<NameValuePair>(); |
||||||
|
Iterator iterator = map.entrySet().iterator(); |
||||||
|
while (iterator.hasNext()) { |
||||||
|
Map.Entry<String, String> elem = (Map.Entry<String, String>) iterator.next(); |
||||||
|
list.add(new BasicNameValuePair(elem.getKey(), elem.getValue())); |
||||||
|
} |
||||||
|
entity = new UrlEncodedFormEntity(list, chartset == null ? "UTF-8" : chartset); |
||||||
|
httpPost.setEntity(entity); |
||||||
|
//执行发送,获取相应结果
|
||||||
|
httpResponse = httpClient.execute(httpPost); |
||||||
|
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { |
||||||
|
result = EntityUtils.toString(httpResponse.getEntity()); |
||||||
|
} else { |
||||||
|
FineLoggerFactory.getLogger().error("Http post form code is {},message is {}", httpResponse.getStatusLine().getStatusCode(), EntityUtils.toString(httpResponse.getEntity())); |
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
return result; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private static void trustAllHttpsCertificates() throws Exception { |
||||||
|
TrustManager[] trustAllCerts = new TrustManager[1]; |
||||||
|
TrustManager tm = new miTM(); |
||||||
|
trustAllCerts[0] = tm; |
||||||
|
SSLContext sc = SSLContext.getInstance("SSL", "SunJSSE"); |
||||||
|
sc.init(null, trustAllCerts, null); |
||||||
|
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* encode url by UTF-8 |
||||||
|
* |
||||||
|
* @param url url before encoding |
||||||
|
* @return url after encoding |
||||||
|
*/ |
||||||
|
public static String encodeUrl(String url) { |
||||||
|
String eurl = url; |
||||||
|
try { |
||||||
|
eurl = URLEncoder.encode(url, "UTF-8"); |
||||||
|
} catch (UnsupportedEncodingException e) { |
||||||
|
} |
||||||
|
return eurl; |
||||||
|
} |
||||||
|
|
||||||
|
private static class miTM implements TrustManager, |
||||||
|
X509TrustManager { |
||||||
|
@Override |
||||||
|
public java.security.cert.X509Certificate[] getAcceptedIssuers() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isServerTrusted( |
||||||
|
java.security.cert.X509Certificate[] certs) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isClientTrusted( |
||||||
|
java.security.cert.X509Certificate[] certs) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void checkServerTrusted( |
||||||
|
java.security.cert.X509Certificate[] certs, String authType) |
||||||
|
throws CertificateException { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void checkClientTrusted( |
||||||
|
java.security.cert.X509Certificate[] certs, String authType) |
||||||
|
throws CertificateException { |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static SSLContext createIgnoreVerifySSL() { |
||||||
|
try { |
||||||
|
SSLContext sc = SSLContext.getInstance("TLSv1.2"); |
||||||
|
|
||||||
|
// 实现一个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; |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
private static CloseableHttpClient getHttpsClient() { |
||||||
|
RegistryBuilder<ConnectionSocketFactory> registryBuilder = RegistryBuilder.<ConnectionSocketFactory>create(); |
||||||
|
ConnectionSocketFactory plainSF = new PlainConnectionSocketFactory(); |
||||||
|
registryBuilder.register("http", plainSF); |
||||||
|
// 指定信任密钥存储对象和连接套接字工厂
|
||||||
|
try { |
||||||
|
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); |
||||||
|
// 信任任何链接
|
||||||
|
TrustStrategy anyTrustStrategy = new TrustStrategy() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isTrusted(java.security.cert.X509Certificate[] arg0, String arg1) throws CertificateException { |
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return true; |
||||||
|
} |
||||||
|
}; |
||||||
|
SSLContext sslContext = SSLContexts.custom().useTLS().loadTrustMaterial(trustStore, anyTrustStrategy).build(); |
||||||
|
LayeredConnectionSocketFactory sslSF = new SSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); |
||||||
|
registryBuilder.register("https", sslSF); |
||||||
|
} catch (KeyStoreException e) { |
||||||
|
throw new RuntimeException(e); |
||||||
|
} catch (KeyManagementException e) { |
||||||
|
throw new RuntimeException(e); |
||||||
|
} catch (NoSuchAlgorithmException e) { |
||||||
|
throw new RuntimeException(e); |
||||||
|
} |
||||||
|
Registry<ConnectionSocketFactory> registry = registryBuilder.build(); |
||||||
|
// 设置连接管理器
|
||||||
|
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(registry); |
||||||
|
// 构建客户端
|
||||||
|
return HttpClientBuilder.create().setConnectionManager(connManager).build(); |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,121 @@ |
|||||||
|
package com.fr.plugin.xxxx.swyy.message.util; |
||||||
|
|
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.log.FineLoggerProvider; |
||||||
|
import com.fr.plugin.context.PluginContexts; |
||||||
|
import com.fr.plugin.xxxx.swyy.message.conf.MessageConfig; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author holger |
||||||
|
* @since 2021/12/04 |
||||||
|
*/ |
||||||
|
public final class LogUtils { |
||||||
|
private static final String DEBUG_PREFIX = "[插件调试] "; |
||||||
|
private static String LOG_PREFIX = "[OA消息推送] "; |
||||||
|
private static final String PLUGIN_VERSION; |
||||||
|
|
||||||
|
private static final FineLoggerProvider LOGGER = FineLoggerFactory.getLogger(); |
||||||
|
|
||||||
|
static { |
||||||
|
String version = PluginContexts.currentContext().getMarker().getVersion(); |
||||||
|
if (StringUtils.isNotBlank(version)) { |
||||||
|
PLUGIN_VERSION = "[v" + version + "] "; |
||||||
|
} else { |
||||||
|
PLUGIN_VERSION = "[unknown version] "; |
||||||
|
} |
||||||
|
|
||||||
|
LOG_PREFIX = LOG_PREFIX + PLUGIN_VERSION; |
||||||
|
} |
||||||
|
|
||||||
|
public static void setPrefix(String prefix) { |
||||||
|
if (prefix != null) { |
||||||
|
LOG_PREFIX = prefix; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static boolean isDebugEnabled() { |
||||||
|
return LOGGER.isDebugEnabled(); |
||||||
|
} |
||||||
|
|
||||||
|
public static void debug(String s) { |
||||||
|
LOGGER.debug(LOG_PREFIX + s); |
||||||
|
} |
||||||
|
|
||||||
|
public static void debug(String s, Object... objects) { |
||||||
|
LOGGER.debug(LOG_PREFIX + s, objects); |
||||||
|
} |
||||||
|
|
||||||
|
public static void debug(String s, Throwable throwable) { |
||||||
|
LOGGER.debug(LOG_PREFIX + s, throwable); |
||||||
|
} |
||||||
|
|
||||||
|
public static void debug4plugin(String s) { |
||||||
|
if (MessageConfig.getInstance().getDebugSwitch()) { |
||||||
|
LOGGER.error(DEBUG_PREFIX + LOG_PREFIX + s); |
||||||
|
} else { |
||||||
|
LOGGER.debug(LOG_PREFIX + s); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static void debug4plugin(String s, Object... objects) { |
||||||
|
if (MessageConfig.getInstance().getDebugSwitch()) { |
||||||
|
LOGGER.error(DEBUG_PREFIX + LOG_PREFIX + s, objects); |
||||||
|
} else { |
||||||
|
LOGGER.debug(LOG_PREFIX + s, objects); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static void debug4plugin(String s, Throwable throwable) { |
||||||
|
if (MessageConfig.getInstance().getDebugSwitch()) { |
||||||
|
LOGGER.error(DEBUG_PREFIX + LOG_PREFIX + s, throwable); |
||||||
|
} else { |
||||||
|
LOGGER.debug(LOG_PREFIX + s, throwable); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public static boolean isInfoEnabled() { |
||||||
|
return LOGGER.isInfoEnabled(); |
||||||
|
} |
||||||
|
|
||||||
|
public static void info(String s) { |
||||||
|
LOGGER.info(LOG_PREFIX + s); |
||||||
|
} |
||||||
|
|
||||||
|
public static void info(String s, Object... objects) { |
||||||
|
LOGGER.info(LOG_PREFIX + s, objects); |
||||||
|
} |
||||||
|
|
||||||
|
public static void warn(String s) { |
||||||
|
LOGGER.warn(LOG_PREFIX + s); |
||||||
|
} |
||||||
|
|
||||||
|
public static void warn(String s, Object... objects) { |
||||||
|
LOGGER.warn(LOG_PREFIX + s, objects); |
||||||
|
} |
||||||
|
|
||||||
|
public static void warn(String s, Throwable throwable) { |
||||||
|
LOGGER.warn(LOG_PREFIX + s, throwable); |
||||||
|
} |
||||||
|
|
||||||
|
public static void warn(Throwable throwable, String s, Object... objects) { |
||||||
|
LOGGER.warn(throwable, LOG_PREFIX + s, objects); |
||||||
|
} |
||||||
|
|
||||||
|
public static void error(String s) { |
||||||
|
LOGGER.error(LOG_PREFIX + s); |
||||||
|
} |
||||||
|
|
||||||
|
public static void error(String s, Object... objects) { |
||||||
|
LOGGER.error(LOG_PREFIX + s, objects); |
||||||
|
} |
||||||
|
|
||||||
|
public static void error(String s, Throwable throwable) { |
||||||
|
LOGGER.error(LOG_PREFIX + s, throwable); |
||||||
|
} |
||||||
|
|
||||||
|
public static void error(Throwable throwable, String s, Object... objects) { |
||||||
|
LOGGER.error(throwable, LOG_PREFIX + s, objects); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,58 @@ |
|||||||
|
!(function () { |
||||||
|
BI.config("dec.constant.account.items",function( items ){ |
||||||
|
//把type: "dec.user.account.setting.item"的去掉
|
||||||
|
debugger; |
||||||
|
items.splice(2,1) |
||||||
|
return items; |
||||||
|
}); |
||||||
|
|
||||||
|
var TodoTerminalType = 32; |
||||||
|
|
||||||
|
Dec.Plugin.OutPutActionProvider.items.push({ |
||||||
|
version: 1.0, |
||||||
|
|
||||||
|
terminalType: TodoTerminalType, |
||||||
|
|
||||||
|
terminalText: BI.i18nText("OA消息推送"), |
||||||
|
|
||||||
|
getItem: function () { |
||||||
|
var self = this; |
||||||
|
return { |
||||||
|
type: "bi.label", |
||||||
|
text: BI.i18nText("提示:OA消息推送"), |
||||||
|
textAlign: "left", |
||||||
|
cls: "bi-disabled", |
||||||
|
height: 24, |
||||||
|
ref: function (_ref) { |
||||||
|
self.welinkItem = _ref; |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
setValue: function (v) { |
||||||
|
if (v.terminal && v.terminal === TodoTerminalType) { |
||||||
|
this.value = v; |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
getValue: function () { |
||||||
|
var self = this; |
||||||
|
// actionName最后一个点后面的类名要和这个return的json的字段名一致
|
||||||
|
// console.log(123);
|
||||||
|
return { |
||||||
|
EarlyMessageAction: BI.extend(self.value, { |
||||||
|
"@class": "com.fr.plugin.xxxx.swyy.message.entity.EarlyMessageAction", |
||||||
|
actionName: "com.fr.plugin.xxxx.swyy.message.entity.EarlyMessageAction", |
||||||
|
terminal: TodoTerminalType |
||||||
|
}) |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
checkValid: function () { |
||||||
|
return this.getValue()?true:false; |
||||||
|
}, |
||||||
|
|
||||||
|
fireEvent: function (v) { |
||||||
|
} |
||||||
|
}); |
||||||
|
}) (); |
Loading…
Reference in new issue