|
@@ -61,16 +61,8 @@ public class TBTaskServiceImpl extends ServiceImpl<TBTaskMapper, TBTask> impleme
|
|
|
if (Objects.isNull(basicAttachment)) {
|
|
|
throw ExceptionResultEnum.ATTACHMENT_ERROR.exception();
|
|
|
} else {
|
|
|
- SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
- TBTask tbTask = new TBTask(taskTypeEnum,
|
|
|
- TaskStatusEnum.INIT,
|
|
|
- basicAttachment.getName(),
|
|
|
- basicAttachment.getPath(),
|
|
|
- requestUser.getId(),
|
|
|
- requestUser.getSchoolId());
|
|
|
map = new HashMap<>();
|
|
|
- map.computeIfAbsent(SystemConstant.TASK, v -> tbTask);
|
|
|
- map.computeIfAbsent(SystemConstant.USER, v -> requestUser);
|
|
|
+ TBTask tbTask = saveTaskCommon(basicAttachment, taskTypeEnum, map);
|
|
|
this.save(tbTask);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -97,17 +89,9 @@ public class TBTaskServiceImpl extends ServiceImpl<TBTaskMapper, TBTask> impleme
|
|
|
if (Objects.isNull(basicAttachment)) {
|
|
|
throw ExceptionResultEnum.ATTACHMENT_ERROR.exception();
|
|
|
} else {
|
|
|
- SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
- TBTask tbTask = new TBTask(taskTypeEnum,
|
|
|
- TaskStatusEnum.INIT,
|
|
|
- basicAttachment.getName(),
|
|
|
- basicAttachment.getPath(),
|
|
|
- requestUser.getId(),
|
|
|
- requestUser.getSchoolId());
|
|
|
- tbTask.setPrintPlanId(printPlanId);
|
|
|
map = new HashMap<>();
|
|
|
- map.computeIfAbsent(SystemConstant.TASK, v -> tbTask);
|
|
|
- map.computeIfAbsent(SystemConstant.USER, v -> requestUser);
|
|
|
+ TBTask tbTask = saveTaskCommon(basicAttachment, taskTypeEnum, map);
|
|
|
+ tbTask.setPrintPlanId(printPlanId);
|
|
|
this.save(tbTask);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -164,6 +148,32 @@ public class TBTaskServiceImpl extends ServiceImpl<TBTaskMapper, TBTask> impleme
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存任务
|
|
|
+ *
|
|
|
+ * @param taskTypeEnum
|
|
|
+ * @param printPlanId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Map<String, Object> saveTask(TaskTypeEnum taskTypeEnum, Long printPlanId) {
|
|
|
+ Map<String, Object> map = null;
|
|
|
+ try {
|
|
|
+ TBTask tbTask = saveTaskCommon(null, taskTypeEnum, map);
|
|
|
+ tbTask.setPrintPlanId(printPlanId);
|
|
|
+ this.save(tbTask);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("请求出错", e);
|
|
|
+ if (e instanceof ApiException) {
|
|
|
+ ResultUtil.error((ApiException) e, e.getMessage());
|
|
|
+ } else {
|
|
|
+ ResultUtil.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询任务列表
|
|
|
*
|
|
@@ -178,4 +188,24 @@ public class TBTaskServiceImpl extends ServiceImpl<TBTaskMapper, TBTask> impleme
|
|
|
public IPage<TaskListResult> query(IPage<Map> iPage, Long printPlanId, TaskStatusEnum status, TaskTypeEnum type, TaskResultEnum result) {
|
|
|
return tbTaskMapper.query(iPage, printPlanId, Objects.nonNull(status) ? status.name() : null, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(result) ? result.name() : null);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存task
|
|
|
+ *
|
|
|
+ * @param basicAttachment
|
|
|
+ * @param taskTypeEnum
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public TBTask saveTaskCommon(BasicAttachment basicAttachment, TaskTypeEnum taskTypeEnum, Map map) {
|
|
|
+ SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+ TBTask tbTask = new TBTask(taskTypeEnum,
|
|
|
+ TaskStatusEnum.INIT,
|
|
|
+ Objects.nonNull(basicAttachment) ? basicAttachment.getName() : null,
|
|
|
+ Objects.nonNull(basicAttachment) ? basicAttachment.getPath() : null,
|
|
|
+ requestUser.getId(),
|
|
|
+ requestUser.getSchoolId());
|
|
|
+ map.computeIfAbsent(SystemConstant.TASK, v -> tbTask);
|
|
|
+ map.computeIfAbsent(SystemConstant.USER, v -> requestUser);
|
|
|
+ return tbTask;
|
|
|
+ }
|
|
|
}
|