|
|
|
@ -2,9 +2,14 @@ package cn.iocoder.yudao.module.system.service.taskinfo;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
|
|
|
|
import cn.iocoder.yudao.framework.common.util.date.DateUtils; |
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
|
|
|
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; |
|
|
|
|
import cn.iocoder.yudao.module.infra.api.job.JobApi; |
|
|
|
|
import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; |
|
|
|
|
import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; |
|
|
|
|
import cn.iocoder.yudao.module.system.api.social.SocialClientApi; |
|
|
|
|
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO; |
|
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.RoleNameAndSelectTypeVO; |
|
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo.EnterpriseInspectionsPageReqVO; |
|
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.tasktag.vo.TaskTagPageReqVO; |
|
|
|
@ -75,6 +80,12 @@ public class TaskInfoServiceImpl implements TaskInfoService {
|
|
|
|
|
@Resource |
|
|
|
|
private TagLibraryService tagLibraryService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
SocialClientApi socialClientApi; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
NotifyMessageSendApi notifyMessageSendApi; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public Long createTaskInfo(TaskInfoSaveReqVO createReqVO) { |
|
|
|
@ -296,9 +307,67 @@ public class TaskInfoServiceImpl implements TaskInfoService {
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询列表
|
|
|
|
|
// 查询列表
|
|
|
|
|
return new PageResult<>(taskInfoDOIPage.getRecords(), taskInfoDOIPage.getTotal()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public void taskExec(TaskInfoSaveReqVO updateReqVO) { |
|
|
|
|
Long taskId = updateReqVO.getId(); |
|
|
|
|
final TaskInfoDO taskInfoDO = taskInfoMapper.selectById(taskId); |
|
|
|
|
if (taskInfoDO == null) { |
|
|
|
|
throw exception(TASK_INFO_NOT_EXISTS); |
|
|
|
|
} |
|
|
|
|
taskInfoDO.setStatus(2); |
|
|
|
|
taskInfoMapper.updateById(taskInfoDO); |
|
|
|
|
|
|
|
|
|
//执法任务更改状态
|
|
|
|
|
LambdaQueryWrapper<EnterpriseInspectionsDO> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
wrapper.eq(EnterpriseInspectionsDO::getTaskId, taskInfoDO.getId()); |
|
|
|
|
List<EnterpriseInspectionsDO> enterpriseInspectionsDOList = enterpriseInspectionsMapper.selectList(wrapper); |
|
|
|
|
if(enterpriseInspectionsDOList!=null && enterpriseInspectionsDOList.size() > 0) { |
|
|
|
|
List<EnterpriseInspectionsDO> list = new ArrayList<>(); |
|
|
|
|
for (EnterpriseInspectionsDO enterpriseInspectionsDO : enterpriseInspectionsDOList) { |
|
|
|
|
//小程序订阅
|
|
|
|
|
try { |
|
|
|
|
//发送消息);
|
|
|
|
|
SocialWxaSubscribeMessageSendReqDTO reqDTO = new SocialWxaSubscribeMessageSendReqDTO(); |
|
|
|
|
reqDTO.setUserType(1); |
|
|
|
|
reqDTO.setTemplateTitle("环保任务通知"); |
|
|
|
|
reqDTO.setPage("sub/task/detail?id="+taskInfoDO.getId()); |
|
|
|
|
reqDTO.setUserId(enterpriseInspectionsDO.getUserId()); |
|
|
|
|
Map<String, String> message = new HashMap<>(); |
|
|
|
|
message.put("thing2", taskInfoDO.getTitle()); |
|
|
|
|
message.put("time3", DateUtil.format(taskInfoDO.getStartDate(), DateUtils.FORMAT_YEAR_MONTH_DAY)); |
|
|
|
|
message.put("thing4", taskInfoDO.getDescription()); |
|
|
|
|
message.put("time5", DateUtil.format(taskInfoDO.getEndDate(), DateUtils.FORMAT_YEAR_MONTH_DAY)); |
|
|
|
|
reqDTO.setMessages(message); |
|
|
|
|
socialClientApi.sendWxaSubscribeMessage(reqDTO); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
catch (Exception e){ |
|
|
|
|
log.error("任务发送通知错误:",e.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//站内信发送通知
|
|
|
|
|
NotifySendSingleToUserReqDTO notifyMessage = new NotifySendSingleToUserReqDTO(); |
|
|
|
|
notifyMessage.setUserId(Long.valueOf(enterpriseInspectionsDO.getUserId())); |
|
|
|
|
notifyMessage.setTemplateCode("task_messages"); |
|
|
|
|
Map<String, Object> templateParams = new HashMap<>(); |
|
|
|
|
templateParams.put("title", taskInfoDO.getTitle()); |
|
|
|
|
templateParams.put("startTime", DateUtil.format(taskInfoDO.getStartDate(), DateUtils.FORMAT_YEAR_MONTH_DAY)); |
|
|
|
|
templateParams.put("endTime", DateUtil.format(taskInfoDO.getEndDate(), DateUtils.FORMAT_YEAR_MONTH_DAY) ); |
|
|
|
|
templateParams.put("url", "sub/task/detail?taskId="+ enterpriseInspectionsDO.getTaskId()); |
|
|
|
|
|
|
|
|
|
notifyMessage.setTemplateParams(templateParams); |
|
|
|
|
notifyMessageSendApi.sendSingleMessageToMember(notifyMessage); |
|
|
|
|
|
|
|
|
|
enterpriseInspectionsDO.setStatus(2); |
|
|
|
|
list.add(enterpriseInspectionsDO); |
|
|
|
|
} |
|
|
|
|
enterpriseInspectionsMapper.updateBatch(list); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|