package com.tofly.feesapi.sfgl.entity.vo;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.tofly.feesapi.common.MoneySerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.beanutils.PropertyUtils;

import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;


@Data
@ApiModel("水费计算结果VO")
public class SfJsJg {

    @ApiModelProperty(value = "应收水量", position = 5)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal yssl = BigDecimal.ZERO;

    @ApiModelProperty(value = "应收水费", position = 6)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal yssf = BigDecimal.ZERO;

    @ApiModelProperty(value = "应收污水费", position = 7)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal yswsf = BigDecimal.ZERO;

    @ApiModelProperty(value = "应收垃圾费", position = 8)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal ysljf = BigDecimal.ZERO;

    @ApiModelProperty(value = "应收水资源费", position = 11)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal ysszyf = BigDecimal.ZERO;

    @ApiModelProperty(value = "应收滞纳金", position = 9)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal znj = BigDecimal.ZERO;

    @ApiModelProperty(value = "应收金额", position = 10)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal ysje = BigDecimal.ZERO;

    @ApiModelProperty(value = "计算日期", position = 99)
    private Date jsrq;

    /**
     * 年度累计量(计算前）
     */
    @ApiModelProperty(value = "年度累计量(计算前）", position = 101)
    private BigDecimal jtzqljlJsq;

    /**
     * 年度累计量
     */
    @ApiModelProperty(value = "年度累计量", position = 102)
    private BigDecimal jtzqljl;

    /**
     * 阶梯标准（多人口阶梯）编码，bm_jtrk
     */
    @ApiModelProperty(value = "阶梯标准（多人口阶梯）编码，bm_jtrk", position = 103)
    private String rks;

    /**
     * 水量
     */
    @ApiModelProperty(value = "水量", position = 104)
    private BigDecimal sl;
    /**
     * 水价编码
     */
    @ApiModelProperty(value = "水价编码", position = 105)
    private String sjbm;

