package com.css.simulation.resource.server.adapter.controller.job_manage;

import api.common.pojo.common.ResponseBodyVO;
import api.common.pojo.param.project.SimulationManualProjectParam;
import api.common.util.ObjectUtil;
import com.css.simulation.resource.server.app.service.job_manage.SimulationProjectService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Calendar;
import java.util.Map;

@RestController
@RequestMapping("/monitor")
public class MonitorController {

    @Resource
    private SimulationProjectService simulationProjectService;

    /**
     * 运行自动任务
     */
    @RequestMapping("/createAutomaticSubProject")
    public ResponseBodyVO<String> createAutomaticSubProject(@RequestBody Map<String, String> paramMap) {
        if (ObjectUtil.isNull(paramMap) || ObjectUtil.isNull(paramMap.get("id"))) {
            return new ResponseBodyVO<>(false, 500, "参数必传！", null);
        }
        SimulationManualProjectParam param = new SimulationManualProjectParam();
        param.setId(paramMap.get("id"));
        System.out.println("运行自动任务:" + Calendar.getInstance().getTime() + "/" + paramMap.get("id"));
        return simulationProjectService.createAutomaticSubProject(param);
    }

}
