tms/src/main/java/com/ruoyi/tms/service/impl/TmsPayableFeeServiceImpl.java
@@ -20,6 +20,8 @@
import com.ruoyi.tms.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -300,6 +302,7 @@
        tmsApBill.setSettledAmount(BigDecimal.ZERO);
        tmsApBill.setInvoiceStatus(0);
        tmsApBill.setStatus(0);
        tmsApBill.setPushStatus(0); // 初始推送状态:未推送
        tmsApBill.setCreateBy(SecurityUtils.getUsername());
        tmsApBillMapper.insertTmsApBill(tmsApBill);
@@ -328,8 +331,9 @@
        }
        
        //向外部系统推送数据
        pushPayableToExternalSystem(tmsApBill, tmsPayableFeeList);
        AsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
        executor.execute(() -> pushPayableToExternalSystem(tmsApBill, tmsPayableFeeList));
        return AjaxResult.success();
    }
    
@@ -439,11 +443,20 @@
            // 发送API请求
            ResponseEntity<String> response = restTemplate.exchange(apiUrl, HttpMethod.POST, entity, String.class);
            logger.info("推送应付数据到外部系统成功,响应: {}", response.getBody());
            // 更新推送状态为成功
            tmsApBill.setPushStatus(2);
            tmsApBill.setPushTime(DateUtils.getNowDate());
            tmsApBillMapper.updateTmsApBill(tmsApBill);
        } catch (Exception e) {
            logger.error("推送应付数据到外部系统失败,账单ID: {}, 供应商: {}", 
                tmsApBill.getId(), tmsApBill.getServiceProviderName(), e);
            logger.debug("推送失败的请求数据: {}", JSON.toJSONString(requestBody));
            // 推送失败不影响主流程,记录日志即可
            // 更新推送状态为失败
            tmsApBill.setPushStatus(3);
            tmsApBill.setPushTime(DateUtils.getNowDate());
            tmsApBillMapper.updateTmsApBill(tmsApBill);
        }
    }