|
@@ -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 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);
|
|
|
+
|
|
|
+ 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 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);
|
|
|
-
|
|
|
- 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);
|
|
|
-
|
|
|
- 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);
|
|
|
+
|
|
|
+ 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) {
|