| | |
| | | import com.vincent.rsf.server.system.constant.GlobalConfigCode; |
| | | import com.vincent.rsf.server.system.entity.Config; |
| | | import com.vincent.rsf.server.system.service.ConfigService; |
| | | import com.vincent.rsf.server.system.utils.SystemAuthUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | |
| | | @Component |
| | | public class TaskSchedules { |
| | | |
| | | public static Logger logger = LoggerFactory.getLogger(TaskSchedules.class); |
| | | |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | |
| | | private TaskLogService taskLogService; |
| | | @Autowired |
| | | private TaskItemLogService taskItemLogService; |
| | | @Autowired |
| | | private StockItemService stockItemService; |
| | | @Autowired |
| | | private PurchaseService purchaseService; |
| | | @Autowired |
| | | private AsnOrderService asnOrderService; |
| | | @Autowired |
| | | private AsnOrderItemService asnOrderItemService; |
| | | @Autowired |
| | | private StockService stockService; |
| | | @Autowired |
| | | private LocService locService; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | List<Long> list = tasks.stream().map(Task::getId).collect(Collectors.toList()); |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getTaskId, list)); |
| | | if (taskItems.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | Map<Long, List<TaskItem>> listMap = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getTaskId)); |
| | | |
| | | tasks.forEach(task -> { |
| | | TaskLog taskLog = new TaskLog(); |
| | | BeanUtils.copyProperties(task, taskLog); |
| | |
| | | if (!taskLogService.save(taskLog)) { |
| | | throw new CoolException("任务历史档保存失败!!"); |
| | | } |
| | | |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | | List<TaskItemLog> itemLogs = new ArrayList<>(); |
| | | for (TaskItem item : listMap.get(task.getId())) { |
| | | for (TaskItem item : taskItems) { |
| | | TaskItemLog itemLog = new TaskItemLog(); |
| | | BeanUtils.copyProperties(item, itemLog); |
| | | itemLog.setId(null) |
| | |
| | | itemLogs.add(itemLog); |
| | | } |
| | | |
| | | if (!taskItemLogService.saveBatch(itemLogs)) { |
| | | throw new CoolException("任务明细历史档保存失败!!"); |
| | | if (!taskService.removeById(task.getId())) { |
| | | throw new CoolException("原始任务删除失败!!"); |
| | | } |
| | | |
| | | if (!taskItems.isEmpty()) { |
| | | if (!taskItemLogService.saveBatch(itemLogs)) { |
| | | throw new CoolException("任务明细历史档保存失败!!"); |
| | | } |
| | | |
| | | if (!taskItemService.remove(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()))) { |
| | | throw new CoolException("原始任务明细删除失败!!"); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | if (!taskService.removeByIds(list)) { |
| | | throw new CoolException("原始任务删除失败!!"); |
| | | } |
| | | |
| | | List<Long> itemIds = taskItems.stream().map(TaskItem::getId).collect(Collectors.toList()); |
| | | |
| | | if (!taskItemService.removeByIds(itemIds)) { |
| | | throw new CoolException("原始任务明细删除失败!!"); |
| | | } |
| | | } |
| | | } |