    /**
     * 水价
     */
    @ApiModelProperty(value = "水价", position = 111)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj;
    /**
     * 水费
     */
    @ApiModelProperty(value = "水费", position = 112)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sf;
    /**
     * 污水费单价
     */
    @ApiModelProperty(value = "污水费单价", position = 113)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal wsfdj;
    /**
     * 污水费
     */
    @ApiModelProperty(value = "污水费", position = 114)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal wsf;
    /**
     * 垃圾费单价
     */
    @ApiModelProperty(value = "垃圾费单价", position = 115)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal ljfdj;
    /**
     * 垃圾费
     */
    @ApiModelProperty(value = "垃圾费", position = 116)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal ljf;
    /**
     * 水资源费单价
     */
    @ApiModelProperty(value = "水资源费单价")
    private BigDecimal szyfDj = BigDecimal.ZERO;
    /**
     * 水资源费
     */
    @ApiModelProperty(value = "水资源费")
    private BigDecimal szyf = BigDecimal.ZERO;
    /**
     * 水价编码2（一表多价时存储）
     */
    @ApiModelProperty(value = "水价编码2（一表多价时存储）", position = 121)
    private String sjbm1;
    /**
     * 水价2（一表多价时存储）
     */
    @ApiModelProperty(value = "水价2（一表多价时存储）", position = 122)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj1;
    /**
     * 水量2（一表多价时存储）
     */
    @ApiModelProperty(value = "水量2（一表多价时存储）", position = 123)
    private BigDecimal sl1;
    /**
     * 水费2（一表多价时存储）
     */
    @ApiModelProperty(value = "水费2（一表多价时存储）", position = 124)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sf1;
    /**
     * 污水费单价2
     */
    @ApiModelProperty(value = "污水费单价2", position = 125)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal wsfdj1;
    /**
     * 污水费2
     */
    @ApiModelProperty(value = "污水费2", position = 126)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal wsf1;
    /**
     * 垃圾费单价2
     */
    @ApiModelProperty(value = "垃圾费单价2", position = 127)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal ljfdj1;
    /**
     * 垃圾费2
     */
    @ApiModelProperty(value = "垃圾费2", position = 128)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal ljf1;
    /**
     * 水资源费单价2
     */
    @ApiModelProperty(value = "水资源费单价2")
    private BigDecimal szyfDj1 = BigDecimal.ZERO;
    /**
     * 水资源费2
     */
    @ApiModelProperty(value = "水资源费2")
    private BigDecimal szyf1 = BigDecimal.ZERO;
    /**
     * 水价编码3（一表多价时存储）
     */
    @ApiModelProperty(value = "水价编码3（一表多价时存储）", position = 131)
    private String sjbm2;
    /**
     * 水价3（一表多价时存储）
     */
    @ApiModelProperty(value = "水价3（一表多价时存储）", position = 132)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj2;
    /**
     * 水量3（一表多价时存储）
     */
    @ApiModelProperty(value = "水量3（一表多价时存储）", position = 133)
    private BigDecimal sl2;
    /**
     * 水费3（一表多价时存储）
     */
    @ApiModelProperty(value = "水费3（一表多价时存储）", position = 134)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sf2;
    /**
     * 污水费单价3
     */
    @ApiModelProperty(value = "污水费单价3", position = 135)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal wsfdj2;
    /**
     * 污水费3
     */
    @ApiModelProperty(value = "污水费3", position = 136)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal wsf2;
    /**
     * 垃圾费单价3
     */
    @ApiModelProperty(value = "垃圾费单价3", position = 137)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal ljfdj2;
    /**
     * 垃圾费3
     */
    @ApiModelProperty(value = "垃圾费3", position = 138)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal ljf2;
    /**
     * 水资源费单价3
     */
    @ApiModelProperty(value = "水资源费单价3")
    private BigDecimal szyfDj2 = BigDecimal.ZERO;
    /**
     * 水资源费3
     */
    @ApiModelProperty(value = "水资源费3")
    private BigDecimal szyf2 = BigDecimal.ZERO;
    /**
     * 水价编码4（一表多价时存储）
     */
    @ApiModelProperty(value = "水价编码4（一表多价时存储）", position = 141)
    private String sjbm3;
    /**
     * 水价4（一表多价时存储）
     */
    @ApiModelProperty(value = "水价4（一表多价时存储）", position = 142)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj3;
    /**
     * 水量4（一表多价时存储）
     */
    @ApiModelProperty(value = "水量4（一表多价时存储）", position = 143)
    private BigDecimal sl3;
    /**
     * 水费4（一表多价时存储）
     */
    @ApiModelProperty(value = "水费4（一表多价时存储）")
    private BigDecimal sf3;
    /**
     * 污水费单价4
     */
    @ApiModelProperty(value = "污水费单价4")
    private BigDecimal wsfdj3;
    /**
     * 污水费4
     */
    @ApiModelProperty(value = "污水费4")
    private BigDecimal wsf3;
    /**
     * 垃圾费单价4
     */
    @ApiModelProperty(value = "垃圾费单价4")
    private BigDecimal ljfdj3;
    /**
     * 垃圾费4
     */
    @ApiModelProperty(value = "垃圾费4")
    private BigDecimal ljf3;
    /**
     * 水资源费单价4
     */
    @ApiModelProperty(value = "水资源费单价4")
    private BigDecimal szyfDj3 = BigDecimal.ZERO;
    /**
     * 水资源费4
     */
    @ApiModelProperty(value = "水资源费4")
    private BigDecimal szyf3 = BigDecimal.ZERO;

    @ApiModelProperty(value = "水价阶梯标志(0为非阶梯，1为阶梯)")
    private String sjjtbz;
    @ApiModelProperty(value = "水价阶梯标志1(0为非阶梯，1为阶梯)")
    private String sjjtbz1;
    @ApiModelProperty(value = "水价阶梯标志2(0为非阶梯，1为阶梯)")
    private String sjjtbz2;
    @ApiModelProperty(value = "水价阶梯标志3(0为非阶梯，1为阶梯)")
    private String sjjtbz3;


    @ApiModelProperty(value = "阶梯1水量", position = 151)
    private BigDecimal jt1sl;

    @ApiModelProperty(value = "阶梯1水价", position = 152)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal jt1sj;

    @ApiModelProperty(value = "阶梯1水费", position = 153)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal jt1sf;

    @ApiModelProperty(value = "阶梯2水量", position = 154)
    private BigDecimal jt2sl;

    @ApiModelProperty(value = "阶梯2水价", position = 155)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal jt2sj;

