package com.brilliance.isc.common.api.liaall.vo;

import com.brilliance.mda.runtime.mda.util.Decimals;
import com.brilliance.isc.bo.Cbb;
import com.brilliance.isc.common.liaall.vo.LiaallVo;
import com.brilliance.isc.common.liaall.vo.TenorSettleVo;
import com.brilliance.isc.common.liaallg.vo.LiaallgVo;
import com.brilliance.isc.common.liaccv.vo.LiaccvgVo;
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.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 LiaallRequest<T1 extends BizInfoVo, T2 extends BizAmdInfoVo> extends AbstractCommonVo {

    @ApiModelProperty(value = "当前交易码", name = "transName", required = true)
    private String transName = NULLSTR;

    @ApiModelProperty(value = "当前经办人员ID", name = "userId", required = true)
    private String userId = NULLSTR;

    @ApiModelProperty(value = "业务摘要信息", name = "rec", required = true)
    private T1 rec;

    @ApiModelProperty(value = "业务摘要修改信息", name = "rec", required = true)
    private T2 amdRec;

    @ApiModelProperty(value = "CBB列表", name = "cbsMap", required = true)
    private Map<String, Cbb> cbsMap;

    @ApiModelProperty(value = "交易角色参与方列表", name = "ptsList", required = true)
    private List<PtsptaVo> ptsList;

    @ApiModelProperty(value = "Liaallg列表", name = "liaallg", required = true)
    private List<LiaallgVo> liaallg;

    @ApiModelProperty(value = "Liaccvg列表", name = "liaccvg", required = true)
    private List<LiaccvgVo> liaccvg;

    @ApiModelProperty(value = "是否读过old数据", name = "oldredflg", required = true)
    private  String oldredflg = NULLSTR;

    private List<TenorSettleVo> tenorSettles;

    private BigDecimal tensetamt = Decimals.ZERO_SCALE2;

    private String tenset = NULLSTR;

    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date tensetmatdat;

    //表外试算计算模型
    @ApiModelProperty(hidden = true)
    private LiaallVo liaallVo;

    @Override
    public void reset() {
        if (rec == null) {
            rec = (T1) new BizInfoVo();
        }
        rec.reset();
        if (amdRec == null) {
            amdRec = (T2) new BizAmdInfoVo();
        }
        amdRec.reset();
        if (cbsMap == null) {
            cbsMap = new HashMap<>();
        }
        if (ptsList == null) {
            ptsList = new ArrayList<>();
        }
        ptsList.forEach(p -> p.reset());
        if (liaallg == null) {
            liaallg = new ArrayList<>();
        }
        liaallg.forEach(liaallgVo -> liaallgVo.reset());
        if (tenorSettles == null) {
            tenorSettles = new ArrayList<>();
        }
        if (liaallVo == null) {
            liaallVo = new LiaallVo(this);
        }
        liaallVo.reset();
    }
}
