sen
2 天以前 7ed2a032d0724e68aec8af940f2ce0023a9f0eb7
tms/src/main/java/com/ruoyi/tms/service/impl/TmsPayableFeeServiceImpl.java
@@ -34,6 +34,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.annotation.DataSource;
@@ -302,6 +303,7 @@
        tmsApBill.setSettledAmount(BigDecimal.ZERO);
        tmsApBill.setInvoiceStatus(0);
        tmsApBill.setStatus(0);
        tmsApBill.setPushStatus(0); // 初始推送状态:未推送
        tmsApBill.setCreateBy(SecurityUtils.getUsername());
        tmsApBillMapper.insertTmsApBill(tmsApBill);
@@ -442,11 +444,31 @@
            // 发送API请求
            ResponseEntity<String> response = restTemplate.exchange(apiUrl, HttpMethod.POST, entity, String.class);
            logger.info("推送应付数据到外部系统成功,响应: {}", response.getBody());
            // 解析响应,获取sourceSystemId
            try {
                JSONObject result = JSONObject.parseObject(response.getBody());
                String sourceSystemId = result.getString("sourceSystemId");
                if (sourceSystemId != null) {
                    tmsApBill.setSourceSystemId(Integer.parseInt(sourceSystemId));
                }
            } catch (Exception e) {
                logger.error("解析外部系统响应失败: {}", e.getMessage());
            }
            // 更新推送状态为成功
            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);
        }
    }