| | |
| | | |
| | | package org.springblade.mdm.flow.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.mp.base.BizServiceImpl; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.mdm.commons.service.ParamService; |
| | | import org.springblade.mdm.flow.entity.TaskDispatch; |
| | | import org.springblade.mdm.flow.mapper.TaskDispatchMapper; |
| | | import org.springblade.mdm.flow.vo.TaskAssignVO; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * 任务派工数据 处理服务 |
| | |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class TaskDispatchService extends BizServiceImpl<TaskDispatchMapper, TaskDispatch> { |
| | | @Autowired |
| | | private ParamService paramService; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public long saveTask(TaskAssignVO startVO) { |
| | | public TaskDispatch saveTask(TaskAssignVO startVO,boolean isDup) { |
| | | TaskDispatch taskDispatch = new TaskDispatch(); |
| | | BeanUtils.copyProperties(startVO, taskDispatch); |
| | | if(isDup){ |
| | | taskDispatch.setStatus(TaskDispatch.STATUS_DUP); |
| | | } |
| | | this.save(taskDispatch); |
| | | |
| | | return taskDispatch.getId(); |
| | | return taskDispatch; |
| | | } |
| | | |
| | | /* |
| | | public void updateSuccess(long id, String instId) { |
| | | TaskDispatch taskDispatch = getById(id); |
| | | taskDispatch.setProcessInstanceId(instId); |
| | | taskDispatch.setStatus(TaskDispatch.STATUS_STARTED); |
| | | this.updateById(taskDispatch); |
| | | } |
| | | |
| | | */ |
| | | |
| | | |
| | | /** |
| | | * 检查是否重复派工 |
| | | * @param startVO |
| | | * @return |
| | | */ |
| | | public boolean checkIsDuplicate(TaskAssignVO startVO) { |
| | | if(startVO.isTemporaryFlow()){ |
| | | //试切补充,不验证重复 |
| | | return false; |
| | | } |
| | | |
| | | int taskDupDays = Func.toInt(paramService.taskDuplicateCheckDays()); |
| | | LocalDateTime checkStartDate = LocalDateTime.now().minusDays(taskDupDays); |
| | | LambdaQueryChainWrapper<TaskDispatch> q = lambdaQuery().eq(TaskDispatch::getDrawingNo,startVO.getDrawingNo()) |
| | | .eq(TaskDispatch::getProcessNo,startVO.getProcessNo()) |
| | | //.eq(TaskDispatch::getProcessEdition,startVO.getProcessEdition()) |
| | | .eq(TaskDispatch::getMachineCode,startVO.getMachineCode()) |
| | | .gt(TaskDispatch::getCreateTime,checkStartDate); |
| | | |
| | | long cnt = q.count(); |
| | | |
| | | return cnt > 0; |
| | | } |
| | | |
| | | } |