package com.dhcc.finance.main.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
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.domain.CwGlSettle;
import com.dhcc.finance.main.model.CwGlSettleAndName;
import com.dhcc.finance.main.model.CwGlTransferWeb;
import com.dhcc.finance.main.service.CwGlSettleService;
import com.github.pagehelper.PageInfo;

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

@RestController
@RequestMapping(value = MsConfigConsts.MS_API_PREFIX + CwGlSettleController.API_PREFIX, 
  	          produces = {MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE })
@Api(value = "结账信息controller", tags = { "结账信息操作接口" })
public class CwGlSettleController {
				// 结账信息操作接口地址前缀
				public static final String API_PREFIX = "/cw_gl_settle";
				@Autowired
				CwGlSettleService cwGlSettleService;
				/**
				 * 获取全部结账信息数据
				 * @param periodLike
				 * @param pageNum
				 * @param pageSize
				 * @param navigatePages
				 * @return RestfulResponse<PageInfo<CwGlSettleAndName>,CurrencyMeta>
				 *@author huangpeng
				 *@date 2019年4月2日 下午1:41:19
				 *@修改日志：
				 */
				@ApiOperation(value = "获取全部结账信息数据", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
				@ApiImplicitParams({
					@ApiImplicitParam(name = "nameLike", value = "账套模糊查询", required = false, dataType = "String", paramType="query"),
					@ApiImplicitParam(name = "periodLike", value = "期间模糊查询", required = false, dataType = "String", paramType="query"),
					@ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "String", paramType="query"),
			        @ApiImplicitParam(name = "pageSize", value = "每页显示数量", required = true, dataType = "String", paramType="query"),
			        @ApiImplicitParam(name = "navigatePages", value = "需要连续显示的页码数量", required = true, dataType = "String", paramType="query"),
			        @ApiImplicitParam(name = "issettle", value = "是否结账", required = false, dataType = "String", paramType="query"),
			        @ApiImplicitParam(name = "settleUser", value = "结账人", required = false, dataType = "String", paramType="query"),
			        @ApiImplicitParam(name = "settleTime", value = "结账时间", required = false, dataType = "String", paramType="query"),
			    }) 
				@RequestMapping(value = { "/searchCwGlSettleAndName" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
				public RestfulResponse<PageInfo<CwGlSettleAndName>, CurrencyMeta> searchCwGlSettleAndName(
						@RequestParam(value="nameLike",required=false) String nameLike,
						@RequestParam(value="periodLike",required=false) String periodLike,
						@RequestParam("pageNum") int pageNum,
			    		@RequestParam("pageSize") int pageSize,
			    		@RequestParam("navigatePages") int navigatePages,
			    		@RequestParam(value="issettle",required=false) String issettle,
			    		@RequestParam(value="settleUser",required=false) String settleUser,
			    		@RequestParam(value="settleTime",required=false) String settleTime){
					return cwGlSettleService.searchCwGlSettleAndName(nameLike,periodLike,pageNum, pageSize, navigatePages
							,issettle,settleUser,settleTime);
		}
				/**
				 * 批量更新结账信息
				 * @param CwGlSettles
				 * @return RestfulResponse<Object,CurrencyMeta>
				 *@author huangpeng
				 *@date 2019年4月2日 下午1:54:51
				 *@修改日志：
				 */
				@ApiOperation(value = "批量更新结账信息", notes = "批量更新结账信息", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
				@ApiImplicitParam(name = "CwGlSettle", value = "数据表名", required = true, dataType = "List")
				@RequestMapping(value = "/updateCwGlSettleForBatch", method = RequestMethod.PUT)
				public RestfulResponse<Object, CurrencyMeta> updateCwGlSettleForBatch(@RequestBody List<CwGlTransferWeb> CwGlSettles ) {
					return cwGlSettleService.updateCwGlSettleForBatch(CwGlSettles);
				}
				/**
				 * 更新反结账信息
				 * @param CwGlSettles
				 * @return RestfulResponse<Object,CurrencyMeta>
				 *@author huangpeng
				 *@date 2019年4月10日 上午9:29:55
				 *@修改日志：
				 */
				@ApiOperation(value = "批量更新反结账信息", notes = "批量更新结账信息", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
				@ApiImplicitParam(name = "CwGlSettle", value = "数据表名", required = true, dataType = "List")
				@RequestMapping(value = "/updateCwGlSettleForBatchReverse", method = RequestMethod.PUT)
				public RestfulResponse<Object, CurrencyMeta> updateCwGlSettleForBatchReverse(@RequestBody List<CwGlSettle> CwGlSettles ) {
					return cwGlSettleService.updateCwGlSettleForBatchReverse(CwGlSettles);
				}
				/**
				 * 查询反结账信息列表
				 * @param nameLike
				 * @param periodLike
				 * @param pageNum
				 * @param pageSize
				 * @param navigatePages
				 * @return RestfulResponse<PageInfo<CwGlSettleAndName>,CurrencyMeta>
				 *@author huangpeng
				 *@date 2019年4月10日 上午9:26:13
				 *@修改日志：
				 */
				@ApiOperation(value = "获取全部反结账信息数据", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
				@ApiImplicitParams({
					@ApiImplicitParam(name = "nameLike", value = "账套模糊查询", required = false, dataType = "String", paramType="query"),
					@ApiImplicitParam(name = "periodLike", value = "期间模糊查询", required = false, dataType = "String", paramType="query"),
					@ApiImplicitParam(name = "issettle", value = "是否结账", required = false, dataType = "String", paramType="query"),
	                @ApiImplicitParam(name = "settleUser", value = "结账人", required = false, dataType = "String", paramType="query"),
	                @ApiImplicitParam(name = "settleTime", value = "结账时间", required = false, dataType = "Decimal", paramType="query"),
					@ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "String", paramType="query"),
			        @ApiImplicitParam(name = "pageSize", value = "每页显示数量", required = true, dataType = "String", paramType="query"),
			        @ApiImplicitParam(name = "navigatePages", value = "需要连续显示的页码数量", required = true, dataType = "String", paramType="query")
			    }) 
				@RequestMapping(value = { "/searchCwGlSettleAndNameForReverse" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
				public RestfulResponse<PageInfo<CwGlSettleAndName>, CurrencyMeta> searchCwGlSettleAndNameForReverse(
						@RequestParam(value="nameLike",required=false) String nameLike,
						@RequestParam(value="periodLike",required=false) String periodLike,
						@RequestParam(value="issettle",required=false) String issettle,
	                    @RequestParam(value="settleUser",required=false) String settleUser,
	                    @RequestParam(value="settleTime",required=false) String settleTime,
						@RequestParam("pageNum") int pageNum,
			    		@RequestParam("pageSize") int pageSize,
			    		@RequestParam("navigatePages") int navigatePages){
					return cwGlSettleService.searchCwGlSettleAndNameForReverse(nameLike,periodLike,pageNum, pageSize, navigatePages,issettle,settleUser,settleTime);
		}
                /**
                 * 功能描述：初始化结账数据
                 * @return RestfulResponse<PageInfo<CwGlSettleAndName>,CurrencyMeta>
                 * @author xuxiao
                 * @date 2019年8月23日 上午11:17:43
                 * @修改日志：
                 */
                @ApiOperation(value = "初始化结账数据", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
                @ApiImplicitParam(name = "period", value = "会计期间", required = true, dataType = "String")
                @RequestMapping(value = { "/insertForSettle" }, method = RequestMethod.POST, consumes = MediaType.ALL_VALUE)
                public RestfulResponse<Object, CurrencyMeta> insertForSettle(
                		@RequestParam(value="period",required=true) String period){
                    return cwGlSettleService.insertForSettle(period);
                }
            	/**
            	 * 功能描述：记账数统计
            	 * @param nameLike
            	 * @param periodLike
            	 * @param pageNum
            	 * @param pageSize
            	 * @param navigatePages
            	 * @param issettle
            	 * @param settleUser
            	 * @param settleTime
            	 * @return RestfulResponse<PageInfo<CwGlSettleAndName>,CurrencyMeta>
            	 * @author dml
            	 * @date 2019年8月28日 下午9:19:25
            	 * @修改日志：
            	 */
            	@ApiOperation(value = "获取全部结账信息数据", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
            	@ApiImplicitParams({
            		@ApiImplicitParam(name = "nameLike", value = "账套模糊查询", required = false, dataType = "String", paramType="query"),
            		@ApiImplicitParam(name = "periodLike", value = "期间模糊查询", required = false, dataType = "String", paramType="query"),
                    @ApiImplicitParam(name = "issettle", value = "是否结账", required = false, dataType = "String", paramType="query"),
                    @ApiImplicitParam(name = "settleUser", value = "结账人", required = false, dataType = "String", paramType="query"),
                    @ApiImplicitParam(name = "settleTime", value = "结账时间", required = false, dataType = "String", paramType="query"),
                }) 
            	@RequestMapping(value = { "/countSettleTotal" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
            	public RestfulResponse<Object, CurrencyMeta> countSettleTotal(
            			@RequestParam(value="nameLike",required=false) String nameLike,
            			@RequestParam(value="periodLike",required=false) String periodLike,
                		@RequestParam(value="issettle",required=false) String issettle,
                		@RequestParam(value="settleUser",required=false) String settleUser,
                		@RequestParam(value="settleTime",required=false) String settleTime){
            		return cwGlSettleService.countSettleTotal(nameLike,periodLike
            				,issettle,settleUser,settleTime);
                 }
}
