Browse Source

水费测算

hdc 1 year ago
parent
commit
42a3b86c95

+ 12 - 6
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/sfgl/controller/YyQfmxController.java

@@ -12,10 +12,8 @@ import com.tofly.feesapi.common.entity.vo.PageResult;
 import com.tofly.feesapi.common.util.GuidGenerator;
 import com.tofly.feesapi.security.model.CzyUserDetails;
 import com.tofly.feesapi.sfgl.entity.YyQfmx;
-import com.tofly.feesapi.sfgl.entity.dto.CbbSf;
-import com.tofly.feesapi.sfgl.entity.dto.SfBc;
-import com.tofly.feesapi.sfgl.entity.dto.YhSf;
-import com.tofly.feesapi.sfgl.entity.dto.YyQfmxFilter;
+import com.tofly.feesapi.sfgl.entity.dto.*;
+import com.tofly.feesapi.sfgl.entity.vo.SfJsJg;
 import com.tofly.feesapi.sfgl.entity.vo.YyQfmxSelect;
 import com.tofly.feesapi.sfgl.mapper.YyQfmxMapper;
 import com.tofly.feesapi.sfgl.service.YyQfmxService;
@@ -227,13 +225,21 @@ public class YyQfmxController {
         return result ? ResultRespone.success(true) : ResultRespone.failed(false);
     }
 
-    @ApiOperationSupport(order = 15)
+    @ApiOperationSupport(order = 16)
     @ApiOperation(value = "水费补差", tags = {"水费补差"})
     @PostMapping("sfbc")
-    public ResultRespone<Boolean> sfbc(@RequestBody SfBc sfBc,
+    public ResultRespone<Boolean> sfBc(@RequestBody SfBc sfBc,
                                        @ApiIgnore @AuthenticationPrincipal CzyUserDetails czyUserDetails) {
         boolean result = yyQfmxService.sfBc(sfBc, czyUserDetails);
         return result ? ResultRespone.success(true) : ResultRespone.failed(false);
     }
+    @ApiOperationSupport(order = 17)
+    @ApiOperation(value = "水费测算", tags = {"水费补差"})
+    @PostMapping("sfjs")
+    public ResultRespone<SfJsJg> sfJs(@RequestBody SfJs sfJs,
+                                      @ApiIgnore @AuthenticationPrincipal CzyUserDetails czyUserDetails) {
+        SfJsJg sfJsJg = yyQfmxService.sfJs(sfJs, czyUserDetails);
+        return ResultRespone.success(sfJsJg);
+    }
 
 }

+ 21 - 0
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/sfgl/entity/dto/SfJs.java

@@ -0,0 +1,21 @@
+package com.tofly.feesapi.sfgl.entity.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+
+@Data
+@ApiModel("水费计算DTO")
+public class SfJs {
+
+    @ApiModelProperty(value = "抄表卡ID", required = true, example = "625520431")
+    private String cbkid;
+
+    @ApiModelProperty(value = "水量", required = true, example = "89")
+    private BigDecimal sjsl = BigDecimal.ZERO;
+
+
+}

+ 349 - 0
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/sfgl/entity/vo/SfJsJg.java

