package cn.com.victorysoft.business.indicator.dto;

import cn.com.victorysoft.business.indicator.entity.MoreSummary;
import cn.com.victorysoft.business.indicator.entity.WellSectionMonth;
import cn.com.victorysoft.business.sys.param.UnitMonthParam;
import cn.com.victorysoft.business.util.DateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

import static cn.com.victorysoft.business.indicator.constant.Constants.*;

@ApiModel("超注统计返回对象")
@Data
public class MeasureCompareDto {

    @ApiModelProperty("单位代码")
    private String unitcode;

    @ApiModelProperty("单位名称")
    private String unitname;

    @ApiModelProperty("年月")
    private String month;

    @ApiModelProperty("单元名称")
    private String blockname;

    @ApiModelProperty("井号")
    private String wellname;

    @ApiModelProperty("层段序号")
    private Integer section;

    @ApiModelProperty("治理措施ID")
    private String measureId;

    @ApiModelProperty("治理措施名称")
    private String measureName;

    @ApiModelProperty("治理前层位")
    private String layerBefore;

    @ApiModelProperty("治理前水嘴")
    private String nozzleBefore;

    @ApiModelProperty("治理前泵压")
    private BigDecimal ppBefore;

    @ApiModelProperty("治理前套压")
    private BigDecimal pcBefore;

    @ApiModelProperty("治理前油压")
    private BigDecimal ptBefore;

    @ApiModelProperty("治理前配注")
    private BigDecimal planDailyWaterBefore;

    @ApiModelProperty("治理前实注")
    private BigDecimal dailyWaterBefore;

    @ApiModelProperty("治理前超/欠注水量")
    private BigDecimal diffWaterBefore;

    @ApiModelProperty("治理后层位")
    private String layerAfter;

    @ApiModelProperty("治理后水嘴")
    private String nozzleAfter;

    @ApiModelProperty("治理后泵压")
    private BigDecimal ppAfter;

    @ApiModelProperty("治理后套压")
    private BigDecimal pcAfter;

    @ApiModelProperty("治理后油压")
    private BigDecimal ptAfter;

    @ApiModelProperty("治理后配注")
    private BigDecimal planDailyWaterAfter;

    @ApiModelProperty("治理后实注")
    private BigDecimal dailyWaterAfter;

    @ApiModelProperty("全称")
    private String fullname;

    public boolean matchNextMonth(WellSectionMonth record) {
        String previousMonth = DateUtils.getPreviousMonth(record.getMonth(), 1);
        return this.getUnitcode().equals(record.getUnitcode())
                && this.getMonth().equals(previousMonth)
                && this.getSection().equals(record.getSection());
    }

    public void setBefore(WellSectionMonth record) {
        this.setUnitcode(record.getUnitcode());
        this.setUnitname(record.getUnitname());
        this.setFullname(record.getFullname());
        this.setMonth(record.getMonth());
        this.setSection(record.getSection());
        this.setBlockname(record.getBlockname());
        this.setWellname(record.getWellname());
        this.setMeasureId(record.getMeasureId());
        this.setMeasureName(record.getMeasureName());
        this.setLayerBefore(record.getLayer());
        this.setPlanDailyWaterBefore(record.getPlanDailyWater());
        this.setNozzleBefore(record.getNozzle());
        this.setPpBefore(record.getPp());
        this.setPcBefore(record.getPc());
        this.setPtBefore(record.getPt());
        this.setDailyWaterBefore(record.getDailyWater());
        this.setDiffWaterBefore(record.getDiffWater());
    }

    public void setAfter(WellSectionMonth record) {
        this.setLayerAfter(record.getLayer());
        this.setPlanDailyWaterAfter(record.getPlanDailyWater());
        this.setNozzleAfter(record.getNozzle());
        this.setPpAfter(record.getPp());
        this.setPcAfter(record.getPc());
        this.setPtAfter(record.getPt());
        this.setDailyWaterAfter(record.getDailyWater());
    }
}
