package com.prolog.rdc.tms.controller;

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;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.service.AlertJobService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 预警控制层
 *
 * @author lhb
 * @since 2022-04-11 09:04:35
 */
@RestController
@Api(tags = "预警控制层")
@RequestMapping("/alert")
public class AlertJobController {

	@Autowired
	private AlertJobService alertJobService;

	@UserLog("未及时提货预警处理")
	@ApiOperation(value = "未及时货预警处理", notes = "未及时提货预警处理")
	@PostMapping("/not_pick_up")
	public RestMessage<String> notPicUpAlertExecute() {
		try {
			alertJobService.notPicUpAlert();
			return RestMessage.newInstance(true, "未及时提货预警处理成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("未及时送货预警处理")
	@ApiOperation(value = "未及时送货预警处理", notes = "未及时送货预警处理")
	@PostMapping("/not_delivery")
	public RestMessage<String> notDeliveryAlertExecute() {
		try {
			alertJobService.notDeliveryAlert();
			return RestMessage.newInstance(true, "未及时送货预警处理成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("未及时理货预警处理")
	@ApiOperation(value = "未及时理货预警处理", notes = "未及时理货预警处理")
	@PostMapping("/not_arrange")
	public RestMessage<String> notArrangeAlertExecute() {
		try {
			alertJobService.notArrangeAlert();
			return RestMessage.newInstance(true, "未及时理货预警处理成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("未及时装卸预警处理")
	@ApiOperation(value = "未及时装卸预警处理", notes = "未及时装卸预警处理")
	@PostMapping("/not_loading_and_unloading")
	public RestMessage<String> notPicUpExecute() {
		try {
			alertJobService.notLoadingAndUnLoadingAlert();
			return RestMessage.newInstance(true, "未及时装卸预警处理成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}
}