@@ -0,0 +1,349 @@
+package com.tofly.feesapi.sfgl.entity.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+
+@Data
+@ApiModel("水费计算结果VO")
+public class SfJsJg {
+
+
+    @ApiModelProperty(value = "应收水量", position = 5)
+    private BigDecimal yssl = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "应收水费", position = 6)
+    private BigDecimal yssf = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "应收污水费", position = 7)
+    private BigDecimal yswsf = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "应收垃圾费", position = 8)
+    private BigDecimal ysljf = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "应收滞纳金", position = 9)
+    private BigDecimal znj = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "应收金额", position = 10)
+    private BigDecimal ysje = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "计算日期", position = 99)
+    private Date jsrq;
+
+    /**
+     * 年度累计量(计算前)
+     */
+    @ApiModelProperty(value = "年度累计量(计算前)", position = 100)
+    private BigDecimal jtzqljlJsq = BigDecimal.ZERO;
+
+    /**
+     * 年度累计量
+     */
+    @ApiModelProperty(value = "年度累计量", position = 100)
+    private BigDecimal jtzqljl = BigDecimal.ZERO;
+
+    /**
+     * 阶梯标准(多人口阶梯)编码,bm_jtrk
+     */
+    @ApiModelProperty(value = "阶梯标准(多人口阶梯)编码,bm_jtrk", position = 100)
+    private String rks;
+
+    /**
+     * 水量
+     */
+    @ApiModelProperty(value = "水量", position = 100)
+    private BigDecimal sl = BigDecimal.ZERO;
+    /**
+     * 水价编码
+     */
+    @ApiModelProperty(value = "水价编码", position = 100)
+    private String sjbm;
+    /**
+     * 水价
+     */
+    @ApiModelProperty(value = "水价", position = 100)
+    private BigDecimal sj = BigDecimal.ZERO;
+    /**
+     * 水费
+     */
+    @ApiModelProperty(value = "水费", position = 100)
+    private BigDecimal sf = BigDecimal.ZERO;
+    /**
+     * 污水费单价
+     */
+    @ApiModelProperty(value = "污水费单价", position = 100)
+    private BigDecimal wsfdj = BigDecimal.ZERO;
+    /**
+     * 污水费
+     */
+    @ApiModelProperty(value = "污水费", position = 100)
+    private BigDecimal wsf = BigDecimal.ZERO;
+    /**
+     * 垃圾费单价
+     */
+    @ApiModelProperty(value = "垃圾费单价", position = 100)
+    private BigDecimal ljfdj = BigDecimal.ZERO;
+    /**
+     * 垃圾费
+     */
+    @ApiModelProperty(value = "垃圾费", position = 100)
+    private BigDecimal ljf = BigDecimal.ZERO;
+    /**
+     * 水价编码2(一表多价时存储)
+     */
+    @ApiModelProperty(value = "水价编码2(一表多价时存储)", position = 100)
+    private String sjbm1;
+    /**
+     * 水价2(一表多价时存储)
+     */
+    @ApiModelProperty(value = "水价2(一表多价时存储)", position = 100)
+    private BigDecimal sj1 = BigDecimal.ZERO;
+    /**
+     * 水量2(一表多价时存储)
+     */
+    @ApiModelProperty(value = "水量2(一表多价时存储)", position = 100)
+    private BigDecimal sl1 = BigDecimal.ZERO;
+    /**
+     * 水费2(一表多价时存储)
+     */
+    @ApiModelProperty(value = "水费2(一表多价时存储)", position = 100)
+    private BigDecimal sf1 = BigDecimal.ZERO;
+    /**
+     * 污水费单价2
+     */
+    @ApiModelProperty(value = "污水费单价2", position = 100)
+    private BigDecimal wsfdj1 = BigDecimal.ZERO;
+    /**
+     * 污水费2
+     */
+    @ApiModelProperty(value = "污水费2", position = 100)
+    private BigDecimal wsf1 = BigDecimal.ZERO;
+    /**
+     * 垃圾费单价2
+     */
+    @ApiModelProperty(value = "垃圾费单价2", position = 100)
+    private BigDecimal ljfdj1 = BigDecimal.ZERO;
+    /**
+     * 垃圾费2
+     */
+    @ApiModelProperty(value = "垃圾费2", position = 100)
+    private BigDecimal ljf1 = BigDecimal.ZERO;
+    /**
+     * 水价编码3(一表多价时存储)
+     */
+    @ApiModelProperty(value = "水价编码3(一表多价时存储)", position = 100)
+    private String sjbm2;
+    /**
+     * 水价3(一表多价时存储)
+     */
+    @ApiModelProperty(value = "水价3(一表多价时存储)", position = 100)
+    private BigDecimal sj2 = BigDecimal.ZERO;
+    /**
+     * 水量3(一表多价时存储)
+     */
+    @ApiModelProperty(value = "水量3(一表多价时存储)", position = 100)
+    private BigDecimal sl2 = BigDecimal.ZERO;
+    /**
+     * 水费3(一表多价时存储)
+     */
+    @ApiModelProperty(value = "水费3(一表多价时存储)", position = 100)
+    private BigDecimal sf2 = BigDecimal.ZERO;
+    /**
+     * 污水费单价3
+     */
+    @ApiModelProperty(value = "污水费单价3", position = 100)
+    private BigDecimal wsfdj2 = BigDecimal.ZERO;
+    /**
+     * 污水费3
+     */
+    @ApiModelProperty(value = "污水费3", position = 100)
+    private BigDecimal wsf2 = BigDecimal.ZERO;
+    /**
+     * 垃圾费单价3
+     */
+    @ApiModelProperty(value = "垃圾费单价3", position = 100)
+    private BigDecimal ljfdj2 = BigDecimal.ZERO;
+    /**
+     * 垃圾费3
+     */
+    @ApiModelProperty(value = "垃圾费3", position = 100)
+    private BigDecimal ljf2 = BigDecimal.ZERO;
+    /**
+     * 水价编码4(一表多价时存储)
+     */
+    @ApiModelProperty(value = "水价编码4(一表多价时存储)", position = 100)
+    private String sjbm3;
+    /**
+     * 水价4(一表多价时存储)
+     */
+    @ApiModelProperty(value = "水价4(一表多价时存储)", position = 100)
+    private BigDecimal sj3 = BigDecimal.ZERO;
+    /**
+     * 水量4(一表多价时存储)
+     */
+    @ApiModelProperty(value = "水量4(一表多价时存储)", position = 100)
+    private BigDecimal sl3 = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "阶梯1水量", position = 100)
+    private BigDecimal jt1sl = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "阶梯1水价", position = 100)
+    private BigDecimal jt1sj = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "阶梯1水费", position = 100)
+    private BigDecimal jt1sf = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "阶梯2水量", position = 100)
+    private BigDecimal jt2sl = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "阶梯2水价", position = 100)
+    private BigDecimal jt2sj = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "阶梯2水费", position = 100)
+    private BigDecimal jt2sf = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "阶梯3水量", position = 100)
+    private BigDecimal jt3sl = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "阶梯3水价", position = 100)
+    private BigDecimal jt3sj = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "阶梯3水费", position = 100)
+    private BigDecimal jt3sf = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "阶梯4水量", position = 100)
+    private BigDecimal jt4sl = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "阶梯4水价", position = 100)
+    private BigDecimal jt4sj = BigDecimal.ZERO;
+
+    @ApiModelProperty(value = "阶梯4水费", position = 100)
+    private BigDecimal jt4sf = BigDecimal.ZERO;
+
+    /**
+     * 水价2.阶梯1水量
+     */
+    @ApiModelProperty(value = "水价2.阶梯1水量")
+    private BigDecimal sj1Jt1sl = BigDecimal.ZERO;
+    /**
+     * 水价2.阶梯1水价
+     */
+    @ApiModelProperty(value = "水价2.阶梯1水价")
+    private BigDecimal sj1Jt1sj = BigDecimal.ZERO;
+    /**
+     * 水价2.阶梯1水费
+     */
+    @ApiModelProperty(value = "水价2.阶梯1水费")
+    private BigDecimal sj1Jt1sf = BigDecimal.ZERO;
+    /**
+     * 水价2.阶梯2水量
+     */
+    @ApiModelProperty(value = "水价2.阶梯2水量")
+    private BigDecimal sj1Jt2sl = BigDecimal.ZERO;
+    /**
+     * 水价2.阶梯2水价
+     */
+    @ApiModelProperty(value = "水价2.阶梯2水价")
+    private BigDecimal sj1Jt2sj = BigDecimal.ZERO;
+    /**
+     * 水价2.阶梯2水费
+     */
+    @ApiModelProperty(value = "水价2.阶梯2水费")
+    private BigDecimal sj1Jt2sf = BigDecimal.ZERO;
+    /**
+     * 水价2.阶梯3水量
+     */
+    @ApiModelProperty(value = "水价2.阶梯3水量")
+    private BigDecimal sj1Jt3sl = BigDecimal.ZERO;
+    /**
+     * 水价2.阶梯3水价
+     */
+    @ApiModelProperty(value = "水价2.阶梯3水价")
+    private BigDecimal sj1Jt3sj = BigDecimal.ZERO;
+    /**
+     * 水价2.阶梯3水费
+     */
+    @ApiModelProperty(value = "水价2.阶梯3水费")
+    private BigDecimal sj1Jt3sf = BigDecimal.ZERO;
+    /**
+     * 水价2.阶梯4水量
+     */
+    @ApiModelProperty(value = "水价2.阶梯4水量")
+    private BigDecimal sj1Jt4sl = BigDecimal.ZERO;
+    /**
+     * 水价2.阶梯4水费
+     */
+    @ApiModelProperty(value = "水价2.阶梯4水费")
+    private BigDecimal sj1Jt4sf = BigDecimal.ZERO;
+    /**
+     * 水价2.阶梯4水价
+     */
+    @ApiModelProperty(value = "水价2.阶梯4水价")
+    private BigDecimal sj1Jt4sj = BigDecimal.ZERO;
+    /**
+     * 水价3.阶梯1水量
+     */
+    @ApiModelProperty(value = "水价3.阶梯1水量")
+    private BigDecimal sj2Jt1sl;
+    /**
+     * 水价3.阶梯1水价
+     */
+    @ApiModelProperty(value = "水价3.阶梯1水价")
+    private BigDecimal sj2Jt1sj = BigDecimal.ZERO;
+    /**
+     * 水价3.阶梯1水费
+     */
+    @ApiModelProperty(value = "水价3.阶梯1水费")
+    private BigDecimal sj2Jt1sf = BigDecimal.ZERO;
+    /**
+     * 水价3.阶梯2水量
+     */
+    @ApiModelProperty(value = "水价3.阶梯2水量")
+    private BigDecimal sj2Jt2sl = BigDecimal.ZERO;
+    /**
+     * 水价3.阶梯2水价
+     */
+    @ApiModelProperty(value = "水价3.阶梯2水价")
+    private BigDecimal sj2Jt2sj = BigDecimal.ZERO;
+    /**
+     * 水价3.阶梯2水费
+     */
+    @ApiModelProperty(value = "水价3.阶梯2水费")
+    private BigDecimal sj2Jt2sf = BigDecimal.ZERO;
+    /**
+     * 水价3.阶梯3水量
+     */
+    @ApiModelProperty(value = "水价3.阶梯3水量")
+    private BigDecimal sj2Jt3sl = BigDecimal.ZERO;
+    /**
+     * 水价3.阶梯3水价
+     */
+    @ApiModelProperty(value = "水价3.阶梯3水价")
+    private BigDecimal sj2Jt3sj = BigDecimal.ZERO;
+    /**
+     * 水价3.阶梯3水费
+     */
+    @ApiModelProperty(value = "水价3.阶梯3水费")
+    private BigDecimal sj2Jt3sf = BigDecimal.ZERO;
+    /**
+     * 水价3.阶梯4水量
+     */
+    @ApiModelProperty(value = "水价3.阶梯4水量")
+    private BigDecimal sj2Jt4sl = BigDecimal.ZERO;
+    /**
+     * 水价3.阶梯4水价
+     */
+    @ApiModelProperty(value = "水价3.阶梯4水价")
+    private BigDecimal sj2Jt4sj = BigDecimal.ZERO;
+    /**
+     * 水价3.阶梯4水费
+     */
+    @ApiModelProperty(value = "水价3.阶梯4水费")
+    private BigDecimal sj2Jt4sf = BigDecimal.ZERO;
+
+
+}

