package cn.superdesk.uniorder.pattern.state.invoice.customer.invoiceInvoiced.isOverdue.context;

import cn.superdesk.uniorder.common.enums.invoice.InvoiceInvoicedIsOverdueEnum;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.invoice.customer.invoiced.InvoiceInvoiced;
import cn.superdesk.uniorder.dto.vo.invoice.customer.invoiced.InvoiceInvoicedExcelExportVo;
import cn.superdesk.uniorder.pattern.state.invoice.customer.invoiceInvoiced.isOverdue.state.InvoiceInvoicedFieldIsOverdueState;
import cn.superdesk.uniorder.pattern.state.invoice.customer.invoiceInvoiced.isOverdue.state.concrete.InvoiceInvoicedFieldIsOverdueConcreteState_0_正常;
import cn.superdesk.uniorder.pattern.state.invoice.customer.invoiceInvoiced.isOverdue.state.concrete.InvoiceInvoicedFieldIsOverdueConcreteState_1_逾期;
import lombok.Data;

/**
 * @Description: 简易状态机 星型结构
 * @Author: linjinyu
 * @CreateDate: 10/12/20 4:28 PM
 * @UpdateUser: linjinyu
 * @UpdateDate: 10/12/20 4:28 PM
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Data
public class InvoiceInvoicedFieldIsOverdueContext {

	private InvoiceInvoicedFieldIsOverdueState state_0_正常;
	private InvoiceInvoicedFieldIsOverdueState state_1_逾期;

	private InvoiceInvoicedFieldIsOverdueState state;

	private InvoiceInvoiced              entity;
	private InvoiceInvoicedExcelExportVo form;
	private LoginSysUser                 loginSysUser;


	public InvoiceInvoicedFieldIsOverdueContext(InvoiceInvoiced entity, InvoiceInvoicedExcelExportVo form, LoginSysUser loginSysUser) {

		this.state_0_正常 = new InvoiceInvoicedFieldIsOverdueConcreteState_0_正常(this);
		this.state_1_逾期 = new InvoiceInvoicedFieldIsOverdueConcreteState_1_逾期(this);


		this.entity = entity;
		this.form = form;
		this.loginSysUser = loginSysUser;

		switch (InvoiceInvoicedIsOverdueEnum.get(this.entity.getIsOverdue())) {

			case 正常:
				state = state_0_正常;
				break;
			case 逾期:
				state = state_1_逾期;
				break;

			default:
//				state = state_0_正常;
				break;

		}
	}

	// 正常(0, "正常"),
	public void opInitOrReset() {
		state.opInitOrReset();
	}

	// 逾期(1, "逾期"),
	public void opOverdued() {
		state.opOverdued();
	}


	@Override
	public String toString() {
		return "状态 :" + getState().getClass().getName();
	}
}
