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

import com.brilliance.mda.runtime.mda.IStream;
import com.brilliance.mda.runtime.mda.impl.StreamImpl;
import com.brilliance.mda.runtime.mda.util.Decimals;
import com.brilliance.isc.common.setgll.vo.SetgllVo;
import com.brilliance.isc.common.vo.AbstractCommonVo;
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 java.math.BigDecimal;
import java.util.*;

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

@Data
@ApiModel(value = "账务信息", description = "账务信息")
@JsonIgnoreProperties(ignoreUnknown = true)
public class SetglgVo extends AbstractCommonVo {

    @ApiModelProperty(value = "", name = "mac", required = true)
    private String mac;

    @ApiModelProperty(value = "", name = "macold", required = true)
    private String macold;

    @ApiModelProperty(value = "", name = "maceog", required = true)
    private String maceog;

    @ApiModelProperty(value = "", name = "maceogold", required = true)
    private String maceogold;

    @ApiModelProperty(value = "外汇款专户过标识", name = "ffaflg", required = true)
    private String ffaflg = NULLSTR;

    @ApiModelProperty(value = "Total amount settled", name = "totamt", required = true)
    private BigDecimal totamt = Decimals.ZERO_SCALE2;

    @ApiModelProperty(value = "Currency of Keyammount", name = "keycur", required = true)
    private String keycur = NULLSTR;

    @ApiModelProperty(value = "Keyamount", name = "keyamt", required = true)
    private int keyamt;

    @ApiModelProperty(value = "Create empty line flag", name = "creemplinflg", required = true)
    private String creemplinflg = NULLSTR;

    @ApiModelProperty(value = "Info of Cache entries for external set amounts", name = "setglgamtcon", required = true)
    private IStream setglgamtcon = new StreamImpl();

    @ApiModelProperty(value = "Info of WRKSUM entries in Cache", name = "wrksumcon", required = true)
    private IStream wrksumcon = new StreamImpl();

    @ApiModelProperty(value = "Groups of", name = "gllgrpstm", required = true)
    private IStream gllgrpstm = new StreamImpl();

    @ApiModelProperty(value = "Default setting for GLLGRP", name = "gllgrpdftstm", required = true)
    private IStream gllgrpdftstm = new StreamImpl();

    @ApiModelProperty(value = "Value date for all lines of settlement", name = "allvaldat", required = true)
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date allvaldat;

    @ApiModelProperty(value = "Type of setting", name = "allvaldatflg", required = true)
    private String allvaldatflg = NULLSTR;

    @ApiModelProperty(value = "结算分录列表", name = "setgll", required = true)
    private List<SetgllVo> setgll;

    //当金额调大的时候 前端会提示信息 然后重算账务
    private boolean recalcSetglg = false;

    /**
     * 可用的报文对象
     * CIPS 202 756 400等
     */
    private List<MessageDetailVo> avlMsgDetial = null;

    /**
     * 待核查账号集合
     */
    private List<ActProVo> actPro = null;

    public void reset() {
        if (mac == null) {
            mac = NULLSTR;
        }
        if (macold == null) {
            macold = NULLSTR;
        }
        if (maceog == null) {
            maceog = NULLSTR;
        }
        if (maceogold == null) {
            maceogold = NULLSTR;
        }
        if (ffaflg == null) {
            ffaflg = NULLSTR;
        }
        if (totamt == null) {
            totamt = Decimals.ZERO_SCALE2;
        }
        if (keycur == null) {
            keycur = NULLSTR;
        }
        if (creemplinflg == null) {
            creemplinflg = NULLSTR;
        }

        if (setglgamtcon == null) {
            setglgamtcon = new StreamImpl();
        }
        if (wrksumcon == null) {
            wrksumcon = new StreamImpl();
        }
        if (gllgrpstm == null) {
            gllgrpstm = new StreamImpl();
        }
        if (gllgrpdftstm == null) {
            gllgrpdftstm = new StreamImpl();
        }
        if (allvaldatflg == null) {
            allvaldatflg = NULLSTR;
        }
        if (setgll == null) {
            setgll = new ArrayList<>();
        }
        setgll.forEach((value) -> {
            value.reset();
        });
        if (avlMsgDetial == null) {
            avlMsgDetial = new ArrayList<>();
        }
        if (actPro == null) {
            actPro = new ArrayList<>();
        }
    }
}
