|
|
@ -3,6 +3,7 @@ package org.dromara.business.service.impl; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.collection.ListUtil; |
|
|
|
import cn.hutool.core.convert.Convert; |
|
|
|
import cn.hutool.core.util.NumberUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
@ -19,6 +20,7 @@ import jakarta.servlet.http.HttpServletResponse; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.dubbo.config.annotation.DubboReference; |
|
|
|
import org.apache.dubbo.config.annotation.DubboService; |
|
|
|
import org.dromara.business.api.domain.bo.RemoteBusinessAlertBo; |
|
|
|
import org.dromara.business.api.domain.vo.RemoteBusinessAlertConstructInfo; |
|
|
|
import org.dromara.business.api.domain.vo.RemoteBusinessAlertVo; |
|
|
@ -43,11 +45,14 @@ import org.dromara.common.core.utils.StreamUtils; |
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery; |
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|
|
|
import org.dromara.common.satoken.utils.LoginHelper; |
|
|
|
import org.dromara.resource.api.RemoteMessageService; |
|
|
|
import org.dromara.system.api.RemoteLabelPostService; |
|
|
|
import org.dromara.system.api.RemoteSubmailConfigService; |
|
|
|
import org.dromara.system.api.RemoteUserService; |
|
|
|
import org.dromara.system.api.domain.vo.RemoteAiLabelPostVo; |
|
|
|
import org.dromara.system.api.domain.vo.RemoteUserVo; |
|
|
|
import org.dromara.business.domain.BusinessAlertConstructInfoOss; |
|
|
|
import org.dromara.business.mapper.BusinessAlertConstructInfoOssMapper; |
|
|
|
import org.dromara.workflow.api.RemoteWorkflowService; |
|
|
|
import org.dromara.workflow.api.domain.RemoteStartProcess; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
@ -67,6 +72,7 @@ import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@ -85,6 +91,7 @@ import java.util.Base64; |
|
|
|
@RequiredArgsConstructor |
|
|
|
@Service |
|
|
|
@Slf4j |
|
|
|
@DubboService |
|
|
|
public class BusinessAlertServiceImpl implements IBusinessAlertService { |
|
|
|
|
|
|
|
private final BusinessAlertMapper baseMapper; |
|
|
@ -94,6 +101,9 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { |
|
|
|
@Autowired |
|
|
|
private BusinessAlertConstructInfoMapper businessAlertConstructInfoMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private BusinessAlertConstructInfoOssMapper businessAlertConstructInfoOssMapper; |
|
|
|
|
|
|
|
@DubboReference(timeout = 30000) |
|
|
|
RemoteWorkflowService remoteWorkflowService; |
|
|
|
|
|
|
@ -109,6 +119,9 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { |
|
|
|
@Autowired |
|
|
|
FeignDeviceGroup feignDeviceGroup; |
|
|
|
|
|
|
|
@DubboReference |
|
|
|
private final RemoteMessageService remoteMessageService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 新增预警任务 |
|
|
|
* |
|
|
@ -197,6 +210,25 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { |
|
|
|
map.put("jobName",alert.getJobName()); |
|
|
|
noticeList.add(map); |
|
|
|
remoteStartProcessList.add(startProcess); |
|
|
|
|
|
|
|
//推送消息-基于部门-找用户 发送json格式
|
|
|
|
ArrayList<Long> deptIds = new ArrayList<>(); |
|
|
|
deptIds.add(Long.parseLong(alert.getDeptId())); |
|
|
|
List<RemoteUserVo> remoteUserVos = remoteUserService.selectUsersByDeptIds(deptIds); |
|
|
|
List<Long> userIds = remoteUserVos.stream().map(RemoteUserVo::getUserId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
String imagePreviewUrl = MinioUntil.getObjectUrlOne(MinIOConstants.BUCKET_DKCY, alertVo.getImages(), 3600).toString(); |
|
|
|
jsonObject.put("deptId", alert.getDeptId()); |
|
|
|
jsonObject.put("deptName", alert.getDeptName()); |
|
|
|
jsonObject.put("images", imagePreviewUrl); |
|
|
|
jsonObject.put("labelCn", alert.getLabelCn()); |
|
|
|
jsonObject.put("lat", alert.getLat()); |
|
|
|
jsonObject.put("lng", alert.getLng()); |
|
|
|
jsonObject.put("createTime", ObjectUtil.isNotEmpty(alert.getCreateTime()) ? alert.getCreateTime() : new Date()); |
|
|
|
jsonObject.put("jobName", alert.getJobName()); |
|
|
|
remoteMessageService.publishMessage(userIds, jsonObject.toString() ); |
|
|
|
System.out.println("已发送:"+ "预警内容:"+ jsonObject.toString()); |
|
|
|
} |
|
|
|
|
|
|
|
int startIndex = 0; // 从第 0 条开始
|
|
|
@ -207,6 +239,14 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { |
|
|
|
}); |
|
|
|
remoteSubmailConfigService.remoteSend("smsMultixsend",noticeList); |
|
|
|
|
|
|
|
//推送消息-基于部门-找用户-批量
|
|
|
|
// List<String> deptStrIds = alertVoList.stream().map(BusinessAlertVo::getDeptId).distinct().collect(Collectors.toList());
|
|
|
|
// List<Long> deptIds = deptStrIds.stream().map(Long::parseLong).collect(Collectors.toList());
|
|
|
|
// List<RemoteUserVo> remoteUserVos = remoteUserService.selectUsersByDeptIds(deptIds);
|
|
|
|
// List<Long> userIds = remoteUserVos.stream().map(RemoteUserVo::getUserId).collect(Collectors.toList());
|
|
|
|
//
|
|
|
|
// remoteMessageService.publishMessage(userIds, "预警");
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -534,9 +574,23 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { |
|
|
|
LambdaQueryWrapper<BusinessAlertConstructInfo> qw = new LambdaQueryWrapper<BusinessAlertConstructInfo>(); |
|
|
|
qw.in(BusinessAlertConstructInfo::getBusinessAlertId, alertIds); |
|
|
|
List<BusinessAlertConstructInfoVo> constructInfoVoList = businessAlertConstructInfoMapper.selectVoList(qw,BusinessAlertConstructInfoVo.class); |
|
|
|
List<Long> constructInfoIds = constructInfoVoList.stream().map(BusinessAlertConstructInfoVo::getId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
List<BusinessAlertConstructInfoOss> alertConstructInfoOssList = new ArrayList<>(); |
|
|
|
if(!constructInfoIds.isEmpty()){ |
|
|
|
LambdaQueryWrapper<BusinessAlertConstructInfoOss> alertConstructOssQw = new LambdaQueryWrapper<>(); |
|
|
|
alertConstructOssQw.in(BusinessAlertConstructInfoOss::getAlertConstructInfoId,constructInfoIds); |
|
|
|
alertConstructInfoOssList = businessAlertConstructInfoOssMapper.selectVoList(alertConstructOssQw, BusinessAlertConstructInfoOss.class); |
|
|
|
} |
|
|
|
|
|
|
|
for (BusinessAlert record : page.getRecords()) { |
|
|
|
BusinessAlertConstructInfoVo businessAlertConstructInfoVo = constructInfoVoList.stream().filter(item -> item.getBusinessAlertId().equals(record.getId())).findFirst().orElse(null); |
|
|
|
if(ObjectUtil.isNotNull(businessAlertConstructInfoVo)){ |
|
|
|
List<BusinessAlertConstructInfoOss> constructInfoOssList = alertConstructInfoOssList.stream().filter(item -> item.getAlertConstructInfoId().equals(businessAlertConstructInfoVo.getId())).collect(Collectors.toList()); |
|
|
|
businessAlertConstructInfoVo.setAlertConstructInfoOssList(constructInfoOssList); |
|
|
|
} |
|
|
|
record.setAlertConstructInfoVo(businessAlertConstructInfoVo); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|