|
|
@ -29,7 +29,6 @@ import com.baiye.system.service.SysUserService;
|
|
|
|
import com.baiye.utils.AssignDataUtil;
|
|
|
|
import com.baiye.utils.AssignDataUtil;
|
|
|
|
import com.baiye.utils.DateTimeToCronUtils;
|
|
|
|
import com.baiye.utils.DateTimeToCronUtils;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
|
|
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
|
|
|
import com.example.entity.Job;
|
|
|
|
import com.example.entity.Job;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
@ -125,26 +124,16 @@ public class DistributeTaskServiceImpl extends ExtendServiceImpl<DistributeTaskM
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 2、修改自动任务信息
|
|
|
|
// 2、修改自动任务信息
|
|
|
|
if (distributeTaskType != null && distributeTaskType == 1) {
|
|
|
|
if (distributeTaskType != null && distributeTaskType == 1 && taskEntity.getDistributeTaskType() == 1) {
|
|
|
|
if (!distributeTaskType.equals(taskEntity.getDistributeTaskType())) {
|
|
|
|
|
|
|
|
// 添加定时任务
|
|
|
|
|
|
|
|
this.addJob(taskId, taskEntity.getStartTime(), true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
Integer timeStatus = taskEntity.getTimeStatus();
|
|
|
|
Integer timeStatus = taskEntity.getTimeStatus();
|
|
|
|
LocalDateTime time = taskEntity.getStartTime();
|
|
|
|
LocalDateTime time = taskEntity.getStartTime();
|
|
|
|
if (status == 1 && timeStatus == 0) {
|
|
|
|
|
|
|
|
// 添加定时任务
|
|
|
|
|
|
|
|
this.addJob(taskId, taskEntity.getStartTime(), true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (timeStatus == 1 && status == 0) {
|
|
|
|
if (timeStatus == 1 && status == 0) {
|
|
|
|
// 删除定时任务
|
|
|
|
// 删除定时任务
|
|
|
|
jobService.removeJob(PrefixKeyConstant.JOB_KEY + taskId);
|
|
|
|
jobService.removeJob(PrefixKeyConstant.JOB_KEY + taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (timeStatus == 1 && startTime != null && time != null && !startTime.isEqual(time)) {
|
|
|
|
if (timeStatus == 1 && status == 1 && startTime != null && time != null && !startTime.isEqual(time)) {
|
|
|
|
// 修改定时任务
|
|
|
|
// 修改定时任务
|
|
|
|
this.addJob(taskId, time, false);
|
|
|
|
this.addJob(taskId, startTime, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (executeStatus != null && executeStatus == 3 && !executeStatus.equals(taskEntity.getExecuteStatus())) {
|
|
|
|
if (executeStatus != null && executeStatus == 3 && !executeStatus.equals(taskEntity.getExecuteStatus())) {
|
|
|
@ -193,21 +182,20 @@ public class DistributeTaskServiceImpl extends ExtendServiceImpl<DistributeTaskM
|
|
|
|
updateEntity.setDistributeTaskId(taskId);
|
|
|
|
updateEntity.setDistributeTaskId(taskId);
|
|
|
|
|
|
|
|
|
|
|
|
if (taskEntity != null) {
|
|
|
|
if (taskEntity != null) {
|
|
|
|
// 执行手动任务
|
|
|
|
// 执行手动任务(立即执行分发)
|
|
|
|
Integer timeStatus = taskEntity.getTimeStatus();
|
|
|
|
Integer timeStatus = taskEntity.getTimeStatus();
|
|
|
|
if (taskEntity.getDistributeTaskType() == 0 || (timeStatus != null && timeStatus == 0)) {
|
|
|
|
if (taskEntity.getDistributeTaskType() == 0 || (timeStatus != null && timeStatus == 0)) {
|
|
|
|
this.execute(taskEntity);
|
|
|
|
this.execute(taskEntity);
|
|
|
|
updateEntity.setExecuteStatus(2);
|
|
|
|
updateEntity.setExecuteStatus(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 执行自动任务
|
|
|
|
// 执行自动任务(对定时任务进行修改)
|
|
|
|
if (taskEntity.getDistributeTaskType() == 1 && timeStatus != null && timeStatus == 1) {
|
|
|
|
if (taskEntity.getDistributeTaskType() == 1 && timeStatus != null && timeStatus == 1) {
|
|
|
|
// 添加定时任务
|
|
|
|
Job jobDetail = jobService.getJobDetail(PrefixKeyConstant.JOB_KEY + taskId);
|
|
|
|
if (taskEntity.getExecuteStatus() == 0) {
|
|
|
|
if (jobDetail != null && jobDetail.getJobName() != null) {
|
|
|
|
this.addJob(taskId, taskEntity.getStartTime(), true);
|
|
|
|
jobService.resumeJob(PrefixKeyConstant.JOB_KEY + taskId);// 开启定时任务
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 开启定时任务
|
|
|
|
else {
|
|
|
|
if (taskEntity.getExecuteStatus() == 3) {
|
|
|
|
this.addJob(taskId, taskEntity.getStartTime(), true);// 添加定时任务
|
|
|
|
jobService.start(PrefixKeyConstant.JOB_KEY + taskId);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updateEntity.setExecuteStatus(1);
|
|
|
|
updateEntity.setExecuteStatus(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -302,13 +290,17 @@ public class DistributeTaskServiceImpl extends ExtendServiceImpl<DistributeTaskM
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(recordIdList)) {
|
|
|
|
// 查询分配人用户信息
|
|
|
|
// 查询分配人用户信息
|
|
|
|
List<SysUser> updateSysUserList = new ArrayList<>();
|
|
|
|
List<SysUser> updateSysUserList = new ArrayList<>();
|
|
|
|
List<SysUser> sysUsers = sysUserService.listByUserIds(userIdList);
|
|
|
|
List<SysUser> sysUsers = sysUserService.listByUserIds(userIdList);
|
|
|
|
Map<Long, List<SysUser>> userIdMap = sysUsers.stream().collect(Collectors.groupingBy(SysUser::getUserId));
|
|
|
|
Map<Long, List<SysUser>> userIdMap = sysUsers.stream()
|
|
|
|
// 获取文件中未分配的资源ID
|
|
|
|
.collect(Collectors.groupingBy(SysUser::getUserId));
|
|
|
|
|
|
|
|
// 获取文件中未分配的资源
|
|
|
|
List<Long> clueIds = clueService.findUndistributedClueIds(recordIdList);
|
|
|
|
List<Long> clueIds = clueService.findUndistributedClueIds(recordIdList);
|
|
|
|
// 分配
|
|
|
|
// 分配
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(clueIds)) {
|
|
|
|
DistributeDTO distributeDTO = new DistributeDTO();
|
|
|
|
DistributeDTO distributeDTO = new DistributeDTO();
|
|
|
|
distributeDTO.setDeptIds(userIdList);
|
|
|
|
distributeDTO.setDeptIds(userIdList);
|
|
|
|
distributeDTO.setResourceList(clueIds);
|
|
|
|
distributeDTO.setResourceList(clueIds);
|
|
|
@ -320,17 +312,16 @@ public class DistributeTaskServiceImpl extends ExtendServiceImpl<DistributeTaskM
|
|
|
|
List<Double> weights = weightList.stream().map(i -> i * 10.0).collect(Collectors.toList());
|
|
|
|
List<Double> weights = weightList.stream().map(i -> i * 10.0).collect(Collectors.toList());
|
|
|
|
distributeDTO.setWeights(weights);
|
|
|
|
distributeDTO.setWeights(weights);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
List<DistributeResponseDTO> responseDTOS = AssignDataUtil.assignData(distributeDTO);
|
|
|
|
// 查询业务管理员用户的默认文件记录
|
|
|
|
// 查询业务管理员用户的默认文件记录
|
|
|
|
Map<Long, List<ClueRecordEntity>> map = null;
|
|
|
|
Map<Long, List<ClueRecordEntity>> map = null;
|
|
|
|
if (createBy == 1) {
|
|
|
|
if (createBy == 1) {
|
|
|
|
List<ClueRecordEntity> recordEntities = clueRecordMapper
|
|
|
|
List<ClueRecordEntity> recordEntities = clueRecordMapper.selectList(
|
|
|
|
.selectList(new LambdaQueryWrapper<ClueRecordEntity>().in(ClueRecordEntity::getCreateBy, userIdList)
|
|
|
|
new LambdaQueryWrapper<ClueRecordEntity>().in(ClueRecordEntity::getCreateBy, userIdList)
|
|
|
|
.eq(ClueRecordEntity::getRecordType, DefaultNumberConstants.ONE_NUMBER));
|
|
|
|
.eq(ClueRecordEntity::getRecordType, DefaultNumberConstants.ONE_NUMBER));
|
|
|
|
map = recordEntities.stream().collect(Collectors.groupingBy(ClueRecordEntity::getCreateBy));
|
|
|
|
map = recordEntities.stream().collect(Collectors.groupingBy(ClueRecordEntity::getCreateBy));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 分配数据
|
|
|
|
|
|
|
|
List<ClueEntity> clueEntityList = new ArrayList<>();
|
|
|
|
List<ClueEntity> clueEntityList = new ArrayList<>();
|
|
|
|
List<DistributeResponseDTO> responseDTOS = AssignDataUtil.assignData(distributeDTO);
|
|
|
|
|
|
|
|
// 更新分配信息
|
|
|
|
// 更新分配信息
|
|
|
|
for (DistributeResponseDTO responseDTO : responseDTOS) {
|
|
|
|
for (DistributeResponseDTO responseDTO : responseDTOS) {
|
|
|
|
// 用户分发量修改
|
|
|
|
// 用户分发量修改
|
|
|
@ -375,18 +366,13 @@ public class DistributeTaskServiceImpl extends ExtendServiceImpl<DistributeTaskM
|
|
|
|
// 修改任务执行次数+1
|
|
|
|
// 修改任务执行次数+1
|
|
|
|
baseMapper.updateByExecuteNumAddOne(taskEntity.getDistributeTaskId());
|
|
|
|
baseMapper.updateByExecuteNumAddOne(taskEntity.getDistributeTaskId());
|
|
|
|
// 修改记录分配状态
|
|
|
|
// 修改记录分配状态
|
|
|
|
if (CollUtil.isNotEmpty(recordIdList))
|
|
|
|
if (CollUtil.isNotEmpty(recordIdList)) {
|
|
|
|
clueRecordMapper.updateAllocationStatus(recordIdList, 1);
|
|
|
|
clueRecordMapper.updateAllocationStatusAndDistributeStatus(recordIdList, 1, 1);
|
|
|
|
// 异步分发下级任务
|
|
|
|
}
|
|
|
|
|
|
|
|
// 分发下级任务
|
|
|
|
if (taskEntity.getCreateBy() == 1) {
|
|
|
|
if (taskEntity.getCreateBy() == 1) {
|
|
|
|
List<DistributeTaskEntity> taskEntities = baseMapper.selectList(
|
|
|
|
this.syncExecuteTask(userIdList);
|
|
|
|
new LambdaQueryWrapper<DistributeTaskEntity>().eq(DistributeTaskEntity::getDefaultType, 0)
|
|
|
|
}
|
|
|
|
.in(DistributeTaskEntity::getCreateBy, userIdList));
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(taskEntities)) {
|
|
|
|
|
|
|
|
List<Long> list = taskEntities.stream()
|
|
|
|
|
|
|
|
.map(DistributeTaskEntity::getDistributeTaskId)
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
this.syncExecuteTask(list);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -556,11 +542,20 @@ public class DistributeTaskServiceImpl extends ExtendServiceImpl<DistributeTaskM
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 执行下级分配
|
|
|
|
* 执行下级分配
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void syncExecuteTask(List<Long> taskIds) {
|
|
|
|
private void syncExecuteTask(List<Long> userIdList) {
|
|
|
|
List<DistributeTaskEntity> distributeTaskEntities = baseMapper.selectBatchIds(taskIds);
|
|
|
|
List<DistributeTaskEntity> taskEntities = baseMapper
|
|
|
|
for (DistributeTaskEntity distributeTaskEntity : distributeTaskEntities) {
|
|
|
|
.selectList(new LambdaQueryWrapper<DistributeTaskEntity>().eq(DistributeTaskEntity::getDefaultType, 0)
|
|
|
|
|
|
|
|
.in(DistributeTaskEntity::getCreateBy, userIdList));
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(taskEntities)) {
|
|
|
|
|
|
|
|
for (DistributeTaskEntity distributeTaskEntity : taskEntities) {
|
|
|
|
|
|
|
|
Integer executeStatus = distributeTaskEntity.getExecuteStatus();
|
|
|
|
|
|
|
|
Integer distributeTaskType = distributeTaskEntity.getDistributeTaskType();
|
|
|
|
|
|
|
|
Integer timeStatus = distributeTaskEntity.getTimeStatus();
|
|
|
|
|
|
|
|
if ((distributeTaskType == 1 && timeStatus == 0) && executeStatus != 0 && executeStatus != 3) {
|
|
|
|
this.execute(distributeTaskEntity);
|
|
|
|
this.execute(distributeTaskEntity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|