|
@@ -1,34 +1,20 @@
|
|
|
package com.usky.iot.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenResponse;
|
|
|
-import com.aliyun.tea.TeaException;
|
|
|
+import com.aliyuncs.exceptions.ClientException;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.dingtalk.api.DefaultDingTalkClient;
|
|
|
-import com.dingtalk.api.DingTalkClient;
|
|
|
-import com.dingtalk.api.request.OapiReportCreateRequest;
|
|
|
-import com.dingtalk.api.request.OapiV2UserGetbymobileRequest;
|
|
|
-import com.dingtalk.api.response.OapiReportCreateResponse;
|
|
|
-import com.dingtalk.api.response.OapiV2UserGetbymobileResponse;
|
|
|
-import com.fasterxml.jackson.databind.JsonNode;
|
|
|
-import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-import com.usky.common.core.bean.ApiResult;
|
|
|
import com.usky.common.core.exception.BusinessException;
|
|
|
import com.usky.common.security.utils.SecurityUtils;
|
|
|
-import com.usky.iot.constant.dingTalkConstant;
|
|
|
import com.usky.iot.domain.*;
|
|
|
import com.usky.iot.mapper.*;
|
|
|
import com.usky.iot.service.PmProjectService;
|
|
|
import com.usky.iot.service.PmWorkContentService;
|
|
|
import com.usky.iot.service.PmWorkReportService;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
+import com.usky.iot.service.config.DingTalkAndMessage;
|
|
|
import com.usky.iot.service.vo.PmProjectWorkTimeVo;
|
|
|
-import com.usky.system.RemoteMceService;
|
|
|
-import com.usky.system.domain.SysUser;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -37,9 +23,9 @@ import java.math.RoundingMode;
|
|
|
import java.time.DayOfWeek;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -55,9 +41,6 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMapper, PmWorkReport> implements PmWorkReportService {
|
|
|
|
|
|
- private static final String INFO_TITLE = "报告提醒";
|
|
|
- private static final String INFO_CONTENT = "的报告";
|
|
|
- private static final int INFO_TYPE = 5;
|
|
|
|
|
|
@Autowired
|
|
|
private PmWorkContentMapper pmWorkContentMapper;
|
|
@@ -72,16 +55,7 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
|
|
|
private PmWorkContentService pmWorkContentService;
|
|
|
|
|
|
@Autowired
|
|
|
- private RemoteMceService remoteMceService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private PmReceiveMapper pmReceiveMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private MceMbuserMapper mceMbuserMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private SysUserMapper sysUserMapper;
|
|
|
+ private DingTalkAndMessage dingTalkAndMessage;
|
|
|
|
|
|
/**
|
|
|
* 获取时间内工作报告
|
|
@@ -218,13 +192,17 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
|
|
|
*/
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public void addReport(PmWorkReport pmWorkReport) {
|
|
|
+ public void addReport(PmWorkReport pmWorkReport) throws ClientException {
|
|
|
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
|
|
String userName = SecurityUtils.getUsername();
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
Integer tenantId = SecurityUtils.getTenantId();
|
|
|
LocalDateTime dateTime = LocalDateTime.now();
|
|
|
BigDecimal totalWorkTime = BigDecimal.ZERO; //计算总工时
|
|
|
+ int minutesToAdd = 5;
|
|
|
+ LocalDateTime timingTime = pmWorkReport.getTimingTime();
|
|
|
+ LocalDateTime currentTimePlusMinutes = dateTime.plusMinutes(minutesToAdd);
|
|
|
+
|
|
|
if (pmWorkReport.getWorkContents() == null) {
|
|
|
throw new BusinessException("报告内容不能为空,请检查!");
|
|
|
}
|
|
@@ -266,6 +244,15 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
|
|
|
newReport.setTenantId(tenantId);
|
|
|
newReport.setTotalHours(totalWorkTime);
|
|
|
newReport.setSendDingTalk(pmWorkReport.getSendDingTalk());
|
|
|
+ if (pmWorkReport.getIsRegularlySend() != 0) {
|
|
|
+ if (timingTime != null && timingTime.isBefore(currentTimePlusMinutes)) {
|
|
|
+ newReport.setIsRegularlySend(pmWorkReport.getIsRegularlySend());
|
|
|
+ newReport.setTimingTime(timingTime);
|
|
|
+ newReport.setReportStatus(0);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("定时时间需大于五分钟!");
|
|
|
+ }
|
|
|
+ }
|
|
|
try {
|
|
|
pmWorkReportMapper.insert(newReport);
|
|
|
|
|
@@ -302,27 +289,17 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
|
|
|
newContent.setTenantId(tenantId);
|
|
|
pmWorkContentMapper.insert(newContent);
|
|
|
}
|
|
|
- //推送消息中心
|
|
|
- List<Long> ids = new ArrayList<>();
|
|
|
- if (!newReport.getCcTo().isEmpty()) {
|
|
|
- ids = Optional.ofNullable(newReport.getCcTo())
|
|
|
- .map(ccTo -> Arrays.stream(ccTo.split(","))
|
|
|
- .map(Long::parseLong)
|
|
|
- .collect(Collectors.toList()))
|
|
|
- .orElse(Collections.emptyList());
|
|
|
- }
|
|
|
- //sendAsyncMessage(newReport, ids);
|
|
|
- List<Long> finalIds = ids;
|
|
|
- CompletableFuture.runAsync(() -> {sendAsyncMessage(newReport, finalIds);});
|
|
|
- //存入消息接收表
|
|
|
- receiveMessages(ids, newReport.getId());
|
|
|
- //是否同步钉钉
|
|
|
- if (pmWorkReport.getSendDingTalk() == 1) {
|
|
|
- //sendDingTalkDailyReport(pmWorkReport);
|
|
|
- CompletableFuture.runAsync(() -> {
|
|
|
- sendDingTalkDailyReport(newReport, pmWorkReport.getWorkContents());
|
|
|
- });
|
|
|
+ //非定时发送
|
|
|
+ if (timingTime == null) {
|
|
|
+ //推送消息中心
|
|
|
+ dingTalkAndMessage.sendAsyncMessage(newReport);
|
|
|
+
|
|
|
+ //是否同步钉钉
|
|
|
+ if (pmWorkReport.getSendDingTalk() == 1) {
|
|
|
+ dingTalkAndMessage.sendDingTalkDailyReport(newReport, pmWorkReport.getWorkContents());
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
} else if (repeat.size() > 0) {
|
|
|
PmWorkReport rp = new PmWorkReport();
|
|
|
rp.setId(pmWorkReport.getId());
|
|
@@ -340,72 +317,34 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
|
|
|
rp.setUpdateBy(userName);
|
|
|
rp.setUpdateTime(dateTime);
|
|
|
rp.setTotalHours(totalWorkTime);
|
|
|
- pmWorkReportMapper.updateById(rp);
|
|
|
- LambdaQueryWrapper<PmWorkContent> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.select(PmWorkContent::getReportId, PmWorkContent::getSubmitterId, PmWorkContent::getCreateBy, PmWorkContent::getCreateTime, PmWorkContent::getDeptId, PmWorkContent::getTenantId)
|
|
|
- .eq(PmWorkContent::getReportId, pmWorkReport.getId())
|
|
|
- .last("LIMIT 1");
|
|
|
- PmWorkContent f = pmWorkContentMapper.selectOne(queryWrapper);
|
|
|
- pmWorkContentService.deleteContent(pmWorkReport.getId());
|
|
|
- List<PmWorkContent> contents = pmWorkReport.getWorkContents();
|
|
|
- for (PmWorkContent e : contents) {
|
|
|
- e.setReportId(f.getReportId());
|
|
|
- e.setUpdateBy(userName);
|
|
|
- e.setUpdateTime(dateTime);
|
|
|
- e.setSubmitterId(f.getSubmitterId());
|
|
|
- e.setCreateTime(f.getCreateTime());
|
|
|
- e.setCreateBy(f.getCreateBy());
|
|
|
- e.setDeptId(f.getDeptId());
|
|
|
- e.setTenantId(f.getTenantId());
|
|
|
- pmWorkContentMapper.insert(e);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void receiveMessages(List<Long> ids, Integer reportId) {
|
|
|
- List<SysUser> users = pmWorkContentService.nickNames(ids);
|
|
|
- if (ids.size() > 0) {
|
|
|
- for (Long id : ids) {
|
|
|
- PmReceive pmReceive = new PmReceive();
|
|
|
- pmReceive.setReceiverId(id);
|
|
|
- pmReceive.setReportId(reportId);
|
|
|
- pmReceive.setTenantId(SecurityUtils.getTenantId());
|
|
|
- pmReceive.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
|
|
|
- pmReceive.setCreateBy(SecurityUtils.getUsername());
|
|
|
- pmReceive.setCreateTime(LocalDateTime.now());
|
|
|
- for (SysUser user : users) {
|
|
|
- if (user.getUserId().equals(id)) {
|
|
|
- pmReceive.setReceiverName(user.getUserName());
|
|
|
- }
|
|
|
+ if (pmWorkReport.getIsRegularlySend() != 0) {
|
|
|
+ if (timingTime != null && timingTime.isBefore(currentTimePlusMinutes)) {
|
|
|
+ rp.setIsRegularlySend(pmWorkReport.getIsRegularlySend());
|
|
|
+ rp.setTimingTime(timingTime);
|
|
|
+ rp.setReportStatus(0);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("定时时间需大于五分钟!");
|
|
|
+ }
|
|
|
+ pmWorkReportMapper.updateById(rp);
|
|
|
+ LambdaQueryWrapper<PmWorkContent> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.select(PmWorkContent::getReportId, PmWorkContent::getSubmitterId, PmWorkContent::getCreateBy, PmWorkContent::getCreateTime, PmWorkContent::getDeptId, PmWorkContent::getTenantId)
|
|
|
+ .eq(PmWorkContent::getReportId, pmWorkReport.getId())
|
|
|
+ .last("LIMIT 1");
|
|
|
+ PmWorkContent f = pmWorkContentMapper.selectOne(queryWrapper);
|
|
|
+ pmWorkContentService.deleteContent(pmWorkReport.getId());
|
|
|
+ List<PmWorkContent> contents = pmWorkReport.getWorkContents();
|
|
|
+ for (PmWorkContent e : contents) {
|
|
|
+ e.setReportId(f.getReportId());
|
|
|
+ e.setUpdateBy(userName);
|
|
|
+ e.setUpdateTime(dateTime);
|
|
|
+ e.setSubmitterId(f.getSubmitterId());
|
|
|
+ e.setCreateTime(f.getCreateTime());
|
|
|
+ e.setCreateBy(f.getCreateBy());
|
|
|
+ e.setDeptId(f.getDeptId());
|
|
|
+ e.setTenantId(f.getTenantId());
|
|
|
+ pmWorkContentMapper.insert(e);
|
|
|
}
|
|
|
- pmReceive.setReadFlag(0);
|
|
|
- pmReceiveMapper.insert(pmReceive);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Async("asyncServiceExecutor")
|
|
|
- public void sendAsyncMessage(PmWorkReport newReport, List<Long> userId) {
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("infoTitle", INFO_TITLE);
|
|
|
- jsonObject.put("infoContent", SecurityUtils.getLoginUser().getSysUser().getNickName() + INFO_CONTENT);
|
|
|
- jsonObject.put("infoType", INFO_TYPE);
|
|
|
- jsonObject.put("id", newReport.getId());
|
|
|
- jsonObject.put("infoTypeName", INFO_TITLE);
|
|
|
- if (userId != null && !userId.isEmpty()) {
|
|
|
- jsonObject.put("userIds", userId);
|
|
|
- }
|
|
|
- // 推送消息中心
|
|
|
- try {
|
|
|
- ApiResult<Void> voidApiResult = remoteMceService.addMce(jsonObject.toString());
|
|
|
-
|
|
|
- if (voidApiResult.isSuccess()) {
|
|
|
- log.info("报告消息发送成功!");
|
|
|
- } else {
|
|
|
- log.error("报告消息发送失败!");
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("发送消息时发生异常", e);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -493,185 +432,38 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
|
|
|
return returnList;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 指定请求
|
|
|
- *
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public static com.aliyun.dingtalkoauth2_1_0.Client createClient() throws Exception {
|
|
|
- com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
|
|
|
- config.protocol = "https";
|
|
|
- config.regionId = "central";
|
|
|
- config.method = "POST";
|
|
|
- return new com.aliyun.dingtalkoauth2_1_0.Client(config);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取钉钉企业内部AccessToken
|
|
|
- *
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public String getDingTalkToken() {
|
|
|
- GetAccessTokenResponse responseBody = new GetAccessTokenResponse();
|
|
|
- com.aliyun.dingtalkoauth2_1_0.Client client = null;
|
|
|
- try {
|
|
|
- client = createClient();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest getAccessTokenRequest = new com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest()
|
|
|
- .setAppKey(dingTalkConstant.DING_TALK_CLIENT_ID)
|
|
|
- .setAppSecret(dingTalkConstant.DING_TALK_CLIENT_SECRET);
|
|
|
- try {
|
|
|
- responseBody = client.getAccessToken(getAccessTokenRequest);
|
|
|
- } catch (TeaException err) {
|
|
|
- if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
- // err 中含有 code 和 message 属性,可帮助开发定位问题
|
|
|
- }
|
|
|
- } catch (Exception _err) {
|
|
|
- TeaException err = new TeaException(_err.getMessage(), _err);
|
|
|
- if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
- // err 中含有 code 和 message 属性,可帮助开发定位问题
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void timedSending(LocalDateTime time) {
|
|
|
+ LambdaQueryWrapper<PmWorkReport> reports = Wrappers.lambdaQuery();
|
|
|
+ reports.eq(PmWorkReport::getIsRegularlySend, 1)
|
|
|
+ .eq(PmWorkReport::getReportStatus, 0)
|
|
|
+ .le(PmWorkReport::getTimingTime, time)
|
|
|
+ .orderByAsc(PmWorkReport::getTimingTime);
|
|
|
+ List<PmWorkReport> reportList = pmWorkReportMapper.selectList(reports);
|
|
|
+ if (!reportList.isEmpty()) {
|
|
|
+ List<Integer> reportIds = new ArrayList<>();
|
|
|
+ for (PmWorkReport report : reportList) {
|
|
|
+ reportIds.add(report.getId());
|
|
|
}
|
|
|
- }
|
|
|
- return responseBody.getBody().accessToken;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取钉钉userId
|
|
|
- *
|
|
|
- * @param userId 平台userid
|
|
|
- * @return
|
|
|
- */
|
|
|
- public String getDingTalkUserId(Long userId) {
|
|
|
- String dingTalkId = "";
|
|
|
- LambdaQueryWrapper<MceMbuser> dingTalkQuery = Wrappers.lambdaQuery();
|
|
|
- dingTalkQuery.select(MceMbuser::getDingTalkId, MceMbuser::getUserId)
|
|
|
- .eq(MceMbuser::getUserId, userId);
|
|
|
- MceMbuser mceMbuser = mceMbuserMapper.selectOne(dingTalkQuery);
|
|
|
- if (mceMbuser != null) {
|
|
|
- String dingId = mceMbuser.getDingTalkId();
|
|
|
- if (dingId != null && dingId != "") {
|
|
|
- return mceMbuser.getDingTalkId();
|
|
|
+ LambdaQueryWrapper<PmWorkContent> reportContents = Wrappers.lambdaQuery();
|
|
|
+ reportContents.in(PmWorkContent::getReportId, reportIds);
|
|
|
+ List<PmWorkContent> pmWorkContentList = pmWorkContentMapper.selectList(reportContents);
|
|
|
+ for (PmWorkReport report : reportList) {
|
|
|
+ Integer id = report.getId();
|
|
|
+ List<PmWorkContent> workContents = new ArrayList<>();
|
|
|
+ for (PmWorkContent content : pmWorkContentList) {
|
|
|
+ Integer reportId = content.getReportId();
|
|
|
+ if (reportId == id) {
|
|
|
+ workContents.add(content);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dingTalkAndMessage.sendDingTalkDailyReport(report, workContents);
|
|
|
+ dingTalkAndMessage.sendAsyncMessage(report);
|
|
|
}
|
|
|
}
|
|
|
- LambdaQueryWrapper<SysUser> phoneQuery = Wrappers.lambdaQuery();
|
|
|
- phoneQuery.select(SysUser::getPhonenumber, SysUser::getUserName)
|
|
|
- .eq(SysUser::getUserId, userId);
|
|
|
- SysUser user = sysUserMapper.selectOne(phoneQuery);
|
|
|
- String mobile = user.getPhonenumber();
|
|
|
- try {
|
|
|
- String accessToken = getDingTalkToken();
|
|
|
- DingTalkClient client = new DefaultDingTalkClient(dingTalkConstant.DING_TALK_USERID_URL);
|
|
|
- OapiV2UserGetbymobileRequest req = new OapiV2UserGetbymobileRequest();
|
|
|
- req.setMobile(mobile);
|
|
|
- OapiV2UserGetbymobileResponse rsp = client.execute(req, accessToken);
|
|
|
- ObjectMapper objectMapper = new ObjectMapper();
|
|
|
- JsonNode rootNode = objectMapper.readTree(rsp.getBody());
|
|
|
- JsonNode resultNode = rootNode.get("result");
|
|
|
- dingTalkId = resultNode.get("userid").asText();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- if (mceMbuser != null) {
|
|
|
- mceMbuser.setDingTalkId(dingTalkId);
|
|
|
- mceMbuser.setUpdateBy(SecurityUtils.getUsername());
|
|
|
- mceMbuser.setUpdateTime(LocalDateTime.now());
|
|
|
- mceMbuserMapper.update(mceMbuser, dingTalkQuery);
|
|
|
- } else {
|
|
|
- MceMbuser mbuser = new MceMbuser();
|
|
|
- mbuser.setDingTalkId(dingTalkId);
|
|
|
- mbuser.setPhone(mobile);
|
|
|
- mbuser.setUserId(userId);
|
|
|
- mbuser.setCreateBy(user.getUserName());
|
|
|
- mbuser.setCreateTime(LocalDateTime.now());
|
|
|
- mceMbuserMapper.insert(mbuser);
|
|
|
- }
|
|
|
- return dingTalkId;
|
|
|
- }
|
|
|
|
|
|
- @Async("asyncServiceExecutor")//异步发送
|
|
|
- @Override
|
|
|
- public void sendDingTalkDailyReport(PmWorkReport workReport, List<PmWorkContent> workContents) {
|
|
|
- String ccToStr = workReport.getCcTo();
|
|
|
- String[] items = ccToStr.split(",");
|
|
|
- List<Long> userIds = new ArrayList<>();
|
|
|
- for (String item : items) {
|
|
|
- long number = Long.parseLong(item.trim());
|
|
|
- userIds.add(number);
|
|
|
- }
|
|
|
- List<String> ccTo = new ArrayList<>();
|
|
|
- for (Long userId : userIds) {
|
|
|
- String dingTalkUserId = getDingTalkUserId(userId);
|
|
|
- ccTo.add(dingTalkUserId);
|
|
|
- }
|
|
|
- String reportCoordinateWork = workReport.getCoordinateWork();
|
|
|
- String reportTomorrowPlan = workReport.getTomorrowPlan();
|
|
|
- String coordinateWork1 = "-";
|
|
|
- String tomorrowPlan1 = "-";
|
|
|
- if (reportCoordinateWork != null && reportCoordinateWork != "") {
|
|
|
- coordinateWork1 = reportCoordinateWork;
|
|
|
- }
|
|
|
- if (reportTomorrowPlan != null && reportTomorrowPlan != "") {
|
|
|
- tomorrowPlan1 = reportTomorrowPlan;
|
|
|
- }
|
|
|
|
|
|
- StringBuilder contentBuilder = new StringBuilder();
|
|
|
- for (PmWorkContent content : workContents) {
|
|
|
- String projectName = content.getProjectName();
|
|
|
- BigDecimal workTime = content.getWorkTime();
|
|
|
- String workContent = content.getWorkContent();
|
|
|
- StringBuilder markdown = new StringBuilder();
|
|
|
- markdown.append("#### ").append(projectName).append(" ").append(workTime).append("h\n\n");
|
|
|
- markdown.append("<span style=\"font-size: 18px;\">").append(workContent).append("\n").append("</span>");
|
|
|
- contentBuilder.append(markdown);
|
|
|
- }
|
|
|
- String completedWork = contentBuilder.toString();
|
|
|
- try {
|
|
|
- DingTalkClient client = new DefaultDingTalkClient(dingTalkConstant.DING_TALK_CREATE_DAILY_REPORT_URL);
|
|
|
- OapiReportCreateRequest req = new OapiReportCreateRequest();
|
|
|
- OapiReportCreateRequest.OapiCreateReportParam obj1 = new OapiReportCreateRequest.OapiCreateReportParam();
|
|
|
- List<OapiReportCreateRequest.OapiReportContentVo> list3 = new ArrayList<>();
|
|
|
- OapiReportCreateRequest.OapiReportContentVo completedWorkD = new OapiReportCreateRequest.OapiReportContentVo();
|
|
|
- completedWorkD.setSort(0L);
|
|
|
- completedWorkD.setType(1L);
|
|
|
- completedWorkD.setContentType(dingTalkConstant.DING_TALK_DAILY_REPORT_CONTENT_TYPE);
|
|
|
- completedWorkD.setContent(completedWork);
|
|
|
- completedWorkD.setKey(dingTalkConstant.DING_TALK_DAILY_REPORT_COMPLETED_WORK);
|
|
|
- list3.add(completedWorkD);
|
|
|
- OapiReportCreateRequest.OapiReportContentVo tomorrowPlan = new OapiReportCreateRequest.OapiReportContentVo();
|
|
|
- tomorrowPlan.setSort(1L);
|
|
|
- tomorrowPlan.setType(1L);
|
|
|
- tomorrowPlan.setContentType(dingTalkConstant.DING_TALK_DAILY_REPORT_CONTENT_TYPE);
|
|
|
- tomorrowPlan.setContent(tomorrowPlan1);
|
|
|
- tomorrowPlan.setKey(dingTalkConstant.DING_TALK_DAILY_REPORT_TOMORROW_PLAN);
|
|
|
- list3.add(tomorrowPlan);
|
|
|
- OapiReportCreateRequest.OapiReportContentVo coordinateWork = new OapiReportCreateRequest.OapiReportContentVo();
|
|
|
- coordinateWork.setSort(2L);
|
|
|
- coordinateWork.setType(1L);
|
|
|
- coordinateWork.setContentType(dingTalkConstant.DING_TALK_DAILY_REPORT_CONTENT_TYPE);
|
|
|
- coordinateWork.setContent(coordinateWork1);
|
|
|
- coordinateWork.setKey(dingTalkConstant.DING_TALK_DAILY_REPORT_COORDINATE_WORK);
|
|
|
- list3.add(coordinateWork);
|
|
|
- obj1.setContents(list3);
|
|
|
- obj1.setToUserids(ccTo);
|
|
|
- obj1.setTemplateId(dingTalkConstant.DING_TALK_DAILY_REPORT_TEMPLATE_ID);
|
|
|
- obj1.setToChat(dingTalkConstant.DING_TALK_DAILY_REPORT_TO_CHAT);
|
|
|
- obj1.setDdFrom(dingTalkConstant.DING_TALK_CORP_ID);
|
|
|
- obj1.setUserid(getDingTalkUserId(SecurityUtils.getUserId()));
|
|
|
- //obj1.setToCids(dingTalkConstant.DING_TALK_DAILY_REPORT_TO_CIDS);//发送到群,群id
|
|
|
- req.setCreateReportParam(obj1);
|
|
|
- OapiReportCreateResponse rsp = client.execute(req, getDingTalkToken());
|
|
|
- if (rsp.isSuccess()) {
|
|
|
- log.info("钉钉报告发送成功");
|
|
|
- } else {
|
|
|
- log.error("钉钉报告发送失败: " + rsp.getErrmsg());
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
|