commit e8e6c7efb14c91189f63eca032759c8dbf2611e6
Author: pioneer
Date: Tue Nov 29 16:44:36 2022 +0800
open
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..2b14d34
--- /dev/null
+++ b/README.md
@@ -0,0 +1,6 @@
+# open-JSD-10220
+
+JSD-10220 总公司和子公司共用一个bi系统,但是需要集成多个消息推送平台\
+免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\
+仅作为开发者学习参考使用!禁止用于任何商业用途!\
+为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。
\ No newline at end of file
diff --git a/lib/finekit-10.0-20220427.jar b/lib/finekit-10.0-20220427.jar
new file mode 100644
index 0000000..6793f18
Binary files /dev/null and b/lib/finekit-10.0-20220427.jar differ
diff --git a/lib/httpasyncclient-4.1.4.jar b/lib/httpasyncclient-4.1.4.jar
new file mode 100644
index 0000000..e6b3b29
Binary files /dev/null and b/lib/httpasyncclient-4.1.4.jar differ
diff --git a/lib/httpclient-4.5.jar b/lib/httpclient-4.5.jar
new file mode 100644
index 0000000..970c989
Binary files /dev/null and b/lib/httpclient-4.5.jar differ
diff --git a/lib/httpclient-cache-4.5.jar b/lib/httpclient-cache-4.5.jar
new file mode 100644
index 0000000..5540226
Binary files /dev/null and b/lib/httpclient-cache-4.5.jar differ
diff --git a/lib/httpcore-4.4.9.jar b/lib/httpcore-4.4.9.jar
new file mode 100644
index 0000000..cddba28
Binary files /dev/null and b/lib/httpcore-4.4.9.jar differ
diff --git a/lib/httpcore-nio-4.4.9.jar b/lib/httpcore-nio-4.4.9.jar
new file mode 100644
index 0000000..00b3444
Binary files /dev/null and b/lib/httpcore-nio-4.4.9.jar differ
diff --git a/lib/httpmime-4.5.jar b/lib/httpmime-4.5.jar
new file mode 100644
index 0000000..b631ceb
Binary files /dev/null and b/lib/httpmime-4.5.jar differ
diff --git a/lib/json-20090211.jar b/lib/json-20090211.jar
new file mode 100644
index 0000000..ef29094
Binary files /dev/null and b/lib/json-20090211.jar differ
diff --git a/lib/unirest-java-1.4.9.jar b/lib/unirest-java-1.4.9.jar
new file mode 100644
index 0000000..59bb357
Binary files /dev/null and b/lib/unirest-java-1.4.9.jar differ
diff --git a/plugin.xml b/plugin.xml
new file mode 100644
index 0000000..1c1d741
--- /dev/null
+++ b/plugin.xml
@@ -0,0 +1,51 @@
+
+
+ com.fr.plugin.yituan
+
+ yes
+ 1.3.8
+ 10.0
+ 2019-03-10
+ fr.open
+
+
+
+ [2020-04-08]项目启动
+ [2021-11-08]支持多企业
+ [2022-6-01]支持pc登录
+ [2022-6-10]支持多企业
+ ]]>
+
+ com.fr.plugin.yt
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/com/fr/plugin/beans/MyAgentBean.java b/src/main/java/com/fr/plugin/beans/MyAgentBean.java
new file mode 100644
index 0000000..ddb61d5
--- /dev/null
+++ b/src/main/java/com/fr/plugin/beans/MyAgentBean.java
@@ -0,0 +1,95 @@
+package com.fr.plugin.beans;
+
+import com.fr.general.ComparatorUtils;
+import com.fr.json.JSONException;
+import com.fr.json.JSONObject;
+import com.fr.plugin.entitys.YTAgentEntity;
+import com.fr.stable.db.data.BaseDataRecord;
+
+import java.io.Serializable;
+
+public class MyAgentBean extends BaseDataRecord implements Serializable {
+ private String agentName;
+ private String teamId;
+ private String groupId;
+ private String clientId;
+ private String secret;
+ private int type;
+ private long timeStamp;
+
+ public YTAgentEntity createEntity(YTAgentEntity var1) {
+ var1.setId(this.getId());
+ var1.setAgentName(this.agentName);
+ var1.setAgentId(this.groupId);
+ var1.setCorpId(this.clientId);
+ var1.setSecret(this.secret);
+ var1.setType(this.type);
+ var1.setTimeStamp(this.timeStamp);
+ return var1;
+ }
+
+ private boolean isAgentTypeValidate() {
+ return ComparatorUtils.equals(this.type, 2);
+ }
+
+
+ public String getAgentName() {
+ return this.agentName;
+ }
+
+ public void setAgentName(String var1) {
+ this.agentName = var1;
+ }
+
+ public String getGroupId() {
+ return this.groupId;
+ }
+
+ public void setGroupId(String var1) {
+ this.groupId = var1;
+ }
+
+ public String getClientId() {
+ return this.clientId;
+ }
+
+ public void setClientId(String var1) {
+ this.clientId = var1;
+ }
+
+ public String getSecret() {
+ return this.secret;
+ }
+
+ public void setSecret(String var1) {
+ this.secret = var1;
+ }
+
+ public int getType() {
+ return this.type;
+ }
+
+ public void setType(int var1) {
+ this.type = var1;
+ }
+
+ public long getTimeStamp() {
+ return this.timeStamp;
+ }
+
+ public void setTimeStamp(long var1) {
+ this.timeStamp = var1;
+ }
+
+
+ public JSONObject toJSONObject() throws JSONException {
+ JSONObject var1 = JSONObject.create();
+ var1.put("id", this.getId());
+ var1.put("agentName", this.agentName);
+ var1.put("agentId", this.groupId);
+ var1.put("corpId", this.clientId);
+ var1.put("secret", this.secret);
+ var1.put("type", this.type);
+ return var1;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/beans/MyDepBean.java b/src/main/java/com/fr/plugin/beans/MyDepBean.java
new file mode 100644
index 0000000..2c27a2f
--- /dev/null
+++ b/src/main/java/com/fr/plugin/beans/MyDepBean.java
@@ -0,0 +1,90 @@
+package com.fr.plugin.beans;
+
+import com.fr.json.JSONArray;
+import com.fr.json.JSONException;
+import com.fr.json.JSONObject;
+import com.fr.plugin.entitys.YtDepEntity;
+
+import java.io.Serializable;
+
+
+public class MyDepBean implements Serializable {
+ private String name;
+ private String depName;
+ private String id;
+ private int order;
+ private String parentId;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDepName() {
+ return depName;
+ }
+
+ public void setDepName(String depName) {
+ this.depName = depName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public int getOrder() {
+ return order;
+ }
+
+ public void setOrder(int order) {
+ this.order = order;
+ }
+
+ public String getParentId() {
+ return parentId;
+ }
+
+ public void setParentId(String parentId) {
+ this.parentId = parentId;
+ }
+ public JSONObject createJSONConfig() throws JSONException {
+ JSONObject var1 = JSONObject.create();
+ var1.put("id", this.getId());
+ var1.put("text", this.getName());
+ var1.put("pId", this.getParentId());
+ var1.put("value", this.getDepName());
+ return var1;
+ }
+ @Override
+ public String toString() {
+ return "MyDepBean{" +
+ "name='" + name + '\'' +
+ ", depName='" + depName + '\'' +
+ ", id='" + id + '\'' +
+ ", order=" + order +
+ ", parentId='" + parentId + '\'' +
+ '}';
+ }
+
+ public JSONArray generateDepartmentTree() {
+ return null;
+ }
+
+ public YtDepEntity createEntity(){
+ YtDepEntity bean=new YtDepEntity();
+ bean.setDepName(this.depName);
+ bean.setId(this.getId());
+ bean.setName(this.name);
+ bean.setParentId(this.parentId);
+ bean.setTop1(this.order);
+ return bean;
+ }
+
+}
diff --git a/src/main/java/com/fr/plugin/beans/MyGroupBean.java b/src/main/java/com/fr/plugin/beans/MyGroupBean.java
new file mode 100644
index 0000000..fca79d9
--- /dev/null
+++ b/src/main/java/com/fr/plugin/beans/MyGroupBean.java
@@ -0,0 +1,59 @@
+package com.fr.plugin.beans;
+
+import com.fr.json.JSONArray;
+import com.fr.json.JSONException;
+import com.fr.json.JSONObject;
+import com.fr.plugin.entitys.YtDepEntity;
+
+import java.io.Serializable;
+
+
+public class MyGroupBean implements Serializable {
+ private String name;
+ private String groupId;
+ private String id;
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(String groupId) {
+ this.groupId = groupId;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public JSONObject createJSONConfig() throws JSONException {
+ JSONObject var1 = JSONObject.create();
+ var1.put("id", this.getGroupId());
+ var1.put("text", this.getName());
+ return var1;
+ }
+
+
+ public JSONArray generateDepartmentTree() {
+ return null;
+ }
+
+ public YtDepEntity createEntity(){
+ YtDepEntity bean=new YtDepEntity();
+ bean.setName(this.name);
+ bean.setId(this.getId());
+ bean.setName(this.name);
+ return bean;
+ }
+
+}
diff --git a/src/main/java/com/fr/plugin/beans/MyUserBean.java b/src/main/java/com/fr/plugin/beans/MyUserBean.java
new file mode 100644
index 0000000..adcde44
--- /dev/null
+++ b/src/main/java/com/fr/plugin/beans/MyUserBean.java
@@ -0,0 +1,128 @@
+package com.fr.plugin.beans;
+
+import com.fr.json.JSONObject;
+import com.fr.plugin.entitys.YTUserEntity;
+import com.fr.stable.db.data.BaseDataRecord;
+import com.fr.third.fasterxml.jackson.annotation.JsonSubTypes;
+
+import java.io.Serializable;
+
+@JsonSubTypes.Type(
+ value = MyUserBean.class,
+ name = "UserBean"
+)
+public class MyUserBean extends BaseDataRecord implements Serializable {
+
+ private String openId;
+ private String name;
+ private String photoUrl;
+ private String phone;
+ private String jobNo;
+ private String department;
+ private int status;
+ private String fsUserName;
+
+ public String getFsUserName() {
+ return fsUserName;
+ }
+
+ public void setFsUserName(String fsUserName) {
+ this.fsUserName = fsUserName;
+ }
+
+ public YTUserEntity createEntity() {
+ YTUserEntity var1=new YTUserEntity();
+ var1.setId(this.getOpenId());
+ var1.setStatus(this.getStatus());
+ var1.setPhotoUrl(this.getPhotoUrl());
+ var1.setJobNo(this.jobNo);
+ var1.setPhone(this.phone);
+ var1.setName(this.name);
+ var1.setDepartment(this.department);
+ var1.setStatus(this.status);
+ var1.setOpenId(this.openId);
+ var1.setFsUserName(this.fsUserName);
+ return var1;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getOpenId() {
+ return openId;
+ }
+
+ public void setOpenId(String openId) {
+ this.openId = openId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPhotoUrl() {
+ return photoUrl;
+ }
+
+ public void setPhotoUrl(String photoUrl) {
+ this.photoUrl = photoUrl;
+ }
+
+ public String getJobNo() {
+ return jobNo;
+ }
+
+ public void setJobNo(String jobNo) {
+ this.jobNo = jobNo;
+ }
+
+ public String getDepartment() {
+ return department;
+ }
+
+ public void setDepartment(String department) {
+ this.department = department;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public JSONObject createJSONConfig() {
+ JSONObject var1 = JSONObject.create();
+ var1.put("id", this.getId());
+ var1.put("name", this.getName());
+ var1.put("phone", this.getPhone());
+ var1.put("fsUserName",fsUserName);
+ return var1;
+ }
+
+ @Override
+ public String toString() {
+ return "MyUserBean{" +
+ "openId='" + openId + '\'' +
+ ", name='" + name + '\'' +
+ ", photoUrl='" + photoUrl + '\'' +
+ ", phone='" + phone + '\'' +
+ ", jobNo='" + jobNo + '\'' +
+ ", department='" + department + '\'' +
+ ", status=" + status +
+ ", fsUserName='" + fsUserName + '\'' +
+ '}';
+ }
+
+
+}
diff --git a/src/main/java/com/fr/plugin/beans/MyYituanBean.java b/src/main/java/com/fr/plugin/beans/MyYituanBean.java
new file mode 100644
index 0000000..8def9d1
--- /dev/null
+++ b/src/main/java/com/fr/plugin/beans/MyYituanBean.java
@@ -0,0 +1,102 @@
+package com.fr.plugin.beans;
+
+import com.fr.general.ComparatorUtils;
+import com.fr.json.JSONException;
+import com.fr.json.JSONObject;
+import com.fr.plugin.entitys.YTYiTuanEntity;
+import com.fr.stable.db.data.BaseDataRecord;
+
+import java.io.Serializable;
+
+public class MyYituanBean extends BaseDataRecord implements Serializable {
+ private String agentName;
+ private String teamId;
+ private String groupId;
+ private String clientId;
+ private String secret;
+ private int type;
+ private long timeStamp;
+
+ public YTYiTuanEntity createEntity(YTYiTuanEntity yiTuanEntity) {
+ yiTuanEntity.setId(this.getId());
+ yiTuanEntity.setAgentName(this.agentName);
+ yiTuanEntity.setGroupId(this.groupId);
+ yiTuanEntity.setTeamId(this.teamId);
+ yiTuanEntity.setClientId(this.clientId);
+ yiTuanEntity.setSecret(this.secret);
+ return yiTuanEntity;
+ }
+
+ public String getTeamId() {
+ return teamId;
+ }
+
+ public void setTeamId(String teamId) {
+ this.teamId = teamId;
+ }
+
+ private boolean isAgentTypeValidate() {
+ return ComparatorUtils.equals(this.type, 2);
+ }
+
+
+ public String getAgentName() {
+ return this.agentName;
+ }
+
+ public void setAgentName(String var1) {
+ this.agentName = var1;
+ }
+
+ public String getGroupId() {
+ return this.groupId;
+ }
+
+ public void setGroupId(String var1) {
+ this.groupId = var1;
+ }
+
+ public String getClientId() {
+ return this.clientId;
+ }
+
+ public void setClientId(String var1) {
+ this.clientId = var1;
+ }
+
+ public String getSecret() {
+ return this.secret;
+ }
+
+ public void setSecret(String var1) {
+ this.secret = var1;
+ }
+
+ public int getType() {
+ return this.type;
+ }
+
+ public void setType(int var1) {
+ this.type = var1;
+ }
+
+ public long getTimeStamp() {
+ return this.timeStamp;
+ }
+
+ public void setTimeStamp(long var1) {
+ this.timeStamp = var1;
+ }
+
+
+ public JSONObject toJSONObject() throws JSONException {
+ JSONObject var1 = JSONObject.create();
+ var1.put("id", this.getId());
+ var1.put("agentName", this.agentName);
+ var1.put("groupId", this.groupId);
+ var1.put("clientId", this.clientId);
+ var1.put("secret", this.secret);
+ var1.put("teamId", this.teamId);
+ return var1;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/beans/YTOutputBean.java b/src/main/java/com/fr/plugin/beans/YTOutputBean.java
new file mode 100644
index 0000000..a281560
--- /dev/null
+++ b/src/main/java/com/fr/plugin/beans/YTOutputBean.java
@@ -0,0 +1,182 @@
+package com.fr.plugin.beans;
+
+import com.fr.decision.system.bean.message.MessageUrlType;
+import com.fr.decision.system.bean.message.MobileMessageType;
+import com.fr.plugin.entitys.YtOutputMyEntity;
+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;
+
+@JsonSubTypes.Type(
+ value = YTOutputBean.class,
+ name = "OutputYT"
+)
+public class YTOutputBean extends BaseOutputAction {
+ private int terminal = 128;
+ private String agentId = null;
+ private String clientId = null;
+ private String subject;
+ private String content;
+ private int linkOpenType;
+ private String customizeLink;
+ private String goUrl;
+ private int type;
+ private String mediaId;
+ private String fromUserId;
+ private int runType;
+ private int sendType;
+
+ public String getGoUrl() {
+ return goUrl;
+ }
+
+ public void setGoUrl(String goUrl) {
+ this.goUrl = goUrl;
+ }
+
+ public String getClientId() {
+ return clientId;
+ }
+
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+ public int getTerminal() {
+ return terminal;
+ }
+
+ public void setTerminal(int terminal) {
+ this.terminal = terminal;
+ }
+
+ public String getAgentId() {
+ return agentId;
+ }
+
+ public void setAgentId(String agentId) {
+ this.agentId = agentId;
+ }
+
+ 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 getSendType() {
+ return sendType;
+ }
+
+ public void setSendType(int sendType) {
+ this.sendType = sendType;
+ }
+
+ 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 getRunType() {
+ return runType;
+ }
+
+ public void setRunType(int runType) {
+ this.runType = runType;
+ }
+ //这里直接关联第一步的entity类
+ public Class extends AbstractScheduleEntity> outputActionEntityClass() {
+ return YtOutputMyEntity.class;
+ }
+
+ public String getFromUserId() {
+ return fromUserId;
+ }
+
+ public void setFromUserId(String fromUserId) {
+ this.fromUserId = fromUserId;
+ }
+
+ @Override
+ public AbstractScheduleEntity createOutputActionEntity() {
+ YtOutputMyEntity var1 = new YtOutputMyEntity();
+ var1.setId(this.getId());
+ var1.setTerminal(this.getTerminal());
+ var1.setAgentId(this.getAgentId());
+ var1.setSubject(this.getSubject());
+ var1.setContent(this.getContent());
+ var1.setGoUrl(this.getGoUrl());
+ var1.setLinkOpenType(this.getLinkOpenType());
+ var1.setCustomizeLink(this.getCustomizeLink());
+ var1.setType(this.getType());
+ var1.setMediaId(this.getMediaId());
+ var1.setActionName(this.getActionName());
+ var1.setResultURL(this.getResultURL());
+ var1.setClientId(this.getClientId());
+ var1.setRunType(this.getRunType());
+ var1.setSendType(this.getSendType());
+ var1.setFromUserId(this.getFromUserId());
+// var1.setExecuteByUser(this.willExecuteByUser());
+ return var1;
+ }
+
+// @Override
+// public OutputMyEntity createEntity() {
+//
+// }
+
+ public YTOutputBean() {
+ this.linkOpenType = MessageUrlType.INNER.toInt();
+ this.type = MobileMessageType.TEXT.toInt();
+ this.runType = RunType.CLIENT_NOTIFICATION.getValue();
+ }
+
+ @Override
+ public boolean willExecuteByUser() {
+ return true;
+ }
+
+ @Override
+ public RunType runType() {
+
+ return RunType.CLIENT_NOTIFICATION;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/beans/msg/MyMessageType.java b/src/main/java/com/fr/plugin/beans/msg/MyMessageType.java
new file mode 100644
index 0000000..22a3ac0
--- /dev/null
+++ b/src/main/java/com/fr/plugin/beans/msg/MyMessageType.java
@@ -0,0 +1,14 @@
+package com.fr.plugin.beans.msg;
+
+import com.fr.decision.system.message.type.MessageType;
+
+public class MyMessageType extends MessageType {
+ public static final MyMessageType KEY = new MyMessageType();
+ public static final String TEXT = "text";
+ public static final String FILE = "file";
+ public static final String NEWS = "news";
+ @Override
+ public int toInteger() {
+ return 128;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/config/YituanPri.java b/src/main/java/com/fr/plugin/config/YituanPri.java
new file mode 100644
index 0000000..1e328d3
--- /dev/null
+++ b/src/main/java/com/fr/plugin/config/YituanPri.java
@@ -0,0 +1,206 @@
+package com.fr.plugin.config;
+
+import com.fr.config.ConfigContext;
+import com.fr.config.DefaultConfiguration;
+import com.fr.config.holder.Conf;
+import com.fr.config.holder.factory.Holders;
+import com.fr.stable.StringUtils;
+
+/**
+ * xx中不适用这个!废弃
+ */
+public class YituanPri extends DefaultConfiguration {
+ private static volatile YituanPri config = null;
+ private Conf appId = Holders.simple(StringUtils.EMPTY);
+ private Conf eid = Holders.simple(StringUtils.EMPTY);
+ private Conf secret = Holders.simple(StringUtils.EMPTY);
+ private Conf url = Holders.simple(StringUtils.EMPTY);
+ private Conf readKey = Holders.simple(StringUtils.EMPTY);
+ private Conf match = Holders.simple(StringUtils.EMPTY);
+ private Conf cloudHost = Holders.simple("https://www.xxx.com");
+ private Conf scanId = Holders.simple(StringUtils.EMPTY);
+ private Conf scanSecret = Holders.simple(StringUtils.EMPTY);
+ private Conf dataSet = Holders.simple(StringUtils.EMPTY);
+ private Conf dataSetFsName = Holders.simple(0);
+ private Conf dataSetUserId = Holders.simple(0);
+ private volatile boolean isAuthorityInited = false;
+ private volatile boolean isDBAccessAvailable = false;
+ private volatile boolean isThreadAlreadyStart = false;
+ private Conf lastSyncUserTime = Holders.simple(StringUtils.EMPTY);
+ private Conf lastSyncDepTime = Holders.simple(StringUtils.EMPTY);
+ private Conf synToken = Holders.simple(StringUtils.EMPTY);
+
+ public static YituanPri getInstance() {
+ if (config == null) {
+ config = ConfigContext.getConfigInstance(YituanPri.class);
+ }
+ return config;
+ }
+
+ public String getCloudHost() {
+ return cloudHost.get();
+ }
+
+ public void setCloudHost(String cloudHost) {
+ this.cloudHost.set(cloudHost);
+ }
+
+ public String getLastSyncUserTime() {
+ return lastSyncUserTime.get();
+ }
+
+ public void setLastSyncUserTime(String lastSyncUserTime) {
+ this.lastSyncUserTime .set( lastSyncUserTime);
+ }
+
+ public String getLastSyncDepTime() {
+ return lastSyncDepTime.get();
+ }
+
+ public void setSynToken(String token) {
+ this.synToken .set( token);
+ }
+
+ public String getSynToken() {
+ return synToken.get();
+ }
+
+ public void setLastSyncDepTime(String lastSyncDepTime) {
+ this.lastSyncDepTime.set(lastSyncDepTime);
+ }
+
+ public String getAppId() {
+ return appId.get();
+ }
+
+ public void setAppId(String appId) {
+ this.appId.set(appId);
+ }
+
+ public String getEid() {
+ return eid.get();
+ }
+
+ public void setEid(String eid) {
+ this.eid.set(eid);
+ }
+
+ public String getSecret() {
+ return secret.get();
+ }
+
+ public void setSecret(String secret) {
+ this.secret.set(secret);
+ }
+
+ public String getUrl() {
+ return url.get();
+ }
+
+ public void setUrl(String url) {
+ this.url.set(url);
+ }
+
+ public String getReadKey() {
+ return readKey.get();
+ }
+
+ public void setReadKey(String readKey) {
+ this.readKey.set(readKey);
+ }
+
+ public boolean isAuthorityInited() {
+ return isAuthorityInited;
+ }
+
+ public void setAuthorityInited(boolean authorityInited) {
+ isAuthorityInited = authorityInited;
+ }
+
+ public boolean isDBAccessAvailable() {
+ return isDBAccessAvailable;
+ }
+
+ public void setDBAccessAvailable(boolean DBAccessAvailable) {
+ isDBAccessAvailable = DBAccessAvailable;
+ }
+
+ public boolean isThreadAlreadyStart() {
+ return isThreadAlreadyStart;
+ }
+
+ public void setThreadAlreadyStart(boolean threadAlreadyStart) {
+ isThreadAlreadyStart = threadAlreadyStart;
+ }
+
+ public String getMatch() {
+ return match.get();
+ }
+
+ public void setMatch(String match) {
+ this.match.set(match);
+ }
+
+ public String getScanId() {
+ return scanId.get();
+ }
+
+ public void setScanId(String scanId) {
+ this.scanId .set(scanId);
+ }
+
+ public String getScanSecret() {
+ return scanSecret.get();
+ }
+
+ public void setScanSecret(String scanSecret) {
+ this.scanSecret .set(scanSecret);
+ }
+
+ public String getDataSet() {
+ return dataSet.get();
+ }
+
+ public void setDataSet(String dataSet) {
+ this.dataSet.set(dataSet);
+ }
+
+ public Integer getDataSetFsName() {
+ return dataSetFsName.get();
+ }
+
+ public void setDataSetFsName(Integer dataSetFsName) {
+ this.dataSetFsName .set(dataSetFsName);
+ }
+
+ public Integer getDataSetUserId() {
+ return dataSetUserId.get();
+ }
+
+ public void setDataSetUserId(Integer dataSetUserId) {
+ this.dataSetUserId .set( dataSetUserId);
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ YituanPri clone = (YituanPri) super.clone();
+ clone.secret = (Conf) secret.clone();
+ clone.appId = (Conf) appId.clone();
+ clone.eid = (Conf) eid.clone();
+ clone.url = (Conf) url.clone();
+ clone.cloudHost = (Conf) cloudHost.clone();
+ clone.readKey = (Conf) readKey.clone();
+ clone.match = (Conf) match.clone();
+
+ clone.scanId = (Conf) scanId.clone();
+ clone.lastSyncUserTime = (Conf) lastSyncUserTime.clone();
+ clone.lastSyncDepTime = (Conf) lastSyncDepTime.clone();
+ clone.synToken = (Conf) synToken.clone();
+ clone.scanSecret = (Conf) scanSecret.clone();
+
+ clone.dataSetUserId = (Conf) dataSetUserId.clone();
+ clone.dataSetFsName = (Conf) dataSetFsName.clone();
+ clone.dataSet = (Conf) dataSet.clone();
+ return clone;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/dao/MyAgentDao.java b/src/main/java/com/fr/plugin/dao/MyAgentDao.java
new file mode 100644
index 0000000..6da3d56
--- /dev/null
+++ b/src/main/java/com/fr/plugin/dao/MyAgentDao.java
@@ -0,0 +1,15 @@
+package com.fr.plugin.dao;
+
+import com.fr.plugin.entitys.YTAgentEntity;
+import com.fr.stable.db.dao.BaseDAO;
+import com.fr.stable.db.session.DAOSession;
+
+public class MyAgentDao extends BaseDAO {
+ public MyAgentDao(DAOSession daoSession) {
+ super(daoSession);
+ }
+
+ protected Class getEntityClass() {
+ return YTAgentEntity.class;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/dao/MyDepDao.java b/src/main/java/com/fr/plugin/dao/MyDepDao.java
new file mode 100644
index 0000000..2d8accd
--- /dev/null
+++ b/src/main/java/com/fr/plugin/dao/MyDepDao.java
@@ -0,0 +1,14 @@
+package com.fr.plugin.dao;
+
+import com.fr.plugin.entitys.YtDepEntity;
+import com.fr.stable.db.dao.BaseDAO;
+import com.fr.stable.db.session.DAOSession;
+
+public class MyDepDao extends BaseDAO {
+ public MyDepDao(DAOSession daoSession) {
+ super(daoSession);
+ }
+ protected Class getEntityClass() {
+ return YtDepEntity.class;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/dao/MyEntityDao.java b/src/main/java/com/fr/plugin/dao/MyEntityDao.java
new file mode 100644
index 0000000..8fea553
--- /dev/null
+++ b/src/main/java/com/fr/plugin/dao/MyEntityDao.java
@@ -0,0 +1,14 @@
+package com.fr.plugin.dao;
+
+import com.fr.plugin.entitys.YtOutputMyEntity;
+import com.fr.stable.db.dao.BaseDAO;
+import com.fr.stable.db.session.DAOSession;
+
+public class MyEntityDao extends BaseDAO {
+ public MyEntityDao(DAOSession daoSession) {
+ super(daoSession);
+ }
+ protected Class getEntityClass() {
+ return YtOutputMyEntity.class;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/dao/MyGroupDao.java b/src/main/java/com/fr/plugin/dao/MyGroupDao.java
new file mode 100644
index 0000000..2bcf734
--- /dev/null
+++ b/src/main/java/com/fr/plugin/dao/MyGroupDao.java
@@ -0,0 +1,15 @@
+package com.fr.plugin.dao;
+
+import com.fr.plugin.entitys.YtGroupEntity;
+import com.fr.stable.db.dao.BaseDAO;
+import com.fr.stable.db.session.DAOSession;
+
+public class MyGroupDao extends BaseDAO {
+ public MyGroupDao(DAOSession daoSession) {
+ super(daoSession);
+ }
+ protected Class getEntityClass() {
+ return YtGroupEntity.class;
+ }
+
+}
diff --git a/src/main/java/com/fr/plugin/dao/MyUserDao.java b/src/main/java/com/fr/plugin/dao/MyUserDao.java
new file mode 100644
index 0000000..0cf7ea7
--- /dev/null
+++ b/src/main/java/com/fr/plugin/dao/MyUserDao.java
@@ -0,0 +1,15 @@
+package com.fr.plugin.dao;
+
+import com.fr.plugin.entitys.YTUserEntity;
+import com.fr.stable.db.dao.BaseDAO;
+import com.fr.stable.db.session.DAOSession;
+
+public class MyUserDao extends BaseDAO {
+ public MyUserDao(DAOSession daoSession) {
+ super(daoSession);
+ }
+ protected Class getEntityClass() {
+ return YTUserEntity.class;
+ }
+
+}
diff --git a/src/main/java/com/fr/plugin/dao/MyYiTuanDao.java b/src/main/java/com/fr/plugin/dao/MyYiTuanDao.java
new file mode 100644
index 0000000..d9612d2
--- /dev/null
+++ b/src/main/java/com/fr/plugin/dao/MyYiTuanDao.java
@@ -0,0 +1,14 @@
+package com.fr.plugin.dao;
+
+import com.fr.plugin.entitys.YTYiTuanEntity;
+import com.fr.stable.db.dao.BaseDAO;
+import com.fr.stable.db.session.DAOSession;
+
+public class MyYiTuanDao extends BaseDAO {
+ public MyYiTuanDao(DAOSession daoSession) {
+ super(daoSession);
+ }
+ protected Class getEntityClass() {
+ return YTYiTuanEntity.class;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/entitys/YTAgentEntity.java b/src/main/java/com/fr/plugin/entitys/YTAgentEntity.java
new file mode 100644
index 0000000..0067a65
--- /dev/null
+++ b/src/main/java/com/fr/plugin/entitys/YTAgentEntity.java
@@ -0,0 +1,133 @@
+package com.fr.plugin.entitys;
+
+import com.fr.plugin.beans.MyAgentBean;
+import com.fr.stable.db.entity.BaseEntity;
+import com.fr.third.javax.persistence.Column;
+import com.fr.third.javax.persistence.Entity;
+import com.fr.third.javax.persistence.Table;
+
+@Entity
+@Table(
+ name = "fine_yt_agent"
+)
+public class YTAgentEntity extends BaseEntity {
+
+ @Column(
+ name = "agentName"
+ )
+ private String agentName = "";
+ @Column(
+ name = "agentId"
+ )
+ private String agentId = "";
+ @Column(
+ name = "corpId"
+ )
+ private String corpId = "";
+ @Column(
+ name = "secret"
+ )
+ private String secret = "";
+ @Column(
+ name = "type"
+ )
+ private Integer type = 2;
+ @Column(
+ name = "timeStamp"
+ )
+ private Long timeStamp = 0L;
+
+ public MyAgentBean createBean(MyAgentBean var1) {
+ var1.setId(this.getId());
+ var1.setAgentName(this.getAgentName());
+ var1.setGroupId(this.getAgentId());
+ var1.setClientId(this.getCorpId());
+ var1.setSecret(this.getSecret());
+ var1.setType(this.getType());
+ var1.setTimeStamp(this.getTimeStamp());
+ return var1;
+ }
+
+ public YTAgentEntity id(String var1) {
+ this.setId(var1);
+ return this;
+ }
+
+ public String getAgentName() {
+ return this.agentName;
+ }
+
+ public void setAgentName(String var1) {
+ this.agentName = var1;
+ }
+
+ public YTAgentEntity agentName(String var1) {
+ this.setAgentName(var1);
+ return this;
+ }
+
+ public String getAgentId() {
+ return this.agentId;
+ }
+
+ public void setAgentId(String var1) {
+ this.agentId = var1;
+ }
+
+ public YTAgentEntity agentId(String var1) {
+ this.setAgentId(var1);
+ return this;
+ }
+
+ public String getCorpId() {
+ return this.corpId;
+ }
+
+ public void setCorpId(String var1) {
+ this.corpId = var1;
+ }
+
+ public YTAgentEntity corpId(String var1) {
+ this.setCorpId(var1);
+ return this;
+ }
+
+ public String getSecret() {
+ return this.secret;
+ }
+
+ public void setSecret(String var1) {
+ this.secret = var1;
+ }
+
+ public YTAgentEntity secret(String var1) {
+ this.setSecret(var1);
+ return this;
+ }
+
+ public Integer getType() {
+ return this.type;
+ }
+
+ public void setType(int var1) {
+ this.type = var1;
+ }
+
+ public YTAgentEntity type(int var1) {
+ this.setType(var1);
+ return this;
+ }
+
+ public Long getTimeStamp() {
+ return timeStamp;
+ }
+
+ public void setTimeStamp(Long timeStamp) {
+ this.timeStamp = timeStamp;
+ }
+
+ public YTAgentEntity timeStamp(long var1) {
+ this.setTimeStamp(var1);
+ return this;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/entitys/YTUserEntity.java b/src/main/java/com/fr/plugin/entitys/YTUserEntity.java
new file mode 100644
index 0000000..6004b55
--- /dev/null
+++ b/src/main/java/com/fr/plugin/entitys/YTUserEntity.java
@@ -0,0 +1,125 @@
+package com.fr.plugin.entitys;
+
+import com.fr.plugin.beans.MyUserBean;
+import com.fr.stable.db.entity.BaseEntity;
+import com.fr.third.javax.persistence.Column;
+import com.fr.third.javax.persistence.Entity;
+import com.fr.third.javax.persistence.Table;
+
+@Entity
+@Table(
+ name = "fine_yt_user"
+)
+public class YTUserEntity extends BaseEntity {
+ @Column(
+ name = "openId"
+ )
+ private String openId;
+ @Column(
+ name = "name"
+ )
+ private String name;
+ @Column(
+ name = "photoUrl"
+ )
+ private String photoUrl;
+ @Column(
+ name = "jobNo"
+ )
+ private String jobNo;
+ @Column(
+ name = "depName"
+ )
+ private String department;
+ @Column(
+ name = "status"
+ )
+ private int status;
+ @Column(
+ name = "phone"
+ )
+ private String phone;
+ @Column(
+ name = "fsUserName"
+ )
+ private String fsUserName;
+
+ public String getFsUserName() {
+ return fsUserName;
+ }
+
+ public void setFsUserName(String fsUserName) {
+ this.fsUserName = fsUserName;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public MyUserBean createBean() {
+ MyUserBean var1 =new MyUserBean();
+ var1.setId(this.getId());
+ var1.setName(this.getName());
+ var1.setDepartment(this.getDepartment());
+ var1.setJobNo(this.getJobNo());
+ var1.setPhotoUrl(this.getPhotoUrl());
+ var1.setStatus(this.getStatus());
+ var1.setPhone(this.getPhone());
+ var1.setFsUserName(this.getFsUserName());
+ return var1;
+ }
+
+ public String getOpenId() {
+ return openId;
+ }
+
+ public void setOpenId(String openId) {
+ this.openId = openId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPhotoUrl() {
+ return photoUrl;
+ }
+
+ public void setPhotoUrl(String photoUrl) {
+ this.photoUrl = photoUrl;
+ }
+
+ public String getJobNo() {
+ return jobNo;
+ }
+
+ public void setJobNo(String jobNo) {
+ this.jobNo = jobNo;
+ }
+
+ public String getDepartment() {
+ return department;
+ }
+
+ public void setDepartment(String department) {
+ this.department = department;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+
+}
diff --git a/src/main/java/com/fr/plugin/entitys/YTYiTuanEntity.java b/src/main/java/com/fr/plugin/entitys/YTYiTuanEntity.java
new file mode 100644
index 0000000..43bd452
--- /dev/null
+++ b/src/main/java/com/fr/plugin/entitys/YTYiTuanEntity.java
@@ -0,0 +1,102 @@
+package com.fr.plugin.entitys;
+
+import com.fr.plugin.beans.MyYituanBean;
+import com.fr.stable.db.entity.BaseEntity;
+import com.fr.third.javax.persistence.Column;
+import com.fr.third.javax.persistence.Entity;
+import com.fr.third.javax.persistence.Table;
+
+@Entity
+@Table(
+ name = "fine_yt_config"
+)
+public class YTYiTuanEntity extends BaseEntity {
+
+ @Column(
+ name = "agentName"
+ )
+ private String agentName = "";
+ @Column(
+ name = "teamId"
+ )
+ private String teamId = "";
+ @Column(
+ name = "groupId"
+ )
+ private String groupId = "";
+ @Column(
+ name = "clientId"
+ )
+ private String clientId = "";
+ @Column(
+ name = "secret"
+ )
+ private String secret = "";
+
+ public String getTeamId() {
+ return teamId;
+ }
+
+ public void setTeamId(String teamId) {
+ this.teamId = teamId;
+ }
+
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(String groupId) {
+ this.groupId = groupId;
+ }
+
+ public String getClientId() {
+ return clientId;
+ }
+
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+ public MyYituanBean createBean(MyYituanBean var1) {
+ var1.setId(this.getId());
+ var1.setAgentName(this.getAgentName());
+ var1.setGroupId(this.getGroupId());
+ var1.setTeamId(this.getTeamId());
+ var1.setClientId(this.getClientId());
+ var1.setSecret(this.getSecret());
+ return var1;
+ }
+
+ public YTYiTuanEntity id(String var1) {
+ this.setId(var1);
+ return this;
+ }
+
+ public String getAgentName() {
+ return this.agentName;
+ }
+
+ public void setAgentName(String var1) {
+ this.agentName = var1;
+ }
+
+ public YTYiTuanEntity agentName(String var1) {
+ this.setAgentName(var1);
+ return this;
+ }
+
+ public String getSecret() {
+ return this.secret;
+ }
+
+ public void setSecret(String var1) {
+ this.secret = var1;
+ }
+
+ public YTYiTuanEntity secret(String var1) {
+ this.setSecret(var1);
+ return this;
+ }
+
+
+}
diff --git a/src/main/java/com/fr/plugin/entitys/YtDepEntity.java b/src/main/java/com/fr/plugin/entitys/YtDepEntity.java
new file mode 100644
index 0000000..7b4cdcc
--- /dev/null
+++ b/src/main/java/com/fr/plugin/entitys/YtDepEntity.java
@@ -0,0 +1,72 @@
+package com.fr.plugin.entitys;
+
+import com.fr.plugin.beans.MyDepBean;
+import com.fr.stable.db.entity.BaseEntity;
+import com.fr.third.javax.persistence.Column;
+import com.fr.third.javax.persistence.Entity;
+import com.fr.third.javax.persistence.Table;
+
+@Entity
+@Table(
+ name = "fine_yt_dep"
+)
+public class YtDepEntity extends BaseEntity {
+ @Column(
+ name = "name"
+ )
+ private String name;
+ @Column(
+ name = "depName"
+ )
+ private String depName;
+
+ @Column(
+ name = "top1"
+ )
+ private int top1;
+ @Column(
+ name = "parentId"
+ )
+ private String parentId;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDepName() {
+ return depName;
+ }
+
+ public void setDepName(String depName) {
+ this.depName = depName;
+ }
+
+ public int getTop1() {
+ return top1;
+ }
+
+ public void setTop1(int top) {
+ this.top1 = top;
+ }
+
+ public String getParentId() {
+ return parentId;
+ }
+
+ public void setParentId(String parentId) {
+ this.parentId = parentId;
+ }
+ public MyDepBean createBean(){
+ MyDepBean bean=new MyDepBean();
+ bean.setDepName(this.depName);
+ bean.setId(this.getId());
+ bean.setName(this.name);
+ bean.setParentId(this.parentId);
+ bean.setOrder(this.top1);
+ return bean;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/entitys/YtGroupEntity.java b/src/main/java/com/fr/plugin/entitys/YtGroupEntity.java
new file mode 100644
index 0000000..11ec76d
--- /dev/null
+++ b/src/main/java/com/fr/plugin/entitys/YtGroupEntity.java
@@ -0,0 +1,46 @@
+package com.fr.plugin.entitys;
+
+import com.fr.plugin.beans.MyGroupBean;
+import com.fr.stable.db.entity.BaseEntity;
+import com.fr.third.javax.persistence.Column;
+import com.fr.third.javax.persistence.Entity;
+import com.fr.third.javax.persistence.Table;
+
+@Entity
+@Table(
+ name = "fine_yt_group"
+)
+public class YtGroupEntity extends BaseEntity {
+ @Column(
+ name = "name"
+ )
+ private String name;
+ @Column(
+ name = "groupId"
+ )
+ private String groupId;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(String groupId) {
+ this.groupId = groupId;
+ }
+
+ public MyGroupBean createBean(){
+ MyGroupBean bean=new MyGroupBean();
+ bean.setId(this.getId());
+ bean.setName(this.name);
+ bean.setGroupId(this.groupId);
+ return bean;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/entitys/YtOutputMyEntity.java b/src/main/java/com/fr/plugin/entitys/YtOutputMyEntity.java
new file mode 100644
index 0000000..238fe2c
--- /dev/null
+++ b/src/main/java/com/fr/plugin/entitys/YtOutputMyEntity.java
@@ -0,0 +1,246 @@
+package com.fr.plugin.entitys;
+
+import com.fr.plugin.beans.YTOutputBean;
+import com.fr.schedule.base.entity.AbstractScheduleEntity;
+import com.fr.schedule.base.entity.output.BaseOutputActionEntity;
+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;
+
+@Entity
+@Table(
+ name = "fine_yt_output"
+)
+@TableAssociation(
+ associated = true
+)
+public class YtOutputMyEntity extends AbstractScheduleEntity {
+ private static final String COLUMN_TERMINAL = "terminal";
+ private static final String COLUMN_AGENTID = "agentId";
+ private static final String COLUMN_CLIENTID = "clientId";
+ 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";
+ @Column(
+ name = "terminal"
+ )
+ private int terminal = 128;// 般应该使用 2 4 8 16 32 64 128 这样的表示其实就是 000001 000010 0000100 00001000类似这个二进制
+ @Column(
+ name = "agentId"
+ )
+ private String agentId = null;
+ @Column(
+ name = "clientId"
+ )
+ private String clientId = null;
+ @Column(
+ name = "subject",
+ length = 65536
+ )
+
+ private String subject;
+ @Column(
+ name = "actionName",
+ nullable = false
+ )
+ private String actionName = "com.fr.plugin.beans.YTOutputBean";
+ @Column(
+ name = "goUrl",
+ length = 1022
+ )
+ private String goUrl = "";
+ @Column(
+ name = "content",
+ length = 65536
+ )
+ private String content;
+ @Column(
+ name = "linkOpenType"
+ )
+ private int linkOpenType = -1;
+ @Column(
+ name = "customizeLink",
+ length = 65536
+ )
+ private String customizeLink;
+ @Column(
+ name = "resultURL",
+ length = 1000
+ )
+ private String resultURL = null;
+ @Column(
+ name = "outputId"
+ )
+ private String outputId = null;
+
+ @Column(
+ name = "type"
+ )
+ private int type;
+ @Column(
+ name = "runType"
+ )
+ private int runType;
+ @Column(
+ name = "sendType"
+ )
+ private int sendType;
+ @Column(
+ name = "mediaId"
+ )
+ private String mediaId;
+ @Column(
+ name = "fromUserId"
+ )
+ private String fromUserId;
+
+ public YtOutputMyEntity() {
+ }
+
+ public String getClientId() {
+ return clientId;
+ }
+
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+ public String getGoUrl() {
+ return goUrl;
+ }
+
+ public void setGoUrl(String goUrl) {
+ this.goUrl = goUrl;
+ }
+
+ public YTOutputBean createBean() {
+ YTOutputBean var1 = new YTOutputBean();
+ var1.setId(this.getId());
+ var1.setAgentId(this.getAgentId());
+ var1.setTerminal(this.getTerminal());
+ var1.setSubject(this.getSubject());
+ var1.setContent(this.getContent());
+ var1.setGoUrl(this.getGoUrl());
+ var1.setLinkOpenType(this.getLinkOpenType());
+ var1.setCustomizeLink(this.getCustomizeLink());
+ var1.setType(this.getType());
+ var1.setClientId(this.getClientId());
+ var1.setMediaId(this.getMediaId());
+ var1.setActionName(this.getActionName());
+ var1.setResultURL(this.getResultURL());
+ var1.setRunType(this.getRunType());
+ var1.setFromUserId(this.getFromUserId());
+ var1.setSendType(this.getSendType());
+ return var1;
+ }
+
+ public int getSendType() {
+ return sendType;
+ }
+
+ public void setSendType(int sendType) {
+ this.sendType = sendType;
+ }
+
+ public int getRunType() {
+ return runType;
+ }
+
+ public void setRunType(int runType) {
+ this.runType = runType;
+ }
+
+ public String getFromUserId() {
+ return fromUserId;
+ }
+
+ public void setFromUserId(String fromUserId) {
+ this.fromUserId = fromUserId;
+ }
+
+ public String getActionName() {
+ return this.actionName;
+ }
+
+ public void setActionName(String var1) {
+ this.actionName = var1;
+ }
+
+
+ public String getResultURL() {
+ return this.resultURL;
+ }
+
+ public void setResultURL(String var1) {
+ this.resultURL = var1;
+ }
+
+
+ public String getAgentId() {
+ return this.agentId;
+ }
+
+ public void setAgentId(String var1) {
+ this.agentId = var1;
+ }
+
+ public int getTerminal() {
+ return this.terminal;
+ }
+
+ public void setTerminal(int var1) {
+ this.terminal = var1;
+ }
+
+ public String getSubject() {
+ return this.subject;
+ }
+
+ public void setSubject(String var1) {
+ this.subject = var1;
+ }
+
+ public String getContent() {
+ return this.content;
+ }
+
+ public void setContent(String var1) {
+ this.content = var1;
+ }
+
+ public int getLinkOpenType() {
+ return this.linkOpenType;
+ }
+
+ public void setLinkOpenType(int var1) {
+ this.linkOpenType = var1;
+ }
+
+ public String getCustomizeLink() {
+ return this.customizeLink;
+ }
+
+ public void setCustomizeLink(String var1) {
+ this.customizeLink = var1;
+ }
+
+ public int getType() {
+ return this.type;
+ }
+
+ public void setType(int var1) {
+ this.type = var1;
+ }
+
+ public String getMediaId() {
+ return this.mediaId;
+ }
+
+ public void setMediaId(String var1) {
+ this.mediaId = var1;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/utils/MyAgentUtils.java b/src/main/java/com/fr/plugin/utils/MyAgentUtils.java
new file mode 100644
index 0000000..d937cab
--- /dev/null
+++ b/src/main/java/com/fr/plugin/utils/MyAgentUtils.java
@@ -0,0 +1,34 @@
+package com.fr.plugin.utils;
+
+import com.fr.plugin.yt.MyCoreDBAccess;
+import com.fr.plugin.dao.MyAgentDao;
+import com.fr.plugin.entitys.YTAgentEntity;
+import com.fr.stable.db.action.DBAction;
+import com.fr.stable.db.dao.DAOContext;
+import com.fr.stable.query.QueryFactory;
+import com.fr.stable.query.restriction.RestrictionFactory;
+
+import java.util.List;
+
+public class MyAgentUtils {
+ public static String getAgentIdBySecret(String var9, String var10) {
+
+ return "";
+ }
+ public static List getAgentsSortedByTimeStamp() throws Exception {
+ return (List) MyCoreDBAccess.getAccessor().runQueryAction(new DBAction>() {
+ public List run(DAOContext var1) throws Exception {
+ return ((MyAgentDao)var1.getDAO(MyAgentDao.class)).find(QueryFactory.create().addSort("timeStamp", true));
+ }
+ });
+ }
+
+
+ public static YTAgentEntity getAgentById(String agentId) throws Exception {
+ return MyCoreDBAccess.getAccessor().runQueryAction(new DBAction() {
+ public YTAgentEntity run(DAOContext var1) throws Exception {
+ return var1.getDAO(MyAgentDao.class).findOne(QueryFactory.create().addRestriction(RestrictionFactory.eq("id",agentId)));
+ }
+ });
+ }
+}
diff --git a/src/main/java/com/fr/plugin/utils/MyUtils.java b/src/main/java/com/fr/plugin/utils/MyUtils.java
new file mode 100644
index 0000000..ec8e380
--- /dev/null
+++ b/src/main/java/com/fr/plugin/utils/MyUtils.java
@@ -0,0 +1,75 @@
+package com.fr.plugin.utils;
+
+import com.fr.json.JSONObject;
+import com.fr.plugin.PluginLicense;
+import com.fr.plugin.PluginLicenseManager;
+import com.fr.plugin.dao.MyGroupDao;
+import com.fr.plugin.dao.MyYiTuanDao;
+import com.fr.plugin.entitys.YTYiTuanEntity;
+import com.fr.plugin.entitys.YtGroupEntity;
+import com.fr.plugin.yt.MyCoreDBAccess;
+import com.fr.plugin.yt.MyStartupThred;
+import com.fr.plugin.dao.MyAgentDao;
+import com.fr.plugin.entitys.YTAgentEntity;
+import com.fr.stable.db.action.DBAction;
+import com.fr.stable.db.dao.DAOContext;
+import com.fr.stable.query.QueryFactory;
+import com.fr.stable.query.condition.QueryCondition;
+import java.util.List;
+
+public class MyUtils {
+ public static boolean isLicenseAvailable() {
+ PluginLicense var0 = PluginLicenseManager.getInstance().getPluginLicenseByID("com.fr.plugin.yituan");
+ return var0.isAvailable();
+ }
+
+
+
+ public static JSONObject createSuccessResponseJSONObject() {
+ JSONObject var0 = JSONObject.create();
+ var0.put("errorCode", 0);
+ var0.put("status", "success");
+ return var0;
+ }
+
+ public static List getCompanysSortedByTimeStamp() throws Exception {
+ return MyCoreDBAccess.getAccessor().runQueryAction(new DBAction>() {
+ public List run(DAOContext var1) throws Exception {
+ QueryCondition queryCondition = QueryFactory.create();
+ return var1.getDAO(MyYiTuanDao.class).find(queryCondition
+ .addSort("id", true));
+ }
+ });
+
+ }
+
+ public static List getAgentsSortedByTimeStamp() throws Exception {
+ return MyCoreDBAccess.getAccessor().runQueryAction(new DBAction>() {
+ public List run(DAOContext var1) throws Exception {
+ QueryCondition queryCondition = QueryFactory.create();
+ return var1.getDAO(MyAgentDao.class).find(queryCondition
+ .addSort("id", true));
+ }
+ });
+
+ }
+
+ public static List getGroupsSortedByTimeStamp() throws Exception {
+ return MyCoreDBAccess.getAccessor().runQueryAction(new DBAction>() {
+ public List run(DAOContext var1) throws Exception {
+ QueryCondition queryCondition = QueryFactory.create();
+ return var1.getDAO(MyGroupDao.class).find(queryCondition
+ .addSort("id", true));
+ }
+ });
+ }
+
+ public static void startUpUserSyncThread() {
+ new MyStartupThred().start();
+ }
+
+ public static void startSyncThread() {
+ new Thread(new SyncThread("user")).start();
+ new Thread(new SyncThread("dep")).start();
+ }
+}
diff --git a/src/main/java/com/fr/plugin/utils/PushUtils.java b/src/main/java/com/fr/plugin/utils/PushUtils.java
new file mode 100644
index 0000000..04f8329
--- /dev/null
+++ b/src/main/java/com/fr/plugin/utils/PushUtils.java
@@ -0,0 +1,40 @@
+package com.fr.plugin.utils;
+
+import com.fr.json.JSONObject;
+import com.fr.log.FineLoggerFactory;
+import com.fr.plugin.config.YituanPri;
+import com.fr.third.org.apache.commons.lang3.StringUtils;
+import org.apache.commons.codec.digest.DigestUtils;
+
+import java.util.Arrays;
+
+public class PushUtils {
+
+ public static void sendPush(JSONObject params) {
+ String cloudHost = YituanPri.getInstance().getCloudHost();
+ String url = cloudHost + "/pubacc/pubsend";
+ String s = WebUtils.sendJsonPost(url, params.toString());
+ JSONObject resp = new JSONObject(s);
+ String pubId = resp.getString("pubId");
+ FineLoggerFactory.getLogger().info("推送成功:{}", pubId);
+ }
+
+ public static JSONObject genernateFrom(String no, String pubId, String pubsercet, String nonce, String time) {
+ JSONObject jsonFrom = new JSONObject();
+ jsonFrom.put("no", no);
+ jsonFrom.put("pub", pubId);
+ jsonFrom.put("nonce", nonce);
+ jsonFrom.put("time", time);
+ String pubtoken = sha(no, pubId, pubsercet, nonce, time);
+ jsonFrom.put("pubtoken", pubtoken);
+ return jsonFrom;
+ }
+
+ private static String sha(String... data) {
+ Arrays.sort(data);
+ String join = StringUtils.join(data);
+ String pubtoken = DigestUtils.sha1Hex(join);
+ return pubtoken;
+ }
+
+}
diff --git a/src/main/java/com/fr/plugin/utils/SyncThread.java b/src/main/java/com/fr/plugin/utils/SyncThread.java
new file mode 100644
index 0000000..6059c72
--- /dev/null
+++ b/src/main/java/com/fr/plugin/utils/SyncThread.java
@@ -0,0 +1,108 @@
+package com.fr.plugin.utils;
+
+import com.fr.general.ComparatorUtils;
+import com.fr.json.JSONArray;
+import com.fr.json.JSONObject;
+import com.fr.log.FineLoggerFactory;
+import com.fr.plugin.beans.MyDepBean;
+import com.fr.plugin.beans.MyUserBean;
+import com.fr.plugin.config.YituanPri;
+import com.fr.plugin.yt.MyCorpManager;
+import com.fr.plugin.yt.MyUserSyncManager;
+import com.fr.stable.StringUtils;
+import com.fr.third.org.apache.commons.lang3.time.DateFormatUtils;
+
+import java.util.Date;
+
+public class SyncThread implements Runnable {
+ private String operation;
+
+ public SyncThread(String operation) {
+ this.operation = operation;
+ }
+
+ @Override
+ public void run() {
+ MyUserSyncManager corpManager = MyUserSyncManager.getInstance();
+ if (ComparatorUtils.equalsIgnoreCase("user", operation)) {
+ FineLoggerFactory.getLogger().info("增量同步用户开始");
+ String lastSyncUserTime = YituanPri.getInstance().getLastSyncUserTime();//格式:“2014-08-02 01:40:38”
+ String format = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
+ if(StringUtils.isBlank(lastSyncUserTime)){
+ lastSyncUserTime=format;
+ }
+ YituanPri.getInstance().setLastSyncUserTime(format);
+ JSONArray userLastSyn = WebUtils.getUserLastSyn(0,lastSyncUserTime);
+ int count = 0;
+ while (userLastSyn != null && !userLastSyn.isEmpty()) {
+ if (userLastSyn.isEmpty()) {
+ break;
+ }
+ int size = userLastSyn.size();
+ for (int i = 0; i < size; i++) {
+ JSONObject userJson = userLastSyn.getJSONObject(i);
+ int status = userJson.getInt("status");
+ String id = userJson.getString("openId");
+ String photoUrl = userJson.getString("photoUrl");
+ String name = userJson.getString("name");
+ String jobNo = userJson.getString("jobNo");
+ String phone = userJson.getString("phone");
+ String depName = userJson.getString("department");
+ MyUserBean entity = new MyUserBean();
+ entity.setPhone(phone);
+ entity.setPhotoUrl(photoUrl);
+ entity.setStatus(status);
+ entity.setOpenId(id);
+ entity.setName(name);
+ entity.setDepartment(depName);
+ entity.setJobNo(jobNo);
+ try {
+ corpManager.saveOrUpdateUser(entity);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ count++;
+ }
+ FineLoggerFactory.getLogger().info("增量同步用户count:{},当前页面:{} 条", count,size);
+ userLastSyn = WebUtils.getUserLastSyn(count,lastSyncUserTime);
+ }
+ FineLoggerFactory.getLogger().info("增量同步用户完成 修改了:{}个用户信息", count);
+ } else {
+ FineLoggerFactory.getLogger().info("增量同步部门开始");
+ JSONArray depLastSyn = WebUtils.getDepLastSyn();
+ MyCorpManager myCorpManager = MyCorpManager.getInstance();
+ int count = 0;
+ if (depLastSyn != null && !depLastSyn.isEmpty()) {
+ int size = depLastSyn.size();
+ for (int i = 0; i < size; i++) {
+ JSONObject depJson = depLastSyn.getJSONObject(i);
+ String id = depJson.getString("id");
+ String pid = depJson.getString("parentId");
+ String name = depJson.getString("name");
+ String depName = depJson.getString("department");
+ int order = depJson.getInt("weights");
+ String opera = depJson.getString("");
+ MyDepBean depBean = new MyDepBean();
+ depBean.setDepName(depName);
+ depBean.setId(id);
+ depBean.setOrder(order);
+ depBean.setParentId(pid);
+ depBean.setName(name);
+ try {
+ if(ComparatorUtils.equalsIgnoreCase(opera,"3")){
+ myCorpManager.removeDep(depBean);
+ }else{
+ myCorpManager.saveOrUpdateDep(depBean);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ count++;
+ }
+ }
+ FineLoggerFactory.getLogger().info("增量同步部门完成 修改了:{}个部门信息", count);
+ }
+ }
+
+
+}
diff --git a/src/main/java/com/fr/plugin/utils/UserSync.java b/src/main/java/com/fr/plugin/utils/UserSync.java
new file mode 100644
index 0000000..7547704
--- /dev/null
+++ b/src/main/java/com/fr/plugin/utils/UserSync.java
@@ -0,0 +1,178 @@
+package com.fr.plugin.utils;
+
+import com.fr.log.FineLoggerFactory;
+import com.fr.plugin.dao.MyUserDao;
+import com.fr.plugin.dao.MyYiTuanDao;
+import com.fr.plugin.entitys.YTUserEntity;
+import com.fr.plugin.entitys.YTYiTuanEntity;
+import com.fr.plugin.yt.MyCoreDBAccess;
+import com.fr.stable.db.action.DBAction;
+import com.fr.stable.db.dao.DAOContext;
+import com.fr.stable.query.QueryFactory;
+import com.fr.stable.query.condition.QueryCondition;
+import com.fr.stable.query.restriction.RestrictionFactory;
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class UserSync {
+
+
+ public static void startSyncUser() {
+ YiTuanMaManager manager = YiTuanMaManager.getInstance();
+ /**
+ * 循环所有的agent
+ */
+ List ytYiTuanEntities = null;
+ try {
+ ytYiTuanEntities = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction>() {
+ @Override
+ public List run(DAOContext daoContext) throws Exception {
+ return daoContext.getDAO(MyYiTuanDao.class).find(QueryFactory.create());
+ }
+ });
+
+ if (ytYiTuanEntities.isEmpty()) {
+ FineLoggerFactory.getLogger().info(" 用户同步 未配置任何的一团企业配置 ");
+ return;
+ }
+ List fromCloud = new ArrayList<>();
+ for (YTYiTuanEntity ytYiTuanEntity : ytYiTuanEntities) {
+ String access_token = YiTuanMaUtils.getAccessToken(ytYiTuanEntity.getClientId());
+ FineLoggerFactory.getLogger().info("同步用户获取的accessTOken:{} ", access_token);
+ try {
+ JSONArray userInfo = YiTuanMaUtils.getUserInfo(ytYiTuanEntity.getClientId() , access_token);
+ int length = userInfo.length();
+ FineLoggerFactory.getLogger().info("同步用户获取的数量:{} ", length);
+ for (int i = 0; i < length; i++) {
+ JSONObject userModel = userInfo.getJSONObject(i);
+ String userid;
+ if (userModel.has("id")) {
+ userid = userModel.getString("id");
+ userModel.put("userId", userid);
+ userModel.remove("id");
+ } else {
+ userid = userModel.getString("userId");
+ }
+ fromCloud.add(userid);
+ String name = userModel.getString("name");
+ String mobile = userModel.getString("mobile");
+ YTUserEntity entity = new YTUserEntity();
+ entity.setId(userid);
+ entity.setName(name);
+ entity.setPhone(mobile);
+ FineLoggerFactory.getLogger().info("同步用户:{} name{} mob:{} ", userid, name, mobile);
+ if (existEntity(userid)) {
+ update(entity);
+ } else {
+ save(entity);
+ }
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ List allUserId = getAllUserId();
+ allUserId.removeAll(fromCloud);
+ for (String id : allUserId) {
+ FineLoggerFactory.getLogger().info("同步用户--删除用户 {} ", id);
+ remove(id);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static List getAllUserId() {
+ try {
+ List ytUserEntities = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction>() {
+ public List run(DAOContext content) throws Exception {
+ return content.getDAO(MyUserDao.class).find(QueryFactory.create());
+ }
+ });
+ int size = ytUserEntities.size();
+ ArrayList objects = new ArrayList<>(size);
+ for (int i = 0; i < size; i++) {
+ YTUserEntity entity = ytUserEntities.get(i);
+ objects.add(entity.getId());
+ }
+ return objects;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return new ArrayList<>();
+ }
+
+ private static boolean existEntity(String id) {
+ try {
+ YTUserEntity entity = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction() {
+ public YTUserEntity run(DAOContext content) throws Exception {
+ return content.getDAO(MyUserDao.class).findOne(QueryFactory.create().addRestriction(RestrictionFactory.eq("id", id)));
+ }
+ });
+ return entity != null;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ private static void remove(String id) {
+ try {
+ MyCoreDBAccess.getAccessor().runDMLAction(new DBAction() {
+ public YTUserEntity run(DAOContext content) throws Exception {
+ content.getDAO(MyUserDao.class).remove(id);
+ return null;
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static void save(YTUserEntity entity) {
+ try {
+ MyCoreDBAccess.getAccessor().runDMLAction(new DBAction() {
+ public YTUserEntity run(DAOContext content) throws Exception {
+ content.getDAO(MyUserDao.class).add(entity);
+ return null;
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static void update(YTUserEntity entity) {
+ try {
+ MyCoreDBAccess.getAccessor().runDMLAction(new DBAction() {
+ public YTUserEntity run(DAOContext content) throws Exception {
+ content.getDAO(MyUserDao.class).update(entity);
+ return null;
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static YTUserEntity findById(String id) {
+ try {
+ YTUserEntity entity = MyCoreDBAccess.getAccessor().runDMLAction(new DBAction() {
+ public YTUserEntity run(DAOContext content) throws Exception {
+ QueryCondition queryCondition = QueryFactory.create().addRestriction(RestrictionFactory.eq("id", id));
+ return content.getDAO(MyUserDao.class).findOne(queryCondition);
+ }
+ });
+ return entity;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+}
diff --git a/src/main/java/com/fr/plugin/utils/WebUtils.java b/src/main/java/com/fr/plugin/utils/WebUtils.java
new file mode 100644
index 0000000..9364891
--- /dev/null
+++ b/src/main/java/com/fr/plugin/utils/WebUtils.java
@@ -0,0 +1,380 @@
+package com.fr.plugin.utils;
+
+import com.fr.base.FRContext;
+import com.fr.base.ServerConfig;
+import com.fr.json.JSONArray;
+import com.fr.json.JSONObject;
+import com.fr.log.FineLoggerFactory;
+import com.fr.plugin.beans.MyDepBean;
+import com.fr.plugin.beans.MyUserBean;
+import com.fr.plugin.config.YituanPri;
+import com.fr.plugin.web.hander.LoginUserModel;
+import com.fr.stable.StringUtils;
+import com.fr.third.org.apache.commons.lang3.RandomStringUtils;
+import com.fr.third.org.apache.commons.lang3.time.DateFormatUtils;
+
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+
+public class WebUtils {
+ public static String post(String path, Map param) {
+ String var3 = getParam(param,ServerConfig.getInstance().getServerCharset());
+ PrintWriter var4 = null;
+ BufferedReader var5 = null;
+ String var6 = "";
+
+ try {
+ URL var7 = new URL(path);
+ HttpURLConnection var8 = (HttpURLConnection) var7.openConnection();
+ var8.setRequestProperty("accept", "*/*");
+ var8.setRequestProperty("connection", "Keep-Alive");
+ var8.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+// var8.setRequestProperty("Accept-Charset", "UTF-8");
+ var8.setRequestMethod("POST");
+ var8.setDoOutput(true);
+ var8.setDoInput(true);
+ var4 = new PrintWriter(new OutputStreamWriter(var8.getOutputStream(), StandardCharsets.UTF_8));
+ var4.print(var3);
+ var4.flush();
+
+ String var9;
+ for (var5 = new BufferedReader(new InputStreamReader(var8.getInputStream(), "UTF-8")); (var9 = var5.readLine()) != null; var6 = var6 + var9) {
+ ;
+ }
+ } catch (Exception var18) {
+ var18.printStackTrace();
+ } finally {
+ try {
+ if (var4 != null) {
+ var4.close();
+ }
+
+ if (var5 != null) {
+ var5.close();
+ }
+ } catch (Exception var17) {
+ ;
+ }
+
+ }
+
+ return var6;
+ }
+
+ /**
+ * 发送json 模式的请求
+ *
+ * @param url
+ * @param param
+ * @return
+ */
+ public static String sendJsonPost(String url, String param) {
+ StringBuilder sb = new StringBuilder();
+ PrintWriter out = null;
+ BufferedReader in = null;
+ HttpURLConnection conn = null;
+ try {
+ URL realUrl = new URL(url);
+ // 打开和URL之间的连接
+ conn = (HttpURLConnection) realUrl.openConnection();
+ // 设置通用的请求属性
+ conn.setRequestProperty("accept", "*/*");
+ conn.setRequestMethod("POST");
+// conn.setRequestProperty("connection", "Keep-Alive");
+ String property = System.getProperty("os.name");
+ String serverCharset="utf-8";
+// if (property.contains("windows")) {
+// serverCharset="GBK";
+// }
+ conn.setRequestProperty("Content-Type", "application/json; charset="+serverCharset);
+
+ conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+ // 发送POST请求必须设置如下两行
+ conn.setDoOutput(true);
+ conn.setDoInput(true);
+ // 获取URLConnection对象对应的输出流
+ out = new PrintWriter(new OutputStreamWriter(conn.getOutputStream(), StandardCharsets.UTF_8));
+ // 发送请求参数
+ if (StringUtils.isNotBlank(param)) {
+ out.print(param);
+ }
+ // flush输出流的缓冲
+ out.flush();
+ // 定义BufferedReader输入流来读取URL的响应
+ in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+ String line;
+ sb = new StringBuilder();
+ while ((line = in.readLine()) != null) {
+ sb.append(line);
+ }
+ } catch (Exception e) {
+ if (conn != null) {
+ InputStream errorStream = ( conn).getErrorStream();
+ in = new BufferedReader(new InputStreamReader(errorStream));
+ sb = new StringBuilder();
+ String line;
+ try {
+ while ((line = in.readLine()) != null) {
+ sb.append(line);
+ }
+ } catch (Exception ee) {
+
+ }
+ System.out.println("错误响应:=======》" + sb);
+ }
+ System.out.println("发送 POST 请求出现异常!" + e);
+ e.printStackTrace();
+ }
+ // 使用finally块来关闭输出流、输入流
+ finally {
+ try {
+ if (null != in) {
+ in.close();
+ }
+ if (out != null) {
+ out.close();
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ return sb.toString();
+ }
+
+ private static String getParam(Map var0,String enc) {
+ String var1 = "";
+ Set var2 = var0.keySet();
+ Iterator var3 = var2.iterator();
+
+ while (var3.hasNext()) {
+ String var4 = (String) var3.next();
+ String var5 = var0.get(var4) + "";
+
+ try {
+ var1 = var1 + (var1.length() == 0 ? "" : "&") + URLEncoder.encode(var4, enc) + "=" + URLEncoder.encode(var5, enc);
+ } catch (Exception var7) {
+ ;
+ }
+ }
+
+ return var1;
+ }
+
+
+
+ public static String getSyncDepOrUserAccessToken(String eid, String secret) {
+ Map parms = new HashMap();
+ parms.put("eid", eid);
+ parms.put("secret", secret);
+ parms.put("scope", "resGroupSecret");
+
+ return getAccessToken(parms);
+ }
+
+ public static LoginUserModel getUserInfo(String appid, String acc, String tick) throws Exception {
+ String cloudHost = YituanPri.getInstance().getCloudHost();
+ String var2 = cloudHost + "/gateway/ticket/user/acquirecontext?accessToken=" + acc;
+ JSONObject params = new JSONObject();
+ params.put("appid", appid);
+ params.put("ticket", tick);
+ String resp = sendJsonPost(var2, params.toString());
+ JSONObject jsonObject = new JSONObject(resp);
+ if (jsonObject.getBoolean("success")) {
+ JSONObject data = jsonObject.getJSONObject("data");
+ LoginUserModel model = new LoginUserModel();
+ model.setAppid(data.getString("appid"));
+ model.setUsername(data.getString("username"));
+ model.setUserid(data.getString("userid"));
+ model.setJobNo(data.getString("jobNo"));
+ model.setOpenid(data.getString("openid"));
+ return model;
+ } else {
+ FRContext.getLogger().info("登陆用户失败,响应:" + resp);
+ }
+ return null;
+ }
+
+ /**
+ * 根据不同的scope获取accessToken
+ * resGroupSecret 组织人员通讯录读取密钥、组织人员通讯录同步密钥、签到数据密钥、时间助手密钥、
+ * 生态圈同步密钥
+ *
+ * @param appId
+ * @param secret
+ * @return
+ */
+ public static String getAppAccessToken(String appId, String secret) {
+ Map parms = new HashMap();
+ parms.put("appId", appId);
+ parms.put("secret", secret);
+ parms.put("scope", "app");
+
+ return getAccessToken(parms);
+ }
+
+ public static String getAccessToken(Map parms) {
+ String cloudHost = YituanPri.getInstance().getCloudHost();
+ String url = cloudHost + "/gateway/oauth2/token/getAccessToken";
+ parms.put("timestamp", System.currentTimeMillis() + "");
+ String content = post(url, parms);
+ FineLoggerFactory.getLogger().error("获取ticket:{}", content);
+ JSONObject object = new JSONObject(content);
+ Boolean success = object.getBoolean("success");
+ if (success) {
+ JSONObject data = object.getJSONObject("data");
+ return data.getString("accessToken");
+ }
+ return null;
+ }
+
+ public static List getUserByPage(String eid, String sect, int page) {
+ String cloudHost = YituanPri.getInstance().getCloudHost();
+ String url = cloudHost +"/gateway/openimport/open/person/getall?accessToken=" + getSyncDepOrUserAccessToken(eid, sect);
+ Map params = new HashMap<>();
+ params.put("nonce", RandomStringUtils.randomAlphabetic(8));
+ params.put("eid", eid);
+ JSONObject object = new JSONObject();
+ object.put("begin", page * 1000);
+ object.put("count", 1000);
+ params.put("data", object.toString());
+ String post = post(url, params);
+ JSONObject json = new JSONObject(post);
+ List list = new ArrayList<>();
+ if (json.getBoolean("success")) {
+ JSONArray deps = json.getJSONArray("data");
+ for (int i = 0; i < deps.size(); i++) {
+ JSONObject userJson = deps.getJSONObject(i);
+ /*
+ * 人员
+ "openId":String, //人员的openid
+ "name":String, //姓名
+ "photoUrl":String, //头像URL
+ "phone":String, //手机号码
+ "isHidePhone":String, //是否在通讯录中隐藏手机号码,0: 不隐藏; 1: 隐藏,默认为0
+ "email":String, //邮箱
+ "department":String, //组织长名称
+ "jobNo":String, //企业工号
+ "jobTitle":String, //职位
+ "gender":int, //性别,0: 不确定; 1: 男; 2: 女
+ "status":int, //状态 0: 注销,1: 正常,2: 禁用
+ "orgUserType":int //是否部门负责人 0:否, 1:是
+ */
+ String id = userJson.getString("openId");
+ String photoUrl = userJson.getString("photoUrl");
+ String name = userJson.getString("name");
+ String jobNo = userJson.getString("jobNo");
+ String phone = userJson.getString("phone");
+ String depName = userJson.getString("department");
+ int status = userJson.getInt("status");
+ MyUserBean entity = new MyUserBean();
+ entity.setPhone(phone);
+ entity.setPhotoUrl(photoUrl);
+ entity.setStatus(status);
+ entity.setOpenId(id);
+ entity.setName(name);
+ entity.setDepartment(depName);
+ entity.setJobNo(jobNo);
+ list.add(entity);
+ }
+ } else {
+ FRContext.getLogger().info("同步用户失败,响应:" + post);
+ }
+ return list;
+ }
+
+ /**
+ * sect 组织人员通讯录读取密钥
+ *
+ * @param eid
+ * @param sect
+ */
+ public static List getAllDep(String eid, String sect) {
+ String cloudHost = YituanPri.getInstance().getCloudHost();
+ String url = cloudHost +"/gateway/openimport/open/dept/getall?accessToken=" + getSyncDepOrUserAccessToken(eid, sect);
+ Map params = new HashMap<>();
+ params.put("nonce", RandomStringUtils.randomAlphabetic(8));
+ params.put("eid", eid);
+ String post = post(url, params);
+ JSONObject json = new JSONObject(post);
+ List list = new ArrayList<>();
+ if (json.getBoolean("success")) {
+ JSONArray deps = json.getJSONArray("data");
+ for (int i = 0; i < deps.size(); i++) {
+ JSONObject depJson = deps.getJSONObject(i);
+ /**
+ * { //组织列表
+ * "id":String, //组织的id
+ * "parentId":String, //组织父Id
+ * "name":String, //组织名称
+ * "department":String, //组织长名称
+ * "weights":int //排序码
+ * }
+ */
+ String id = depJson.getString("id");
+ String pid = depJson.getString("parentId");
+ String name = depJson.getString("name");
+ String depName = depJson.getString("department");
+ int order = depJson.getInt("weights");
+ MyDepBean depBean = new MyDepBean();
+ depBean.setDepName(depName);
+ depBean.setId(id);
+ depBean.setOrder(order);
+ depBean.setParentId(pid);
+ depBean.setName(name);
+ list.add(depBean);
+ }
+ } else {
+ FRContext.getLogger().info("同步部门失败,响应:" + post);
+ }
+ return list;
+ }
+
+ public static JSONArray getUserLastSyn(int begin, String lastSyncUserTime) {
+ YituanPri myConfig = YituanPri.getInstance();
+ String eid = myConfig.getEid();
+ String sect = myConfig.getReadKey();
+ String cloudHost = myConfig.getCloudHost();
+ String url = cloudHost +"/gateway/openimport/open/person/getAtTime?accessToken=" + getSyncDepOrUserAccessToken(eid, sect);
+ Map params = new HashMap<>();
+ params.put("eid", eid);
+ params.put("time", lastSyncUserTime);
+ params.put("begin", begin);
+ String post = post(url, params);
+// FineLoggerFactory.getLogger().info("同步的用户数据:{}",post);
+ JSONObject json = new JSONObject(post);
+ if (json.getBoolean("success")) {
+ return json.getJSONArray("data");
+ }
+ return JSONArray.create();
+ }
+
+ public static JSONArray getDepLastSyn() {
+ YituanPri myConfig = YituanPri.getInstance();
+ String eid = myConfig.getEid();
+ String sect = myConfig.getReadKey();
+ String cloudHost = myConfig.getCloudHost();
+ String url = cloudHost+"/gateway/openimport/open/dept/getAtTime?accessToken=" + getSyncDepOrUserAccessToken(eid, sect);
+ String lastSyncUserTime = myConfig.getLastSyncDepTime();//格式:“2014-08-02 01:40:38”
+ String format = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
+ if (StringUtils.isBlank(lastSyncUserTime)) {
+ lastSyncUserTime = format;
+ }
+ myConfig.setLastSyncDepTime(format);
+ Map params = new HashMap<>();
+ params.put("eid", eid);
+ params.put("time", lastSyncUserTime);
+ String post = post(url, params);
+ FineLoggerFactory.getLogger().info("同步的部门数据:{}", post);
+ JSONObject json = new JSONObject(post);
+ if (json.getBoolean("success")) {
+ JSONArray users = json.getJSONArray("data");
+ return users;
+ }
+ return JSONArray.create();
+ }
+
+}
diff --git a/src/main/java/com/fr/plugin/utils/YiTuanMaManager.java b/src/main/java/com/fr/plugin/utils/YiTuanMaManager.java
new file mode 100644
index 0000000..d323b7d
--- /dev/null
+++ b/src/main/java/com/fr/plugin/utils/YiTuanMaManager.java
@@ -0,0 +1,85 @@
+package com.fr.plugin.utils;
+
+import com.fr.config.ConfigContext;
+import com.fr.config.DefaultConfiguration;
+import com.fr.config.holder.Conf;
+import com.fr.config.holder.factory.Holders;
+import com.fr.stable.StringUtils;
+
+
+public class YiTuanMaManager extends DefaultConfiguration {
+
+ private static volatile YiTuanMaManager config = null;
+
+ private Conf eid = Holders.simple("xxx");
+ private Conf url = Holders.simple("");
+ private Conf clientId = Holders.simple("xxx");
+ private Conf clientSecret = Holders.simple("xxx");
+ private Conf sendUserId = Holders.simple("xxx");
+ private Conf groupId = Holders.simple("xxx");
+ private Conf reportServerUrl = Holders.simple(StringUtils.EMPTY);
+
+
+ public static YiTuanMaManager getInstance() {
+ if (config == null) {
+ config = ConfigContext.getConfigInstance(YiTuanMaManager.class);
+ }
+ return config;
+ }
+
+ public String getReportServerUrl() {
+ return reportServerUrl.get();
+ }
+
+ public void setReportServerUrl(String reportServerUrl) {
+ this.reportServerUrl.set(reportServerUrl);
+ }
+
+ public String getEid() {
+ return eid.get();
+ }
+
+ public void setEid(String eid) {
+ this.eid.set(eid);
+ }
+
+ public String getUrl() {
+ return url.get();
+ }
+
+ public void setUrl(String url) {
+ this.url.set(url);
+ }
+
+ public String getClientId() {
+ return clientId.get();
+ }
+
+ public void setClientId(String clientId) {
+ this.clientId.set(clientId);
+ }
+
+ public String getClientSecret() {
+ return clientSecret.get();
+ }
+
+ public void setClientSecret(String clientSecret) {
+ this.clientSecret.set(clientSecret);
+ }
+
+ public String getGroupId() {
+ return groupId.get();
+ }
+
+ public void setGroupId(String groupId) {
+ this.groupId.set(groupId);
+ }
+
+ public String getSendUserId() {
+ return sendUserId.get();
+ }
+
+ public void setSendUserId(String sendUserId) {
+ this.sendUserId.set(sendUserId);
+ }
+}
diff --git a/src/main/java/com/fr/plugin/utils/YiTuanMaUtils.java b/src/main/java/com/fr/plugin/utils/YiTuanMaUtils.java
new file mode 100644
index 0000000..60fee22
--- /dev/null
+++ b/src/main/java/com/fr/plugin/utils/YiTuanMaUtils.java
@@ -0,0 +1,677 @@
+package com.fr.plugin.utils;
+
+import com.fanruan.api.log.LogKit;
+import com.fanruan.api.net.http.HttpKit;
+import com.fr.general.ComparatorUtils;
+import com.fr.log.FineLoggerFactory;
+import com.fr.plugin.dao.MyYiTuanDao;
+import com.fr.plugin.entitys.YTYiTuanEntity;
+import com.fr.plugin.yt.MyCoreDBAccess;
+import com.fr.report.stable.fun.Actor;
+import com.fr.stable.ActorConstants;
+import com.fr.stable.ActorFactory;
+import com.fr.stable.StringUtils;
+import com.fr.stable.db.action.DBAction;
+import com.fr.stable.db.dao.DAOContext;
+import com.fr.stable.query.QueryFactory;
+import com.fr.stable.query.restriction.RestrictionFactory;
+import com.fr.third.guava.cache.*;
+import com.mashape.unirest.http.HttpResponse;
+import com.mashape.unirest.http.JsonNode;
+import com.mashape.unirest.http.Unirest;
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * xx码API调用工具类
+ * Created by Shinelon on 2017/12/13.
+ */
+public class YiTuanMaUtils {
+ public final static String API_BASE_URL = "https://xxxx.cn/openapi/" ;
+ public final static String APP_TOKEN_URL = API_BASE_URL + "oauth/token" ;
+ public final static String APP_TICKET_URL = API_BASE_URL + "oauth/ticket" ;
+ public final static String APP_AUTHCODE_URL = API_BASE_URL + "oauth/authorize" ;
+ public final static String APP_AUTHUSERID_URL = API_BASE_URL + "user/get-user-ids?authCode=" ;
+ public final static String GET_ALLUSER_URL = API_BASE_URL + "group/members/" ;
+ public final static String APP_SENDMSG_URL = API_BASE_URL + "message/send-to-eapp" ;
+ public final static String APP_SENDMSG_TO_USER = API_BASE_URL + "message/send-to-users" ;
+ public final static String GROUP_SENDMSG_URL = API_BASE_URL + "message/send-to-group" ;
+
+ public final static String ACCOUNT_URL = "https://xxxx.cn/esenaccount/openapi/account" ;
+
+
+ public final static int SUCCESS_CODE = 200;
+ public final static int EXPIRE_CODE = 400;
+ public final static int ERROR_CODE = 401;
+ public final static int SYS_ERROR_CODE = 500;
+
+ public final static String APPLICATION_JSON_UTF8 = "application/json;charset=UTF-8" ;
+
+ /**
+ * token缓存,2小时有效期
+ */
+ private static LoadingCache tokenCache = CacheBuilder.newBuilder()
+ .expireAfterWrite(2, TimeUnit.HOURS)
+ .removalListener(new RemovalListener() {
+ @Override
+ public void onRemoval(
+ RemovalNotification notification) {
+ LogKit.debug(notification.getKey() + " was removed, cause is " + notification.getCause());
+ }
+ }).build(new CacheLoader() {
+ @Override
+ public String load(String key) throws Exception {
+ return getAccessTokenFromAPI(key);
+ }
+ });
+
+ /**
+ * ticket缓存,10分钟有效期
+ */
+ private static LoadingCache ticketCache = CacheBuilder.newBuilder()
+ .expireAfterWrite(10, TimeUnit.MINUTES)
+ .removalListener(new RemovalListener() {
+ @Override
+ public void onRemoval(
+ RemovalNotification notification) {
+ LogKit.debug(notification.getKey() + " was removed, cause is " + notification.getCause());
+ }
+ }).build(new CacheLoader() {
+ @Override
+ public String load(String key) throws Exception {
+ return getTicketFromAPI(key);
+ }
+ });
+
+ private static LoadingCache testCache = CacheBuilder.newBuilder()
+ .expireAfterWrite(5, TimeUnit.SECONDS)
+ .removalListener(new RemovalListener() {
+ @Override
+ public void onRemoval(RemovalNotification notification) {
+ LogKit.debug(notification.getKey() + " was removed, cause is " + notification.getCause());
+ }
+ }).build(new CacheLoader() {
+ @Override
+ public String load(String key) throws Exception {
+ return getTicketFromAPI(key);
+ }
+ });
+
+
+ /**
+ * post请求
+ *
+ * @param bodyJSON
+ * @param url
+ * @return
+ * @throws Exception
+ */
+ private static HttpResponse buildPostResponce(JSONObject bodyJSON, String url) throws Exception {
+ HttpResponse jsonResponse = null;
+ jsonResponse = Unirest
+ .post(url)
+ .header("Content-Type" , APPLICATION_JSON_UTF8)
+ .body(bodyJSON.toString()).asJson();
+ return jsonResponse;
+ }
+
+ /**
+ * post请求(header处理)
+ *
+ * @param bodyJSON
+ * @param url
+ * @param access_token
+ * @return
+ * @throws Exception
+ */
+ private static HttpResponse buildPostResponceWithToken(JSONObject bodyJSON, String url, String access_token) throws Exception {
+ HttpResponse jsonResponse = null;
+ jsonResponse = Unirest
+ .post(url)
+ .header("Content-Type" , APPLICATION_JSON_UTF8)
+ .header("Authorization" , getAuthorizationHeader(access_token))
+ .body(bodyJSON.toString()).asJson();
+ return jsonResponse;
+ }
+
+ /**
+ * get请求
+ *
+ * @param url
+ * @param access_token
+ * @return
+ * @throws Exception
+ */
+ private static HttpResponse buildGetResponceWithToken(String url, String access_token) throws Exception {
+ HttpResponse jsonResponse = null;
+ jsonResponse = Unirest
+ .get(url)
+ .header("Content-Type" , APPLICATION_JSON_UTF8)
+ .header("Authorization" , getAuthorizationHeader(access_token))
+ .asJson();
+ return jsonResponse;
+ }
+
+ /**
+ * 获取缓存中的token
+ *
+ * @return
+ */
+ public static String getAccessToken(String clientId) {
+ try {
+ String token = tokenCache.get(clientId);
+ if (StringUtils.isEmpty(token)) {
+ token = getAccessTokenFromAPI(clientId);
+ if (StringUtils.isNotBlank(token)) {
+ tokenCache.put(clientId, token);
+ }
+ }
+ return token;
+ } catch (Exception e) {
+ FineLoggerFactory.getLogger().debug("==================== 获取缓存access_token失败!");
+ }
+ return "" ;
+ }
+
+ /**
+ * 根据clientId以及clientSecret获取token
+ *
+ * @param clientId
+ * @param clientSecret
+ * @return
+ * @throws Exception
+ */
+ public static String getAccessTokenFromConfig(String clientId, String clientSecret) throws Exception {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("clientId" , clientId);
+ jsonObject.put("clientSecret" , clientSecret);
+ HttpResponse jsonResponse = buildPostResponce(jsonObject, APP_TOKEN_URL);
+ if (jsonResponse.getStatus() == SUCCESS_CODE) {
+ JsonNode jsonNode = jsonResponse.getBody();
+ return jsonNode.getObject().getString("access_token");
+ } else {
+ FineLoggerFactory.getLogger().debug("==================== 获取xx码access_token失败!");
+ FineLoggerFactory.getLogger().debug("==================== 获取xx码access_token失败! responseCode = " + jsonResponse.getStatus());
+ FineLoggerFactory.getLogger().debug("==================== responseBody = " + jsonResponse.getBody().toString());
+ }
+ return "" ;
+ }
+
+ /**
+ * 缓存build时专用,获取token
+ * todo 改成查询clientId
+ *
+ * @return
+ * @throws Exception
+ */
+ public static String getAccessTokenFromAPI(String clientId) throws Exception {
+// YiTuanMaManager manager = YiTuanMaManager.getInstance();
+// return getAccessTokenFromConfig(manager.getClientId(), manager.getClientSecret());
+ YTYiTuanEntity entity = getYituanEntityByClientId(clientId);
+ if (entity != null) {
+ String secret = entity.getSecret();
+ return getAccessTokenFromConfig(clientId, secret);
+ }
+ return "" ;
+ }
+
+ public static YTYiTuanEntity getYituanEntityByClientId(String clientId) throws Exception {
+ List ytYiTuanEntities = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction>() {
+ @Override
+ public List run(DAOContext daoContext) throws Exception {
+ return daoContext.getDAO(MyYiTuanDao.class).find(QueryFactory.create().addRestriction(RestrictionFactory.eq("clientId" , clientId)));
+ }
+ });
+ if (!ytYiTuanEntities.isEmpty()) {
+ return ytYiTuanEntities.get(0);
+ }
+ return null;
+ }
+
+ /**
+ * 获取缓存中的ticket
+ *
+ * @return
+ */
+ public static String getTicket(String clientid) {
+ try {
+ String ticket = ticketCache.get(clientid);
+ if (StringUtils.isEmpty(ticket)) {
+ ticket = getTicketFromAPI(clientid);
+ ticketCache.put(clientid, ticket);
+ }
+ return ticket;
+ } catch (Exception e) {
+ FineLoggerFactory.getLogger().debug("==================== 获取缓存ticket失败!");
+ }
+ return "" ;
+ }
+
+ public static String refreshToken(String clientId) throws Exception {
+ String access_token = getAccessTokenFromAPI(clientId);
+ if (StringUtils.isNotBlank(access_token)) {
+ tokenCache.put(clientId, access_token);
+ }
+ return access_token;
+ }
+
+
+ /**
+ * 根据token获取ticket
+ *
+ * @param access_token
+ * @return
+ * @throws Exception
+ */
+ public static String getTicketWithToken(String clientId, String access_token) throws Exception {
+ LogKit.debug("==================== :获取ticket token=" + access_token);
+ return getTicket4ThreeTimes(clientId, access_token, 0);
+
+ }
+
+ private static String getTicket4ThreeTimes(String clientId, String access_token, int count) throws Exception {
+ if (count < 3) {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("accessToken" , access_token);
+ HttpResponse jsonResponse = buildPostResponceWithToken(jsonObject, APP_TICKET_URL, access_token);
+ if (jsonResponse.getStatus() == SUCCESS_CODE) {
+ JsonNode jsonNode = jsonResponse.getBody();
+ return jsonNode.getObject().getString("ticket");
+ } else if (jsonResponse.getStatus() == EXPIRE_CODE || jsonResponse.getStatus() == ERROR_CODE) {
+ LogKit.debug("==================== 获取xx码ticket失败! token失效,重新获取");
+ access_token = refreshToken(clientId);
+ count++;
+ return getTicket4ThreeTimes(clientId, access_token, count);
+ } else {
+ FineLoggerFactory.getLogger().debug("==================== 获取xx码ticket失败!");
+ FineLoggerFactory.getLogger().debug("==================== 获取xx码ticket失败! responseCode = " + jsonResponse.getStatus());
+ FineLoggerFactory.getLogger().debug("==================== responseBody = " + jsonResponse.getBody().toString());
+ return "" ;
+ }
+ } else {
+ FineLoggerFactory.getLogger().debug("==================== 3次获取xx码ticket失败!");
+ return "" ;
+ }
+ }
+
+ /**
+ * 缓存build时专用,获取ticket
+ *
+ * @return
+ * @throws Exception
+ */
+ public static String getTicketFromAPI(String clientId) throws Exception {
+ String access_token = getAccessToken(clientId);
+ if (StringUtils.isNotEmpty(access_token)) {
+ return getTicketWithToken(clientId, access_token);
+ }
+ return "" ;
+ }
+
+ /**
+ * 获取authCode,已弃
+ *
+ * @param ticket
+ * @param access_token
+ * @return
+ * @throws Exception
+ */
+ public static String getAuthCode(String ticket, String access_token) throws Exception {
+ LogKit.debug("==================== :获取authCode token=" + access_token);
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("ticket" , ticket);
+ HttpResponse jsonResponse = buildPostResponceWithToken(jsonObject, APP_AUTHCODE_URL, access_token);
+ if (jsonResponse.getStatus() == SUCCESS_CODE) {
+ JsonNode jsonNode = jsonResponse.getBody();
+ return jsonNode.getObject().getString("authCode");
+ } else {
+ FineLoggerFactory.getLogger().debug("==================== 获取xx码authCode失败!");
+ FineLoggerFactory.getLogger().debug("==================== 获取xx码authCode失败! responseCode = " + jsonResponse.getStatus());
+ FineLoggerFactory.getLogger().debug("==================== responseBody = " + jsonResponse.getBody().toString());
+ }
+ return null;
+ }
+
+ /**
+ * 获取当前xx码用户id
+ *
+ * @param authCode
+ * @param access_token
+ * @return
+ * @throws Exception
+ */
+ public static String getCurrentUserId(String clientId, String authCode, String access_token) throws Exception {
+ LogKit.debug("==================== :获取当前xx码用户id token=" + access_token);
+ return getCurrentUserId4ThreeTimes(clientId, authCode, access_token, 0);
+ }
+
+ private static String getCurrentUserId4ThreeTimes(String clientId, String authCode, String access_token, int count) throws Exception {
+ if (count < 3) {
+ HttpResponse jsonResponse = buildGetResponceWithToken(APP_AUTHUSERID_URL + authCode, access_token);
+ if (jsonResponse.getStatus() == SUCCESS_CODE) {
+ JsonNode jsonNode = jsonResponse.getBody();
+ return jsonNode.getObject().getString("userId");
+ } else if (jsonResponse.getStatus() == EXPIRE_CODE || jsonResponse.getStatus() == ERROR_CODE) {
+ LogKit.debug("==================== 获取xx码用户ID失败! token失效,重新获取");
+ access_token = refreshToken(clientId);
+ count++;
+ return getCurrentUserId4ThreeTimes(clientId, authCode, access_token, count);
+ } else {
+ FineLoggerFactory.getLogger().debug("==================== 获取xx码用户ID失败!");
+ FineLoggerFactory.getLogger().debug("==================== 获取xx码用户ID失败! responseCode = " + jsonResponse.getStatus());
+ FineLoggerFactory.getLogger().debug("==================== responseBody = " + jsonResponse.getBody().toString());
+ return null;
+ }
+ } else {
+ FineLoggerFactory.getLogger().debug("==================== 3次获取xx码用户ID失败!");
+ return null;
+ }
+ }
+
+ /**
+ * 获取团队id,已弃
+ *
+ * @param authCode
+ * @param access_token
+ * @return
+ * @throws Exception
+ */
+ public static String getGroupId(String authCode, String access_token) throws Exception {
+ LogKit.debug("==================== :获取团队id token=" + access_token);
+ HttpResponse jsonResponse = buildGetResponceWithToken(APP_AUTHUSERID_URL + authCode, access_token);
+ if (jsonResponse.getStatus() == SUCCESS_CODE) {
+ JsonNode jsonNode = jsonResponse.getBody();
+ return jsonNode.getObject().getString("tenantId");
+ } else {
+ FineLoggerFactory.getLogger().debug("==================== 获取BI团队ID失败!");
+ FineLoggerFactory.getLogger().debug("==================== 获取BI团队ID失败! responseCode = " + jsonResponse.getStatus());
+ FineLoggerFactory.getLogger().debug("==================== responseBody = " + jsonResponse.getBody().toString());
+ }
+ return null;
+ }
+
+ /**
+ * 获取团队下所有用户
+ *
+ * @param access_token
+ * @return
+ * @throws Exception
+ */
+ public static JSONArray getUserInfo(String clientId, String access_token) throws Exception {
+ YTYiTuanEntity tuanEntity = getYituanEntityByClientId(clientId);
+ if (tuanEntity != null) {
+ String groupId = tuanEntity.getGroupId();
+ return getUserInfo4ThreeTimes(clientId, groupId, access_token, 0);
+ }
+ LogKit.error("同步 client ID : {} 无法获取到对应的配置" , clientId);
+ return new JSONArray();
+ }
+
+ private static JSONArray getUserInfo4ThreeTimes(String clientId, String groupId, String access_token, int count) throws Exception {
+ if (count < 3) {
+ HttpResponse jsonResponse = buildGetResponceWithToken(GET_ALLUSER_URL + groupId, access_token);
+ if (jsonResponse.getStatus() == SUCCESS_CODE) {
+ JsonNode jsonNode = jsonResponse.getBody();
+ return jsonNode.getObject().getJSONArray("members");
+ } else if (jsonResponse.getStatus() == EXPIRE_CODE || jsonResponse.getStatus() == ERROR_CODE) {
+ LogKit.debug("==================== 获取xx码团队所有用户失败! token失效,重新获取");
+ access_token = refreshToken(clientId);
+ count++;
+ return getUserInfo4ThreeTimes(clientId, groupId, access_token, count);
+ } else {
+ FineLoggerFactory.getLogger().debug("==================== 获取xx码团队所有用户失败!");
+ FineLoggerFactory.getLogger().debug("==================== 获取xx码团队所有用户失败! responseCode = " + jsonResponse.getStatus());
+ FineLoggerFactory.getLogger().debug("==================== responseBody = " + jsonResponse.getBody().toString());
+ return null;
+ }
+ } else {
+ FineLoggerFactory.getLogger().debug("==================== 3次获取xx码团队所有用户失败!");
+ return null;
+ }
+ }
+
+ /**
+ * build请求header
+ *
+ * @param access_token
+ * @return
+ */
+ private static String getAuthorizationHeader(String access_token) {
+ String authorization = "Bearer " + access_token;
+ return authorization;
+ }
+
+ /**
+ * 兼容旧报表h5插件
+ *
+ * @return
+ */
+ public static String getCprOP() {
+ //兼容老的h5插件
+ Actor newH5Actor = ActorFactory.getActor("h5");
+ if (newH5Actor == null || ComparatorUtils.equalsIgnoreCase(ActorFactory.getType(newH5Actor), ActorConstants.TYPE_PAGE)) {
+ return "h5_page" ;
+ }
+ return "h5" ;
+ }
+
+ /**
+ * 消息发送接口message实体拼接
+ *
+ * @param title
+ * @param content
+ * @param linkUrl
+ * @return
+ * @throws Exception
+ */
+ private static JSONObject buildMessage(String title, String content, String linkUrl, String image) throws Exception {
+ JSONObject message = new JSONObject();
+ message.put("content" , content);
+ if (StringUtils.isNotEmpty(linkUrl)) {
+ message.put("linkUrl" , linkUrl);
+ }
+ message.put("msgType" , "TEXT");
+ message.put("appletName" , "BI平台");
+ YiTuanMaManager manager = YiTuanMaManager.getInstance();
+ String logourl = manager.getUrl() + "/url/ytlogo";
+// String logourl = manager.getUrl() + "/resources?path=com/fr/plugin/web/images/log.jpg" ;
+ message.put("appletLogoUrl" , logourl);
+ message.put("avatar" , logourl);
+ message.put("msgType" , "TEXT");
+ message.put("msgType" , "TEXT");
+ message.put("imageUrl" , image);
+ message.put("title" , StringUtils.isNotEmpty(title) ? title : "BI消息推送");
+ return message;
+ }
+
+ /**
+ * 发送应用消息
+ *
+ * @param access_token
+ * @param eappId
+ * @param targetIds
+ * @param title
+ * @param content
+ * @param linkUrl
+ * @throws Exception
+ */
+ public static void sendMsgToUserFromAppWithToken(String clientId, String access_token, String eappId, List targetIds, String title, String content, String linkUrl, String imageUrl) throws Exception {
+ LogKit.debug("ASP ==================== :发送应用消息clientId:{} token={}" , clientId, access_token);
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("eappId" , eappId);
+ jsonObject.put("appId" , eappId);
+ jsonObject.put("targetIds" , targetIds);
+ jsonObject.put("message" , buildMessage(title, content, linkUrl, imageUrl));
+ LogKit.debug("==================== 消息内容为:" + jsonObject.toString());
+ sendMsgToUserFromAppWithToken4ThreeTimes(clientId, jsonObject, access_token, 0);
+ }
+
+ private static void sendMsgToUserFromAppWithToken4ThreeTimes(String clientId, JSONObject jsonObject, String access_token, int count) throws Exception {
+ if (count < 3) {
+ HttpResponse jsonResponse = buildPostResponceWithToken(jsonObject, APP_SENDMSG_URL, access_token);
+ if (jsonResponse.getStatus() == SUCCESS_CODE) {
+ LogKit.debug("==================== 发送应用消息成功!");
+ LogKit.debug("==================== 响应{}" , jsonResponse.getBody());
+ } else if (jsonResponse.getStatus() == EXPIRE_CODE || jsonResponse.getStatus() == ERROR_CODE) {
+ LogKit.debug("==================== 发送应用消息失败! token失效,重新获取:{}",jsonResponse.getBody());
+ access_token = refreshToken(clientId);
+ count++;
+ sendMsgToUserFromAppWithToken4ThreeTimes(clientId, jsonObject, access_token, count);
+ } else {
+ FineLoggerFactory.getLogger().debug("==================== 发送应用消息失败!");
+ FineLoggerFactory.getLogger().debug("==================== 发送应用消息失败! responseCode = " + jsonResponse.getStatus());
+ FineLoggerFactory.getLogger().debug("==================== responseBody = " + jsonResponse.getBody().toString());
+ }
+ } else {
+ FineLoggerFactory.getLogger().debug("==================== 3次发送应用消息失败!");
+ }
+ }
+
+ /**
+ * 发送应用消息
+ *
+ * @param targetIds
+ * @param title
+ * @param content
+ * @param linkUrl
+ * @throws Exception
+ */
+ public static void sendMsgToUserFromApp(String clientId, List targetIds, String title, String content, String linkUrl, String imageUrl) throws Exception {
+ YTYiTuanEntity entity = getYituanEntityByClientId(clientId);
+ if (entity != null) {
+ LogKit.debug("发送请求到clientId {} 团队ID:{}" , clientId, entity.getTeamId());
+ sendMsgToUserFromAppWithToken(clientId, getAccessToken(clientId), entity.getTeamId(), targetIds, title, content, linkUrl, imageUrl);
+ } else {
+ LogKit.debug("发送请求到clientId 未能找到?????" , clientId);
+ }
+ }
+
+ /**
+ * 发送用户信息
+ *
+ * @param targetIds
+ * @param title
+ * @param content
+ * @param linkUrl
+ * @throws Exception
+ */
+ public static void sendMSGtoUser(String clientId, String fromUserId, List targetIds, String title, String content, String linkUrl, String imageUrl) throws Exception {
+ JSONObject params = new JSONObject();
+ params.put("fromUserId" , fromUserId);
+ JSONObject message = buildMessage(title, content, linkUrl, imageUrl);
+ params.put("message" , message);
+ JSONArray targets = new JSONArray();
+ for (String targetId : targetIds) {
+ targets.put(targetId);
+ }
+ params.put("targetIds" , targets);
+ sendMSGtoUserWithToken(clientId, params, getAccessToken(clientId), 0);
+ }
+
+ private static void sendMSGtoUserWithToken(String clientId, JSONObject jsonObject, String access_token, int count) throws Exception {
+ if (count < 3) {
+ HttpResponse jsonResponse = buildPostResponceWithToken(jsonObject, APP_SENDMSG_TO_USER, access_token);
+ if (jsonResponse.getStatus() == SUCCESS_CODE) {
+ LogKit.debug("==================== 发送个人成功!");
+ } else if (jsonResponse.getStatus() == EXPIRE_CODE || jsonResponse.getStatus() == ERROR_CODE) {
+ LogKit.debug("==================== 发送个人! token失效,重新获取");
+ access_token = refreshToken(clientId);
+ count++;
+ sendMSGtoUserWithToken(clientId, jsonObject, access_token, count);
+ } else {
+ FineLoggerFactory.getLogger().debug("==================== 发送个人失败!");
+ FineLoggerFactory.getLogger().debug("==================== 发送个人失败! responseCode = " + jsonResponse.getStatus());
+ FineLoggerFactory.getLogger().debug("==================== responseBody = " + jsonResponse.getBody().toString());
+ }
+ } else {
+ FineLoggerFactory.getLogger().debug("==================== 3次个人失败!");
+ }
+ }
+
+ /**
+ * 发送聊天群消息
+ *
+ * @param access_token
+ * @param groupId
+ * @param fromUserId
+ * @param title
+ * @param content
+ * @param linkUrl
+ * @throws Exception
+ */
+ public static void sendMsgToGroupWithToken(String clientId, String access_token, String groupId, String fromUserId, String title, String content, String linkUrl, String image) throws Exception {
+ LogKit.debug("==================== :发送聊天群消息 token=" + access_token);
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("groupId" , groupId);
+ jsonObject.put("fromUserId" , fromUserId);
+ jsonObject.put("message" , buildMessage(title, content, linkUrl, image));
+ LogKit.debug("==================== 消息内容为:" + jsonObject.toString());
+ sendMsgToGroupWithToken4ThreeTimes(clientId, jsonObject, access_token, 0);
+ }
+
+ private static void sendMsgToGroupWithToken4ThreeTimes(String clientId, JSONObject jsonObject, String access_token, int count) throws Exception {
+ if (count < 3) {
+ HttpResponse jsonResponse = buildPostResponceWithToken(jsonObject, GROUP_SENDMSG_URL, access_token);
+ if (jsonResponse.getStatus() == SUCCESS_CODE) {
+ LogKit.debug("==================== 发送聊天群消息成功!");
+ } else if (jsonResponse.getStatus() == EXPIRE_CODE || jsonResponse.getStatus() == ERROR_CODE) {
+ LogKit.debug("==================== 发送聊天群消息失败! token失效,重新获取");
+ access_token = refreshToken(clientId);
+ count++;
+ sendMsgToGroupWithToken4ThreeTimes(clientId, jsonObject, access_token, count);
+ } else {
+ FineLoggerFactory.getLogger().debug("==================== 发送聊天群消息失败!");
+ FineLoggerFactory.getLogger().debug("==================== 发送聊天群消息失败! responseCode = " + jsonResponse.getStatus());
+ FineLoggerFactory.getLogger().debug("==================== responseBody = " + jsonResponse.getBody().toString());
+ }
+ } else {
+ FineLoggerFactory.getLogger().debug("==================== 3次发送聊天群消息失败!");
+ }
+ }
+
+ /**
+ * 发送聊天群消息
+ *
+ * @param groupId
+ * @param fromUserId
+ * @param title
+ * @param content
+ * @param linkUrl
+ * @throws Exception
+ */
+ public static void sendMsgToGroup(String clientId, String groupId, String fromUserId, String title, String content, String linkUrl, String image) throws Exception {
+ sendMsgToGroupWithToken(clientId, getAccessToken(clientId), groupId, fromUserId, title, content, linkUrl, image);
+ }
+
+ /**
+ * 发送公告号消息,未实现
+ *
+ * @param pubOrGroupId
+ * @param userIds
+ * @param title
+ * @param content
+ * @param url
+ * @throws Exception
+ */
+ public static void sendMsgToUserFromPublicNum(String pubOrGroupId, List userIds, String title, String content, String url) throws Exception {
+ LogKit.debug("==================== 发送公告号消息未实现!");
+ FineLoggerFactory.getLogger().warn("==================== 发送公告号消息未实现!");
+ }
+
+ public static String getUserInfoByAccessToken(String accessToken) throws IOException {
+ String url = ACCOUNT_URL;
+ Map headers = new HashMap<>();
+ headers.put("Authorization" , "Bearer " + accessToken);
+ headers.put("Content-Type" , "application/json; charset=utf-8");
+ String resp = HttpKit.get(url, new HashMap<>(), headers);
+ LogKit.error("==================== 获取用户信息返回结果ByAccessToken:" + resp);
+ com.fr.json.JSONObject jsonObject = new com.fr.json.JSONObject(resp);
+ return jsonObject.getString("id");
+ }
+}
diff --git a/src/main/java/com/fr/plugin/web/hander/DelAgentHander.java b/src/main/java/com/fr/plugin/web/hander/DelAgentHander.java
new file mode 100644
index 0000000..d5eff29
--- /dev/null
+++ b/src/main/java/com/fr/plugin/web/hander/DelAgentHander.java
@@ -0,0 +1,46 @@
+package com.fr.plugin.web.hander;
+
+import com.fr.decision.fun.impl.BaseHttpHandler;
+import com.fr.json.JSONObject;
+import com.fr.plugin.yt.MyCoreDBAccess;
+import com.fr.plugin.dao.MyAgentDao;
+import com.fr.plugin.entitys.YTAgentEntity;
+import com.fr.plugin.utils.MyUtils;
+import com.fr.stable.db.action.DBAction;
+import com.fr.stable.db.dao.DAOContext;
+import com.fr.third.springframework.web.bind.annotation.RequestMethod;
+import com.fr.web.utils.WebUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+public class DelAgentHander extends BaseHttpHandler {
+ @Override
+ public RequestMethod getMethod() {
+ return RequestMethod.DELETE;
+ }
+
+ @Override
+ public String getPath() {
+ return "/yt/agent";
+ }
+
+ @Override
+ public boolean isPublic() {
+ return false;
+ }
+
+ @Override
+ public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
+ final String var3 = WebUtils.getHTTPRequestParameter(httpServletRequest, "id");
+ MyCoreDBAccess.getAccessor().runDMLAction(new DBAction>() {
+ public List run(DAOContext var1) throws Exception {
+ var1.getDAO(MyAgentDao.class).remove(var3);
+ return null;
+ }
+ });
+ JSONObject var4 = MyUtils.createSuccessResponseJSONObject();
+ WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, var4);
+ }
+}
diff --git a/src/main/java/com/fr/plugin/web/hander/DelGroupHandler.java b/src/main/java/com/fr/plugin/web/hander/DelGroupHandler.java
new file mode 100644
index 0000000..3e64270
--- /dev/null
+++ b/src/main/java/com/fr/plugin/web/hander/DelGroupHandler.java
@@ -0,0 +1,93 @@
+package com.fr.plugin.web.hander;
+
+import com.fr.decision.fun.impl.BaseHttpHandler;
+import com.fr.json.JSONArray;
+import com.fr.json.JSONObject;
+import com.fr.plugin.dao.MyGroupDao;
+import com.fr.plugin.entitys.YtGroupEntity;
+import com.fr.plugin.yt.MyCoreDBAccess;
+import com.fr.stable.StringUtils;
+import com.fr.stable.db.action.DBAction;
+import com.fr.stable.db.dao.DAOContext;
+import com.fr.stable.query.QueryFactory;
+import com.fr.stable.query.condition.QueryCondition;
+import com.fr.stable.query.restriction.RestrictionFactory;
+import com.fr.third.springframework.web.bind.annotation.RequestMethod;
+import com.fr.web.utils.WebUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+public class DelGroupHandler extends BaseHttpHandler {
+ @Override
+ public RequestMethod getMethod() {
+ return RequestMethod.POST;
+ }
+
+ @Override
+ public String getPath() {
+ return "/yt/delgroup";
+ }
+
+ @Override
+ public boolean isPublic() {
+ return false;
+ }
+
+ @Override
+ public void handle(HttpServletRequest request, HttpServletResponse httpServletResponse) throws Exception {
+ JSONArray resp = new JSONArray();
+ String groupId = WebUtils.getHTTPRequestParameter(request, "groupId");
+ JSONObject respJson = JSONObject.create();
+ List ytGroupEntities = checkExist(groupId);
+ if (StringUtils.isBlank(groupId)) {
+ respJson.put("msg", "group id 为空");
+ respJson.put("errorCode", 1);
+ WebUtils.flushSuccessMessageAutoClose(request, httpServletResponse, respJson);
+ return;
+ }
+ if (ytGroupEntities.isEmpty()) {
+ respJson.put("msg", "群组不存在");
+ respJson.put("errorCode", 1);
+ WebUtils.flushSuccessMessageAutoClose(request, httpServletResponse, respJson);
+ return;
+ }
+ delGroup(ytGroupEntities.get(0));
+ respJson.put("errorCode", 0);
+ WebUtils.flushSuccessMessageAutoClose(request, httpServletResponse, respJson);
+ }
+
+ private void delGroup(YtGroupEntity entity) {
+ try {
+ MyCoreDBAccess.getAccessor().runDMLAction(new DBAction