+ 10 - 4
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/sfgl/service/YyQfmxService.java

@@ -5,10 +5,8 @@ import com.tofly.feesapi.common.entity.dto.PageDto;
 import com.tofly.feesapi.common.entity.vo.PageResult;
 import com.tofly.feesapi.security.model.CzyUserDetails;
 import com.tofly.feesapi.sfgl.entity.YyQfmx;
-import com.tofly.feesapi.sfgl.entity.dto.CbbSf;
-import com.tofly.feesapi.sfgl.entity.dto.SfBc;
-import com.tofly.feesapi.sfgl.entity.dto.YhSf;
-import com.tofly.feesapi.sfgl.entity.dto.YyQfmxFilter;
+import com.tofly.feesapi.sfgl.entity.dto.*;
+import com.tofly.feesapi.sfgl.entity.vo.SfJsJg;
 import com.tofly.feesapi.sfgl.entity.vo.YyQfmxSelect;
 
 /**
@@ -42,4 +40,12 @@ public interface YyQfmxService extends IService<YyQfmx> {
      * @return
      */
     boolean sfBc(SfBc sfBc, CzyUserDetails czyUserDetails);
+
+    /**
+     * 水费测算
+     * @param sfJs
+     * @param czyUserDetails
+     * @return
+     */
+    SfJsJg sfJs(SfJs sfJs, CzyUserDetails czyUserDetails);
 }

+ 342 - 316
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/sfgl/service/impl/YyQfmxServiceImpl.java

@@ -20,6 +20,7 @@ import com.tofly.feesapi.common.exception.FeesException;
 import com.tofly.feesapi.security.model.CzyUserDetails;
 import com.tofly.feesapi.sfgl.entity.YyQfmx;
 import com.tofly.feesapi.sfgl.entity.dto.*;
+import com.tofly.feesapi.sfgl.entity.vo.SfJsJg;
 import com.tofly.feesapi.sfgl.entity.vo.YyQfmxSelect;
 import com.tofly.feesapi.sfgl.mapper.YyQfmxMapper;
 import com.tofly.feesapi.sfgl.service.YyQfmxService;
@@ -151,6 +152,294 @@ public class YyQfmxServiceImpl extends ServiceImpl<YyQfmxMapper, YyQfmx> impleme
         return this.save(bcQfmx);
     }
 
