package com.brilliance.isc.common.limmod.vo;

import com.brilliance.mda.runtime.mda.util.Decimals;
import com.brilliance.isc.bo.Cbb;
import com.brilliance.isc.bo.Lim;
import com.brilliance.isc.bo.Limtrn;
import com.brilliance.isc.bo.Lme;
import com.brilliance.isc.common.api.lim.vo.LimRequest;
import com.brilliance.isc.common.liaall.vo.LiaallVo;
import com.brilliance.isc.common.liaccv.vo.LiaccvVo;
import com.brilliance.isc.common.transaction.vo.TrnInfo;
import com.brilliance.isc.common.vo.AbstractCommonVo;
import com.brilliance.isc.common.vo.BizAmdInfoVo;
import com.brilliance.isc.common.vo.BizInfoVo;
import com.brilliance.isc.common.vo.PtsptaVo;
import com.brilliance.isc.vo.ErrorVo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import static com.brilliance.mda.runtime.mda.Constants.NULLSTR;

@NoArgsConstructor
@Data
@ApiModel(value = "额度信息", description = "额度信息")
@JsonIgnoreProperties(ignoreUnknown = true)
public class LimmodVo extends AbstractCommonVo {
    @ApiModelProperty(value = "credat", name = "credat", required = true)
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date credat;
    @ApiModelProperty(value = "到期日", name = "enddat", required = true)
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date enddat;
    @ApiModelProperty(value = "业务余额", name = "comamt", required = true)
    private BigDecimal comamt = Decimals.ZERO_SCALE2;
    @ApiModelProperty(value = "前手业务余额", name = "oldcomamt", required = true)
    private BigDecimal oldcomamt = Decimals.ZERO_SCALE2;
    @ApiModelProperty(value = "组合标志", name = "lmcflg", required = true)
    private String lmcflg = NULLSTR;
    @ApiModelProperty(value = "占用标志", name = "lmaflg", required = true)
    private String lmaflg = NULLSTR;
    @ApiModelProperty(value = "EXTID", name = "extid", required = true)
    private String extid = NULLSTR;
    @ApiModelProperty(value = "业务币种", name = "cur", required = true)
    private String cur = NULLSTR;
    @ApiModelProperty(value = "释放标志", name = "lmoflg", required = true)
    private String lmoflg = NULLSTR;
    @ApiModelProperty(value = "国结业务编号", name = "ownref", required = true)
    private String ownref = NULLSTR;
    @ApiModelProperty(value = "业务摘要信息", name = "rec", required = true)
    private BizInfoVo rec;
    /**
     * 父摘要信息
     */
    private BizInfoVo parentrec;
    @ApiModelProperty(value = "业务摘要信息", name = "amdrec", required = true)
    private BizAmdInfoVo amdRec;
    @ApiModelProperty(value = "CBB列表", name = "cbsMap", required = true)
    private Map<String, Cbb> cbsMap;

    private String accbranch;

    private PtsptaVo limptspta;

    private LimptsVo limpts;

    private List<LimgrdVo> limgrd;

    private List<LmegrdVo> lmegrd;

    private BigDecimal oldccvamt;

    private BigDecimal limamt;

    private String objtyp;

    //表外记账
    private LiaallVo liaall;
    //保证金
    private LiaccvVo liaccvVo;

    private String Ccvtyp;
    private BigDecimal ccvamt;
    private BigDecimal amt;

    private BigDecimal difamt;
    /**
     * 查询标志
     */
    private String type;
    /**
     * 同业标志
     */
    private String idtyp;
    /**
     * 双占的同业标志
     */
    private String idtyp2;
    /**
     * 客户号
     */
    private String ecifno;

    /**
     * 计算角色
     */
    private String wrkrol;

    private String intsta;

    private String trninr;

    private String orderinr;

    private String limref1;

    private String limref2;

    private String itfinr;

    //交易角色参与方列表
    private List ptsList;
    /**
     * 额度柜员用户
     */
    private String user;
    /**
     * 额度柜员机构
     */
    private String branch;
    /**
     * 额度查询信息
     */
    private LimQueryVo limQueryVo;
    /**
     * 界面额度查询信息
     */
    private LimQueryVo oldlimQueryVo;
    /**
     * 额度试算信息
     */
    private LimPreCalVo limPreCalVo;
    /**
     * 界面额度查询信息
     */
    private LimPreCalVo oldlimPreCalVo;
    /**
     * 额度占用
     */
    private LimOccVo limOccVo;
    /**
     * 错误信息
     */
    ErrorVo errorVo;

    /**
     * 额度表
     *
     * @param limRequest
     */
    private Lim lim;
    /**
     * 额度业务表
     */
    private Limtrn limtrn;
    /**
     * 额度明细表
     */
    private List<Lme> lmes;
    /**
     * 同业额度明细
     */
    private List<Lme> wrklmes;
    /**
     * 转授权列表
     */
    private List<ZsqInfoVo> zsqInfos;

    /**
     * 预警信息提示
     */
    private List<String> rw02ConfirmInfos;


    /**
     * 预警信息命中
     */
    private String rw02Rmatch;

    /**
     * 交易信息，收单行标志
     */
    private TrnInfo trnInfo;
    /**
     * cecm批量模型
     */
    private CecmBatchVo cecmBatchVo;

    public LimmodVo(LimRequest limRequest) {
        this.rec = limRequest.getRec();
        this.cbsMap = limRequest.getCbsMap();
        this.liaall = limRequest.getLiaall();
        this.liaccvVo = limRequest.getLiaccv();
        this.ptsList = limRequest.getPtsList();
        this.limpts = limRequest.getLimpts();
        this.trnInfo = limRequest.getTrnInfo();
        this.oldlimQueryVo = limRequest.getOldlimQueryVo();
        this.limQueryVo = limRequest.getLimQueryVo();
        this.limPreCalVo = limRequest.getLimPreCalVo();
        this.oldlimPreCalVo = limRequest.getLimPreCalVo();
    }

    public void reset() {
        if (liaall == null) {
            liaall = new LiaallVo();
        }
        liaall.reset();
        if (liaccvVo == null) {
            liaccvVo = new LiaccvVo();
        }
        liaccvVo.reset();

        if (limpts == null) {
            limpts = new LimptsVo();
        }
        limpts.reset();

        if (limPreCalVo == null) {
            limPreCalVo = new LimPreCalVo();
        }
        limPreCalVo.reset();
        if (limQueryVo == null) {
            limQueryVo = new LimQueryVo();
        }
        limQueryVo.reset();
        if (limOccVo == null) {
            limOccVo = new LimOccVo();
        }

        if (lim == null) {
            lim = new Lim();
        }
        if (lmes == null) {
            lmes = new ArrayList<>();
        }
        if (wrklmes == null) {
            wrklmes = new ArrayList<>();
        }
        if (limtrn == null) {
            limtrn = new Limtrn();
        }
        if (limptspta == null) {
            limptspta = new PtsptaVo();
        }
        if (trnInfo == null) {
            trnInfo = new TrnInfo();
        }
        if (errorVo == null) {
            errorVo = new ErrorVo();
        }
        if (cecmBatchVo == null) {
            cecmBatchVo = new CecmBatchVo();
        }
        cecmBatchVo.reset();
    }

}
