| | |
| | | private LocService locService; |
| | | @Autowired |
| | | private LocStsService locStsService; |
| | | @Autowired |
| | | private TaskLogService taskLogService; |
| | | @Autowired |
| | | private TaskDetlLogService taskDetlLogService; |
| | | @Autowired |
| | | private TaskDetlFieldLogService taskDetlFieldLogService; |
| | | |
| | | @Override |
| | | public String generateTaskNo(Long taskType) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean completeTask(Long taskId) { |
| | | Task task = taskService.getById(taskId); |
| | | if(task == null){ |
| | | throw new CoolException("任务不存在"); |
| | | } |
| | | |
| | | List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(taskId); |
| | | if (taskDetls.isEmpty()) { |
| | | throw new CoolException("任务明细不存在"); |
| | | } |
| | | |
| | | if (task.getTaskType() < 100) { |
| | | //入库 |
| | | task.setTaskSts(99L);//99.入库完成 |
| | | }else { |
| | | //出库 |
| | | task.setTaskSts(199L);//199.出库完成 |
| | | } |
| | | |
| | | task.setUpdateTime(new Date()); |
| | | if (!taskService.updateById(task)) { |
| | | throw new CoolException("任务更新失败"); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public boolean cancelTask(Long taskId) { |
| | | Task task = taskService.getById(taskId); |
| | |
| | | } |
| | | } |
| | | |
| | | //删除明细扩展 |
| | | boolean removeField = taskDetlFieldService.remove(new LambdaQueryWrapper<TaskDetlField>().eq(TaskDetlField::getDetlId, taskDetl.getId())); |
| | | if(!removeField){ |
| | | throw new CoolException("回滚扩展明细失败"); |
| | | List<TaskDetlField> detlFields = taskDetlFieldService.list(new LambdaQueryWrapper<TaskDetlField>().eq(TaskDetlField::getDetlId, taskDetl.getId())); |
| | | for (TaskDetlField detlField : detlFields) { |
| | | //明细扩展字段数据保存至历史档 |
| | | TaskDetlFieldLog taskDetlFieldLog = new TaskDetlFieldLog(); |
| | | taskDetlFieldLog.sync(detlField); |
| | | if (!taskDetlFieldLogService.save(taskDetlFieldLog)) { |
| | | throw new CoolException("明细扩展字段转历史档案失败"); |
| | | } |
| | | |
| | | //删除明细扩展 |
| | | boolean removeField = taskDetlFieldService.removeById(detlField.getId()); |
| | | if(!removeField){ |
| | | throw new CoolException("回滚扩展明细失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | //明细数据保存至历史档 |
| | | TaskDetlLog taskDetlLog = new TaskDetlLog(); |
| | | taskDetlLog.sync(taskDetl); |
| | | if (!taskDetlLogService.save(taskDetlLog)) { |
| | | throw new CoolException("明细数据转历史档案失败"); |
| | | } |
| | | |
| | | //删除明细 |
| | |
| | | } |
| | | } |
| | | |
| | | //数据保存至历史档 |
| | | TaskLog taskLog = new TaskLog(); |
| | | taskLog.sync(task); |
| | | if (!taskLogService.save(taskLog)) { |
| | | throw new CoolException("任务档案转历史档案失败"); |
| | | } |
| | | |
| | | //删除任务 |
| | | boolean removeTask = taskService.removeById(taskId); |
| | | if(!removeTask){ |