package com.dhcc.finance.main.controller;

import com.dhcc.common.constant.SysConstants;
import com.dhcc.common.model.CurrencyMeta;
import com.dhcc.common.model.response.RestfulResponse;
import com.dhcc.finance.constant.MsConfigConsts;
import com.dhcc.finance.main.service.FinanceBatchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 功能描述：财务批量入口
 *
 * @author dml
 * @date 2019年11月27日 上午9:54:42
 * @修改日志：
 */
@RestController
@RequestMapping(value = MsConfigConsts.MS_API_PREFIX + FinanceBatchController.API_PREFIX,
        produces = {MediaType.APPLICATION_JSON_UTF8_VALUE}, consumes = {MediaType.APPLICATION_JSON_UTF8_VALUE})
@Api(value = "批量接口controller", tags = {"批量接口"})
public class FinanceBatchController {
    // 财务批量入口地址前缀
    public static final String API_PREFIX = "/finance_batch";

    @Autowired
    FinanceBatchService financeBatchService;

    /**
     * 功能描述：月底批量处理结转结账
     *
     * @param period
     * @return RestfulResponse<Object, CurrencyMeta>
     * @author dml
     * @date 2019年11月27日 上午10:56:48
     * @修改日志：
     */
    @ApiOperation(value = "月底批量处理结转结账", notes = "月底批量处理结转结账", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "quartzJobName", value = "任务名", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "batchMonitorId", value = "批次号", required = true, dataType = "String", paramType = "query"),
    })
    @RequestMapping(value = "/startCarryForwardAndSettle", method = RequestMethod.POST, consumes = MediaType.ALL_VALUE)
    RestfulResponse<Object, CurrencyMeta> startCarryForwardAndSettle(String quartzJobName, String batchMonitorId) {
        financeBatchService.startCarryForwardAndSettle(quartzJobName, batchMonitorId);
        return new RestfulResponse<Object, CurrencyMeta>(SysConstants.CODE.SUCCESS, SysConstants.DEFAULT_MESSAGE.OPERATION_SUCCESS);
    }


    @ApiOperation(value = "月底批量处理结转", notes = "月底批量处理结转", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "quartzJobName", value = "任务名", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "batchMonitorId", value = "批次号", required = true, dataType = "String", paramType = "query"),
    })
    @RequestMapping(value = "/startCarryForward", method = RequestMethod.POST, consumes = MediaType.ALL_VALUE)
    RestfulResponse<Object, CurrencyMeta> startCarryForward(String quartzJobName, String batchMonitorId) {
        financeBatchService.startCarryForward(quartzJobName, batchMonitorId);
        return new RestfulResponse<Object, CurrencyMeta>(SysConstants.CODE.SUCCESS, SysConstants.DEFAULT_MESSAGE.OPERATION_SUCCESS);
    }


    @ApiOperation(value = "月底批量处理结账", notes = "月底批量处理结账", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "quartzJobName", value = "任务名", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "batchMonitorId", value = "批次号", required = true, dataType = "String", paramType = "query"),
    })
    @RequestMapping(value = "/startSettle", method = RequestMethod.POST, consumes = MediaType.ALL_VALUE)
    RestfulResponse<Object, CurrencyMeta> startSettle(String quartzJobName, String batchMonitorId) {
        financeBatchService.startSettle(quartzJobName, batchMonitorId);
        return new RestfulResponse<Object, CurrencyMeta>(SysConstants.CODE.SUCCESS, SysConstants.DEFAULT_MESSAGE.OPERATION_SUCCESS);
    }


}