+    @Override
+    public SfJsJg sfJs(SfJs sfJs, CzyUserDetails czyUserDetails) {
+        String cbkid = sfJs.getCbkid();
+        BigDecimal sjsl = sfJs.getSjsl();
+        if (cbkid == null) throw new FeesException("抄表卡ID为空", FeesErrorCode.BUSINESS_ERROR);
+        List<YhCbkxx> list = cbkxxService.lambdaQuery()
+                .eq(YhCbkxx::getCbkid, cbkid).list();
+        if (list.isEmpty()) throw new FeesException("抄表卡不存在", FeesErrorCode.BUSINESS_ERROR);
+        sjCache();//缓存表价信息(计算前必须)
+        return sfJs(list.get(0), sjsl);
+    }
+
+    private SfJsJg sfJs(YhCbkxx cbkxx, BigDecimal sjsl) {
+        String cbkid = cbkxx.getCbkid();
+        SfJsJg sfJsJg = new SfJsJg();
+        Date now = new Date();
+        sfJsJg.setJsrq(now);
+        String ybdjbz = cbkxx.getYbdjbz();
+        if (StringUtils.isBlank(ybdjbz) || "0".equals(ybdjbz)) {
+            String sjbm = cbkxx.getSjbm();
+            if (StringUtils.isBlank(sjbm))
+                throw new FeesException(String.format("水价未配置:%s", cbkid), FeesErrorCode.BUSINESS_ERROR);
+            Sjmx sjmx = sfSf(sjsl, sjbm);
+            sfJsJg.setSjbm(sjbm);
+            sfJsJg.setYssl(sjmx.getYssl());
+            sfJsJg.setYssf(sjmx.getYssf());
+            sfJsJg.setYsje(sjmx.getYssf());
+            Sjmx.Jtmx jtmx = sjmx.getJtmx();
+            if (jtmx != null) {//非阶梯水价
+                sfJsJg.setSl(jtmx.getSl());
+                sfJsJg.setSj(jtmx.getSj());
+                sfJsJg.setSf(jtmx.getSf());
+            } else {//阶梯水价
+                Sjmx.Jtmx jtmx1 = sjmx.getJtmx1();
+                if (jtmx1 == null) {
+                    sfJsJg.setJt1sl(jtmx1.getSl());
+                    sfJsJg.setJt1sj(jtmx1.getSj());
+                    sfJsJg.setJt1sf(jtmx1.getSf());
+                }
+                Sjmx.Jtmx jtmx2 = sjmx.getJtmx2();
+                if (jtmx2 == null) {
+                    sfJsJg.setJt2sl(jtmx2.getSl());
+                    sfJsJg.setJt2sj(jtmx2.getSj());
+                    sfJsJg.setJt2sf(jtmx2.getSf());
+                }
+                Sjmx.Jtmx jtmx3 = sjmx.getJtmx3();
+                if (jtmx3 == null) {
+                    sfJsJg.setJt3sl(jtmx3.getSl());
+                    sfJsJg.setJt3sj(jtmx3.getSj());
+                    sfJsJg.setJt3sf(jtmx3.getSf());
+                }
+                Sjmx.Jtmx jtmx4 = sjmx.getJtmx4();
+                if (jtmx4 == null) {
+                    sfJsJg.setJt4sl(jtmx4.getSl());
+                    sfJsJg.setJt4sj(jtmx4.getSj());
+                    sfJsJg.setJt4sf(jtmx4.getSf());
+                }
+            }
+            log.info("{}:{}", cbkid, sjmx);
+        } else {
+            String sjbm1 = cbkxx.getSjbm1();
+            BigDecimal slbl1 = cbkxx.getSlbl1();
+            String sjbm2 = cbkxx.getSjbm2();
+            BigDecimal slbl2 = cbkxx.getSlbl2();
+            String sjbm3 = cbkxx.getSjbm3();
+            BigDecimal slbl3 = cbkxx.getSlbl3();
+
+            BigDecimal yssl = BigDecimal.ZERO;
+            BigDecimal yssf = BigDecimal.ZERO;
+            Sjmx sjmx1 = null;
+            Sjmx sjmx2 = null;
+            Sjmx sjmx3 = null;
+
+            //定量
+            BigDecimal sl1 = null;
+            BigDecimal sl2 = null;
+            BigDecimal sl3 = null;
+            //BigDecimal sl4 = null;
+            BigDecimal sysl = sjsl;//剩余水量
+            if (slbl1 != null && slbl1.compareTo(BigDecimal.ZERO) > 0 && StringUtils.isNotBlank(sjbm1)) {
+                if (slbl1.compareTo(BigDecimal.ONE) > 0) {//按量
+                    if (sysl.compareTo(slbl1) >= 0) {
+                        sl1 = slbl1;
+                        sysl = sysl.subtract(slbl1);
+                    } else {
+                        sl1 = sysl;
+                        sysl = BigDecimal.ZERO;
+                    }
+                }
+            }
+
+            if (slbl2 != null && slbl2.compareTo(BigDecimal.ZERO) > 0 && StringUtils.isNotBlank(sjbm2)) {
+                if (slbl2.compareTo(BigDecimal.ONE) > 0) {//按量
+                    if (sysl.compareTo(slbl2) >= 0) {
+                        sl2 = slbl2;
+                        sysl = sysl.subtract(slbl2);
+                    } else {
+                        sl2 = sysl;
+                        sysl = BigDecimal.ZERO;
+                    }
+                }
+            }
+
+            if (slbl3 != null && slbl3.compareTo(BigDecimal.ZERO) > 0 && StringUtils.isNotBlank(sjbm3)) {
+                if (slbl3.compareTo(BigDecimal.ONE) > 0) {//按量
+                    if (sysl.compareTo(slbl3) >= 0) {
+                        sl3 = slbl3;
+                        sysl = sysl.subtract(slbl3);
+                    } else {
+                        sl3 = sysl;
+                        sysl = BigDecimal.ZERO;
+                    }
+                }
+            }
+
+            BigDecimal sysl2 = sysl;//按量以外的剩余水量
+            if (slbl1 != null && slbl1.compareTo(BigDecimal.ZERO) > 0 && StringUtils.isNotBlank(sjbm1)) {
+                if (slbl1.compareTo(BigDecimal.ONE) <= 0) {//按比例
+                    sl1 = sysl2.multiply(slbl1);
+                    sysl = sysl.subtract(sl1);
+                }
+            }
+
+            if (slbl2 != null && slbl2.compareTo(BigDecimal.ZERO) > 0 && StringUtils.isNotBlank(sjbm2)) {
+                if (slbl2.compareTo(BigDecimal.ONE) <= 0) {//按比例
+                    sl2 = sysl2.multiply(slbl2);
+                    sysl = sysl.subtract(sl2);
+                }
+            }
+
+            if (slbl3 != null && slbl3.compareTo(BigDecimal.ZERO) > 0 && StringUtils.isNotBlank(sjbm3)) {
+                if (slbl3.compareTo(BigDecimal.ONE) <= 0) {//按比例
+                    sl3 = sysl2.multiply(slbl3);
+                    sysl = sysl.subtract(sl3);
+                }
+            }
+
+            if (slbl1 != null && slbl1.compareTo(BigDecimal.ZERO) == 0) {
+                sl1 = sysl;
+                sysl = BigDecimal.ZERO;
+            }
+            if (slbl2 != null && slbl2.compareTo(BigDecimal.ZERO) == 0) {
+                sl2 = sysl;
+                sysl = BigDecimal.ZERO;
+            }
+            if (slbl3 != null && slbl3.compareTo(BigDecimal.ZERO) == 0) {
+                sl3 = sysl;
+                sysl = BigDecimal.ZERO;
+            }
+
+            if (sysl.compareTo(BigDecimal.ZERO) > 0) {
+                throw new FeesException(String.format("一表多价有水量未进入计算,剩余水量=%s:%s", sysl, cbkid), FeesErrorCode.BUSINESS_ERROR);
+            }
+
+            if (sl1 != null) {
+                if (StringUtils.isBlank(sjbm1))
+                    throw new FeesException(String.format("水价1未配置:%s", cbkid), FeesErrorCode.BUSINESS_ERROR);
+                sjmx1 = sfSf(sl1, sjbm1);
+                yssl = yssl.add(sl1);
+
+                BigDecimal sf1 = sjmx1.getYssf();
+                yssf = yssf.add(sf1);
+                Sjmx.Jtmx jtmx = sjmx1.getJtmx();
+                if (jtmx != null) {//非阶梯
+                    sfJsJg.setSj(jtmx.getSj());
+                } else {
+                    Sjmx.Jtmx jtmx1 = sjmx1.getJtmx1();
+                    if (jtmx1 != null) {
+                        sfJsJg.setJt1sl(jtmx1.getSl());
+                        sfJsJg.setJt1sj(jtmx1.getSj());
+                        sfJsJg.setJt1sf(jtmx1.getSf());
+                    }
+                    Sjmx.Jtmx jtmx2 = sjmx1.getJtmx2();
+                    if (jtmx2 != null) {
+                        sfJsJg.setJt2sl(jtmx2.getSl());
+                        sfJsJg.setJt2sj(jtmx2.getSj());
+                        sfJsJg.setJt2sf(jtmx2.getSf());
+                    }
+                    Sjmx.Jtmx jtmx3 = sjmx1.getJtmx3();
+                    if (jtmx3 != null) {
+                        sfJsJg.setJt3sl(jtmx3.getSl());
+                        sfJsJg.setJt3sj(jtmx3.getSj());
+                        sfJsJg.setJt3sf(jtmx3.getSf());
+                    }
+                    Sjmx.Jtmx jtmx4 = sjmx1.getJtmx4();
+                    if (jtmx4 != null) {
+                        sfJsJg.setJt4sl(jtmx4.getSl());
+                        sfJsJg.setJt4sj(jtmx4.getSj());
+                        sfJsJg.setJt4sf(jtmx4.getSf());
+                    }
+                }
+                sfJsJg.setSjbm(sjbm1);
+                sfJsJg.setSl(sjmx1.getYssl());
+                sfJsJg.setSf(sjmx1.getYssf());
+            }
+
+            if (sl2 != null) {
+                if (StringUtils.isBlank(sjbm2))
+                    throw new FeesException(String.format("水价2未配置:%s", cbkid), FeesErrorCode.BUSINESS_ERROR);
+                sjmx2 = sfSf(sl2, sjbm2);
+
+                yssl = yssl.add(sl2);
+                BigDecimal sf2 = sjmx2.getYssf();
+                yssf = yssf.add(sf2);
+                Sjmx.Jtmx jtmx = sjmx2.getJtmx();
+                if (jtmx != null) {//非阶梯
+                    sfJsJg.setSj1(jtmx.getSj());
+                } else {
+                    Sjmx.Jtmx jtmx1 = sjmx2.getJtmx1();
+                    if (jtmx != null) {
+                        sfJsJg.setSj1Jt1sl(jtmx1.getSl());
+                        sfJsJg.setSj1Jt1sj(jtmx1.getSj());
+                        sfJsJg.setSj1Jt1sf(jtmx1.getSf());
+                    }
+                    Sjmx.Jtmx jtmx2 = sjmx1.getJtmx2();
+                    if (jtmx2 != null) {
+                        sfJsJg.setSj1Jt2sl(jtmx2.getSl());
+                        sfJsJg.setSj1Jt2sj(jtmx2.getSj());
+                        sfJsJg.setSj1Jt2sf(jtmx2.getSf());
+                    }
+                    Sjmx.Jtmx jtmx3 = sjmx1.getJtmx3();
+                    if (jtmx3 != null) {
+                        sfJsJg.setSj1Jt3sl(jtmx3.getSl());
+                        sfJsJg.setSj1Jt3sj(jtmx3.getSj());
+                        sfJsJg.setSj1Jt3sf(jtmx3.getSf());
+                    }
+                    Sjmx.Jtmx jtmx4 = sjmx1.getJtmx4();
+                    if (jtmx4 != null) {
+                        sfJsJg.setSj1Jt4sl(jtmx4.getSl());
+                        sfJsJg.setSj1Jt4sj(jtmx4.getSj());
+                        sfJsJg.setSj1Jt4sf(jtmx4.getSf());
+                    }
+                }
+                sfJsJg.setSjbm1(sjbm2);
+                sfJsJg.setSl1(sjmx2.getYssl());
+                sfJsJg.setSf1(sjmx2.getYssf());
+            }
+
+            if (sl3 != null) {
+                if (StringUtils.isBlank(sjbm2))
+                    throw new FeesException(String.format("水价3未配置:%s", cbkid), FeesErrorCode.BUSINESS_ERROR);
+                sjmx3 = sfSf(sl3, sjbm3);
+                yssl = yssl.add(sl3);
+                BigDecimal sf3 = sjmx3.getYssf();
+                yssf = yssf.add(sf3);
+                Sjmx.Jtmx jtmx = sjmx3.getJtmx();
+                if (jtmx != null) {//非阶梯
+                    sfJsJg.setSj2(jtmx.getSj());
+                } else {
+                    Sjmx.Jtmx jtmx1 = sjmx3.getJtmx1();
+                    if (jtmx1 != null) {
+                        sfJsJg.setSj2Jt1sl(jtmx1.getSl());
+                        sfJsJg.setSj2Jt1sj(jtmx1.getSj());
+                        sfJsJg.setSj2Jt1sf(jtmx1.getSf());
+                    }
+                    Sjmx.Jtmx jtmx2 = sjmx1.getJtmx2();
+                    if (jtmx2 != null) {
+                        sfJsJg.setSj2Jt2sl(jtmx2.getSl());
+                        sfJsJg.setSj2Jt2sj(jtmx2.getSj());
+                        sfJsJg.setSj2Jt2sf(jtmx2.getSf());
+                    }
+                    Sjmx.Jtmx jtmx3 = sjmx1.getJtmx3();
+                    if (jtmx3 != null) {
+                        sfJsJg.setSj2Jt3sl(jtmx3.getSl());
+                        sfJsJg.setSj2Jt3sj(jtmx3.getSj());
+                        sfJsJg.setSj2Jt3sf(jtmx3.getSf());
+                    }
+                    Sjmx.Jtmx jtmx4 = sjmx1.getJtmx4();
+                    if (jtmx4 != null) {
+                        sfJsJg.setSj2Jt4sl(jtmx4.getSl());
+                        sfJsJg.setSj2Jt4sj(jtmx4.getSj());
+                        sfJsJg.setSj2Jt4sf(jtmx4.getSf());
+                    }
+                }
+                sfJsJg.setSjbm2(sjbm3);
+                sfJsJg.setSl2(sjmx3.getYssl());
+                sfJsJg.setSf2(sjmx3.getYssf());
+            }
+
+            sfJsJg.setYssl(yssl);
+            sfJsJg.setYssf(yssf);
+            sfJsJg.setYsje(yssf);
+            //yyQfmxes.add(yyQfmx);
+            log.info("{}:{},{},{}", cbkid, sjmx1, sjmx2, sjmx3);
+        }
+        return sfJsJg;
+    }
+
     private final static Map<String, BmSj> sjCache = new HashMap<>();//水价缓存
 
     private void sjCache() {
@@ -187,282 +476,20 @@ public class YyQfmxServiceImpl extends ServiceImpl<YyQfmxMapper, YyQfmx> impleme
                         YhCbkxx::getWsfbz, YhCbkxx::getLjfbz)
                 .in(YhCbkxx::getCbkid, cblrMap.keySet()).list();
         Map<String, YhCbkxx> yhCbkxxMap = cbkxxes.stream().collect(Collectors.toMap(e -> e.getCbkid(), e -> e));
