飞书机器人提醒
continuous-integration/drone/push Build is passing Details

于相涌/Lark
YXY 1 year ago
parent 56a21f01f7
commit 8a04ab6932

@ -34,9 +34,9 @@ public class LarkTableFilterScriptHelper {
StringBuilder sb = new StringBuilder("AND("); StringBuilder sb = new StringBuilder("AND(");
sb.append(String.format("YEAR(CurrentValue.[%s]) = %s",paramCode,fromTime.getYear())).append(","); sb.append(String.format("YEAR(CurrentValue.[%s]) = %s",paramCode,fromTime.getYear())).append(",");
sb.append(String.format("MONTH(CurrentValue.[%s]) = %s",paramCode,fromTime.getMonth().getValue())).append(","); sb.append(String.format("MONTH(CurrentValue.[%s]) = %s",paramCode,fromTime.getMonth().getValue())).append(",");
sb.append(String.format("DAY(CurrentValue.[%s]) = %s",paramCode,fromTime.getDayOfMonth())); sb.append(String.format("DAY(CurrentValue.[%s]) = %s",paramCode,fromTime.getDayOfMonth())).append(",");
sb.append(String.format("HOUR(CurrentValue.[%s]) = %s",paramCode,fromTime.getHour())); sb.append(String.format("HOUR(CurrentValue.[%s]) = %s",paramCode,fromTime.getHour())).append(",");
sb.append(String.format("HOUR(CurrentValue.[%s]) %s 30",paramCode,range)); sb.append(String.format("MINUTE(CurrentValue.[%s]) %s 30",paramCode,range));
sb.append(")"); sb.append(")");
return sb.toString(); return sb.toString();
} }

