|
|
|
@ -1,13 +1,14 @@ |
|
|
|
package com.biutag.supervision.service; |
|
|
|
package com.biutag.supervision.service; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.biutag.supervision.constants.enums.*; |
|
|
|
import com.biutag.supervision.constants.enums.*; |
|
|
|
import com.biutag.supervision.mapper.*; |
|
|
|
import com.biutag.supervision.mapper.*; |
|
|
|
|
|
|
|
import com.biutag.supervision.pojo.dto.ModelClueTaskDistribute; |
|
|
|
import com.biutag.supervision.pojo.dto.NegativeDto; |
|
|
|
import com.biutag.supervision.pojo.dto.NegativeDto; |
|
|
|
import com.biutag.supervision.pojo.entity.*; |
|
|
|
import com.biutag.supervision.pojo.entity.*; |
|
|
|
import com.biutag.supervision.pojo.model.ModelClueModel; |
|
|
|
import com.biutag.supervision.pojo.model.ModelClueModel; |
|
|
|
@ -19,6 +20,10 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.Objects; |
|
|
|
import java.time.ZoneId; |
|
|
|
import java.time.ZoneId; |
|
|
|
import java.time.ZonedDateTime; |
|
|
|
import java.time.ZonedDateTime; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
@ -48,38 +53,49 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> { |
|
|
|
public final SupDepartMapper supDepartMapper; |
|
|
|
public final SupDepartMapper supDepartMapper; |
|
|
|
|
|
|
|
|
|
|
|
public Page<ModelClueModel> page(ModelClueQueryParam param) { |
|
|
|
public Page<ModelClueModel> page(ModelClueQueryParam param) { |
|
|
|
LambdaQueryWrapper<ModelClue> queryWrapper = new LambdaQueryWrapper<ModelClue>() |
|
|
|
if (Objects.nonNull(param.getModelIds()) && param.getModelIds().isEmpty()) { |
|
|
|
.eq(Objects.nonNull(param.getInvolveDepartId()), ModelClue::getInvolveDepartId, param.getInvolveDepartId()) |
|
|
|
return new Page<ModelClueModel>().setTotal(0).setRecords(new ArrayList<>()); |
|
|
|
.eq(StrUtil.isNotBlank(param.getDistributionState()), ModelClue::getDistributionState, param.getDistributionState()) |
|
|
|
|
|
|
|
.like(StrUtil.isNotBlank(param.getThingDesc()), ModelClue::getThingDesc, param.getThingDesc()) |
|
|
|
|
|
|
|
.orderByDesc(ModelClue::getCreateTime); |
|
|
|
|
|
|
|
if (Objects.nonNull(param.getCreateTime()) && param.getCreateTime().size() == 2) { |
|
|
|
|
|
|
|
queryWrapper.between(ModelClue::getCreateTime, param.getCreateTime().get(0), param.getCreateTime().get(1)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
Page<ModelClue> page = page(Page.of(param.getCurrent(), param.getSize()), queryWrapper); |
|
|
|
QueryWrapper<ModelClue> queryWrapper = new QueryWrapper<ModelClue>() |
|
|
|
if (page.getRecords().isEmpty()) { |
|
|
|
.eq(StrUtil.isNotBlank(param.getDistributionMethod()), "m.distribution_method", param.getDistributionMethod()) |
|
|
|
return new Page<ModelClueModel>().setRecords(new ArrayList<>()).setTotal(0); |
|
|
|
.in(Objects.nonNull(param.getModelIds()) && !param.getModelIds().isEmpty(), "mc.model_id", param.getModelIds()) |
|
|
|
|
|
|
|
.eq(Objects.nonNull(param.getInvolveDepartId()), "mc.involve_depart_id", param.getInvolveDepartId()) |
|
|
|
|
|
|
|
.eq(StrUtil.isNotBlank(param.getDistributionState()), "mc.distribution_state", param.getDistributionState()) |
|
|
|
|
|
|
|
.like(StrUtil.isNotBlank(param.getThingDesc()), "mc.thing_desc", param.getThingDesc()) |
|
|
|
|
|
|
|
.orderByDesc("mc.create_time"); |
|
|
|
|
|
|
|
if (Objects.nonNull(param.getCreateTime()) && param.getCreateTime().size() == 2) { |
|
|
|
|
|
|
|
queryWrapper.between("mc.create_time", param.getCreateTime().get(0), param.getCreateTime().get(1)); |
|
|
|
} |
|
|
|
} |
|
|
|
Set<Integer> modelIds = page.getRecords().stream().map(ModelClue::getModelId).collect(Collectors.toSet()); |
|
|
|
return baseMapper.queryPage(Page.of(param.getCurrent(), param.getSize()), queryWrapper); |
|
|
|
List<Model> models = modelMapper.selectBatchIds(modelIds); |
|
|
|
|
|
|
|
List<ModelClueModel> list = page.getRecords().stream().map(item -> { |
|
|
|
|
|
|
|
ModelClueModel modelClueModel = new ModelClueModel(); |
|
|
|
|
|
|
|
BeanUtil.copyProperties(item, modelClueModel); |
|
|
|
|
|
|
|
String modelName = models.stream().filter(model -> model.getId().equals(item.getModelId())).findFirst().map(Model::getModelName).orElse(""); |
|
|
|
|
|
|
|
modelClueModel.setModelName(modelName); |
|
|
|
|
|
|
|
return modelClueModel; |
|
|
|
|
|
|
|
}).toList(); |
|
|
|
|
|
|
|
return new Page<ModelClueModel>().setRecords(list).setTotal(page.getTotal()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<ModelClue> listByUnDistributed(Integer modelId) { |
|
|
|
public List<ModelClue> listByUnDistributed(Integer modelId) { |
|
|
|
return list(new LambdaQueryWrapper<ModelClue>().eq(ModelClue::getModelId, modelId).eq(ModelClue::getDistributionState, ModelDistributionStateEnum.UNDISTRIBUTED.getValue())); |
|
|
|
return list(new LambdaQueryWrapper<ModelClue>().eq(ModelClue::getModelId, modelId).eq(ModelClue::getDistributionState, ModelDistributionStateEnum.UNDISTRIBUTED.getValue())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public boolean distribution(ModelClueTaskDistribute taskDistribute) { |
|
|
|
|
|
|
|
List<ModelClue> modelClues = taskDistribute.getModelClues(); |
|
|
|
|
|
|
|
Model model = modelMapper.selectById(modelClues.get(0).getModelId()); |
|
|
|
|
|
|
|
model.setTimeLimit(taskDistribute.getTimeLimit()); |
|
|
|
|
|
|
|
model.setMaxSignDuration(taskDistribute.getMaxSignDuration()); |
|
|
|
|
|
|
|
model.setMaxHandleDuration(taskDistribute.getMaxHandleDuration()); |
|
|
|
|
|
|
|
model.setMaxExtensionDuration(taskDistribute.getMaxExtensionDuration()); |
|
|
|
|
|
|
|
model.setApprovalFlow(taskDistribute.getApprovalFlow()); |
|
|
|
|
|
|
|
model.setDistributionFlow(taskDistribute.getDistributionFlow()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return distribution(modelClues, model, taskDistribute.getTaskName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean distribution(Integer modelId) { |
|
|
|
public boolean distribution(Integer modelId) { |
|
|
|
List<ModelClue> modelClues = listByUnDistributed(modelId); |
|
|
|
List<ModelClue> modelClues = listByUnDistributed(modelId); |
|
|
|
Model model = modelMapper.selectById(modelId); |
|
|
|
Model model = modelMapper.selectById(modelId); |
|
|
|
|
|
|
|
String taskName = "自动下发"; |
|
|
|
|
|
|
|
return distribution(modelClues, model, taskName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
|
|
public boolean distribution(List<ModelClue> modelClues, Model model, String taskName) { |
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
modelClues.forEach(item -> { |
|
|
|
modelClues.forEach(item -> { |
|
|
|
if (Objects.isNull(item.getInvolveDepartId())) { |
|
|
|
if (Objects.isNull(item.getInvolveDepartId())) { |
|
|
|
@ -130,7 +146,8 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> { |
|
|
|
updateById(item); |
|
|
|
updateById(item); |
|
|
|
}); |
|
|
|
}); |
|
|
|
ModelClueTask modelClueTask = new ModelClueTask(); |
|
|
|
ModelClueTask modelClueTask = new ModelClueTask(); |
|
|
|
modelClueTask.setModelId(modelId); |
|
|
|
modelClueTask.setTaskName(taskName); |
|
|
|
|
|
|
|
modelClueTask.setModelId(model.getId()); |
|
|
|
modelClueTask.setSize(modelClues.size()); |
|
|
|
modelClueTask.setSize(modelClues.size()); |
|
|
|
modelClueTask.setDistributionTime(now); |
|
|
|
modelClueTask.setDistributionTime(now); |
|
|
|
// 下发方式
|
|
|
|
// 下发方式
|
|
|
|
|