-        sjCache();
-        Date now = new Date();
+        sjCache();//缓存表价信息(计算前必须)
         int ret = transactionTemplate.execute(status -> {
             try {
                 cblrMap.forEach((cbkid, cblr) -> {
                     YhCbkxx cbkxx = yhCbkxxMap.get(cbkid);
                     if (cbkxx == null) return;
                     BigDecimal sjsl = cblr.getSl();
-                    String ybdjbz = cbkxx.getYbdjbz();
-                    ybdjbz = ybdjbz == null ? "0" : ybdjbz;
-                    if (!Arrays.asList("1", "0").contains(ybdjbz))
-                        return;
                     YyQfmx yyQfmx = new YyQfmx();
                     yyQfmx.setQflsbh(getQflsbh());
-                    yyQfmx.setJsrq(now);
+                    SfJsJg sfJsJg = sfJs(cbkxx, sjsl);
                     BeanUtils.copyProperties(cblr, yyQfmx, "sl");
-                    if ("0".equals(ybdjbz)) {
-                        String sjbm = cbkxx.getSjbm();
-                        Sjmx sjmx = sfSf(sjsl, sjbm);
-                        yyQfmx.setSjbm(sjbm);
-                        yyQfmx.setYssl(sjmx.getYssl());
-                        yyQfmx.setYssf(sjmx.getYssf());
-                        Sjmx.Jtmx jtmx = sjmx.getJtmx();
-                        if (jtmx != null) {//非阶梯水价
-                            yyQfmx.setSl(jtmx.getSl());
-                            yyQfmx.setSj(jtmx.getSj());
-                            yyQfmx.setSf(jtmx.getSf());
-                        } else {//阶梯水价
-                            Sjmx.Jtmx jtmx1 = sjmx.getJtmx1();
-                            if (jtmx1 == null) {
-                                yyQfmx.setJt1sl(jtmx1.getSl());
-                                yyQfmx.setJt1sj(jtmx1.getSj());
-                                yyQfmx.setJt1sf(jtmx1.getSf());
-                            }
-                            Sjmx.Jtmx jtmx2 = sjmx.getJtmx2();
-                            if (jtmx2 == null) {
-                                yyQfmx.setJt2sl(jtmx2.getSl());
-                                yyQfmx.setJt2sj(jtmx2.getSj());
-                                yyQfmx.setJt2sf(jtmx2.getSf());
-                            }
-                            Sjmx.Jtmx jtmx3 = sjmx.getJtmx3();
-                            if (jtmx3 == null) {
-                                yyQfmx.setJt3sl(jtmx3.getSl());
-                                yyQfmx.setJt3sj(jtmx3.getSj());
-                                yyQfmx.setJt3sf(jtmx3.getSf());
-                            }
-                            Sjmx.Jtmx jtmx4 = sjmx.getJtmx4();
-                            if (jtmx4 == null) {
-                                yyQfmx.setJt4sl(jtmx4.getSl());
-                                yyQfmx.setJt4sj(jtmx4.getSj());
-                                yyQfmx.setJt4sf(jtmx4.getSf());
-                            }
-                        }
-                        log.info("{}:{}", cbkid, sjmx);
-                    } else {
-                        String sjbm1 = cbkxx.getSjbm1();
-                        BigDecimal slbl1 = cbkxx.getSlbl1();
-                        String sjbm2 = cbkxx.getSjbm2();
-                        BigDecimal slbl2 = cbkxx.getSlbl2();
-                        String sjbm3 = cbkxx.getSjbm3();
-                        BigDecimal slbl3 = cbkxx.getSlbl3();
-
-                        BigDecimal yssl = BigDecimal.ZERO;
-                        BigDecimal yssf = BigDecimal.ZERO;
-                        Sjmx sjmx1 = null;
-                        Sjmx sjmx2 = null;
-                        Sjmx sjmx3 = null;
-
-                        //定量
-                        BigDecimal sl1 = null;
-                        BigDecimal sl2 = null;
-                        BigDecimal sl3 = null;
-                        //BigDecimal sl4 = null;
-                        BigDecimal sysl = sjsl;//剩余水量
-                        if (slbl1 != null && slbl1.compareTo(BigDecimal.ZERO) > 0 && StringUtils.isNotBlank(sjbm1)) {
-                            if (slbl1.compareTo(BigDecimal.ONE) > 0) {//按量
-                                if (sysl.compareTo(slbl1) >= 0) {
-                                    sl1 = slbl1;
-                                    sysl = sysl.subtract(slbl1);
-                                } else {
-                                    sl1 = sysl;
-                                    sysl = BigDecimal.ZERO;
-                                }
-                            }
-                        }
-
-                        if (slbl2 != null && slbl2.compareTo(BigDecimal.ZERO) > 0 && StringUtils.isNotBlank(sjbm2)) {
-                            if (slbl2.compareTo(BigDecimal.ONE) > 0) {//按量
-                                if (sysl.compareTo(slbl2) >= 0) {
-                                    sl2 = slbl2;
-                                    sysl = sysl.subtract(slbl2);
-                                } else {
-                                    sl2 = sysl;
-                                    sysl = BigDecimal.ZERO;
-                                }
-                            }
-                        }
-
-                        if (slbl3 != null && slbl3.compareTo(BigDecimal.ZERO) > 0 && StringUtils.isNotBlank(sjbm3)) {
-                            if (slbl3.compareTo(BigDecimal.ONE) > 0) {//按量
-                                if (sysl.compareTo(slbl3) >= 0) {
-                                    sl3 = slbl3;
-                                    sysl = sysl.subtract(slbl3);
-                                } else {
-                                    sl3 = sysl;
-                                    sysl = BigDecimal.ZERO;
-                                }
-                            }
-                        }
-
-                        if (slbl1 != null && slbl1.compareTo(BigDecimal.ZERO) > 0 && StringUtils.isNotBlank(sjbm1)) {
-                            if (slbl1.compareTo(BigDecimal.ONE) <= 0) {//按比例
-                                sl1 = sysl.multiply(slbl1);
-                                sysl = sysl.subtract(sl1);
-                            }
-                        }
-
-                        if (slbl2 != null && slbl2.compareTo(BigDecimal.ZERO) > 0 && StringUtils.isNotBlank(sjbm2)) {
-                            if (slbl2.compareTo(BigDecimal.ONE) <= 0) {//按比例
-                                sl2 = sysl.multiply(slbl2);
-                                sysl = sysl.subtract(sl2);
-                            }
-                        }
-
-                        if (slbl3 != null && slbl3.compareTo(BigDecimal.ZERO) > 0 && StringUtils.isNotBlank(sjbm3)) {
-                            if (slbl3.compareTo(BigDecimal.ONE) <= 0) {//按比例
-                                sl3 = sysl.multiply(slbl3);
-                                sysl = sysl.subtract(sl3);
-                            }
-                        }
-
-                        if (slbl1 != null && slbl1.compareTo(BigDecimal.ZERO) == 0) {
-                            sl1 = sysl;
-                            sysl = BigDecimal.ZERO;
-                        }
-                        if (slbl2 != null && slbl2.compareTo(BigDecimal.ZERO) == 0) {
-                            sl2 = sysl;
-                            sysl = BigDecimal.ZERO;
-                        }
-                        if (slbl3 != null && slbl3.compareTo(BigDecimal.ZERO) == 0) {
-                            sl3 = sysl;
-                            sysl = BigDecimal.ZERO;
-                        }
-
-                        if (sysl.compareTo(BigDecimal.ZERO) > 0) {
-                            throw new FeesException("一表多价算费完成,但还有水量未进入计算", FeesErrorCode.BUSINESS_ERROR);
-                        }
-
-                        if (sl1 != null) {
-                            sjmx1 = sfSf(sl1, sjbm1);
-                            yssl = yssl.add(sl1);
-
-                            BigDecimal sf1 = sjmx1.getYssf();
-                            yssf = yssf.add(sf1);
-                            Sjmx.Jtmx jtmx = sjmx1.getJtmx();
-                            if (jtmx != null) {//非阶梯
-                                yyQfmx.setSj(jtmx.getSj());
-                            } else {
-                                Sjmx.Jtmx jtmx1 = sjmx1.getJtmx1();
-                                if (jtmx1 == null) {
-                                    yyQfmx.setJt1sl(jtmx1.getSl());
-                                    yyQfmx.setJt1sj(jtmx1.getSj());
-                                    yyQfmx.setJt1sf(jtmx1.getSf());
-                                }
-                                Sjmx.Jtmx jtmx2 = sjmx1.getJtmx2();
-                                if (jtmx2 == null) {
-                                    yyQfmx.setJt2sl(jtmx2.getSl());
-                                    yyQfmx.setJt2sj(jtmx2.getSj());
-                                    yyQfmx.setJt2sf(jtmx2.getSf());
-                                }
-                                Sjmx.Jtmx jtmx3 = sjmx1.getJtmx3();
-                                if (jtmx3 == null) {
-                                    yyQfmx.setJt3sl(jtmx3.getSl());
-                                    yyQfmx.setJt3sj(jtmx3.getSj());
-                                    yyQfmx.setJt3sf(jtmx3.getSf());
-                                }
-                                Sjmx.Jtmx jtmx4 = sjmx1.getJtmx4();
-                                if (jtmx4 == null) {
-                                    yyQfmx.setJt4sl(jtmx4.getSl());
-                                    yyQfmx.setJt4sj(jtmx4.getSj());
-                                    yyQfmx.setJt4sf(jtmx4.getSf());
-                                }
-                            }
-                            yyQfmx.setSjbm(sjbm1);
-                            yyQfmx.setSl(sjmx1.getYssl());
-                            yyQfmx.setSf(sjmx1.getYssf());
-                        }
-
-                        if (sl2 != null) {
-                            sjmx2 = sfSf(sl2, sjbm2);
-
-                            yssl = yssl.add(sl2);
-                            BigDecimal sf2 = sjmx2.getYssf();
-                            yssf = yssf.add(sf2);
-                            Sjmx.Jtmx jtmx = sjmx2.getJtmx();
-                            if (jtmx != null) {//非阶梯
-                                yyQfmx.setSj1(jtmx.getSj());
-                            } else {
-                                Sjmx.Jtmx jtmx1 = sjmx2.getJtmx1();
-                                if (jtmx1 == null) {
-                                    yyQfmx.setSj1Jt1sl(jtmx1.getSl());
-                                    yyQfmx.setSj1Jt1sj(jtmx1.getSj());
-                                    yyQfmx.setSj1Jt1sf(jtmx1.getSf());
-                                }
-                                Sjmx.Jtmx jtmx2 = sjmx1.getJtmx2();
-                                if (jtmx2 == null) {
-                                    yyQfmx.setSj1Jt2sl(jtmx2.getSl());
-                                    yyQfmx.setSj1Jt2sj(jtmx2.getSj());
-                                    yyQfmx.setSj1Jt2sf(jtmx2.getSf());
-                                }
-                                Sjmx.Jtmx jtmx3 = sjmx1.getJtmx3();
-                                if (jtmx3 == null) {
-                                    yyQfmx.setSj1Jt3sl(jtmx3.getSl());
-                                    yyQfmx.setSj1Jt3sj(jtmx3.getSj());
-                                    yyQfmx.setSj1Jt3sf(jtmx3.getSf());
-                                }
-                                Sjmx.Jtmx jtmx4 = sjmx1.getJtmx4();
-                                if (jtmx4 == null) {
-                                    yyQfmx.setSj1Jt4sl(jtmx4.getSl());
-                                    yyQfmx.setSj1Jt4sj(jtmx4.getSj());
-                                    yyQfmx.setSj1Jt4sf(jtmx4.getSf());
-                                }
-                            }
-                            yyQfmx.setSjbm1(sjbm2);
-                            yyQfmx.setSl1(sjmx2.getYssl());
-                            yyQfmx.setSf1(sjmx2.getYssf());
-                        }
-
-                        if (sl3 != null) {
-                            sjmx3 = sfSf(sl3, sjbm3);
-                            yssl = yssl.add(sl3);
-                            BigDecimal sf3 = sjmx3.getYssf();
-                            yssf = yssf.add(sf3);
-                            Sjmx.Jtmx jtmx = sjmx3.getJtmx();
-                            if (jtmx != null) {//非阶梯
-                                yyQfmx.setSj2(jtmx.getSj());
-                            } else {
-                                Sjmx.Jtmx jtmx1 = sjmx3.getJtmx1();
-                                if (jtmx1 == null) {
-                                    yyQfmx.setSj2Jt1sl(jtmx1.getSl());
-                                    yyQfmx.setSj2Jt1sj(jtmx1.getSj());
-                                    yyQfmx.setSj2Jt1sf(jtmx1.getSf());
-                                }
-                                Sjmx.Jtmx jtmx2 = sjmx1.getJtmx2();
-                                if (jtmx2 == null) {
-                                    yyQfmx.setSj2Jt2sl(jtmx2.getSl());
-                                    yyQfmx.setSj2Jt2sj(jtmx2.getSj());
-                                    yyQfmx.setSj2Jt2sf(jtmx2.getSf());
-                                }
-                                Sjmx.Jtmx jtmx3 = sjmx1.getJtmx3();
-                                if (jtmx3 == null) {
-                                    yyQfmx.setSj2Jt3sl(jtmx3.getSl());
-                                    yyQfmx.setSj2Jt3sj(jtmx3.getSj());
-                                    yyQfmx.setSj2Jt3sf(jtmx3.getSf());
-                                }
-                                Sjmx.Jtmx jtmx4 = sjmx1.getJtmx4();
-                                if (jtmx4 == null) {
-                                    yyQfmx.setSj2Jt4sl(jtmx4.getSl());
-                                    yyQfmx.setSj2Jt4sj(jtmx4.getSj());
-                                    yyQfmx.setSj2Jt4sf(jtmx4.getSf());
-                                }
-                            }
-                            yyQfmx.setSjbm2(sjbm3);
-                            yyQfmx.setSl2(sjmx3.getYssl());
-                            yyQfmx.setSf2(sjmx3.getYssf());
-                        }
-
-                        yyQfmx.setYssl(yssl);
-                        yyQfmx.setYssf(yssf);
-                        yyQfmx.setYsje(yssf);
-                        //yyQfmxes.add(yyQfmx);
-                        log.info("{}:{},{},{}", cbkid, sjmx1, sjmx2, sjmx3);
-                    }
+                    BeanUtils.copyProperties(sfJsJg, yyQfmx);
                     this.save(yyQfmx);
                     cblrService.updateJsbz(cbkid);
-
                 });
 
                 return 1;
@@ -492,62 +519,61 @@ public class YyQfmxServiceImpl extends ServiceImpl<YyQfmxMapper, YyQfmx> impleme
      */
     private Sjmx sfSf(BigDecimal sl, String sjbm) {
         BmSj bmSj = sjCache.get(sjbm);
-        if (bmSj != null) {
-            String jtbz = bmSj.getJtbz();
-            if ("1".equals(jtbz)) {
-
-                Sjmx.Jtmx jtmx1 = null;
-                Sjmx.Jtmx jtmx2 = null;
-                Sjmx.Jtmx jtmx3 = null;
-                Sjmx.Jtmx jtmx4 = null;
-                BigDecimal yssl = BigDecimal.ZERO;
-                BigDecimal yssf = BigDecimal.ZERO;
-
-                BigDecimal jt1Zs = bmSj.getJt1Zs();
-                BigDecimal jt1Sj = bmSj.getJt1Sj();
-                BigDecimal sjJtZs = BigDecimal.ZERO;
-                if (isEnabled(jt1Zs)) {
-                    jtmx1 = getJtSf(sl, jt1Zs, jt1Sj, sjJtZs);
-                    sjJtZs = jt1Zs;
-                    yssl = yssl.add(jtmx1.getSl());
-                    yssf = yssf.add(jtmx1.getSf());
-                }
-
-                BigDecimal jt2Zs = bmSj.getJt2Zs();
-                BigDecimal jt2Sj = bmSj.getJt2Sj();
-                if (isEnabled(jt2Zs) && isEnabled(jt1Zs)) {
-                    jtmx2 = getJtSf(sl, jt2Zs, jt2Sj, sjJtZs);
-                    sjJtZs = jt2Zs;
-                    yssl = yssl.add(jtmx2.getSl());
-                    yssf = yssf.add(jtmx2.getSf());
-                }
+        if (bmSj == null) new FeesException("水价编码不存在", FeesErrorCode.BUSINESS_ERROR);
+        String jtbz = bmSj.getJtbz();
+        if ("1".equals(jtbz)) {
+
+            Sjmx.Jtmx jtmx1 = null;
+            Sjmx.Jtmx jtmx2 = null;
+            Sjmx.Jtmx jtmx3 = null;
+            Sjmx.Jtmx jtmx4 = null;
+            BigDecimal yssl = BigDecimal.ZERO;
+            BigDecimal yssf = BigDecimal.ZERO;
+
+            BigDecimal jt1Zs = bmSj.getJt1Zs();
+            BigDecimal jt1Sj = bmSj.getJt1Sj();
+            BigDecimal sjJtZs = BigDecimal.ZERO;
+            if (isEnabled(jt1Zs)) {
+                jtmx1 = getJtSf(sl, jt1Zs, jt1Sj, sjJtZs);
+                sjJtZs = jt1Zs;
+                yssl = yssl.add(jtmx1.getSl());
+                yssf = yssf.add(jtmx1.getSf());
+            }
 
-                BigDecimal jt3Zs = bmSj.getJt3Zs();
-                BigDecimal jt3Sj = bmSj.getJt3Sj();
-                if (isEnabled(jt3Zs) && isEnabled(jt2Zs)) {
-                    jtmx3 = getJtSf(sl, jt3Zs, jt3Sj, sjJtZs);
-                    sjJtZs = jt3Zs;
-                    yssl = yssl.add(jtmx3.getSl());
-                    yssf = yssf.add(jtmx3.getSf());
-                }
+            BigDecimal jt2Zs = bmSj.getJt2Zs();
+            BigDecimal jt2Sj = bmSj.getJt2Sj();
+            if (isEnabled(jt2Zs) && isEnabled(jt1Zs)) {
+                jtmx2 = getJtSf(sl, jt2Zs, jt2Sj, sjJtZs);
+                sjJtZs = jt2Zs;
+                yssl = yssl.add(jtmx2.getSl());
+                yssf = yssf.add(jtmx2.getSf());
+            }
 
-                BigDecimal jt4Zs = bmSj.getJt4Zs();
-                BigDecimal jt4Sj = bmSj.getJt4Sj();
-                if (isEnabled(jt4Zs) && isEnabled(jt3Zs)) {
-                    jtmx4 = getJtSf(sl, jt4Zs, jt4Sj, sjJtZs);
-                    //sjJtZs = jt4Zs;
-                    yssl = yssl.add(jtmx4.getSl());
-                    yssf = yssf.add(jtmx4.getSf());
-                }
+            BigDecimal jt3Zs = bmSj.getJt3Zs();
+            BigDecimal jt3Sj = bmSj.getJt3Sj();
+            if (isEnabled(jt3Zs) && isEnabled(jt2Zs)) {
+                jtmx3 = getJtSf(sl, jt3Zs, jt3Sj, sjJtZs);
+                sjJtZs = jt3Zs;
+                yssl = yssl.add(jtmx3.getSl());
+                yssf = yssf.add(jtmx3.getSf());
+            }
 
-                return new Sjmx(jtmx1, jtmx2, jtmx3, jtmx4, yssl, yssf);
-            } else {
-                BigDecimal sj = bmSj.getSj();
-                BigDecimal sf = sfSf(sl, sj);
-                return new Sjmx(sj, sl, sf);
+            BigDecimal jt4Zs = bmSj.getJt4Zs();
+            BigDecimal jt4Sj = bmSj.getJt4Sj();
+            if (isEnabled(jt4Zs) && isEnabled(jt3Zs)) {
+                jtmx4 = getJtSf(sl, jt4Zs, jt4Sj, sjJtZs);
+                //sjJtZs = jt4Zs;
+                yssl = yssl.add(jtmx4.getSl());
+                yssf = yssf.add(jtmx4.getSf());
             }
+
+            return new Sjmx(jtmx1, jtmx2, jtmx3, jtmx4, yssl, yssf);
+        } else {
+            BigDecimal sj = bmSj.getSj();
+            BigDecimal sf = sfSf(sl, sj);
+            return new Sjmx(sj, sl, sf);
         }
-        return new Sjmx(BigDecimal.ZERO, sl, BigDecimal.ZERO);
+
     }
 
     private boolean isEnabled(BigDecimal jtZs) {