package com.dhcc.finance.main.controller;

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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.dhcc.common.model.CurrencyMeta;
import com.dhcc.common.model.response.RestfulResponse;
import com.dhcc.finance.constant.MsConfigConsts;
import com.dhcc.finance.main.model.FileUploadRequest;
import com.dhcc.finance.main.model.FileUploadRequestTemp;
import com.dhcc.finance.main.service.CwGlBalanceService;

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

/**
 * 功能描述：科目辅助余额表接口
 * @author dml
 * @date 2019年4月22日 下午3:15:21
 * @修改日志：
 */
@RestController
@RequestMapping(value = MsConfigConsts.MS_API_PREFIX + CwGlBalanceController.API_PREFIX, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE })
@Api(value = "科目辅助余额表controller", tags = { "科目辅助余额表接口" })
public class CwGlBalanceController {
	// 科目辅助余额表接口地址前缀
    public static final String API_PREFIX = "/cw_gl_balance";
    
    @Autowired
    CwGlBalanceService cwGlBalanceService;
    
    /**
     * 功能描述：年初重算
     * @param pkGlorgbook
     * @param year
     * @return RestfulResponse<Object,CurrencyMeta>
     * @author dml
     * @date 2019年4月22日 下午7:28:26
     * @修改日志：
     */
    @ApiOperation(value = "年初重算", notes = "年初重算", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "pkGlorgbook", value = "账套主键", required = true, dataType = "String"),
    	@ApiImplicitParam(name = "year", value = "年", required = true, dataType = "String")
    }) 
	@RequestMapping(value = "/earlyYearRecalculation", method = RequestMethod.POST , consumes = MediaType.ALL_VALUE)
    public RestfulResponse<Object, CurrencyMeta> earlyYearRecalculation(@RequestParam("pkGlorgbook") String pkGlorgbook,@RequestParam("year") String year){
    	return cwGlBalanceService.earlyYearRecalculation(pkGlorgbook, year);
    }
    
    /**
     * 功能描述：导入期初余额
     * @param fileUploadRequest
     * @param type
     * @return RestfulResponse<String,CurrencyMeta>
     * @author dml
     * @date 2019年4月24日 下午3:53:20
     * @修改日志：
     */
    @ApiOperation(value = "导入期初余额", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @RequestMapping(value = "/uploadCwGlBalance", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    RestfulResponse<String,CurrencyMeta> uploadCwGlBalance( FileUploadRequest fileUploadRequest, String  type){
    	return cwGlBalanceService.uploadCwGlBalance(fileUploadRequest, type);
    }
    /**
     * 计算科目余额(余额控制方向)
     * @param pkGlorgbook
     * @param period
     * @param pkAccsub
     * @return RestfulResponse<String,CurrencyMeta>
     *@author huangpeng
     *@date 2019年4月28日 下午7:05:54
     *@修改日志：
     */
    @ApiOperation(value = "计算科目余额(余额控制方向)", notes = "年初重算", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "pkGlorgbook", value = "账套主键", required = true, dataType = "String"),
    	@ApiImplicitParam(name = "period", value = "期间", required = true, dataType = "String"),
    	@ApiImplicitParam(name = "pkAccsubj", value = "科目主键", required = true, dataType = "String"),
    	@ApiImplicitParam(name = "balanorient", value = "科目方向", required = true, dataType = "String")
    }) 
	@RequestMapping(value = "/seachCwGlBalanceSum", method = RequestMethod.GET , consumes = MediaType.ALL_VALUE)
    public RestfulResponse<String, CurrencyMeta> seachCwGlBalanceSum(@RequestParam("pkGlorgbook") String pkGlorgbook,
    		@RequestParam("period") String period,
    		@RequestParam("pkAccsubj") String pkAccsubj,
    		@RequestParam("balanorient") String balanorient){
    	return cwGlBalanceService.seachCwGlBalanceSum(pkGlorgbook, period,pkAccsubj,balanorient);
    }
    /**
     * 功能描述:期初余额临时表导入
     * @param fileUploadRequestTemp
     * @param pkGlorgbook
     * @param period
     * @return RestfulResponse<String,CurrencyMeta>
     *@author baiyc
     *@date 2019年4月30日 下午3:00:08
     *@修改日志:
     */
    @ApiOperation(value = "期初余额Excel导入", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @RequestMapping(value = "/uploadCwGlInitbuildTemp", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
 RestfulResponse<String,CurrencyMeta> uploadCwGlInitbuildTemp( FileUploadRequestTemp fileUploadRequestTemp,
                                                                 String pkGlorgbook,String period) {
        return cwGlBalanceService.uploadCwGlInitbuildTemp(fileUploadRequestTemp,pkGlorgbook,period);
         
        }
    
}
