package cn.superdesk.uniorder.controller.accounting.customer;


import cn.superdesk.uniorder.common.json.AnJsonUtils;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.controller.base.BaseController;
import cn.superdesk.uniorder.dto.param.accounting.AutoCreateScheduleTaskStatementOfAccountParam;
import cn.superdesk.uniorder.dto.param.accounting.AutoCreateScheduleTaskStatementOfAccountReportVo;
import cn.superdesk.uniorder.dubbo.consumer.accounting.customer.AccountingUnifiedCustomerDubboConsumerService;
import cn.superdesk.uniorder.dubbo.consumer.scheduler.SysQuartzScheduleTaskStatementOfAccountDubboConsumerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description: 客户结算-自动创建-对账单-商品维度
 * @Author: linjinyu
 * @CreateDate: 2020/12/16 下午3:56
 * @UpdateUser: linjinyu
 * @UpdateDate: 2020/12/16 下午3:56
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Api(value = "客户结算-自动创建-对账单-商品维度", tags = {"客户结算-自动创建-对账单-商品维度"})
@Slf4j
@RestController
@RequestMapping("/accounting/unified/customer/auto/dim/goods")
public class UnifiedCustomerAutoCreateAccountingDimGoodsController extends BaseController {

	@Autowired
	private AccountingUnifiedCustomerDubboConsumerService accountingUnifiedCustomerDubboConsumerService;

	@Autowired
	private SysQuartzScheduleTaskStatementOfAccountDubboConsumerService sysQuartzScheduleTaskStatementOfAccountDubboConsumerService;


	/**
	 * http://192.168.1.223:8089/web/accounting/unified/customer/auto/dim/goods/autoCreateScheduleTaskStatementOfAccount
	 *
	 * @param params
	 * @return
	 */
	@ApiOperation(value = "客户结算-自动-对账单 按条件 排列组合 生成任务-新版本 permutationAndCombinationAutoCreate")
	@RequestMapping(value = "/autoCreateScheduleTaskStatementOfAccount", method = RequestMethod.POST)
	@ResponseBody
	public R<AutoCreateScheduleTaskStatementOfAccountReportVo> autoCreateScheduleTaskStatementOfAccount(
			@RequestBody
//			@Valid
					AutoCreateScheduleTaskStatementOfAccountParam params) {

		log.info(AnJsonUtils.toJson(params));

		R<AutoCreateScheduleTaskStatementOfAccountReportVo> response = new R<>();

		Integer hasError = 0;
		if (null == params.getStartTime()) {

			hasError = 1;
		}

		if (null == params.getEndTime()) {
			hasError = 1;
		}

		if (hasError.equals(1)) {
			response.setCode(500);
			response.setMessage("账单周期不能为空");

			return response;
		}


//		SysConfig sysConfigConditions = BeanUtils.mapToBean(conditions,SysConfig.class);


		AutoCreateScheduleTaskStatementOfAccountReportVo report = sysQuartzScheduleTaskStatementOfAccountDubboConsumerService.autoCreateScheduleTaskStatementOfAccountDimGoods(getToken(), params);

		response.setData(report);

		return response;


	}


}