@ -14,9 +14,9 @@ public class LarkTemplate extends BaseEntity {
private Long id; private Long id;
/** /**
* id * id
*/ */
private Long larkTableId; private Long relationId;
/** /**
* *

@ -164,7 +164,7 @@
LEFT JOIN lark_company_relation cr ON tr.lark_company_relation_id = cr.id LEFT JOIN lark_company_relation cr ON tr.lark_company_relation_id = cr.id
WHERE WHERE
tr.flag = #{flag} tr.flag = #{flag}
AND cr.app_type = #{appType}; AND cr.app_type = #{appType}
AND tr.relation_type = #{relationType}; AND tr.relation_type = #{relationType};
</select> </select>
</mapper> </mapper>

@ -6,8 +6,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="com.ruoyi.flyingbook.domain.LarkTemplate" id="LarkTemplateResult"> <resultMap type="com.ruoyi.flyingbook.domain.LarkTemplate" id="LarkTemplateResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="larkTableId" column="lark_table_id" /> <result property="relationId" column="relation_id" />
<result property="templateTypeEnum" column="template_type" /> <result property="templateType" column="template_type" />
<result property="subTemplateType" column="sub_template_type" /> <result property="subTemplateType" column="sub_template_type" />
<result property="templateContent" column="template_content" /> <result property="templateContent" column="template_content" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
@ -19,14 +19,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectLarkTemplateVo"> <sql id="selectLarkTemplateVo">
select id, lark_table_id, template_type, sub_template_type, template_content, create_by, create_time, update_by, update_time, flag, remark from lark_template select id, relation_id, template_type, sub_template_type, template_content, create_by, create_time, update_by, update_time, flag, remark from lark_template
</sql> </sql>
<select id="selectLarkTemplateList" parameterType="com.ruoyi.flyingbook.domain.LarkTemplate" resultMap="LarkTemplateResult"> <select id="selectLarkTemplateList" parameterType="com.ruoyi.flyingbook.domain.LarkTemplate" resultMap="LarkTemplateResult">
<include refid="selectLarkTemplateVo"/> <include refid="selectLarkTemplateVo"/>
<where> <where>
<if test="larkTableId != null "> and lark_table_id = #{larkTableId}</if> <if test="relationId != null "> and relation_id = #{relationId}</if>
<if test="templateTypeEnum != null and templateTypeEnum != ''"> and template_type = #{templateTypeEnum}</if> <if test="templateType != null and templateType != ''"> and template_type = #{templateType}</if>
<if test="subTemplateType != null and subTemplateType != ''"> and sub_template_type = #{subTemplateType}</if> <if test="subTemplateType != null and subTemplateType != ''"> and sub_template_type = #{subTemplateType}</if>
<if test="templateContent != null and templateContent != ''"> and template_content = #{templateContent}</if> <if test="templateContent != null and templateContent != ''"> and template_content = #{templateContent}</if>
<if test="flag != null "> and flag = #{flag}</if> <if test="flag != null "> and flag = #{flag}</if>
@ -41,8 +41,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertLarkTemplate" parameterType="com.ruoyi.flyingbook.domain.LarkTemplate" useGeneratedKeys="true" keyProperty="id"> <insert id="insertLarkTemplate" parameterType="com.ruoyi.flyingbook.domain.LarkTemplate" useGeneratedKeys="true" keyProperty="id">
insert into lark_template insert into lark_template
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="larkTableId != null">lark_table_id,</if> <if test="relationId != null">relation_id,</if>
<if test="templateTypeEnum != null and templateTypeEnum != ''">template_type,</if> <if test="templateType != null and templateType != ''">template_type,</if>
<if test="subTemplateType != null and subTemplateType != ''">sub_template_type,</if> <if test="subTemplateType != null and subTemplateType != ''">sub_template_type,</if>
<if test="templateContent != null">template_content,</if> <if test="templateContent != null">template_content,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
@ -53,8 +53,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="larkTableId != null">#{larkTableId},</if> <if test="relationId != null">#{relationId},</if>
<if test="templateTypeEnum != null and templateTypeEnum != ''">#{templateTypeEnum},</if> <if test="templateType != null and templateType != ''">#{templateType},</if>
<if test="subTemplateType != null and subTemplateType != ''">#{subTemplateType},</if> <if test="subTemplateType != null and subTemplateType != ''">#{subTemplateType},</if>
<if test="templateContent != null">#{templateContent},</if> <if test="templateContent != null">#{templateContent},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
@ -69,8 +69,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateLarkTemplate" parameterType="com.ruoyi.flyingbook.domain.LarkTemplate"> <update id="updateLarkTemplate" parameterType="com.ruoyi.flyingbook.domain.LarkTemplate">
update lark_template update lark_template
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="larkTableId != null">lark_table_id = #{larkTableId},</if> <if test="relationId != null">relation_id = #{relationId},</if>
<if test="templateTypeEnum != null and templateTypeEnum != ''">template_type = #{templateTypeEnum},</if> <if test="templateType != null and templateType != ''">template_type = #{templateType},</if>
<if test="subTemplateType != null and subTemplateType != ''">sub_template_type = #{subTemplateType},</if> <if test="subTemplateType != null and subTemplateType != ''">sub_template_type = #{subTemplateType},</if>
<if test="templateContent != null">template_content = #{templateContent},</if> <if test="templateContent != null">template_content = #{templateContent},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if> <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>

@ -97,7 +97,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求 // 过滤请求
.authorizeRequests() .authorizeRequests()
// 对于登录login 验证码captchaImage 允许匿名访问 // 对于登录login 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/captchaImage", "/approval","/syncEmail", "/approval2").anonymous() .antMatchers("/login", "/captchaImage", "/approval","/syncEmail","/scheduledReminders", "/approval2").anonymous()
.antMatchers( .antMatchers(
HttpMethod.GET, HttpMethod.GET,
"/*.html", "/*.html",

@ -2,6 +2,7 @@ package com.ruoyi.quartz.controller;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.quartz.task.MailSyncTask; import com.ruoyi.quartz.task.MailSyncTask;
import com.ruoyi.quartz.task.ScheduledRemindersTask;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -14,11 +15,18 @@ public class MailInfoController extends BaseController {
@Autowired @Autowired
private MailSyncTask mailSyncTask; private MailSyncTask mailSyncTask;
@Autowired
private ScheduledRemindersTask scheduledRemindersTask;
@PostMapping("/syncEmail") @PostMapping("/syncEmail")
public void syncEmail(Boolean readFlag) { public void syncEmail(Boolean readFlag) {
mailSyncTask.syncMail(readFlag); mailSyncTask.syncMail(readFlag);
} }
@PostMapping("/scheduledReminders")
public void scheduledReminders() {
scheduledRemindersTask.scheduledReminders();
}
} }

@ -3,6 +3,8 @@ package com.ruoyi.quartz.task;
import cn.hutool.extra.template.Template; import cn.hutool.extra.template.Template;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.gson.internal.LinkedTreeMap;
import com.lark.oapi.service.bitable.v1.model.AppTableRecord;
import com.lark.oapi.service.bitable.v1.model.ListAppTableRecordRespBody; import com.lark.oapi.service.bitable.v1.model.ListAppTableRecordRespBody;
import com.ruoyi.common.enums.*; import com.ruoyi.common.enums.*;
import com.ruoyi.flyingbook.LarkHelper.LarkTableHelper; import com.ruoyi.flyingbook.LarkHelper.LarkTableHelper;
@ -51,118 +53,128 @@ public class ScheduledRemindersTask {
@Autowired @Autowired
private EventLogMapper eventLogMapper; private EventLogMapper eventLogMapper;
/**查询分页大小*/ /**
*
*/
private static final Integer PAGE_SIZE = 20; private static final Integer PAGE_SIZE = 20;
/**查询分页大小*/ /**
*
*/
private static final String RANGE_KEY = "日期"; private static final String RANGE_KEY = "日期";
public void scheduledReminders() { public void scheduledReminders() {
log.info("scheduledRemindersTask start"); log.info("scheduledRemindersTask start");
List<LarkCompanyTableInfo> larkList = this.getLarkList(); List<LarkCompanyTableInfo> larkList = this.getLarkList();
if (CollectionUtils.isEmpty(larkList)){ if (CollectionUtils.isEmpty(larkList)) {
return; return;
} }
List<EventLog> logList = new ArrayList<>(); List<EventLog> logList = new ArrayList<>();
LocalDateTime now = LocalDateTime.now();
// LocalDateTime now = LocalDateTime.of(2023, 4, 22, 10, 0);
for (LarkCompanyTableInfo larkCompanyTableInfo : larkList) { for (LarkCompanyTableInfo larkCompanyTableInfo : larkList) {
try { try {
List<LarkTableConfiguration> larkConfiguration = this.getLarkConfiguration(larkCompanyTableInfo); List<LarkTableConfiguration> larkConfiguration = this.getLarkConfiguration(larkCompanyTableInfo);
for (LarkTableConfiguration larkTableConfiguration : larkConfiguration) { for (LarkTableConfiguration larkTableConfiguration : larkConfiguration) {
ConfigurationSubTypeEnum subType = ConfigurationSubTypeEnum.getByCode(larkTableConfiguration.getSubConfigType()); ConfigurationSubTypeEnum subType = ConfigurationSubTypeEnum.getByCode(larkTableConfiguration.getSubConfigType());
if (subType == null){ if (subType == null) {
throw new RuntimeException(String.format("tableId:%s 配置子类:%s 无对应策略处理逻辑",larkTableConfiguration.getLarkTableId(),larkTableConfiguration.getSubConfigType())); throw new RuntimeException(String.format("tableId:%s 配置子类:%s 无对应策略处理逻辑", larkTableConfiguration.getLarkTableId(), larkTableConfiguration.getSubConfigType()));
}
if (ConfigurationSubTypeEnum.REMINDER_AROUND.equals(subType)){
String script = LarkTableFilterScriptHelper.buildTimeRange(larkTableConfiguration,ConfigurationSubTypeEnum.REMINDER_BEFORE,RANGE_KEY,LocalDateTime.now());
this.sendMessage(script,larkCompanyTableInfo,logList);
script = LarkTableFilterScriptHelper.buildTimeRange(larkTableConfiguration,ConfigurationSubTypeEnum.REMINDER_AFTER,RANGE_KEY,LocalDateTime.now());
this.sendMessage(script,larkCompanyTableInfo,logList);
}else {
String script = LarkTableFilterScriptHelper.buildTimeRange(larkTableConfiguration,subType,RANGE_KEY,LocalDateTime.now());
this.sendMessage(script,larkCompanyTableInfo,logList);
} }
if (ConfigurationSubTypeEnum.REMINDER_AROUND.equals(subType)) {
String script = LarkTableFilterScriptHelper.buildTimeRange(larkTableConfiguration, ConfigurationSubTypeEnum.REMINDER_BEFORE, RANGE_KEY, now);
this.sendMessage(script, larkCompanyTableInfo, logList,larkTableConfiguration);
script = LarkTableFilterScriptHelper.buildTimeRange(larkTableConfiguration, ConfigurationSubTypeEnum.REMINDER_AFTER, RANGE_KEY, now);
this.sendMessage(script, larkCompanyTableInfo, logList,larkTableConfiguration);
} else {
String script = LarkTableFilterScriptHelper.buildTimeRange(larkTableConfiguration, subType, RANGE_KEY, now);
this.sendMessage(script, larkCompanyTableInfo, logList,larkTableConfiguration);
} }
}catch (Exception e){
log.error("ScheduledRemindersTask#scheduledReminders error request:{}",JSONObject.toJSONString(larkCompanyTableInfo),e);
new EventLog(larkCompanyTableInfo.getId(),EventOperateType.SCHEDULE_REMINDER.getCode(), JSONObject.toJSONString(larkCompanyTableInfo),null,e.getMessage());
} }
} catch (Exception e) {
log.error("ScheduledRemindersTask#scheduledReminders error request:{}", JSONObject.toJSONString(larkCompanyTableInfo), e);
logList.add(new EventLog(larkCompanyTableInfo.getId(), EventOperateType.SCHEDULE_REMINDER.getCode(), JSONObject.toJSONString(larkCompanyTableInfo), null, e.getMessage()));
} }
if (CollectionUtils.isNotEmpty(logList)){ }
if (CollectionUtils.isNotEmpty(logList)) {
eventLogMapper.insertBatchEventLog(logList); eventLogMapper.insertBatchEventLog(logList);
} }
log.info("scheduledRemindersTask end"); log.info("scheduledRemindersTask end");
} }
private void sendMessage(String script,LarkCompanyTableInfo larkCompanyTableInfo,List<EventLog> logList){ private void sendMessage(String script, LarkCompanyTableInfo larkCompanyTableInfo, List<EventLog> logList,LarkTableConfiguration larkTableConfiguration) {
String pageToken = null; String pageToken = null;
LarkTableRequest request = this.buildRequest(larkCompanyTableInfo, script); LarkTableRequest request = this.buildRequest(larkCompanyTableInfo, script);
LarkTemplate template = this.getTemplate(larkCompanyTableInfo); LarkTemplate template = this.getTemplate(larkCompanyTableInfo,larkTableConfiguration.getId());
do { do {
JSONObject msg = new JSONObject(); JSONObject msg = new JSONObject();
try {
ListAppTableRecordRespBody respBody = larkTableHelper.listTableRecord(request); ListAppTableRecordRespBody respBody = larkTableHelper.listTableRecord(request);
if (respBody.getPageToken().equals(pageToken)){
return;
}else {
pageToken = respBody.getPageToken(); pageToken = respBody.getPageToken();
Arrays.stream(respBody.getItems()).forEach(r -> {
Map<String, Object> fields = r.getFields();
JSONObject msg = this.buildMsg(larkCompanyTableInfo,fields, template);
OkHttpHelper.post(larkCompanyTableInfo.getToAppToken(),msg.toString());
});
new EventLog(larkCompanyTableInfo.getId(),EventOperateType.SCHEDULE_REMINDER.getCode(), msg.toString());
}catch (Exception e){
log.error("ScheduledRemindersTask#scheduledReminders error request tableId:{} msg:{}",JSONObject.toJSONString(larkCompanyTableInfo),msg.toString(),e);
new EventLog(larkCompanyTableInfo.getId(),EventOperateType.SCHEDULE_REMINDER.getCode(), msg.toString(),null,e.getMessage());
} }
}while (StringUtils.isNotBlank(pageToken)); for (AppTableRecord item : respBody.getItems()) {
try {
Map<String, Object> fields = item.getFields();
msg = this.buildMsg(larkCompanyTableInfo, fields, template);
OkHttpHelper.post(larkCompanyTableInfo.getToAppToken(), msg.toString());
logList.add(new EventLog(larkCompanyTableInfo.getId(), EventOperateType.SCHEDULE_REMINDER.getCode(), msg.toString()));
} catch (Exception e) {
log.error("ScheduledRemindersTask#scheduledReminders error request tableId:{} msg:{}", JSONObject.toJSONString(larkCompanyTableInfo), msg.toString(), e);
logList.add(new EventLog(larkCompanyTableInfo.getId(), EventOperateType.SCHEDULE_REMINDER.getCode(), msg.toString(), null, e.getMessage()));
}
}
} while (StringUtils.isNotBlank(pageToken));
} }
private LarkTemplate getTemplate(LarkCompanyTableInfo larkCompanyTableInfo){ private LarkTemplate getTemplate(LarkCompanyTableInfo larkCompanyTableInfo,Long configurationId) {
LarkTemplate larkTemplate = new LarkTemplate(); LarkTemplate larkTemplate = new LarkTemplate();
larkTemplate.setTemplateType(TemplateTypeEnum.SCHEDULED_REMINDER.getCode()); larkTemplate.setTemplateType(TemplateTypeEnum.SCHEDULED_REMINDER.getCode());
larkTemplate.setFlag(FlagStatus.OK.getCode()); larkTemplate.setFlag(FlagStatus.OK.getCode());
larkTemplate.setLarkTableId(larkCompanyTableInfo.getId()); larkTemplate.setRelationId(configurationId);
List<LarkTemplate> larkTemplates = larkTemplateMapper.selectLarkTemplateList(larkTemplate); List<LarkTemplate> larkTemplates = larkTemplateMapper.selectLarkTemplateList(larkTemplate);
if (CollectionUtils.isEmpty(larkTemplates)){ if (CollectionUtils.isEmpty(larkTemplates)) {
throw new RuntimeException(String.format("当前tableId:%s %s类型的模板配置不存在",larkCompanyTableInfo.getId(),larkTemplate.getTemplateType())); throw new RuntimeException(String.format("当前tableId:%s %s类型的模板配置不存在", larkCompanyTableInfo.getId(), larkTemplate.getTemplateType()));
} }
if (larkTemplates.size() > 1){ if (larkTemplates.size() > 1) {
throw new RuntimeException(String.format("当前tableId:%s %s类型存在多个有效的模板配置",larkCompanyTableInfo.getId(),larkTemplate.getTemplateType())); throw new RuntimeException(String.format("当前tableId:%s %s类型存在多个有效的模板配置", larkCompanyTableInfo.getId(), larkTemplate.getTemplateType()));
} }
return larkTemplates.get(0); return larkTemplates.get(0);
} }
private List<LarkTableConfiguration> getLarkConfiguration(LarkCompanyTableInfo larkCompanyTableInfo){ private List<LarkTableConfiguration> getLarkConfiguration(LarkCompanyTableInfo larkCompanyTableInfo) {
List<LarkTableConfiguration> configurationList = new ArrayList<>(); List<LarkTableConfiguration> configurationList = new ArrayList<>();
LarkTableConfiguration query = new LarkTableConfiguration(); LarkTableConfiguration query = new LarkTableConfiguration();
query.setLarkTableId(larkCompanyTableInfo.getId()); query.setLarkTableId(larkCompanyTableInfo.getId());
query.setFlag(FlagStatus.OK.getCode()); query.setFlag(FlagStatus.OK.getCode());
query.setConfigType(ConfigurationTypeEnum.SCHEDULE_REMINDER.getCode()); query.setConfigType(ConfigurationTypeEnum.SCHEDULE_REMINDER.getCode());
configurationList = larkTableConfigurationMapper.selectLarkTableConfigurationList(query); configurationList = larkTableConfigurationMapper.selectLarkTableConfigurationList(query);
if (CollectionUtils.isEmpty(configurationList)){ if (CollectionUtils.isEmpty(configurationList)) {
throw new RuntimeException(String.format("当前tableId:%s 无定时提醒配置",larkCompanyTableInfo.getId())); throw new RuntimeException(String.format("当前tableId:%s 无定时提醒配置", larkCompanyTableInfo.getId()));
} }
return configurationList; return configurationList;
} }
private JSONObject buildMsg(LarkCompanyTableInfo larkCompanyTableInfo,Map<String, Object> fields, LarkTemplate template){ private JSONObject buildMsg(LarkCompanyTableInfo larkCompanyTableInfo, Map<String, Object> fields, LarkTemplate template) {
JSONObject msg = new JSONObject(); JSONObject msg = new JSONObject();
TemplateSubTypeEnum templateSubTypeEnum = TemplateSubTypeEnum.getByCode(template.getSubTemplateType()); TemplateSubTypeEnum templateSubTypeEnum = TemplateSubTypeEnum.getByCode(template.getSubTemplateType());
if (templateSubTypeEnum == null){ if (templateSubTypeEnum == null) {
throw new RuntimeException(String.format("当前tableId:%s 模板类型%s对应策略不存在",larkCompanyTableInfo.getId(),template.getSubTemplateType())); throw new RuntimeException(String.format("当前tableId:%s 模板类型%s对应策略不存在", larkCompanyTableInfo.getId(), template.getSubTemplateType()));
} }
switch (templateSubTypeEnum){ switch (templateSubTypeEnum) {
case TEXT: case TEXT:
msg.put("msg_type",templateSubTypeEnum.getCode()); msg.put("msg_type", templateSubTypeEnum.getCode());
String templateContent = template.getTemplateContent(); String templateContent = template.getTemplateContent();
JSONArray people = JSONObject.parseArray(String.valueOf(fields.get("人员"))); List<LinkedTreeMap<String,String>> people = (List<LinkedTreeMap<String,String>>)fields.get("人员");
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < people.size(); i++) { for (int i = 0; i < people.size(); i++) {
JSONObject jsonObject = people.getJSONObject(i); LinkedTreeMap<String,String> detail = people.get(i);
sb.append(String.format("<at user_id = \"%s\">%s</at>",jsonObject.getString("id"),jsonObject.getString("name"))); sb.append(String.format("<at user_id = \"%s\">%s</at>", detail.get("id"), detail.get("name")));
} }
templateContent.replaceAll("@name",sb.toString()).replaceAll("#name",String.valueOf(fields.get("学生姓名"))); templateContent = templateContent.replaceAll("#name", String.valueOf(fields.get("学生姓名")));
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
content.put("text",sb.append(templateContent).toString()); content.put("text", sb.append(templateContent).toString());
msg.put("content",content); msg.put("content", content);
break; break;
default: default:
break; break;
@ -171,7 +183,7 @@ public class ScheduledRemindersTask {
} }
private List<LarkCompanyTableInfo> getLarkList() { private List<LarkCompanyTableInfo> getLarkList() {
List<LarkCompanyTableInfo> larkCompanyTableInfos = larkTableRelationMapper.queryListJoinLarkCompany(FlagStatus.OK.getCode(), AppType.SCHEDULED_REMINDERS.getCode(), TableRelationTypeEnum.SYNC_EMAIL.getCode()); List<LarkCompanyTableInfo> larkCompanyTableInfos = larkTableRelationMapper.queryListJoinLarkCompany(FlagStatus.OK.getCode(), AppType.SCHEDULED_REMINDERS.getCode(), TableRelationTypeEnum.SCHEDULED_REMINDERS.getCode());
return larkCompanyTableInfos.stream() return larkCompanyTableInfos.stream()
.filter(r -> { .filter(r -> {
return r.getId() != null return r.getId() != null
@ -184,11 +196,23 @@ public class ScheduledRemindersTask {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
private LarkTableRequest buildRequest(LarkCompanyTableInfo larkCompanyTableInfo,String script){ private LarkTableRequest buildRequest(LarkCompanyTableInfo larkCompanyTableInfo, String script) {
LarkTableRequest request = new LarkTableRequest(larkCompanyTableInfo.getAppId(),larkCompanyTableInfo.getAppSecret(),larkCompanyTableInfo.getFromAppToken(), larkCompanyTableInfo.getFromTableId()); LarkTableRequest request = new LarkTableRequest(larkCompanyTableInfo.getAppId(), larkCompanyTableInfo.getAppSecret(), larkCompanyTableInfo.getFromAppToken(), larkCompanyTableInfo.getFromTableId());
request.setFilter(script); request.setFilter(script);
request.setPageSize(PAGE_SIZE); request.setPageSize(PAGE_SIZE);
return request; return request;
} }
public static void main(String[] args) {
String str = "[{avatar_url:https://s1-imfile.feishucdn.com/static-resource/v1/v2_5462d76b-2c9c-405f-8753-149c36bf097g~?image_size:72x72&cut_type:default-face&quality:&format:jpeg&sticker_format:.webp, email:, en_name:于相涌, id:ou_cd09481727e91fce1f12b7b0ed1500d2, name:于相涌}]";
str = str.replace("https:","https")
.replaceAll("\\{","{\"")
.replaceAll(":","\":\"")
.replaceAll(",","\",\"")
.replaceAll("}","}")
.replace("https","https:");
JSONArray objects = JSONArray.parseArray(str);
int i = 0;
}
} }

Loading…
Cancel
Save