| | |
| | | package com.zy.asrs.task; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.api.controller.params.WorkTaskParams; |
| | | import com.zy.api.service.WcsApiService; |
| | | import com.zy.asrs.entity.Task; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.TaskService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.task.handler.WorkMastHandler; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/7/7 |
| | | */ |
| | | //@Component |
| | | @Component |
| | | public class WorkMastScheduler { |
| | | |
| | | private static final Logger log = LoggerFactory.getLogger(WorkMastScheduler.class); |
| | |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private WorkMastHandler workMastHandler; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private WcsApiService wcsApiService; |
| | | |
| | | @Scheduled(cron = "0/3 * * * * ? ") |
| | | private void execute(){ |
| | | private void execute() { |
| | | List<WrkMast> wrkMasts = wrkMastService.selectToBeCompleteData(); |
| | | if (wrkMasts.isEmpty()) { |
| | | return; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 任务自动下发 |
| | | * |
| | | * @author Ryan |
| | | * @date 2026/1/10 14:42 |
| | | */ |
| | | // @Scheduled(cron = "0/15 * * * * ? ") |
| | | private void autoPubTasks() { |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().in("wrk_sts", Arrays.asList(1L, 11L))); |
| | | if (wrkMasts.isEmpty()) { |
| | | return; |
| | | } |
| | | Collections.shuffle(wrkMasts); |
| | | wrkMasts.forEach(wrkMast -> { |
| | | WorkTaskParams params = new WorkTaskParams(); |
| | | if (wrkMast.getIoType().equals(1)) { |
| | | params.setType("in"); |
| | | params.setTaskNo(wrkMast.getWrkCode()) |
| | | .setLocNo(wrkMast.getLocNo()) |
| | | .setBarcode(wrkMast.getBarcode()) |
| | | .setTaskPri(Integer.parseInt(wrkMast.getIoPri() + "")); |
| | | } else { |
| | | params.setType("out") |
| | | .setTaskNo(wrkMast.getWrkCode()) |
| | | .setLocNo(wrkMast.getLocNo()) |
| | | .setStaNo(wrkMast.getStaNo()) |
| | | .setTaskPri(Integer.parseInt(wrkMast.getIoPri() + "")); |
| | | } |
| | | wcsApiService.pubWrkToWcs(params); |
| | | }); |
| | | } |
| | | } |