From 0e0a373af02e073f6bd079873743c58fcd4251f3 Mon Sep 17 00:00:00 2001
From: wujianwei <wjw@11.com>
Date: 星期四, 02 四月 2026 13:38:07 +0800
Subject: [PATCH] 1.TMS 增加一个推送状态字段,记录是否推送成功 2.TMS 增加一个手动推送按钮,如果推送失败或者被驳回的账单可以二次手动推送

---
 tms/src/main/java/com/ruoyi/tms/service/impl/TmsReceivableFeeServiceImpl.java |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/tms/src/main/java/com/ruoyi/tms/service/impl/TmsReceivableFeeServiceImpl.java b/tms/src/main/java/com/ruoyi/tms/service/impl/TmsReceivableFeeServiceImpl.java
index 8bd2362..922e5f8 100644
--- a/tms/src/main/java/com/ruoyi/tms/service/impl/TmsReceivableFeeServiceImpl.java
+++ b/tms/src/main/java/com/ruoyi/tms/service/impl/TmsReceivableFeeServiceImpl.java
@@ -1,15 +1,33 @@
 package com.ruoyi.tms.service.impl;
 
+import java.io.File;
+import java.io.FileOutputStream;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.enums.SystemDataNoEnum;
+import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.DateUtils;
+
+import com.ruoyi.common.utils.file.DownloadExportUtil;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.config.RuoYiConfig;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.streaming.SXSSFSheet;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.apache.poi.xssf.usermodel.XSSFColor;
 import javax.annotation.Resource;
 
 import com.ruoyi.common.utils.SecurityUtils;
@@ -27,6 +45,8 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.scheduling.annotation.Async;
+import org.springframework.core.task.AsyncTaskExecutor;
+import org.springframework.core.task.SimpleAsyncTaskExecutor;
 import org.springframework.web.client.RestTemplate;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -71,7 +91,8 @@
     @Value("${custom.cwxtApi.url}")
     private String url;
 
-
+    @Autowired
+    private RedisCache redisCache;
     /**
      * 鏌ヨ搴旀敹璐圭敤
      *
@@ -151,6 +172,16 @@
             return selectTmsReceivableFeeList(tmsReceivableFee);
         });
     }
+
+
+
+
+
+
+
+
+
+
 
 
     /**
@@ -299,6 +330,7 @@
         tmsArBill.setSettledAmount(BigDecimal.ZERO);
         tmsArBill.setInvoiceStatus(0);
         tmsArBill.setStatus(0);
+        tmsArBill.setPushStatus(0); // 鍒濆鎺ㄩ�佺姸鎬侊細鏈帹閫�
         tmsArBill.setCreateBy(SecurityUtils.getUsername());
         tmsArBillMapper.insertTmsArBill(tmsArBill);
 
@@ -326,8 +358,9 @@
         }).collect(Collectors.toList());
         tmsArBillItemMapper.insertTmsArBillItemBatch(rmb);
 
-        //todo 鍚戝閮ㄧ郴缁熸帹閫佹暟鎹�
-        pushToExternalSystem(tmsArBill, tmsReceivableFees);
+        // 鍚戝閮ㄧ郴缁熸帹閫佹暟鎹�
+        AsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
+        executor.execute(() -> pushToExternalSystem(tmsArBill, tmsReceivableFees));
         
         return AjaxResult.success();
     }
@@ -409,14 +442,16 @@
                     amountStr.append(hkbAmount).append("娓竵");
                 }
                 feeMap.put("receivableAmountStr", amountStr.toString());
-                feeMap.put("status", "0");
+                feeMap.put("status", "1");
                 feeMap.put("remark", "");
                 
                 // 鏋勫缓feeDetails閮ㄥ垎
                 List<java.util.Map<String, Object>> feeDetailsList = new java.util.ArrayList<>();
                 List<TmsReceivableFeeItem> items = fee.getItems();
-                for (TmsReceivableFeeItem item : items) {
+                for (int j = 0; j < items.size(); j++) {
+                    TmsReceivableFeeItem item = items.get(j);
                     java.util.Map<String, Object> feeDetailMap = new java.util.HashMap<>();
+                    feeDetailMap.put("serialNumber", String.format("%03d", j + 1));
                     feeDetailMap.put("feeType", item.getFeeType());
                     feeDetailMap.put("feeName", item.getFeeName());
                     feeDetailMap.put("billingUnit", "娆�");
@@ -447,11 +482,20 @@
             // 鍙戦�丄PI璇锋眰
             ResponseEntity<String> response = restTemplate.exchange(apiUrl, HttpMethod.POST, entity, String.class);
             logger.info("鎺ㄩ�佹暟鎹埌澶栭儴绯荤粺鎴愬姛锛屽搷搴�: {}", response.getBody());
+            
+            // 鏇存柊鎺ㄩ�佺姸鎬佷负鎴愬姛
+            tmsArBill.setPushStatus(2);
+            tmsArBill.setPushTime(DateUtils.getNowDate());
+            tmsArBillMapper.updateTmsArBill(tmsArBill);
         } catch (Exception e) {
             logger.error("鎺ㄩ�佹暟鎹埌澶栭儴绯荤粺澶辫触锛岃处鍗旾D: {}, 瀹㈡埛: {}", 
                 tmsArBill.getId(), tmsArBill.getCustomerName(), e);
             logger.debug("鎺ㄩ�佸け璐ョ殑璇锋眰鏁版嵁: {}", JSON.toJSONString(requestBody));
-            // 鎺ㄩ�佸け璐ヤ笉褰卞搷涓绘祦绋嬶紝璁板綍鏃ュ織鍗冲彲
+            
+            // 鏇存柊鎺ㄩ�佺姸鎬佷负澶辫触
+            tmsArBill.setPushStatus(3);
+            tmsArBill.setPushTime(DateUtils.getNowDate());
+            tmsArBillMapper.updateTmsArBill(tmsArBill);
         }
     }
 

--
Gitblit v1.8.0