Kaynağa Gözat

feature 代码提交

xiahan 1 hafta önce
ebeveyn
işleme
d2ef8c7538

+ 4 - 1
zhsw-common/src/main/java/com/rongwei/zhsw/system/config/ZHSWQuerySqlAdaptationInterceptor.java

@@ -126,6 +126,7 @@ public class ZHSWQuerySqlAdaptationInterceptor implements Interceptor {
         String schema = null;
         schema = ContextHolder.getValue("dsKey");
         if(StringUtils.isNotBlank(schema)){
+            logger.info("通过上下文对象获取到的schema: " + schema);
             return schema;
         }
 
@@ -142,6 +143,7 @@ public class ZHSWQuerySqlAdaptationInterceptor implements Interceptor {
 
         schema = request.getHeader("schema");
         if(StringUtils.isNotBlank(schema)) {
+            logger.info("通过请求头获取到的schema: " + schema);
             return schema;
         }
         String token = request.getHeader("token");
@@ -172,9 +174,10 @@ public class ZHSWQuerySqlAdaptationInterceptor implements Interceptor {
         Object tokenDskey = request.getAttribute(Constants.SAAS_LOGIN_TOKEN);
         if(tokenDskey != null && StringUtils.isNotBlank(tokenDskey.toString())){
             schema = (String) tokenDskey;
-            logger.info("通过请求属性获取到的schema:" + schema);
+            logger.info("通过请求属性获取到的schema: " + schema);
         }else {
             schema = getSchemaByToken(token);
+            logger.info("通过token解析出到的schema: " + schema);
         }
         System.out.println("Dskey:"+schema);
         Long endTime = System.currentTimeMillis();

+ 16 - 7
zhsw-common/src/main/java/com/rongwei/zhsw/system/service/impl/BillGenerationServiceImpl.java

@@ -78,7 +78,7 @@ public class BillGenerationServiceImpl {
     public void generateBill(List<SwWaterUsageEntryDo> swWaterUsageEntryDoList, Map<String, SwUserManagementDo> userMap) {
         String dsKey = ContextHolder.getValue("dsKey");
         log.info("dsKey:{}", dsKey);
-        log.debug("需要生成账单的抄表记录为:{}", swWaterUsageEntryDoList);
+        log.debug("需要生成账单的抄表记录为:{},条数为:{}", swWaterUsageEntryDoList,swWaterUsageEntryDoList.size());
         long asyncTasksStart = System.currentTimeMillis();
         // 对数据按照抄表日期排序
         List<SwWaterUsageEntryDo> collect = swWaterUsageEntryDoList.parallelStream()
@@ -148,12 +148,19 @@ public class BillGenerationServiceImpl {
                 saveUsageEntryList.add(usageEntryDo);
                 continue;
             }
-            try {
-                // 生成代缴费账单
-                swBillManagementUnpaidDo = produceBill(swUserManagementDo, swWaterUsageEntry, currentUser);
-            } catch (Exception e) {
-                e.printStackTrace();
-                log.error("缴费记录生成失败原因:{}", e.getMessage());
+            // 特殊处理 上次抄表数为1本次为0
+            if(BigDecimal.ZERO.compareTo(swWaterUsageEntry.getThisreading())==0 && BigDecimal.ONE.compareTo(swWaterUsageEntry.getLastreading())==0 ) {
+                log.debug("户号:{}上次抄表数为1本次为0", swWaterUsageEntry.getUsernumber());
+              // 不生成账单
+                usageEntryDo.setState("5");
+            }else{
+                try {
+                    // 生成代缴费账单
+                    swBillManagementUnpaidDo = produceBill(swUserManagementDo, swWaterUsageEntry, currentUser);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    log.error("缴费记录生成失败原因:{}", e.getMessage());
+                }
             }
 
             if (swBillManagementUnpaidDo == null) {
@@ -265,6 +272,8 @@ public class BillGenerationServiceImpl {
         if (waterPrice == null || waterPrice.compareTo(BigDecimal.ZERO) <= 0) {
             throw new CustomException("当前用户水价异常:" + waterPrice);
         }
+        // TODO at [ 2025-07-17】 xh: 考虑后续可能增加阶梯水价的逻辑
+
         BigDecimal meterMaxValue = swUserManagementDo.getMetermaxvalue();
         if (meterMaxValue == null || meterMaxValue.compareTo(BigDecimal.ZERO) <= 0) {
             throw new CustomException("当前用户表具最大度数异常:" + meterMaxValue);

+ 6 - 2
zhsw-common/src/main/java/com/rongwei/zhsw/system/service/impl/SwBillManagementUnpaidServiceImpl.java

@@ -235,7 +235,9 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
             paymentBatchId = SecurityUtil.getUUID();
             /**************实际应缴为0的数据**********************/
             // 实际应缴为0的账单信息
-            List<SwBillManagementUnpaidDo> noPaymentData = swBillManagementUnpaidDos.stream().filter(data -> data.getActualdue().compareTo(BigDecimal.ZERO) <= 0).collect(Collectors.toList());
+            List<SwBillManagementUnpaidDo> noPaymentData = swBillManagementUnpaidDos.stream()
+                    .filter(data -> data.getActualdue().compareTo(BigDecimal.ZERO) <= 0)
+                    .collect(Collectors.toList());
             noPaymentRequiredDataDispose(noPaymentData, currentUser, ownerInfo, swBillingRecordDoList, transferAccountDo);
             /**************实际应缴大于0的数据**********************/
             List<SwBillManagementUnpaidDo> paymentData = swBillManagementUnpaidDos.stream().filter(data -> data.getActualdue().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
@@ -251,7 +253,9 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
      * @param ownerInfo
      * @param transferAccountDo
      */
-    public void paymentRequiredDataDispose(List<SwBillManagementUnpaidDo> zeroDueData, SysUserVo currentUser, SwUserManagementDo ownerInfo, TransferAccountDo transferAccountDo, boolean isBalanceExceeded, BigDecimal billAmount, String paymentBatchId, List<SwBillManagementUnpaidDo> unpaidDos) {
+    public void paymentRequiredDataDispose(List<SwBillManagementUnpaidDo> zeroDueData, SysUserVo currentUser, SwUserManagementDo ownerInfo,
+                                           TransferAccountDo transferAccountDo, boolean isBalanceExceeded, BigDecimal billAmount,
+                                           String paymentBatchId, List<SwBillManagementUnpaidDo> unpaidDos) {
         SwBillManagementPaidDo paid;
         for (SwBillManagementUnpaidDo unpaidDo : zeroDueData) {
             if (isBalanceExceeded) {