    @ApiModelProperty(value = "阶梯2水费", position = 156)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal jt2sf;

    @ApiModelProperty(value = "阶梯3水量", position = 157)
    private BigDecimal jt3sl;

    @ApiModelProperty(value = "阶梯3水价", position = 158)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal jt3sj;

    @ApiModelProperty(value = "阶梯3水费", position = 159)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal jt3sf;

    @ApiModelProperty(value = "阶梯4水量", position = 160)
    private BigDecimal jt4sl;

    @ApiModelProperty(value = "阶梯4水价", position = 161)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal jt4sj;

    @ApiModelProperty(value = "阶梯4水费", position = 162)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal jt4sf;

    /**
     * 水价2.阶梯1水量
     */
    @ApiModelProperty(value = "水价2.阶梯1水量", position = 201)
    private BigDecimal sj1Jt1sl;
    /**
     * 水价2.阶梯1水价
     */
    @ApiModelProperty(value = "水价2.阶梯1水价", position = 202)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj1Jt1sj;
    /**
     * 水价2.阶梯1水费
     */
    @ApiModelProperty(value = "水价2.阶梯1水费", position = 203)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj1Jt1sf;
    /**
     * 水价2.阶梯2水量
     */
    @ApiModelProperty(value = "水价2.阶梯2水量", position = 204)
    private BigDecimal sj1Jt2sl;
    /**
     * 水价2.阶梯2水价
     */
    @ApiModelProperty(value = "水价2.阶梯2水价", position = 205)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj1Jt2sj;
    /**
     * 水价2.阶梯2水费
     */
    @ApiModelProperty(value = "水价2.阶梯2水费", position = 206)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj1Jt2sf;
    /**
     * 水价2.阶梯3水量
     */
    @ApiModelProperty(value = "水价2.阶梯3水量", position = 207)
    private BigDecimal sj1Jt3sl;
    /**
     * 水价2.阶梯3水价
     */
    @ApiModelProperty(value = "水价2.阶梯3水价", position = 208)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj1Jt3sj;
    /**
     * 水价2.阶梯3水费
     */
    @ApiModelProperty(value = "水价2.阶梯3水费", position = 209)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj1Jt3sf;
    /**
     * 水价2.阶梯4水量
     */
    @ApiModelProperty(value = "水价2.阶梯4水量", position = 210)
    private BigDecimal sj1Jt4sl;
    /**
     * 水价2.阶梯4水费
     */
    @ApiModelProperty(value = "水价2.阶梯4水费", position = 211)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj1Jt4sf;
    /**
     * 水价2.阶梯4水价
     */
    @ApiModelProperty(value = "水价2.阶梯4水价", position = 212)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj1Jt4sj;
    /**
     * 水价3.阶梯1水量
     */
    @ApiModelProperty(value = "水价3.阶梯1水量", position = 301)
    private BigDecimal sj2Jt1sl;
    /**
     * 水价3.阶梯1水价
     */
    @ApiModelProperty(value = "水价3.阶梯1水价", position = 302)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj2Jt1sj;
    /**
     * 水价3.阶梯1水费
     */
    @ApiModelProperty(value = "水价3.阶梯1水费", position = 303)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj2Jt1sf;
    /**
     * 水价3.阶梯2水量
     */
    @ApiModelProperty(value = "水价3.阶梯2水量", position = 304)
    private BigDecimal sj2Jt2sl;
    /**
     * 水价3.阶梯2水价
     */
    @ApiModelProperty(value = "水价3.阶梯2水价", position = 305)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj2Jt2sj;
    /**
     * 水价3.阶梯2水费
     */
    @ApiModelProperty(value = "水价3.阶梯2水费", position = 306)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj2Jt2sf;
    /**
     * 水价3.阶梯3水量
     */
    @ApiModelProperty(value = "水价3.阶梯3水量", position = 307)
    private BigDecimal sj2Jt3sl;
    /**
     * 水价3.阶梯3水价
     */
    @ApiModelProperty(value = "水价3.阶梯3水价", position = 308)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj2Jt3sj;
    /**
     * 水价3.阶梯3水费
     */
    @ApiModelProperty(value = "水价3.阶梯3水费", position = 309)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj2Jt3sf;
    /**
     * 水价3.阶梯4水量
     */
    @ApiModelProperty(value = "水价3.阶梯4水量", position = 310)
    private BigDecimal sj2Jt4sl;
    /**
     * 水价3.阶梯4水价
     */
    @ApiModelProperty(value = "水价3.阶梯4水价", position = 311)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj2Jt4sj;
    /**
     * 水价3.阶梯4水费
     */
    @ApiModelProperty(value = "水价3.阶梯4水费", position = 312)
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal sj2Jt4sf;
    /**
     * 抄表计算标志（0正常单价，1一表多价，2阶梯,3 一表多价含阶梯，4超定额，5两高一剩；用于判断计价类型，处理显示水价）
     */
    @ApiModelProperty(value = "抄表计算标志（0正常单价，1一表多价，2阶梯,3 一表多价含阶梯，4超定额，5两高一剩；用于判断计价类型，处理显示水价）", position = 400)
    private String cbjsbz;
    /**
     * 抄表计算方式（正常单价计费，一表多价计费，阶梯计费, 一表多价含阶梯，超定额，两高一剩；用于查询显示）
     */
    @ApiModelProperty(value = "抄表计算方式（正常单价计费，一表多价计费，阶梯计费, 一表多价含阶梯，超定额，两高一剩；用于查询显示）", position = 400)
    private String cbjsfs;
    @ApiModelProperty(value = "补差金额")
    private BigDecimal bcje;
    @ApiModelProperty(value = "补差水量")
    private BigDecimal bcsl;
    @ApiModelProperty(value = "补差水费")
    private BigDecimal bcsf;
    @ApiModelProperty(value = "补差污水费")
    private BigDecimal bcwsf;
    @ApiModelProperty(value = "补差垃圾费")
    private BigDecimal bcljf;
    @ApiModelProperty(value = "补差水资源费")
    private BigDecimal bcszyf;
    @ApiModelProperty("优惠水量")
    @JsonSerialize(using = MoneySerializer.class)
    private BigDecimal yhsl = BigDecimal.ZERO;
    @ApiModelProperty("是否优惠：0否1是")
    private String isYh = "0";
    @ApiModelProperty("减免类型")
    private String jyType;
    @ApiModelProperty("收费标志")
    private String sfbz = "0";

