/**
 * 
 */
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.CwGlTransferExec;
import com.dhcc.finance.main.model.CwGlTransferExecAndName;
import com.dhcc.finance.main.model.CwGlTransferExecDetail;
import com.dhcc.finance.main.model.CwGlTransferWeb;
import com.dhcc.finance.main.service.CwGlTransferExecService;
import com.esotericsoftware.minlog.Log;
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;

/**
 * @author hp
 *
 */
@RestController
@RequestMapping(value = MsConfigConsts.MS_API_PREFIX + CwGlTransferExecController.API_PREFIX, 
  	          produces = {MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE })
@Api(value = "结转信息controller", tags = { "结转信息操作接口" })
public class CwGlTransferExecController {
			// 结转信息操作接口地址前缀
			public static final String API_PREFIX = "/cw_gl_transfer_exec";
			
			@Autowired
			CwGlTransferExecService cwGlTransferExecService;
			

			/**
			 * 获取全部结转信息兼模糊查询
			 * @param nameLike
			 * @param pageNum
			 * @param pageSize
			 * @param navigatePages
			 * @return RestfulResponse<PageInfo<CwGlTransferExecAndName>,CurrencyMeta>
			 *@author huangpeng
			 *@date 2019年4月1日 下午8:37:50
			 *@修改日志：
			 */
			@ApiOperation(value = "获取全部结转信息数据", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
			@ApiImplicitParams({
				@ApiImplicitParam(name = "nameLike", value = "账套模糊查询", required = true, 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"),
		    }) 
			@RequestMapping(value = { "/searchCwGlTransferExecAndName" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
			public RestfulResponse<PageInfo<CwGlTransferExecAndName>, CurrencyMeta> searchCwGlTransferExecAndName(
					@RequestParam(value="nameLike") String nameLike,
					@RequestParam("pageNum") int pageNum,
		    		@RequestParam("pageSize") int pageSize,
		    		@RequestParam("navigatePages") int navigatePages){
				return cwGlTransferExecService.searchCwGlTransferExecAndName(nameLike,pageNum, pageSize, navigatePages);
	}
			/**
			 * 批量更新结转信息
			 * @param CwGlTransferExecs
			 * @return RestfulResponse<Object,CurrencyMeta>
			 *@author huangpeng
			 *@date 2019年4月2日 上午10:16:42
			 *@修改日志：
			 */
			@ApiOperation(value = "批量更新结转信息", notes = "批量更新结转信息", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
			@ApiImplicitParam(name = "CwGlTransferExec", value = "数据表名", required = true, dataType = "List")
			@RequestMapping(value = "/updateCwGlTransferExecForBatch", method = RequestMethod.PUT)
			public RestfulResponse<Object, CurrencyMeta> updateCwGlTransferExecForBatch(@RequestBody List<CwGlTransferWeb> CwGlTransferExecs ) {
				Log.info(CwGlTransferExecs.toString());
				return cwGlTransferExecService.updateCwGlTransferExecForBatch(CwGlTransferExecs);
			}
			/**
			 * 批量更新反结转信息
			 * @param CwGlTransferExecs
			 * @return RestfulResponse<Object,CurrencyMeta>
			 *@author huangpeng
			 *@date 2019年4月2日 上午10:16:42
			 *@修改日志：
			 */
			@ApiOperation(value = "批量更新反结转信息", notes = "批量更新结转信息", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
			@ApiImplicitParam(name = "CwGlTransferExec", value = "数据表名", required = true, dataType = "List")
			@RequestMapping(value = "/updateCwGlTransferExecForBatchReverse", method = RequestMethod.PUT)
			public RestfulResponse<Object, CurrencyMeta> updateCwGlTransferExecForBatchReverse(@RequestBody List<CwGlTransferExec> CwGlTransferExecs ) {
				return cwGlTransferExecService.updateCwGlTransferExecForBatchReverse(CwGlTransferExecs);
			}
			/**
			 * 获取全部反结转信息数据
			 * @param nameLike
			 * @param pkAccperiodLike
			 * @param pageNum
			 * @param pageSize
			 * @param navigatePages
			 * @return RestfulResponse<PageInfo<CwGlTransferExecAndName>,CurrencyMeta>
			 *@author huangpeng
			 *@date 2019年4月9日 下午8:54:21
			 *@修改日志：
			 */
			@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 = "pkAccperiodLike", value = "期间模糊查询", required = false, dataType = "String", paramType="query"),
				@ApiImplicitParam(name = "istransfer", value = "是否结转", required = false, dataType = "String", paramType="query"),
				@ApiImplicitParam(name = "transferUser", value = "结转人", required = false, dataType = "String", paramType="query"),
				@ApiImplicitParam(name = "transferTime", 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 = { "/searchCwGlTransferExecAndNameForReverse" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
			public RestfulResponse<PageInfo<CwGlTransferExecAndName>, CurrencyMeta> searchCwGlTransferExecAndNameForReverse(
					@RequestParam(value="nameLike",required=false) String nameLike,
					@RequestParam(value="pkAccperiodLike",required=false) String pkAccperiodLike,
					@RequestParam(value="istransfer",required=false) String istransfer,
					@RequestParam(value="transferUser",required=false) String transferUser,
					@RequestParam(value="transferTime",required=false) String transferTime,
					@RequestParam("pageNum") int pageNum,
		    		@RequestParam("pageSize") int pageSize,
		    		@RequestParam("navigatePages") int navigatePages){
				return cwGlTransferExecService.searchCwGlTransferExecAndNameForReverse(nameLike,pkAccperiodLike,pageNum, pageSize, navigatePages,istransfer,transferUser,transferTime);
	}
			/**
			 * 功能描述    初始化结转数据
			 * @param period
			 * @return RestfulResponse<Object,CurrencyMeta>
			 * @author xuxiao
			 * @date 2019年8月23日 上午10:06:23
			 * 修改日志
			 */
			@ApiOperation(value = "初始化结转数据", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,consumes = MediaType.ALL_VALUE)
			@ApiImplicitParam(name = "period", value = "会计期间", required = true, dataType = "String")
			@RequestMapping(value = "/insertForTransfer", method = RequestMethod.POST,consumes = MediaType.ALL_VALUE)
			public RestfulResponse<Object, CurrencyMeta> insertForTransfer(
					@RequestParam(value="period",required=true) String period){
				return cwGlTransferExecService.insertForTransfer(period);
			}
			/**
			 * 功能描述：结转统计
			 * @param nameLike
			 * @param pkAccperiodLike
			 * @param pageNum
			 * @param pageSize
			 * @param navigatePages
			 * @param istransfer
			 * @param transferUser
			 * @param transferTime
			 * @return RestfulResponse<PageInfo<CwGlTransferExecAndName>,CurrencyMeta>
			 * @author dml
			 * @date 2019年8月28日 下午9:53:23
			 * @修改日志：
			 */
			@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 = "pkAccperiodLike", value = "期间模糊查询", required = false, dataType = "String", paramType="query"),
		        @ApiImplicitParam(name = "istransfer", value = "是否结转", required = false, dataType = "String", paramType="query"),
		        @ApiImplicitParam(name = "transferUser", value = "结转人", required = false, dataType = "String", paramType="query"),
		        @ApiImplicitParam(name = "transferTime", value = "结转时间", required = false, dataType = "String", paramType="query"),
		    }) 
			@RequestMapping(value = { "/countTransferTotal" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
			public RestfulResponse<Object, CurrencyMeta>  countTransferTotal(
					@RequestParam(value="nameLike",required=false) String nameLike,
					@RequestParam(value="pkAccperiodLike",required=false) String pkAccperiodLike,
		    		@RequestParam(value="istransfer",required=false) String istransfer,
		    		@RequestParam(value="transferUser",required=false) String transferUser,
		    		@RequestParam(value="transferTime",required=false) String transferTime){
				return cwGlTransferExecService.countTransferTotal(nameLike,pkAccperiodLike,
						istransfer,transferUser,transferTime);
			}
			/**
			 * 功能描述 查询结转金额数据(收入费用)
			 *@param pkGlorgbook
			 *@param period
			 *@param pageNum
			 *@param pageSize
			 *@param navigatePages
			 *@return RestfulResponse<PageInfo<CwGlTransferAndSubjectName>,CurrencyMeta>
			 *@author huangpeng
			 *@date 2019年10月9日 下午2:07:41
			 *修改日志:
			 */
			@ApiOperation(value = "查询结转金额数据(收入费用)",notes = "",produces = MediaType.APPLICATION_JSON_UTF8_VALUE,consumes = MediaType.ALL_VALUE)
			@ApiImplicitParams({
				@ApiImplicitParam(name = "pkGlorgbook", value = "账套id", required = false, dataType = "String", paramType="query"),
				@ApiImplicitParam(name = "period", value = "当前期间", required = false, dataType = "String", paramType="query"),
			})
			@RequestMapping(value = "/searchTransferForIncome", method = RequestMethod.GET,consumes = MediaType.ALL_VALUE)
			public RestfulResponse<List<CwGlTransferExecDetail>, CurrencyMeta> searchTransferForIncome(@RequestParam(value="pkGlorgbook") String pkGlorgbook,
					@RequestParam(value="period") String period){
				return cwGlTransferExecService.searchTransferForIncome(pkGlorgbook,period);
			}
			/**
			 * 批量更新结转信息
			 * @param CwGlTransferExecs
			 * @return RestfulResponse<Object,CurrencyMeta>
			 *@author huangpeng
			 *@date 2019年4月2日 上午10:16:42
			 *@修改日志：
			 */
			@ApiOperation(value = "利润结转", notes = "批量更新结转信息", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
			@ApiImplicitParam(name = "CwGlTransferWeb", value = "数据表名", required = true, dataType = "List")
			@RequestMapping(value = "/updateCwGlTransferExecForProfit", method = RequestMethod.PUT)
			public RestfulResponse<Object, CurrencyMeta> updateCwGlTransferExecForProfit(@RequestBody List<CwGlTransferWeb> CwGlTransferExecs ) {
				return cwGlTransferExecService.updateCwGlTransferExecForProfit(CwGlTransferExecs);
			}
}
