package com.shkj.wcs.controller.busin;

import com.shkj.common.annotation.Log;
import com.shkj.common.annotation.RepeatSubmit;
import com.shkj.common.core.controller.BaseController;
import com.shkj.common.core.domain.Result;
import com.shkj.common.enums.BusinessType;
import com.shkj.wcs.plc.PlcEventTask;
import com.shkj.wcs.scheduled.ScheduledTasks;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor(onConstructor_ =@Autowired)
@RestController
@RequestMapping("/wcs/task")
public class TaskController extends BaseController {

    @Autowired
    ScheduledTasks scheduledTasks;


    @Autowired
    PlcEventTask plcEventTask;

    /**
     * 执行task
     */
    @Log(title = "手动调度任务流程",businessType = BusinessType.UPDATE)
    @PostMapping("/exeTask")
    @RepeatSubmit
    public Result<Boolean> exeTask(){
       // scheduledTasks.task();
        return  Result.ok();
    }


    /**
     * 执行PLC相关任务--正式
     */
    @Log(title = "执行PLC相关任务",businessType = BusinessType.UPDATE)
    @PostMapping("/exePlcTask")
    @RepeatSubmit
    public Result<Boolean> exePlcTask(){
        plcEventTask.init();
        return  Result.ok();
    }
}
