增加教师发送消息

yxy/生成PDF
YXY 1 year ago
parent cfcdb9c05d
commit a34f2d540b

@ -87,4 +87,30 @@ public class LarkFileHelper extends LarkHelper {
throw new RuntimeException(new LarkException("LarkFileHelper.uploadFile",uploadAllFileResp.getMsg(),request).getErrorMessageBody()); throw new RuntimeException(new LarkException("LarkFileHelper.uploadFile",uploadAllFileResp.getMsg(),request).getErrorMessageBody());
} }
} }
/**
*
* @param request
* @return
*/
public BatchGetTmpDownloadUrlMediaRespBody getTemporaryMediaFileLink(LarkFileRequest request) {
BatchGetTmpDownloadUrlMediaResp linkResult = null;
try {
linkResult = buildClient(request)
.drive()
.media()
.batchGetTmpDownloadUrl(
BatchGetTmpDownloadUrlMediaReq.newBuilder()
.fileTokens(request.getFileToken())
.build()
);
} catch (Exception e) {
throw new RuntimeException(new LarkException("LarkFileHelper.getTemporaryMediaFileLink",e.getMessage(),request).getErrorMessageBody());
}
if (linkResult!= null && linkResult.getCode() == 0){
return linkResult.getData();
}else {
throw new RuntimeException(new LarkException("LarkFileHelper.getTemporaryMediaFileLink",linkResult.getMsg(),request).getErrorMessageBody());
}
}
} }

@ -75,12 +75,12 @@ public class LarkTaskHelper extends LarkHelper {
.build() .build()
); );
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(new LarkException("LarkTaskHelper.createTask",e.getMessage(),request).getErrorMessageBody()); throw new RuntimeException(new LarkException("LarkTaskHelper.getTaskInfo",e.getMessage(),request).getErrorMessageBody());
} }
if (getTaskResp != null && getTaskResp.getCode() == 0){ if (getTaskResp != null && getTaskResp.getCode() == 0){
return getTaskResp.getData(); return getTaskResp.getData();
}else { }else {
throw new RuntimeException(new LarkException("LarkTaskHelper.createTask", getTaskResp.getMsg(),request).getErrorMessageBody()); throw new RuntimeException(new LarkException("LarkTaskHelper.getTaskInfo", getTaskResp.getMsg(),request).getErrorMessageBody());
} }
} }
} }

