|
|
@ -1,22 +1,33 @@ |
|
|
|
package org.dromara.business.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import org.apache.dubbo.config.annotation.DubboReference; |
|
|
|
import org.dromara.business.domain.BusinessAlert; |
|
|
|
import org.dromara.business.domain.bo.BusinessAlertBo; |
|
|
|
import org.dromara.business.domain.vo.BusinessAlertVo; |
|
|
|
import org.dromara.business.mapper.BusinessAlertMapper; |
|
|
|
import org.dromara.business.service.BusinessAlertService; |
|
|
|
import org.dromara.common.core.enums.BusinessStatusEnum; |
|
|
|
import org.dromara.common.core.exception.ServiceException; |
|
|
|
import org.dromara.common.core.utils.MapstructUtils; |
|
|
|
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.system.api.domain.vo.RemoteUserVo; |
|
|
|
import org.dromara.workflow.api.RemoteWorkflowService; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
* 预警任务Service业务层处理 |
|
|
@ -30,43 +41,8 @@ public class BusinessAlertServiceImpl implements BusinessAlertService { |
|
|
|
|
|
|
|
private final BusinessAlertMapper baseMapper; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询预警任务 |
|
|
|
* |
|
|
|
* @param id 主键 |
|
|
|
* @return 预警任务 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public BusinessAlertVo getBusinessAlert(String id){ |
|
|
|
return baseMapper.selectVoById(id); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 分页查询预警任务列表 |
|
|
|
* |
|
|
|
* @param param 查询条件 |
|
|
|
* @param pageQuery 分页参数 |
|
|
|
* @return 预警任务分页列表 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public TableDataInfo<BusinessAlertVo> pageBusinessAlert(BusinessAlertBo param, PageQuery pageQuery) { |
|
|
|
LambdaQueryWrapper<BusinessAlert> lqw = buildQueryWrapper(param); |
|
|
|
Page<BusinessAlertVo> result = baseMapper.pageAlert(pageQuery.build(), lqw); |
|
|
|
return TableDataInfo.build(result); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 查询符合条件的预警任务列表 |
|
|
|
* |
|
|
|
* @param param 查询条件 |
|
|
|
* @return 预警任务列表 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<BusinessAlertVo> listBusinessAlert(BusinessAlertBo param) { |
|
|
|
LambdaQueryWrapper<BusinessAlert> lqw = buildQueryWrapper(param); |
|
|
|
return baseMapper.selectVoList(lqw); |
|
|
|
} |
|
|
|
@DubboReference |
|
|
|
RemoteWorkflowService remoteWorkflowService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
@ -105,14 +81,6 @@ public class BusinessAlertServiceImpl implements BusinessAlertService { |
|
|
|
return baseMapper.updateById(businessAlert) > 0; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 保存前的数据校验 |
|
|
|
*/ |
|
|
|
private void validEntityBeforeSave(BusinessAlert alert, Boolean validId){ |
|
|
|
if (ObjectUtil.isEmpty(alert.getId())){ |
|
|
|
throw new ServiceException("预警【Id】为空!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 校验并批量删除预警任务信息 |
|
|
@ -131,11 +99,119 @@ public class BusinessAlertServiceImpl implements BusinessAlertService { |
|
|
|
return baseMapper.deleteByIds(alertIdList) > 0; |
|
|
|
} |
|
|
|
|
|
|
|
private LambdaQueryWrapper<BusinessAlert> buildQueryWrapper(BusinessAlertBo bo) { |
|
|
|
LambdaQueryWrapper<BusinessAlert> wrapper = Wrappers.lambdaQuery(); |
|
|
|
/** |
|
|
|
* 修改预警中处置状态 |
|
|
|
* @param businessId |
|
|
|
* @param flowStatus |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void updateAlertStatus(String businessId, String flowStatus) { |
|
|
|
LambdaUpdateWrapper<BusinessAlert> wrapper = new LambdaUpdateWrapper<>(); |
|
|
|
wrapper.set(BusinessAlert::getHandleType, BusinessStatusEnum.getByStatus(flowStatus)); |
|
|
|
|
|
|
|
wrapper.eq(BusinessAlert::getId, businessId); |
|
|
|
|
|
|
|
this.baseMapper.update(wrapper); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 查询全部预警 |
|
|
|
* @param bo |
|
|
|
* @param pageQuery |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public TableDataInfo<BusinessAlert> pageBusinessAlert(BusinessAlertBo bo, PageQuery pageQuery) { |
|
|
|
QueryWrapper<BusinessAlert> wrapper = buildQueryWrapper(bo); |
|
|
|
|
|
|
|
wrapper.orderByAsc(BusinessAlert::getCreateTime); |
|
|
|
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlert(pageQuery.build(), wrapper); |
|
|
|
|
|
|
|
return TableDataInfo.build(page); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询当前用户已完成预警 |
|
|
|
* @param bo |
|
|
|
* @param pageQuery |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public TableDataInfo<BusinessAlert> pageBusinessAlertFinish(BusinessAlertBo bo, PageQuery pageQuery) { |
|
|
|
QueryWrapper<BusinessAlert> wrapper = buildQueryWrapper(bo); |
|
|
|
buildCommonQueryWrapper(wrapper); |
|
|
|
|
|
|
|
wrapper.in("a.approver", LoginHelper.getUserId()); |
|
|
|
Page<BusinessAlert> page = this.baseMapper.pageAlertFinish(pageQuery.build(), wrapper); |
|
|
|
|
|
|
|
return TableDataInfo.build(page); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 查询当前用户待办预警 |
|
|
|
* @param bo |
|
|
|
* @param pageQuery |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public TableDataInfo<BusinessAlert> pageBusinessAlertTodo(BusinessAlertBo bo, PageQuery pageQuery) { |
|
|
|
QueryWrapper<BusinessAlert> wrapper = buildQueryWrapper(bo); |
|
|
|
buildCommonQueryWrapper(wrapper); |
|
|
|
|
|
|
|
wrapper.eq("uu.del_flag", 0); |
|
|
|
wrapper.in("uu.type", 1,2,3); |
|
|
|
|
|
|
|
wrapper.in("a.processed_by", remoteWorkflowService.getPermissions()); |
|
|
|
wrapper.in("a.flow_status", BusinessStatusEnum.WAITING.getStatus()); |
|
|
|
|
|
|
|
Page<BusinessAlert> page = this.baseMapper.pageAlertTodo(pageQuery.build(), wrapper); |
|
|
|
List<BusinessAlert> records = page.getRecords(); |
|
|
|
if (CollUtil.isNotEmpty(records)) { |
|
|
|
List<Long> taskIds = StreamUtils.toList(records, BusinessAlert::getFlowTaskId); |
|
|
|
Map<Long, List<RemoteUserVo>> listMap = remoteWorkflowService.currentTaskAllUser(taskIds); |
|
|
|
records.forEach(t -> { |
|
|
|
List<RemoteUserVo> userList = listMap.getOrDefault(t.getId(), Collections.emptyList()); |
|
|
|
if (CollUtil.isNotEmpty(userList)) { |
|
|
|
t.setApprover(StreamUtils.join(userList, e -> String.valueOf(e.getUserId()))); |
|
|
|
t.setApproveName(StreamUtils.join(userList, RemoteUserVo::getNickName)); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
return TableDataInfo.build(page); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 构建wrapper |
|
|
|
* @param bo |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private QueryWrapper<BusinessAlert> buildQueryWrapper(BusinessAlertBo bo) { |
|
|
|
QueryWrapper<BusinessAlert> wrapper = new QueryWrapper<>(); |
|
|
|
|
|
|
|
wrapper.orderByAsc("ba.create_time"); |
|
|
|
return wrapper; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 构建通用流程wrapper |
|
|
|
* @param wrapper |
|
|
|
*/ |
|
|
|
private void buildCommonQueryWrapper(QueryWrapper<BusinessAlert> wrapper) { |
|
|
|
wrapper.eq("a.del_flag",0); |
|
|
|
wrapper.eq("b.del_flag",0); |
|
|
|
wrapper.eq("c.del_flag",0); |
|
|
|
wrapper.in("a.node_type",1,3,4); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 保存前的数据校验 |
|
|
|
*/ |
|
|
|
private void validEntityBeforeSave(BusinessAlert alert, Boolean validId){ |
|
|
|
if (ObjectUtil.isEmpty(alert.getId())){ |
|
|
|
throw new ServiceException("预警【Id】为空!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|