    @ApiModelProperty(value = "应收二次加压费")
    private BigDecimal ysecjyf = BigDecimal.ZERO;

    @ApiModelProperty(value = "应收附加费")
    private BigDecimal ysfjf = BigDecimal.ZERO;

    @ApiModelProperty(value = "应收其它费")
    private BigDecimal ysqt = BigDecimal.ZERO;

    /**
     * 计算水量、水费增量
     *
     * @param scJg 上次计算结果
     */
    public void subtract(SfJsJg scJg) {
        Set<String> names = new LinkedHashSet<>();
        for (int i = 0; i < 4; i++) {
            names.add(i == 0 ? "sl" : "sl" + i);
        }
        for (int i = 0; i < 3; i++) {
            for (int j = 1; j < 5; j++) {
                names.add(i == 0 ? String.format("jt%ssl", j) : String.format("sj%sJt%ssl", i, j));
            }
        }
        names.forEach(name -> {
            BigDecimal diff = getDiff(this, scJg, name);
            try {
                PropertyUtils.setProperty(this, name, diff);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        for (int i = 0; i < 4; i++) {//水费
            String name1 = i == 0 ? "sj" : "sj" + i;
            String name2 = i == 0 ? "sl" : "sl" + i;
            String name3 = i == 0 ? "sf" : "sf" + i;
            jsJe(name1, name2, name3);
        }
        for (int i = 0; i < 3; i++) {
            for (int j = 1; j < 5; j++) {
                String name1 = i == 0 ? String.format("jt%ssj", j) : String.format("sj%sJt%ssj", i, j);
                String name2 = i == 0 ? String.format("jt%ssl", j) : String.format("sj%sJt%ssl", i, j);
                String name3 = i == 0 ? String.format("jt%ssf", j) : String.format("sj%sJt%ssf", i, j);
                jsJe(name1, name2, name3);
            }
        }
//        for (int i = 0; i < 4; i++) {//污水费
//            String name1 = i == 0 ? "wsfdj" : "wsfdj" + i;
//            String name2 = i == 0 ? "sl" : "sl" + i;
//            String name3 = i == 0 ? "wsf" : "wsf" + i;
//            jsJe(name1, name2, name3);
//        }
//        for (int i = 0; i < 4; i++) {//垃圾费
//            String name1 = i == 0 ? "ljfdj" : "ljfdj" + i;
//            String name2 = i == 0 ? "sl" : "sl" + i;
//            String name3 = i == 0 ? "ljf" : "ljf" + i;
//            jsJe(name1, name2, name3);
//        }
        try {
            for (int i = 0; i < 3; i++) {
                BigDecimal zsf = BigDecimal.ZERO;
                String sjjtbzname = i == 0 ? String.format("sjjtbz") : String.format("sjjtbz", i);
                if (PropertyUtils.getProperty(this, sjjtbzname).equals("1")) {
                    for (int j = 1; j < 5; j++) {
                        String name = i == 0 ? String.format("jt%ssf", j) : String.format("sj%sJt%ssf", i, j);
                        BigDecimal sf = (BigDecimal) PropertyUtils.getProperty(this, name);
                        if (sf != null) {
                            zsf = zsf.add(sf);
                        }
                    }
                } else {
                    String name = i == 0 ? "sf" : "sf" + i;
                    BigDecimal sf = (BigDecimal) PropertyUtils.getProperty(this, name);
                    if (sf != null) {
                        zsf = zsf.add(sf);
                    }
                }
                String name = i == 0 ? "sf" : "sf" + i;
                PropertyUtils.setProperty(this, name, zsf);
            }
            BigDecimal yssl0 = BigDecimal.ZERO;
            for (int i = 0; i < 4; i++) {
                String name = i == 0 ? "sl" : "sl" + i;
                BigDecimal sl0 = (BigDecimal) PropertyUtils.getProperty(this, name);
                if (sl0 != null) {
                    yssl0 = yssl0.add(sl0);
                }
            }
            PropertyUtils.setProperty(this, "yssl", yssl0);

            BigDecimal yssf0 = BigDecimal.ZERO;
            for (int i = 0; i < 4; i++) {
                String name = i == 0 ? "sf" : "sf" + i;
                BigDecimal sf0 = (BigDecimal) PropertyUtils.getProperty(this, name);
                if (sf0 != null) {
                    yssf0 = yssf0.add(sf0);
                }
            }
            PropertyUtils.setProperty(this, "yssf", yssf0);

//            BigDecimal yswsf = BigDecimal.ZERO;
//            for (int i = 0; i < 4; i++) {
//                String name = i == 0 ? "wsf" : "wsf" + i;
//                BigDecimal sf = (BigDecimal) PropertyUtils.getProperty(this, name);
//                if (sf != null) {
//                    yswsf = yswsf.add(sf);
//                }
//            }
//            PropertyUtils.setProperty(this, "yswsf", yswsf);

//            BigDecimal ysljf = BigDecimal.ZERO;
//            for (int i = 0; i < 4; i++) {
//                String name = i == 0 ? "ljf" : "ljf" + i;
//                BigDecimal sf = (BigDecimal) PropertyUtils.getProperty(this, name);
//                if (sf != null) {
//                    yswsf = yswsf.add(sf);
//                }
//            }
//            PropertyUtils.setProperty(this, "ysljf", ysljf);

            this.ysje = yssf.add(yswsf).add(ysljf);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void jsJe(String name1, String name2, String name3) {
        try {
            BigDecimal xValue = (BigDecimal) PropertyUtils.getProperty(this, name1);//单价
            BigDecimal yValue = (BigDecimal) PropertyUtils.getProperty(this, name2);//数量
            if (xValue != null && xValue.compareTo(BigDecimal.ZERO) > 0 && yValue != null) {
                PropertyUtils.setProperty(this, name3, xValue.multiply(yValue));
            }
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }

    private BigDecimal getDiff(SfJsJg x, SfJsJg y, String name) {
        try {
            Object xValue = PropertyUtils.getProperty(x, name);
            Object yValue = PropertyUtils.getProperty(y, name);
            if (xValue != null && yValue != null && xValue instanceof BigDecimal && yValue instanceof BigDecimal) {
                return ((BigDecimal) xValue).subtract(((BigDecimal) yValue));
            }
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
        return null;
    }
}