@ -3,20 +3,25 @@ package com.ruoyi.flyingbook.LarkHelper.script;
import com.google.gson.internal.LinkedTreeMap; import com.google.gson.internal.LinkedTreeMap;
import com.lark.oapi.service.bitable.v1.model.AppTableRecord; import com.lark.oapi.service.bitable.v1.model.AppTableRecord;
import com.lark.oapi.service.bitable.v1.model.GetAppTableRecordResp; import com.lark.oapi.service.bitable.v1.model.GetAppTableRecordResp;
import com.lark.oapi.service.drive.v1.model.BatchGetTmpDownloadUrlMediaRespBody;
import com.lark.oapi.service.drive.v1.model.TmpDownloadUrl;
import com.lark.oapi.service.drive.v1.model.UploadAllMediaRespBody; import com.lark.oapi.service.drive.v1.model.UploadAllMediaRespBody;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.PdfEntity; import com.ruoyi.common.core.domain.PdfEntity;
import com.ruoyi.common.enums.ConfigurationSubTypeEnum; import com.ruoyi.common.enums.ConfigurationSubTypeEnum;
import com.ruoyi.common.enums.ConfigurationTypeEnum; import com.ruoyi.common.enums.ConfigurationTypeEnum;
import com.ruoyi.common.enums.FlagStatus; import com.ruoyi.common.enums.FlagStatus;
import com.ruoyi.common.enums.TemplateSubTypeEnum;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.PdfUtils; import com.ruoyi.common.utils.PdfUtils;
import com.ruoyi.flyingbook.LarkHelper.LarkFileHelper; import com.ruoyi.flyingbook.LarkHelper.LarkFileHelper;
import com.ruoyi.flyingbook.LarkHelper.LarkRobotHelper;
import com.ruoyi.flyingbook.LarkHelper.LarkTableHelper; import com.ruoyi.flyingbook.LarkHelper.LarkTableHelper;
import com.ruoyi.flyingbook.domain.LarkTableConfiguration; import com.ruoyi.flyingbook.domain.LarkTableConfiguration;
import com.ruoyi.flyingbook.domain.LarkTableRelation; import com.ruoyi.flyingbook.domain.LarkTableRelation;
import com.ruoyi.flyingbook.domain.RequestVo; import com.ruoyi.flyingbook.domain.RequestVo;
import com.ruoyi.flyingbook.domain.lark.LarkFileRequest; import com.ruoyi.flyingbook.domain.lark.LarkFileRequest;
import com.ruoyi.flyingbook.domain.lark.LarkRobotRequest;
import com.ruoyi.flyingbook.domain.lark.LarkTableRequest; import com.ruoyi.flyingbook.domain.lark.LarkTableRequest;
import com.ruoyi.flyingbook.domain.template.CourseFeedbackTemplateDto; import com.ruoyi.flyingbook.domain.template.CourseFeedbackTemplateDto;
import com.ruoyi.flyingbook.mapper.LarkTableConfigurationMapper; import com.ruoyi.flyingbook.mapper.LarkTableConfigurationMapper;
@ -51,6 +56,8 @@ public class LarkCreatePdfHelper {
@Autowired @Autowired
private LarkTableHelper larkTableHelper; private LarkTableHelper larkTableHelper;
@Autowired
private LarkRobotHelper larkRobotHelper;
private static final String FOLDER_SPLIT = Constants.FOLDER_SPLIT; private static final String FOLDER_SPLIT = Constants.FOLDER_SPLIT;
@ -112,12 +119,23 @@ public class LarkCreatePdfHelper {
String fileToken = uploadAllMediaRespBody.getFileToken(); String fileToken = uploadAllMediaRespBody.getFileToken();
Map<String, Object> fileMap = new HashMap<>(); Map<String, Object> fileMap = new HashMap<>();
fileMap.put("file_token", fileToken); fileMap.put("file_token", fileToken);
String user = getUser(fields.get("人员"), "id");
fields.clear(); fields.clear();
fields.put(attachment, Arrays.asList(fileMap)); fields.put(attachment, Arrays.asList(fileMap));
LarkTableRequest updateRequest = new LarkTableRequest(request.getAppId(), request.getAppSecret(), LarkTableRequest updateRequest = new LarkTableRequest(request.getAppId(), request.getAppSecret(),
tableRelation.getFromAppToken(), tableRelation.getFromTableId(), record.getRecordId(), fields); tableRelation.getFromAppToken(), tableRelation.getFromTableId(), record.getRecordId(), fields);
larkTableHelper.updateTableRecord(updateRequest); larkTableHelper.updateTableRecord(updateRequest);
removeLocalFile(file); removeLocalFile(file);
LarkFileRequest getTokenUrl = new LarkFileRequest(request.getAppId(), request.getAppSecret(), fileToken);
BatchGetTmpDownloadUrlMediaRespBody temporaryMediaFileLink = larkFileHelper.getTemporaryMediaFileLink(getTokenUrl);
TmpDownloadUrl[] tmpDownloadUrls = temporaryMediaFileLink.getTmpDownloadUrls();
if (tmpDownloadUrls != null && tmpDownloadUrls.length > 0){
TmpDownloadUrl tmpDownloadUrl = tmpDownloadUrls[0];
String content = String.format("{\"text\":\"课程反馈表已生成完毕,%s\"}", tmpDownloadUrl.getTmpDownloadUrl());
LarkRobotRequest larkRobotRequest = new LarkRobotRequest(request.getAppId(), request.getAppSecret(), user, TemplateSubTypeEnum.TEXT.getCode(),content);
larkRobotHelper.sendUserMessage(larkRobotRequest);
}
} }
} }

@ -20,6 +20,7 @@ public class LarkFileRequest extends LarkRequest{
private String fileName; private String fileName;
private Integer fileSize; private Integer fileSize;
private String parentNode; private String parentNode;
private String[] fileToken;
public LarkFileRequest(String appId, String appSecret, File file, String fileName, Integer fileSize, String parentNode) { public LarkFileRequest(String appId, String appSecret, File file, String fileName, Integer fileSize, String parentNode) {
super(appId, appSecret); super(appId, appSecret);
@ -28,4 +29,15 @@ public class LarkFileRequest extends LarkRequest{
this.fileSize = fileSize; this.fileSize = fileSize;
this.parentNode = parentNode; this.parentNode = parentNode;
} }
public LarkFileRequest(String appId, String appSecret, String fileToken) {
super(appId, appSecret);
String[] strings = {fileToken};
this.fileToken = strings;
}
public LarkFileRequest(String appId, String appSecret, String[] fileToken) {
super(appId, appSecret);
this.fileToken = fileToken;
}
} }

Loading…
Cancel
Save