/**
 * 
 */
package com.dhcc.finance.main.controller;

import java.text.ParseException;
import java.util.List;

import org.apache.commons.lang.StringUtils;
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.CwBdGlorgbook;
import com.dhcc.finance.main.model.CwBdGlorgbookAndOther;
import com.dhcc.finance.main.model.CwBdGlorgbookLike;
import com.dhcc.finance.main.model.CwGlTransferWeb;
import com.dhcc.finance.main.service.CwBdGlorgbookService;
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 + CwBdGlorgbookContrller.API_PREFIX, 
  	          produces = {MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE })
@Api(value = "账套管理controller", tags = { "账套管理操作接口" })
public class CwBdGlorgbookContrller {
	// 账套管理哦操作接口地址前缀
		public static final String API_PREFIX = "/cw_bd_glorgbook";
		
		@Autowired
		CwBdGlorgbookService cwBdGlorgbookService;
		/**
		 * 
		 * @param nameLike
		 * @param pkAccperiod
		 * @param pageNum
		 * @param pageSize
		 * @param navigatePages
		 * @return RestfulResponse<PageInfo<CwBdGlorgbookAndOther>,CurrencyMeta>
		 *@author huangpeng
		 *@date 2019年3月30日 上午11:02:40
		 *@修改日志：
		 */
		@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 = "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 = { "/searchCwBdGlorgbookAndOther" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
		public RestfulResponse<PageInfo<CwBdGlorgbookAndOther>, CurrencyMeta> searchCwBdGlorgbookAndOther(
				@RequestParam(value="nameLike",required=false) String nameLike,
				@RequestParam(value="pkAccperiodLike",required=false) String pkAccperiodLike,
				@RequestParam("pageNum") int pageNum,
	    		@RequestParam("pageSize") int pageSize,
	    		@RequestParam("navigatePages") int navigatePages){
			CwBdGlorgbookLike cwBdGlorgbookLike = new CwBdGlorgbookLike();
			cwBdGlorgbookLike.setNameLike(StringUtils.isEmpty(nameLike)?null:nameLike);
			cwBdGlorgbookLike.setPkAccperiodLike(StringUtils.isEmpty(pkAccperiodLike)?null:pkAccperiodLike);
			return cwBdGlorgbookService.searchCwBdGlorgbookAndOther(cwBdGlorgbookLike,pageNum, pageSize, navigatePages);
}
		/**
		 * 逻辑删除账套
		 * @param pkGlorgbook
		 * @return RestfulResponse<Object,CurrencyMeta>
		 *@author huangpeng
		 *@date 2019年3月30日 下午12:01:58
		 *@修改日志：
		 */
		@ApiOperation(value = "逻辑删除账套", notes = "删除账套", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
		@ApiImplicitParam(name = "pkGlorgbook", value = "账套主键", required = true, dataType = "String")
		@RequestMapping(value = "/deleteCwBdGlorgbook", method = RequestMethod.DELETE , consumes = MediaType.ALL_VALUE)
		public RestfulResponse<Object, CurrencyMeta> deleteCwBdGlorgbookByPk(@RequestParam("pkGlorgbook") String pkGlorgbook){
			return cwBdGlorgbookService.deleteCwBdGlorgbookByPk(pkGlorgbook);
		}
		/**
		 * 新增账套数据
		 * @param cwBdAccass
		 * @return RestfulResponse<Object,CurrencyMeta>
		 *@author huangpeng
		 *@date 2019年3月30日 下午12:06:52
		 *@修改日志：
		 */
		@ApiOperation(value = "新增账套数据", notes = "新增账套数据", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
		@ApiImplicitParam(name = "CwBdGlorgbook", value = "账套管理数据", required = true, dataType = "CwBdGlorgbook")
		@RequestMapping(value = "/addCwBdGlorgbook", method = RequestMethod.POST)
		RestfulResponse<Object, CurrencyMeta> addCwBdGlorgbook(@RequestBody CwBdGlorgbook CwBdGlorgbook){
			return cwBdGlorgbookService.addCwBdGlorgbook(CwBdGlorgbook);
		}
		/**
		 * 修改账套数据
		 * @param CwBdGlorgbook
		 * @return RestfulResponse<Object,CurrencyMeta>
		 *@author huangpeng
		 * @throws ParseException 
		 *@date 2019年3月30日 下午2:58:21
		 *@修改日志：
		 */
		@ApiOperation(value = "修改账套数据", notes = "修改账套数据", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
		@ApiImplicitParam(name = "CwBdGlorgbook", value = "账套管理数据", required = true, dataType = "CwBdGlorgbook")
		@RequestMapping(value = "/updateCwBdGlorgbook", method = RequestMethod.PUT)
		RestfulResponse<Object, CurrencyMeta> updateCwBdGlorgbook(@RequestBody CwBdGlorgbook CwBdGlorgbook,@RequestParam("pkCurrperiodBefore") String pkCurrperiodBefore) throws ParseException{
			return cwBdGlorgbookService.updateCwBdGlorgbook(CwBdGlorgbook, pkCurrperiodBefore);
		}
		/**
		 * 获取全部的账套信息
		 * @return RestfulResponse<List<CwBdGlorgbook>,CurrencyMeta>
		 *@author huangpeng
		 *@date 2019年4月8日 上午11:52:53
		 *@修改日志：
		 */
		@ApiOperation(value = "获取全部的账套信息", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,consumes = MediaType.ALL_VALUE)
		@RequestMapping(value = "/searchCwBdGlorgbookAllData", method = RequestMethod.GET,consumes = MediaType.ALL_VALUE)
		public RestfulResponse<List<CwBdGlorgbook>, CurrencyMeta> searchCwBdGlorgbookAllData() {
			return cwBdGlorgbookService.searchCwBdGlorgbookAllData();
		}
		/**
		 * (non-Javadoc) <br/> 
		 * Title: searchCwBdGlorgbookNowDayNuANDSum <br/>  
		 * Description: TODO 查询帐套今日新增数目和总数<br/> 
		 * @author lipeng
		 * @return  
		 */
		@ApiOperation(value = "查询帐套今日新增数目和总数", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
		@RequestMapping(value = { "/searchCwBdGlorgbookNowDayNuANDSum" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
		public RestfulResponse<Object, CurrencyMeta> searchCwBdGlorgbookNowDayNuANDSum(){
			return cwBdGlorgbookService.searchCwBdGlorgbookNowDayNuANDSum();
        }
		/**
		 * 功能描述 校验:当前日期是否允许生成凭证
		 *@param xtzxmbh
		 *@param makeDate
		 *@param tradeCode
		 *@return RestfulResponse<Object,CurrencyMeta>
		 *@author huangpeng
		 *@date 2019年8月30日 上午9:39:23
		 *修改日志:
		 */
		@ApiOperation(value = "校验:当前日期是否允许生成凭证(对外)", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
		@ApiImplicitParams({
			@ApiImplicitParam(name = "xtzxmbh", value = "信托子项目编号", required = true, dataType = "String", paramType="query"),
			@ApiImplicitParam(name = "makeDate", value = "制单日期", required = true, dataType = "String", paramType="query"),
			@ApiImplicitParam(name = "tradeCode", value = "交易码", required = false, dataType = "String", paramType="query"),
	    }) 
		@RequestMapping(value = "/selectCwBdGlorgbookIsCreate", method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
		public RestfulResponse<Object, CurrencyMeta> selectCwBdGlorgbookIsCreate(
				@RequestParam("xtzxmbh") String xtzxmbh,
				@RequestParam("makeDate") String makeDate,
				@RequestParam(value="tradeCode",required=false) String tradeCode){
			return cwBdGlorgbookService.selectCwBdGlorgbookIsCreate(xtzxmbh,makeDate,tradeCode);
		}
		
		/**
		 * 功能描述:批量校验多个子项目的制单日期是否在当前期间
		 * @param xtzxmbhs
		 * @param makeDate
		 * @param tradeCode
		 * @return RestfulResponse<Object,CurrencyMeta>
		 *@author likai
		 *@data 2020年4月27日下午1:33:25
		 *修改日志
		 */
		@ApiOperation(value = "批量校验多个子项目的制单日期是否在当前期间", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
		@ApiImplicitParams({
			@ApiImplicitParam(name = "xtzxmbhs", value = "信托子项目编号", required = true, dataType = "List<String>"),
	    }) 
		@RequestMapping(value = "/batchCheckCwBdGlorgbookIsCreate", method = RequestMethod.POST)
		public RestfulResponse<Object, CurrencyMeta> batchCheckCwBdGlorgbookIsCreate(
				@RequestBody List<String> xtzxmbhs,
				@RequestParam("makeDate") String makeDate,
				@RequestParam(value="tradeCode",required=false) String tradeCode){
			return cwBdGlorgbookService.batchCheckCwBdGlorgbookIsCreate(xtzxmbhs, makeDate, tradeCode);
		}
		/**
		 * Title: searchBdGlorgbooksbyXTzxmbh <br/>  
		 * Description: TODO 跟据信托子项目编号查询帐套主键信息<br/>
		 * @author lipeng 
		 * @param xtzxmbh
		 * @return RestfulResponse<CwBdGlorgbook,CurrencyMeta>
		 * @date 2019年8月6日 上午11:34:29
		 */
		@ApiOperation(value = "跟据信托子项目编号查询帐套主键信息", notes = "跟据信托子项目编号查询帐套主键信息", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
		@ApiImplicitParam(name = "xtzxmbh", value = "账套名称模糊查询", required = false, dataType = "String", paramType="query")
		@RequestMapping(value = "/searchBdGlorgbooksbyXTzxmbh", method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
		public RestfulResponse<CwBdGlorgbook, CurrencyMeta> searchBdGlorgbooksbyXTzxmbh(
				@RequestParam("xtzxmbh") String xtzxmbh){
			return cwBdGlorgbookService.searchBdGlorgbooksbyXTzxmbh(xtzxmbh);
		}
		/**
		 * 功能描述 获取全部版本信息列表下拉框
		 *@param nameLike
		 *@param pageNum
		 *@param pageSize
		 *@param navigatePages
		 *@return RestfulResponse<PageInfo<CwBdGlorgbook>,CurrencyMeta>
		 *@author huangpeng
		 *@date 2019年8月28日 上午9:21:38
		 *修改日志:
		 */
		@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 = "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 = { "/searchCwBdGlorgbookForSelect" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
		public RestfulResponse<PageInfo<CwBdGlorgbook>, CurrencyMeta> searchCwBdGlorgbookForSelect(
				@RequestParam(value="nameLike",required=false) String nameLike,
				@RequestParam("pageNum") int pageNum,
	    		@RequestParam("pageSize") int pageSize,
	    		@RequestParam("navigatePages") int navigatePages){
			return cwBdGlorgbookService.searchCwBdGlorgbookForSelect(nameLike,pageNum, pageSize, navigatePages);
}		
		/**
		 * 功能描述    校验:当前日期是否允许生成凭证
		 * @param xtzxmbh
		 * @param makeDate
		 * @return RestfulResponse<Object,CurrencyMeta>
		 * @author huangpeng
		 * @date 2019年7月25日 下午1:55:10
		 * 修改日志
		 */
		@ApiOperation(value = "校验:当前日期是否允许生成凭证(内部使用)", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
		@ApiImplicitParams({
			@ApiImplicitParam(name = "xtzxmbh", value = "信托子项目编号", required = true, dataType = "String", paramType="query"),
			@ApiImplicitParam(name = "makeDate", value = "制单日期", required = true, dataType = "String", paramType="query"),
	    }) 
		@RequestMapping(value = "/selectCwBdGlorgbookForLocal", method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
		public RestfulResponse<Object, CurrencyMeta> selectCwBdGlorgbookForLocal(
				@RequestParam("xtzxmbh") String xtzxmbh,
				@RequestParam("makeDate") String makeDate){
			return cwBdGlorgbookService.selectCwBdGlorgbookForLocal(xtzxmbh,makeDate);
		}
		/**
		 * 功能描述
		 *@param nameLike
		 *@param period
		 *@param pageNum
		 *@param pageSize
		 *@param navigatePages
		 *@return RestfulResponse<PageInfo<CwBdGlorgbookAndOther>,CurrencyMeta>
		 *@author huangpeng
		 *@date 2019年10月4日 上午10:49:41
		 *修改日志:
		 */
		@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 = "period", value = "启用期间模糊查询", required = false, dataType = "String", paramType="query"),
			@ApiImplicitParam(name = "userId", value = "核算会计", required = false, dataType = "String", paramType="query"),
			@ApiImplicitParam(name = "istransfer", 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")
	    }) 
		@RequestMapping(value = { "/searchCwBdGlorgbookofTransferDetail" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
		public RestfulResponse<PageInfo<CwGlTransferWeb>, CurrencyMeta> searchCwBdGlorgbookofTransferDetail(
				@RequestParam(value="nameLike",required=false) String nameLike,
				@RequestParam(value="period",required=false) String period,
				@RequestParam(value="userId",required=false) String userId,
				@RequestParam(value="istransfer",required=false) String istransfer,
				@RequestParam("pageNum") int pageNum,
	    		@RequestParam("pageSize") int pageSize,
	    		@RequestParam("navigatePages") int navigatePages){
			return cwBdGlorgbookService.searchCwBdGlorgbookofTransferDetail(nameLike,period,userId,istransfer,pageNum, pageSize, navigatePages);
}
		/**
		 * 功能描述
		 *@param nameLike
		 *@param period
		 *@param pageNum
		 *@param pageSize
		 *@param navigatePages
		 *@return RestfulResponse<PageInfo<CwBdGlorgbookAndOther>,CurrencyMeta>
		 *@author huangpeng
		 *@date 2019年10月4日 上午10:49:41
		 *修改日志:
		 */
		@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 = "period", value = "启用期间模糊查询", required = false, dataType = "String", paramType="query"),
			@ApiImplicitParam(name = "userId", 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")
	    }) 
		@RequestMapping(value = { "/searchCwBdGlorgbookofSettle" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
		public RestfulResponse<PageInfo<CwGlTransferWeb>, CurrencyMeta> searchCwBdGlorgbookofSettle(
				@RequestParam(value="nameLike",required=false) String nameLike,
				@RequestParam(value="period",required=false) String period,
				@RequestParam(value="userId",required=false) String userId,
				@RequestParam("pageNum") int pageNum,
	    		@RequestParam("pageSize") int pageSize,
	    		@RequestParam("navigatePages") int navigatePages){
			return cwBdGlorgbookService.searchCwBdGlorgbookofSettle(nameLike,period,userId,pageNum, pageSize, navigatePages);
}
}