From ba87fd72f14c5ed0caf14e9d8ff116d254a8c113 Mon Sep 17 00:00:00 2001
From: zhangback <zhangback@163.com>
Date: 星期四, 16 四月 2026 10:11:32 +0800
Subject: [PATCH] 新增线上配置

---
 tms/src/main/java/com/ruoyi/tms/service/impl/TmsArBillServiceImpl.java |  874 +++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 705 insertions(+), 169 deletions(-)

diff --git a/tms/src/main/java/com/ruoyi/tms/service/impl/TmsArBillServiceImpl.java b/tms/src/main/java/com/ruoyi/tms/service/impl/TmsArBillServiceImpl.java
index fb8e5a2..841d013 100644
--- a/tms/src/main/java/com/ruoyi/tms/service/impl/TmsArBillServiceImpl.java
+++ b/tms/src/main/java/com/ruoyi/tms/service/impl/TmsArBillServiceImpl.java
@@ -1,12 +1,12 @@
 package com.ruoyi.tms.service.impl;
 
-import java.util.List;
-
 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.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.DictUtils;
+import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.system.service.ISysConfigService;
 import com.ruoyi.tms.domain.*;
 import com.ruoyi.tms.mapper.*;
@@ -21,6 +21,7 @@
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
+import java.util.stream.Collectors;
 
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.stereotype.Service;
@@ -35,6 +36,17 @@
 
 import com.ruoyi.tms.service.ITmsArBillService;
 import com.ruoyi.common.core.text.Convert;
+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;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
 
 /**
  * 搴旀敹璐﹀崟Service涓氬姟灞傚鐞�
@@ -67,6 +79,12 @@
 
     @Resource
     private TmsDispatchOrderMapper tmsDispatchOrderMapper;
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Value("${custom.cwxtApi.url}")
+    private String url;
 
     /**
      * 鏌ヨ搴旀敹璐﹀崟
@@ -241,6 +259,268 @@
     }
 
     /**
+     * 鎵嬪姩鎺ㄩ�佸簲鏀惰处鍗曞埌澶栭儴绯荤粺
+     *
+     * @param id 搴旀敹璐﹀崟ID
+     * @return 缁撴灉
+     */
+    @Override
+    public void manualPushToExternalSystem(Integer id) {
+        TmsArBill tmsArBill = tmsArBillMapper.selectTmsArBillById(id);
+        if (tmsArBill == null) {
+            throw new RuntimeException("搴旀敹璐﹀崟涓嶅瓨鍦�");
+        }
+
+        // 鏌ヨ鍏宠仈鐨勫簲鏀惰垂鐢ㄥ垪琛�
+        List<TmsReceivableFee> tmsReceivableFees = tmsReceivableFeeMapper.selectList(new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<TmsReceivableFee>()
+                .eq(TmsReceivableFee::getBillRelationId, id)
+        );
+
+        // 涓烘瘡涓簲鏀惰垂鐢ㄥ姞杞芥槑缁�
+        for (TmsReceivableFee fee : tmsReceivableFees) {
+            List<TmsReceivableFeeItem> items = tmsReceivableFeeItemMapper.selectTmsReceivableFeeItemList(new TmsReceivableFeeItem() {
+                {
+                    setHeadId(fee.getId());
+                }
+            });
+            fee.setItems(items);
+        }
+
+        // 寮傛鎺ㄩ��
+        AsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
+        executor.execute(() -> pushToExternalSystem(tmsArBill, tmsReceivableFees));
+    }
+
+    @Override
+    public void cancelPushToExternalSystem(Integer id) {
+        TmsArBill tmsArBill = tmsArBillMapper.selectTmsArBillById(id);
+        if (tmsArBill == null) {
+            throw new RuntimeException("搴旀敹璐﹀崟涓嶅瓨鍦�");
+        }
+
+        // 寮傛鎺ㄩ�佷綔搴熻姹�
+        AsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
+        executor.execute(() -> pushCancelToExternalSystem(tmsArBill));
+    }
+
+    /**
+     * 鍚戝閮ㄧ郴缁熸帹閫佸簲鏀舵暟鎹綔搴�
+     * @param tmsArBill 搴旀敹璐﹀崟
+     */
+    @Async
+    protected void pushCancelToExternalSystem(TmsArBill tmsArBill) {
+        java.util.Map<String, Object> requestBody = new java.util.HashMap<>();
+        try {
+    ;
+
+            // 鏋勫缓璇锋眰浣�
+            String apiUrl = url+"/cancelBill";
+
+            // 鏋勫缓璇锋眰浣擄紝鍙渶瑕乻ourceSystemId
+            requestBody.put("sourceSystemId", tmsArBill.getSourceSystemId());
+
+            // 璁剧疆HTTP澶�
+            HttpHeaders headers = new HttpHeaders();
+            headers.setContentType(MediaType.APPLICATION_JSON);
+            HttpEntity<String> entity = new HttpEntity<>(JSON.toJSONString(requestBody), headers);
+
+            // 鍙戦�丄PI璇锋眰
+            ResponseEntity<String> response = restTemplate.exchange(apiUrl, HttpMethod.POST, entity, String.class);
+            logger.info("鎺ㄩ�佸簲鏀舵暟鎹綔搴熷埌澶栭儴绯荤粺鎴愬姛锛屽搷搴�: {}", response.getBody());
+
+            // 鏇存柊鎺ㄩ�佺姸鎬佷负鎴愬姛
+        
+            tmsArBill.setStatus(3); // 璁剧疆璐﹀崟鐘舵�佷负浣滃簾
+    
+            tmsArBillMapper.updateTmsArBill(tmsArBill);
+
+            // 閲嶇疆鍏宠仈鐨勫簲鏀惰垂鐢ㄧ姸鎬佷负寰呯‘璁�
+            tmsReceivableFeeMapper.update(new com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper<TmsReceivableFee>()
+                    .set(TmsReceivableFee::getStatus, 0)
+                    .set(TmsReceivableFee::getBillRelationId, null)
+                    .set(TmsReceivableFee::getBillRelationNo, null)
+                    .eq(TmsReceivableFee::getBillRelationId, tmsArBill.getId())
+            );
+            logger.info("閲嶇疆搴旀敹璐圭敤鐘舵�佹垚鍔燂紝璐﹀崟ID: {}", tmsArBill.getId());
+        } 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);
+        }
+    }
+
+    /**
+     * 鏇存柊鎺ㄩ�佺姸鎬�
+     *
+     * @param id 搴旀敹璐﹀崟ID
+     * @param pushStatus 鎺ㄩ�佺姸鎬�
+     * @return 缁撴灉
+     */
+    @Override
+    public int updatePushStatus(Integer id, Integer pushStatus) {
+        TmsArBill tmsArBill = new TmsArBill();
+        tmsArBill.setId(id);
+        tmsArBill.setPushStatus(pushStatus);
+        tmsArBill.setPushTime(DateUtils.getNowDate());
+        return tmsArBillMapper.updateTmsArBill(tmsArBill);
+    }
+
+    /**
+     * 鍚戝閮ㄧ郴缁熸帹閫佹暟鎹�
+     * @param tmsArBill 搴旀敹璐﹀崟
+     * @param tmsReceivableFees 搴旀敹璐圭敤鍒楄〃
+     */
+    @Async
+    protected void pushToExternalSystem(TmsArBill tmsArBill, List<TmsReceivableFee> tmsReceivableFees) {
+        java.util.Map<String, Object> requestBody = new java.util.HashMap<>();
+        try {
+            // 鏇存柊鎺ㄩ�佺姸鎬佷负鎺ㄩ�佷腑
+            tmsArBill.setPushStatus(1);
+            tmsArBill.setPushTime(DateUtils.getNowDate());
+            tmsArBillMapper.updateTmsArBill(tmsArBill);
+
+            // 鏋勫缓璇锋眰浣�
+            String apiUrl = url+"/addBill";
+
+            // 鏋勫缓bill閮ㄥ垎
+            java.util.Map<String, Object> billMap = new java.util.HashMap<>();
+            billMap.put("billName", tmsArBill.getBillName());
+            billMap.put("customerName", tmsArBill.getCustomerName());
+            billMap.put("payee", "");
+            billMap.put("responsiblePerson", "");
+            billMap.put("responsibleLeader", "");
+            billMap.put("settlementMethod", "");
+            billMap.put("businessType", "");
+            billMap.put("promotionRequirement", "");
+            billMap.put("isInternalSettlement", "0");
+            billMap.put("internalSettlementUnit", "");
+            billMap.put("documentCount", tmsReceivableFees.size());
+            billMap.put("totalAmount", tmsArBill.getSettleAmount());
+            billMap.put("currency", "RMB");
+            billMap.put("discountAmount", 0.00);
+            billMap.put("receivedAmount", 0.00);
+            billMap.put("pendingAmount", tmsArBill.getSettleAmount());
+            billMap.put("exchangeRate", tmsArBill.getSettleRate());
+            billMap.put("cnyAmount", tmsArBill.getSettleAmount());
+            billMap.put("periodType", "");
+            billMap.put("businessStartDate", "");
+            billMap.put("businessEndDate", "");
+            billMap.put("billingStartDate", "");
+            billMap.put("billingEndDate", "");
+            billMap.put("billGenerateDate", "");
+            billMap.put("billSendDate", "");
+            billMap.put("billDueDate", "");
+            billMap.put("settlementCategory", "");
+            billMap.put("settlementPeriod", "");
+            billMap.put("status", "0");
+            billMap.put("remark", "");
+            billMap.put("sourceSystemId", tmsArBill.getId());
+
+            // 鏋勫缓fees閮ㄥ垎
+            List<java.util.Map<String, Object>> feesList = new java.util.ArrayList<>();
+            for (int i = 0; i < tmsReceivableFees.size(); i++) {
+                TmsReceivableFee fee = tmsReceivableFees.get(i);
+                java.util.Map<String, Object> feeMap = new java.util.HashMap<>();
+                feeMap.put("serialNumber", String.format("%03d", i + 1));
+                feeMap.put("relatedBillNo", "");
+                feeMap.put("sourceSystem", "TMS");
+                feeMap.put("businessSector", "0");
+                feeMap.put("documentType", "0");
+                feeMap.put("documentNo", fee.getDispatchNo() != null ? fee.getDispatchNo() : "");
+                feeMap.put("isInternalSettlement", "0");
+                feeMap.put("internalSettlementUnit", "");
+                feeMap.put("customerName", tmsArBill.getCustomerName());
+                feeMap.put("projectName", fee.getProjectName() != null ? fee.getProjectName() : "");
+                feeMap.put("businessTime", fee.getDispatchConfirmTime());
+                feeMap.put("receivableConfirmTime", fee.getDispatchConfirmTime());
+                feeMap.put("receivableAmount", fee.getReceivableRMBAmount().add(fee.getReceivableHKBAmount()));
+                // 鏋勫缓receivableAmountStr
+                BigDecimal rmbAmount = fee.getReceivableRMBAmount();
+                BigDecimal hkbAmount = fee.getReceivableHKBAmount();
+                StringBuilder amountStr = new StringBuilder();
+                if (rmbAmount.compareTo(BigDecimal.ZERO) > 0) {
+                    amountStr.append(rmbAmount).append("浜烘皯甯�");
+                }
+                if (hkbAmount.compareTo(BigDecimal.ZERO) > 0) {
+                    if (amountStr.length() > 0) {
+                        amountStr.append(" ");
+                    }
+                    amountStr.append(hkbAmount).append("娓竵");
+                }
+                feeMap.put("receivableAmountStr", amountStr.toString());
+                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 (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", "娆�");
+                    feeDetailMap.put("unitPrice", item.getRegisterAmount());
+                    feeDetailMap.put("billingQuantity", item.getRegisterAmount());
+                    feeDetailMap.put("billingAmount", item.getRegisterAmount());
+                    feeDetailMap.put("actualAmount", item.getRegisterAmount());
+                    feeDetailMap.put("currency", item.getCurrency());
+                    feeDetailMap.put("feeRegTime", item.getRegisterTime());
+                    feeDetailMap.put("remark", "");
+                    feeDetailsList.add(feeDetailMap);
+                }
+
+                feeMap.put("feeDetails", feeDetailsList);
+                feesList.add(feeMap);
+            }
+
+            // 鏋勫缓瀹屾暣璇锋眰浣�
+            requestBody.put("bill", billMap);
+            requestBody.put("fees", feesList);
+
+            // 璁剧疆HTTP澶�
+            HttpHeaders headers = new HttpHeaders();
+            headers.setContentType(MediaType.APPLICATION_JSON);
+            HttpEntity<String> entity = new HttpEntity<>(JSON.toJSONString(requestBody), headers);
+
+            // 鍙戦�丄PI璇锋眰
+            ResponseEntity<String> response = restTemplate.exchange(apiUrl, HttpMethod.POST, entity, String.class);
+            logger.info("鎺ㄩ�佹暟鎹埌澶栭儴绯荤粺鎴愬姛锛屽搷搴�: {}", response.getBody());
+
+    
+            // 瑙f瀽鍝嶅簲锛岃幏鍙杝ourceSystemId
+            try {
+                JSONObject result = JSONObject.parseObject(response.getBody());
+                String sourceSystemId = result.getString("sourceSystemId");
+                if (sourceSystemId != null) {
+                    tmsArBill.setSourceSystemId(Integer.parseInt(sourceSystemId));
+                }
+            } catch (Exception e) {
+                logger.error("瑙f瀽澶栭儴绯荤粺鍝嶅簲澶辫触: {}", e.getMessage());
+            }
+            // 鏇存柊鎺ㄩ�佺姸鎬佷负鎴愬姛
+            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);
+        }
+    }
+
+    /**
      * 瀵煎嚭瀵硅处鍗曚竴寮忓鑱旀牸寮�
      *
      * @param tmsArBill 搴旀敹璐﹀崟
@@ -291,8 +571,8 @@
             String rateStr = sysConfigService.selectConfigByKey("sys.hk.rmb.rate");
             BigDecimal exchangeRate = new BigDecimal(rateStr);
             
-            // 鏀堕泦鎵�鏈夎垂鐢ㄥ悕绉帮紝鐢ㄤ簬鍔ㄦ�佺敓鎴愬垪
-            Set<String> feeNames = new HashSet<>();
+            // 鏀堕泦鎵�鏈夎垂鐢ㄥ悕绉板拰瀵瑰簲鐨勮揣甯侊紝鐢ㄤ簬鍔ㄦ�佺敓鎴愬垪
+            Map<String, String> feeCurrencyMap = new HashMap<>();
 
                 for (TmsArBillItem item : bill.getItems()) {
                     // 搴旀敹璐圭敤ID
@@ -301,15 +581,33 @@
                     List<TmsReceivableFeeItem> tmsReceivableFeeItems = tmsReceivableFeeItemMapper.selectTmsReceivableFeeItemList(new TmsReceivableFeeItem() {{
                         setHeadId(arFeeId);
                     }});
-                    // 浠庡簲鏀惰垂鐢ㄦ槑缁嗕腑鏀堕泦璐圭敤鍚嶇О
+                    // 浠庡簲鏀惰垂鐢ㄦ槑缁嗕腑鏀堕泦璐圭敤鍚嶇О鍜岃揣甯�
                     for (TmsReceivableFeeItem feeItem : tmsReceivableFeeItems) {
-                        feeNames.add(feeItem.getFeeName());
+                        feeCurrencyMap.put(feeItem.getFeeName(), feeItem.getCurrency());
                     }
                 }
 
             
-            // 灏嗚垂鐢ㄥ悕绉拌浆鎹负鍒楄〃锛屼繚鎸侀『搴�
-            List<String> feeNameList = new ArrayList<>(feeNames);
+            // 灏嗚垂鐢ㄥ悕绉拌浆鎹负鍒楄〃锛屽苟鎸夎姹傛帓搴忥細杩愯垂鏀惧湪鏈�鍓嶉潰锛屾潅璐规斁鍦ㄦ渶鍚庨潰
+            List<String> feeNameList = new ArrayList<>();
+            List<String> otherFees = new ArrayList<>();
+            
+            for (String feeName : feeCurrencyMap.keySet()) {
+                if ("杩愯垂".equals(feeName)) {
+                    feeNameList.add(feeName);
+                } else if ("鏉傝垂".equals(feeName)) {
+                    otherFees.add(feeName);
+                } else {
+                    otherFees.add(feeName);
+                }
+            }
+            
+            // 娣诲姞鍏朵粬璐圭敤
+            feeNameList.addAll(otherFees.stream().filter(fee -> !"鏉傝垂".equals(fee)).collect(Collectors.toList()));
+            // 娣诲姞鏉傝垂鍒版渶鍚�
+            if (feeCurrencyMap.containsKey("鏉傝垂")) {
+                feeNameList.add("鏉傝垂");
+            }
             
             // 鍩虹鍒楁暟锛堝簭鍙枫�佽璐ф棩鏈熴�佽璐х偣銆佸嵏璐х偣銆佽溅鐗屻�佸瀷鍙凤級
             int baseColumns = 6;
@@ -332,13 +630,13 @@
             sheet.setColumnWidth(remarkColumn, 10000); // 澶囨敞
             
             // 鏍囬鍖哄煙
-            createTitleArea(sheet, styles,tmsArBill);
+            createTitleArea(sheet, styles,bill);
             
             // 琛ㄥご
-            createDynamicTableHeader(sheet, styles, feeNameList, baseColumns, remarkColumn);
+            createDynamicTableHeader(sheet, styles, feeNameList, feeCurrencyMap, baseColumns, remarkColumn);
             
             // 鏁版嵁鍖哄煙
-            int startRow = 4;
+            int startRow = 5;
             // 璐圭敤鍚堣鏄犲皠
             Map<String, BigDecimal> feeTotals = new HashMap<>();
             for (String feeName : feeNameList) {
@@ -364,42 +662,41 @@
                         }
                         // 瑁呰揣鏃ユ湡
                         Cell cell1 = row.createCell(1);
-                        if (dispatchOrder != null) {
-                          TmsTrip tmsTrip = tmsTripMapper.selectTmsTripByTripType(3,dispatchOrder.getId() );
-
-                            cell1.setCellValue(DateUtils.parseDateToStr("yyyy-MM-dd", tmsTrip.getTripTime()));
-                            cell1.setCellStyle(styles.get("data"));
+                        if (dispatchOrder != null && dispatchOrder.getOrderTime() !=null) {
+                            cell1.setCellValue(DateUtils.parseDateToStr("yyyy-MM-dd", dispatchOrder.getOrderTime()));
                         }
+                        cell1.setCellStyle(styles.get("data"));
 
-
-                        
                         // 瑁呰揣鐐�
                         Cell cell2 = row.createCell(2);
-                        if (dispatchOrder != null && dispatchOrder.getShipperAddress() != null) {
-                            cell2.setCellValue(dispatchOrder.getShipperAddress());
-                            cell2.setCellStyle(styles.get("data"));
+                        if (dispatchOrder != null && dispatchOrder.getShipperRegionLabel() != null) {
+                            cell2.setCellValue(dispatchOrder.getShipperRegionLabel());
                         }
+                        cell2.setCellStyle(styles.get("data"));
 
                         // 鍗歌揣鐐�
                         Cell cell3 = row.createCell(3);
-                        if (dispatchOrder != null && dispatchOrder.getReceiverAddress() != null) {
-                            cell3.setCellValue(dispatchOrder.getReceiverAddress());
-                            cell3.setCellStyle(styles.get("data"));
+                        if (dispatchOrder != null && dispatchOrder.getReceiverRegionLabel() != null) {
+                            cell3.setCellValue(dispatchOrder.getReceiverRegionLabel());
                         }
+                        cell3.setCellStyle(styles.get("data"));
 
                         // 杞︾墝
                         Cell cell4 = row.createCell(4);
                         if (dispatchOrder != null && dispatchOrder.getLicensePlate() != null) {
                             cell4.setCellValue(dispatchOrder.getLicensePlate());
-                            cell4.setCellStyle(styles.get("data"));
                         }
+                        cell4.setCellStyle(styles.get("data"));
 
                         // 鍨嬪彿
                         Cell cell5 = row.createCell(5);
                         if (dispatchOrder != null && dispatchOrder.getActualVehicleType() != null) {
-                            cell5.setCellValue(dispatchOrder.getActualVehicleType());
-                            cell5.setCellStyle(styles.get("data"));
+                            // 浣跨敤瀛楀吀杞崲杞﹁締鍨嬪彿
+                            String vehicleType = dispatchOrder.getActualVehicleType();
+                            String vehicleTypeLabel = DictUtils.getDictLabel("vehicle_type", vehicleType);
+                            cell5.setCellValue(StringUtils.isNotEmpty(vehicleTypeLabel) ? vehicleTypeLabel : vehicleType);
                         }
+                        cell5.setCellStyle(styles.get("data"));
 
                         // 鏋勫缓璐圭敤鍚嶇О鍒伴噾棰濈殑鏄犲皠锛堟腐甯佽浆浜烘皯甯侊級
                         Map<String, BigDecimal> feeMap = new HashMap<>();
@@ -409,12 +706,8 @@
                         }});
                         // 澶勭悊搴旀敹璐圭敤鏄庣粏
                         for (TmsReceivableFeeItem feeItem : tmsReceivableFeeItems) {
-                            BigDecimal amount = feeItem.getRegisterAmount();
-                            // 濡傛灉鏄腐甯侊紝杞崲涓轰汉姘戝竵
-                            if ("HKD".equals(feeItem.getCurrency()) || "娓竵".equals(feeItem.getCurrency())) {
-                                amount = amount.multiply(exchangeRate).setScale(2, RoundingMode.HALF_UP);
-                            }
-                            feeMap.put(feeItem.getFeeName(), amount);
+                            // 淇濇寔鍘熷閲戦锛屼笉杩涜甯佺杞崲
+                            feeMap.put(feeItem.getFeeName(), feeItem.getRegisterAmount());
                         }
                         
                         // 濉厖璐圭敤鍒�
@@ -429,9 +722,9 @@
                             feeTotals.put(feeName, feeTotals.get(feeName).add(feeAmount));
                         }
                         
-                        // 澶囨敞
+                        // 澶囨敞 - 涓虹┖
                         Cell remarkCell = row.createCell(remarkColumn);
-                        remarkCell.setCellValue("" + (fee.getDispatchNo() != null ? fee.getDispatchNo() : ""));
+                        remarkCell.setCellValue("");
                         remarkCell.setCellStyle(styles.get("data"));
                         
                         rowIndex++;
@@ -442,54 +735,89 @@
             // 灏忚琛�
             int subTotalRow = startRow + rowIndex;
             Row subTotal = sheet.createRow(subTotalRow);
-            Cell subTotalCell = subTotal.createCell(2);
-            subTotalCell.setCellValue("灏忚");
-            subTotalCell.setCellStyle(styles.get("total"));
-            sheet.addMergedRegion(new CellRangeAddress(subTotalRow, subTotalRow, 2, 5));
+            // 涓烘墍鏈夊垪鍒涘缓鍗曞厓鏍�
+            for (int i = 0; i <= remarkColumn; i++) {
+                Cell cell = subTotal.createCell(i);
+                if (i == 0) {
+                    cell.setCellValue("灏忚");
+                }
+                cell.setCellStyle(styles.get("total"));
+            }
+            sheet.addMergedRegion(new CellRangeAddress(subTotalRow, subTotalRow, 0, 5));
             
             // 濉厖璐圭敤灏忚
             for (int j = 0; j < feeNameList.size(); j++) {
                 String feeName = feeNameList.get(j);
-                Cell cell = subTotal.createCell(baseColumns + j);
+                Cell cell = subTotal.getCell(baseColumns + j);
                 cell.setCellValue(feeTotals.get(feeName).doubleValue());
-                cell.setCellStyle(styles.get("total"));
             }
-            
+
             // 鍚堣琛�
             int totalRow = subTotalRow + 1;
             Row total = sheet.createRow(totalRow);
-            Cell totalCell = total.createCell(2);
-            totalCell.setCellValue("鍚堣(CNB)");
-            totalCell.setCellStyle(styles.get("total"));
-            sheet.addMergedRegion(new CellRangeAddress(totalRow, totalRow, 2, 5));
-            
-            // 濉厖璐圭敤鍚堣
-            for (int j = 0; j < feeNameList.size(); j++) {
-                String feeName = feeNameList.get(j);
-                Cell cell = total.createCell(baseColumns + j);
-                cell.setCellValue(feeTotals.get(feeName).doubleValue());
+            // 涓烘墍鏈夊垪鍒涘缓鍗曞厓鏍�
+            for (int i = 0; i <= remarkColumn; i++) {
+                Cell cell = total.createCell(i);
+                if (i == 0) {
+                    cell.setCellValue("鍚堣(RMB)");
+                }
+                // 鍚堣琛岀殑澶囨敞璁剧疆姹囩巼
+                if (i == remarkColumn) {
+                    cell.setCellValue("姹囩巼: " + exchangeRate);
+                }
                 cell.setCellStyle(styles.get("total"));
+            }
+            sheet.addMergedRegion(new CellRangeAddress(totalRow, totalRow, 0, 5));
+
+            // 璁$畻鎵�鏈夎垂鐢ㄧ殑鍚堣锛堣浆鎹负浜烘皯甯侊級
+            BigDecimal grandTotal = BigDecimal.ZERO;
+            for (String feeName : feeTotals.keySet()) {
+                BigDecimal amount = feeTotals.get(feeName);
+                // 鑾峰彇璇ヨ垂鐢ㄧ殑甯佺
+                String currency = feeCurrencyMap.get(feeName);
+                // 濡傛灉鏄腐甯侊紝杞崲涓轰汉姘戝竵
+                if ("HKD".equals(currency) || "娓竵".equals(currency)) {
+                    amount = amount.multiply(exchangeRate).setScale(2, RoundingMode.HALF_UP);
+                }
+                grandTotal = grandTotal.add(amount);
+            }
+            
+            // 濉厖璐圭敤鍚堣锛堟墍鏈夎垂鐢ㄧ殑鎬诲拰锛�
+            for (int j = 0; j < feeNameList.size(); j++) {
+                Cell cell = total.getCell(baseColumns + j);
+                if (j == 0) {
+                    cell.setCellValue(grandTotal.doubleValue());
+                }
+            }
+            // 鍚堝苟璐圭敤鍒楀崟鍏冩牸
+            if (feeNameList.size() > 1) {
+                sheet.addMergedRegion(new CellRangeAddress(totalRow, totalRow, baseColumns, baseColumns + feeNameList.size() - 1));
             }
             
             // 澶囨敞璇存槑鍖哄煙
-            createNotesArea(sheet, styles, totalRow + 1);
+            createNotesArea(sheet, styles, totalRow + 1, grandTotal);
             
-            // 璐︽埛淇℃伅鍖哄煙
-            createAccountInfo(sheet, styles, totalRow + 4);
-            
-            // 绛惧瓧鐩栫珷鍖哄煙
-            createSignatureArea(sheet, styles, totalRow + 8);
-            
-            // 鐢熸垚鏂囦欢
-            File file = new File(fileName);
+            // 璐︽埛淇℃伅鍜岀瀛楃洊绔犲尯鍩燂紙鍚堝苟鎴愪竴涓ぇ鏍硷級
+            createAccountAndSignatureArea(sheet, styles, totalRow + 4, bill);
+
+            // 淇濆瓨鏂囦欢
+            String path = RuoYiConfig.getDownloadPath() + fileName;
+            File file = new File(path);
+            File parentFile = file.getParentFile();
+            if (!parentFile.exists()) {
+                parentFile.mkdirs();
+            }
+
             try (FileOutputStream fos = new FileOutputStream(file)) {
                 workbook.write(fos);
             }
+
             return fileName;
         } catch (Exception e) {
             logger.error("瀵煎嚭瀵硅处鍗曚竴寮忓鑱旀牸寮忓け璐�", e);
             throw new RuntimeException("瀵煎嚭澶辫触锛岃妫�鏌ユ暟鎹�", e);
         }
+
     }
 
     /**
@@ -505,6 +833,10 @@
         CellStyle titleStyle = workbook.createCellStyle();
         titleStyle.setAlignment(HorizontalAlignment.CENTER);
         titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        titleStyle.setBorderTop(BorderStyle.THIN);
+        titleStyle.setBorderBottom(BorderStyle.THIN);
+        titleStyle.setBorderLeft(BorderStyle.THIN);
+        titleStyle.setBorderRight(BorderStyle.THIN);
         Font titleFont = workbook.createFont();
         titleFont.setFontName("寰蒋闆呴粦");
         titleFont.setFontHeightInPoints((short) 16);
@@ -520,8 +852,6 @@
         headerStyle.setBorderBottom(BorderStyle.THIN);
         headerStyle.setBorderLeft(BorderStyle.THIN);
         headerStyle.setBorderRight(BorderStyle.THIN);
-        headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
-        headerStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
         Font headerFont = workbook.createFont();
         headerFont.setFontName("寰蒋闆呴粦");
         headerFont.setFontHeightInPoints((short) 11);
@@ -551,8 +881,6 @@
         totalStyle.setBorderBottom(BorderStyle.THIN);
         totalStyle.setBorderLeft(BorderStyle.THIN);
         totalStyle.setBorderRight(BorderStyle.THIN);
-        totalStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
-        totalStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
         Font totalFont = workbook.createFont();
         totalFont.setFontName("寰蒋闆呴粦");
         totalFont.setFontHeightInPoints((short) 11);
@@ -564,11 +892,29 @@
         CellStyle textStyle = workbook.createCellStyle();
         textStyle.setAlignment(HorizontalAlignment.LEFT);
         textStyle.setVerticalAlignment(VerticalAlignment.TOP);
+        textStyle.setBorderTop(BorderStyle.THIN);
+        textStyle.setBorderBottom(BorderStyle.THIN);
+        textStyle.setBorderLeft(BorderStyle.THIN);
+        textStyle.setBorderRight(BorderStyle.THIN);
         Font textFont = workbook.createFont();
         textFont.setFontName("寰蒋闆呴粦");
         textFont.setFontHeightInPoints((short) 11);
         textStyle.setFont(textFont);
         styles.put("text", textStyle);
+
+        // 鏂囨湰鏍峰紡
+        CellStyle textStyle2 = workbook.createCellStyle();
+        textStyle2.setAlignment(HorizontalAlignment.LEFT);
+        textStyle2.setVerticalAlignment(VerticalAlignment.TOP);
+        textStyle2.setBorderTop(BorderStyle.THIN);
+        textStyle2.setBorderBottom(BorderStyle.THIN);
+        textStyle2.setBorderLeft(BorderStyle.THIN);
+
+        Font textFont2 = workbook.createFont();
+        textFont2.setFontName("寰蒋闆呴粦");
+        textFont2.setFontHeightInPoints((short) 11);
+        textStyle2.setFont(textFont2);
+        styles.put("text2", textStyle2);
         
         return styles;
     }
@@ -578,35 +924,63 @@
      *
      * @param sheet 宸ヤ綔琛�
      * @param styles 鏍峰紡鏄犲皠
-     * @param tmsReceivableFee 搴旀敹璐圭敤鏌ヨ鏉′欢
      */
     private void createTitleArea(SXSSFSheet sheet, Map<String, CellStyle> styles, TmsArBill tmsArBill) {
-        // 鏍囬琛�
+        // 鏍囬琛岋紙鏃犺竟妗嗭紝灞呬腑锛�
         Row titleRow = sheet.createRow(0);
         titleRow.setHeightInPoints(30);
-        Cell titleCell = titleRow.createCell(0);
-        titleCell.setCellValue(tmsArBill.getCustomerName());
-        titleCell.setCellStyle(styles.get("title"));
+        for (int i = 0; i <= 9; i++) {
+            Cell cell = titleRow.createCell(i);
+            if (i == 0) {
+                cell.setCellValue("鐝犳捣甯傛眹鐣呬氦閫氭姇璧勬湁闄愬叕鍙�");
+                // 灞呬腑鏄剧ず
+                CellStyle centerStyle = sheet.getWorkbook().createCellStyle();
+                centerStyle.setAlignment(HorizontalAlignment.CENTER);
+                centerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+                cell.setCellStyle(centerStyle);
+            }
+            // 涓嶈缃竟妗嗘牱寮�
+        }
         sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 9));
 
-        // 瀵硅处鍗曡
+        // 瀵硅处鍗曡 - 灞呬腑鏄剧ず锛堟棤杈规锛�
         Row billRow = sheet.createRow(1);
         billRow.setHeightInPoints(20);
-        Cell toCell = billRow.createCell(0);
-        toCell.setCellValue("TO: "+tmsArBill.getCustomerName());
-        toCell.setCellStyle(styles.get("text"));
+        for (int i = 0; i <= 9; i++) {
+            Cell cell = billRow.createCell(i);
+            if (i == 0) {
+                cell.setCellValue(tmsArBill.getBillName());
+                // 灞呬腑鏄剧ず
+                CellStyle centerStyle = sheet.getWorkbook().createCellStyle();
+                centerStyle.setAlignment(HorizontalAlignment.CENTER);
+                centerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+                cell.setCellStyle(centerStyle);
+            }
+            // 涓嶈缃竟妗嗘牱寮�
+        }
+        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 9));
 
-        Cell billTitleCell = billRow.createCell(3);
-        billTitleCell.setCellValue(tmsArBill.getBillName());
-        billTitleCell.setCellStyle(styles.get("text"));
-        sheet.addMergedRegion(new CellRangeAddress(1, 1, 3, 6));
+        // FROM琛岋紙鍦═O涓婇潰锛屾棤杈规锛�
+        Row fromRow = sheet.createRow(2);
+        fromRow.setHeightInPoints(20);
+        for (int i = 0; i <= 9; i++) {
+            Cell cell = fromRow.createCell(i);
+            if (i == 0) {
+                cell.setCellValue("FROM:鐝犳捣甯傛眹鐣呬氦閫氭姇璧勬湁闄愬叕鍙�");
+            }
+            // 涓嶈缃竟妗嗘牱寮�
+        }
 
-        // 鍏徃淇℃伅琛�
-        Row companyRow = sheet.createRow(2);
-        companyRow.setHeightInPoints(20);
-        Cell fromCell = companyRow.createCell(0);
-        fromCell.setCellValue("FROM:鐝犳捣甯傛眹鐣呬氦閫氭姇璧勬湁闄愬叕鍙�");
-        fromCell.setCellStyle(styles.get("text"));
+        // TO琛岋紙鏃犺竟妗嗭級
+        Row toRow = sheet.createRow(3);
+        toRow.setHeightInPoints(20);
+        for (int i = 0; i <= 9; i++) {
+            Cell cell = toRow.createCell(i);
+            if (i == 0) {
+                cell.setCellValue("TO: "+tmsArBill.getCustomerName());
+            }
+            // 涓嶈缃竟妗嗘牱寮�
+        }
     }
 
     /**
@@ -615,11 +989,12 @@
      * @param sheet 宸ヤ綔琛�
      * @param styles 鏍峰紡鏄犲皠
      * @param feeNameList 璐圭敤鍚嶇О鍒楄〃
+     * @param feeCurrencyMap 璐圭敤鍚嶇О鍒拌揣甯佺殑鏄犲皠
      * @param baseColumns 鍩虹鍒楁暟
      * @param remarkColumn 澶囨敞鍒椾綅缃�
      */
-    private void createDynamicTableHeader(SXSSFSheet sheet, Map<String, CellStyle> styles, List<String> feeNameList, int baseColumns, int remarkColumn) {
-        Row headerRow = sheet.createRow(3);
+    private void createDynamicTableHeader(SXSSFSheet sheet, Map<String, CellStyle> styles, List<String> feeNameList, Map<String, String> feeCurrencyMap, int baseColumns, int remarkColumn) {
+        Row headerRow = sheet.createRow(4);
         headerRow.setHeightInPoints(25);
         
         // 鍩虹鍒�
@@ -633,7 +1008,10 @@
         // 璐圭敤鍒�
         for (int i = 0; i < feeNameList.size(); i++) {
             Cell cell = headerRow.createCell(baseColumns + i);
-            cell.setCellValue(feeNameList.get(i) + "(浜烘皯甯�)");
+            String feeName = feeNameList.get(i);
+            String currency = feeCurrencyMap.get(feeName);
+          
+            cell.setCellValue(feeName + "(" + currency + ")");
             cell.setCellStyle(styles.get("header"));
         }
         
@@ -644,119 +1022,277 @@
     }
 
     /**
+     * 灏嗛噾棰濊浆鎹负涓枃澶у啓
+     *
+     * @param amount 閲戦
+     * @return 涓枃澶у啓閲戦
+     */
+    private String convertToChineseUppercase(BigDecimal amount) {
+        if (amount == null) {
+            return "闆跺厓鏁�";
+        }
+        
+        String[] digits = {"闆�", "澹�", "璐�", "鍙�", "鑲�", "浼�", "闄�", "鏌�", "鎹�", "鐜�"};
+        String[] units = {"", "鎷�", "浣�", "浠�"};
+        String[] bigUnits = {"", "涓�", "浜�"};
+        
+        String amountStr = amount.setScale(2, RoundingMode.HALF_UP).toString();
+        String integerPart = amountStr.split("\\.")[0];
+        String decimalPart = amountStr.split("\\.")[1];
+        
+        StringBuilder result = new StringBuilder();
+        
+        // 澶勭悊鏁存暟閮ㄥ垎
+        int length = integerPart.length();
+        for (int i = 0; i < length; i++) {
+            int digit = Integer.parseInt(String.valueOf(integerPart.charAt(i)));
+            int unitIndex = (length - i - 1) % 4;
+            int bigUnitIndex = (length - i - 1) / 4;
+            
+            if (digit != 0) {
+                result.append(digits[digit]).append(units[unitIndex]).append(bigUnits[bigUnitIndex]);
+            } else {
+                // 閬垮厤杩炵画鐨勯浂
+                if (i > 0 && Integer.parseInt(String.valueOf(integerPart.charAt(i - 1))) != 0) {
+                    result.append(digits[digit]);
+                }
+                // 鍙湪闈炴湯灏句綅缃坊鍔犲ぇ鍗曚綅
+                if (unitIndex == 0 && bigUnitIndex > 0 && i < length - 1) {
+                    result.append(bigUnits[bigUnitIndex]);
+                }
+            }
+        }
+        
+        result.append("鍏�");
+        
+        // 澶勭悊灏忔暟閮ㄥ垎
+        int jiao = Integer.parseInt(String.valueOf(decimalPart.charAt(0)));
+        int fen = Integer.parseInt(String.valueOf(decimalPart.charAt(1)));
+        
+        if (jiao == 0 && fen == 0) {
+            result.append("鏁�");
+        } else if (jiao == 0) {
+            result.append("闆�").append(digits[fen]).append("鍒�");
+        } else if (fen == 0) {
+            result.append(digits[jiao]).append("瑙掓暣");
+        } else {
+            result.append(digits[jiao]).append("瑙�").append(digits[fen]).append("鍒�");
+        }
+        
+        return result.toString();
+    }
+
+    /**
      * 鍒涘缓澶囨敞璇存槑鍖哄煙
      *
      * @param sheet 宸ヤ綔琛�
      * @param styles 鏍峰紡鏄犲皠
      * @param startRow 璧峰琛�
+     * @param grandTotal 鎬婚噾棰�
      */
-    private void createNotesArea(SXSSFSheet sheet, Map<String, CellStyle> styles, int startRow) {
-        Row note1Row = sheet.createRow(startRow);
-        Cell note1Cell = note1Row.createCell(0);
-        note1Cell.setCellValue("1.渚濇嵁鍚堝悓鐩稿叧瑙勫畾锛岃吹鍙搁渶鍚戞垜鍙告敮浠橈骏锛堝ぇ鍐欓噾棰濓細锛夌殑璐圭敤锛岃璐靛徃鍙婃椂瀹夋帓鏀粯銆�");
-        note1Cell.setCellStyle(styles.get("text"));
-        sheet.addMergedRegion(new CellRangeAddress(startRow, startRow, 0, 9));
-
-        Row note2Row = sheet.createRow(startRow + 1);
-        Cell note2Cell = note2Row.createCell(0);
-        note2Cell.setCellValue("2.浼犵湡浠朵笌鍘熶欢璧峰悓绛夋硶寰嬫晥鍔涖��");
-        note2Cell.setCellStyle(styles.get("text"));
-        sheet.addMergedRegion(new CellRangeAddress(startRow + 1, startRow + 1, 0, 9));
+    private void createNotesArea(SXSSFSheet sheet, Map<String, CellStyle> styles, int startRow, BigDecimal grandTotal) {
+        // 鍒涘缓鏃犺竟鐣屾牱寮�
+        CellStyle noBorderStyle = sheet.getWorkbook().createCellStyle();
+        
+        // 鍒涘缓涓よ
+        for (int rowIdx = 0; rowIdx < 2; rowIdx++) {
+            Row row = sheet.createRow(startRow + rowIdx);
+            for (int i = 0; i <= 9; i++) {
+                Cell cell = row.createCell(i);
+                if (i == 0) {
+                    // 绗竴鍒楄缃甫杈规鐨勬牱寮�
+                    cell.setCellStyle(styles.get("text2"));
+                } else {
+                    // 鍏朵粬鍒楄缃棤杈圭晫鏍峰紡
+                    cell.setCellStyle(noBorderStyle);
+                }
+            }
+        }
+        
+        // 绗竴琛屽娉�
+        Row firstRow = sheet.getRow(startRow);
+        Cell cell1 = firstRow.getCell(0);
+        String chineseAmount = convertToChineseUppercase(grandTotal);
+        cell1.setCellValue("1.渚濇嵁鍚堝悓鐩稿叧瑙勫畾锛岃吹鍙搁渶鍚戞垜鍙告敮浠橈骏" + grandTotal.setScale(2, RoundingMode.HALF_UP) + "锛堝ぇ鍐欓噾棰濓細" + chineseAmount + "锛夌殑璐圭敤锛岃璐靛徃鍙婃椂瀹夋帓鏀粯銆�");
+        
+        // 绗簩琛屽娉�
+        Row secondRow = sheet.getRow(startRow + 1);
+        Cell cell2 = secondRow.getCell(0);
+        cell2.setCellValue("2.浼犵湡浠朵笌鍘熶欢璧峰悓绛夋硶寰嬫晥鍔涖��");
+        
+    
     }
 
+
+
     /**
-     * 鍒涘缓璐︽埛淇℃伅鍖哄煙
+     * 鍒涘缓璐︽埛淇℃伅鍜岀瀛楃洊绔犲尯鍩�
      *
-     * @param sheet 宸ヤ綔琛�
-     * @param styles 鏍峰紡鏄犲皠
+     * @param sheet    宸ヤ綔琛�
+     * @param styles   鏍峰紡鏄犲皠
      * @param startRow 璧峰琛�
+     * @param bill
      */
-    private void createAccountInfo(SXSSFSheet sheet, Map<String, CellStyle> styles, int startRow) {
-        Row accountTitleRow = sheet.createRow(startRow);
-        Cell accountTitleCell = accountTitleRow.createCell(0);
-        accountTitleCell.setCellValue("鐑﹁鏍稿纭骞惰浆鑷虫垜鍙稿涓嬪笎鍙凤細");
-        accountTitleCell.setCellStyle(styles.get("text"));
-        sheet.addMergedRegion(new CellRangeAddress(startRow, startRow, 0, 9));
+    private void createAccountAndSignatureArea(SXSSFSheet sheet, Map<String, CellStyle> styles, int startRow, TmsArBill bill) {
+        // 璁$畻缁撴潫琛岋紙璐︽埛淇℃伅4琛� + 绛惧瓧鐩栫珷6琛岋級
+        int endRow = startRow + 9;
+        
+        // 鍒涘缓鎵�鏈夎锛岃缃楂�
+        for (int rowIdx = 0; rowIdx <= 9; rowIdx++) {
+            Row row = sheet.createRow(startRow + rowIdx);
+            row.setHeightInPoints(20);
+            for (int i = 0; i <= 9; i++) {
+                Cell cell = row.createCell(i);
+                // 涓嶈缃竟妗嗘牱寮忥紝鍙樉绀烘暟鎹�
+            }
+        }
+        
+        // 璐︽埛淇℃伅鍖哄煙锛堝乏涓婅锛�
+        Row infoRow1 = sheet.getRow(startRow);
+        Cell infoCell1 = infoRow1.getCell(0);
+        infoCell1.setCellValue("鐑﹁鏍稿纭骞惰浆鑷虫垜鍙稿涓嬪笎鍙凤細");
+        
+        Row infoRow2 = sheet.getRow(startRow + 1);
+        Cell infoCell2 = infoRow2.getCell(0);
+        infoCell2.setCellValue("寮�鎴烽摱琛�:涓浗鍐滀笟鍙戝睍閾惰鐝犳捣甯傚垎琛�");
+        
+        Row infoRow3 = sheet.getRow(startRow + 2);
+        Cell infoCell3 = infoRow3.getCell(0);
+        infoCell3.setCellValue("璐﹀彿:20344990100000422001");
+        
+        Row infoRow4 = sheet.getRow(startRow + 3);
+        Cell infoCell4 = infoRow4.getCell(0);
+        infoCell4.setCellValue("鎴峰悕:鐝犳捣甯傛眹鐣呬氦閫氭姇璧勬湁闄愬叕鍙�");
+        
+        // 浠樻鍗曚綅锛堝乏涓嬭锛�
+        Row payerRow = sheet.getRow(startRow + 4);
+        Cell payerCell = payerRow.getCell(0);
+        payerCell.setCellValue("浠樻鍗曚綅锛堢敳鏂癸級锛�" + bill.getCustomerName());
+        
+        // 鏀舵鍗曚綅锛堝彸涓嬭锛�
+        Row payeeRow = sheet.getRow(startRow + 4);
+        Cell payeeCell = payeeRow.getCell(6);
+        payeeCell.setCellValue("鏀舵鍗曚綅锛堜箼鏂癸級锛氱彔娴峰競姹囩晠浜ら�氭姇璧勬湁闄愬叕鍙�");
+        
+        // 鍒惰〃浜哄憳
+        Row creatorRow = sheet.getRow(startRow + 5);
+        Cell creatorCell1 = creatorRow.getCell(0);
+        creatorCell1.setCellValue("鍒惰〃浜哄憳锛�");
+        Cell creatorCell2 = creatorRow.getCell(6);
+        creatorCell2.setCellValue("鍒惰〃浜哄憳锛�");
+        
+        // 瀹℃牳浜哄憳
+        Row checkerRow = sheet.getRow(startRow + 6);
+        Cell checkerCell1 = checkerRow.getCell(0);
+        checkerCell1.setCellValue("瀹℃牳浜哄憳锛�");
+        Cell checkerCell2 = checkerRow.getCell(6);
+        checkerCell2.setCellValue("瀹℃牳浜哄憳锛�");
+        
+        // 澶嶆牳浜哄憳
+        Row reviewerRow = sheet.getRow(startRow + 7);
+        Cell reviewerCell1 = reviewerRow.getCell(0);
+        reviewerCell1.setCellValue("澶嶆牳浜哄憳锛�");
+        Cell reviewerCell2 = reviewerRow.getCell(6);
+        reviewerCell2.setCellValue("澶嶆牳浜哄憳锛�");
+        
+        // 鐩栫珷
+        Row stampRow = sheet.getRow(startRow + 8);
+        Cell stampCell1 = stampRow.getCell(0);
+        stampCell1.setCellValue("鐩栫珷锛�");
+        Cell stampCell2 = stampRow.getCell(6);
+        stampCell2.setCellValue("鐩栫珷锛�");
+        
+        // 鏃ユ湡
+        Row dateRow = sheet.getRow(startRow + 9);
+        Cell dateCell1 = dateRow.getCell(0);
+        dateCell1.setCellValue("鏃ユ湡锛�2026骞�  鏈�  鏃�");
+        Cell dateCell2 = dateRow.getCell(6);
+        dateCell2.setCellValue("鏃ユ湡锛�2026骞�  鏈�  鏃�");
+        
 
-        Row bankRow = sheet.createRow(startRow + 1);
-        Cell bankCell = bankRow.createCell(0);
-        bankCell.setCellValue("寮�鎴烽摱琛�:涓浗鍐滀笟鍙戝睍閾惰鐝犳捣甯傚垎琛�");
-        bankCell.setCellStyle(styles.get("text"));
-        sheet.addMergedRegion(new CellRangeAddress(startRow + 1, startRow + 1, 0, 9));
 
-        Row accountRow = sheet.createRow(startRow + 2);
-        Cell accountCell = accountRow.createCell(0);
-        accountCell.setCellValue("璐﹀彿:20344990100000422001");
-        accountCell.setCellStyle(styles.get("text"));
-        sheet.addMergedRegion(new CellRangeAddress(startRow + 2, startRow + 2, 0, 9));
-
-        Row nameRow = sheet.createRow(startRow + 3);
-        Cell nameCell = nameRow.createCell(0);
-        nameCell.setCellValue("鎴峰悕:鐝犳捣甯傛眹鐣呬氦閫氭姇璧勬湁闄愬叕鍙�");
-        nameCell.setCellStyle(styles.get("text"));
-        sheet.addMergedRegion(new CellRangeAddress(startRow + 3, startRow + 3, 0, 9));
     }
 
     /**
      * 鍒涘缓绛惧瓧鐩栫珷鍖哄煙
      *
-     * @param sheet 宸ヤ綔琛�
-     * @param styles 鏍峰紡鏄犲皠
+     * @param sheet    宸ヤ綔琛�
+     * @param styles   鏍峰紡鏄犲皠
      * @param startRow 璧峰琛�
+     * @param bill
      */
-    private void createSignatureArea(SXSSFSheet sheet, Map<String, CellStyle> styles, int startRow) {
+    private void createSignatureArea(SXSSFSheet sheet, Map<String, CellStyle> styles, int startRow, TmsArBill bill) {
+        // 浠樻鍗曚綅锛堢敳鏂癸級鍜屾敹娆惧崟浣嶏紙涔欐柟锛夎
         Row payerRow = sheet.createRow(startRow);
-        Cell payerCell = payerRow.createCell(0);
-        payerCell.setCellValue("浠樻鍗曚綅锛堢敳鏂癸級锛歑XXXXXXXXXXXXX");
-        payerCell.setCellStyle(styles.get("text"));
+        for (int i = 0; i <= 9; i++) {
+            Cell cell = payerRow.createCell(i);
+            if (i == 0) {
+                cell.setCellValue("浠樻鍗曚綅锛堢敳鏂癸級锛�"+bill.getCustomerName());
+            } else if (i == 6) {
+                cell.setCellValue("鏀舵鍗曚綅锛堜箼鏂癸級锛氱彔娴峰競姹囩晠浜ら�氭姇璧勬湁闄愬叕鍙�");
+            }
+            cell.setCellStyle(styles.get("text"));
+        }
 
-        Cell payeeCell = payerRow.createCell(6);
-        payeeCell.setCellValue("鏀舵鍗曚綅锛堜箼鏂癸級锛氱彔娴峰競姹囩晠浜ら�氭姇璧勬湁闄愬叕鍙�");
-        payeeCell.setCellStyle(styles.get("text"));
-
+        // 鍒惰〃浜哄憳琛�
         Row creatorRow = sheet.createRow(startRow + 1);
-        Cell creatorCell = creatorRow.createCell(0);
-        creatorCell.setCellValue("鍒惰〃浜哄憳锛�");
-        creatorCell.setCellStyle(styles.get("text"));
+        for (int i = 0; i <= 9; i++) {
+            Cell cell = creatorRow.createCell(i);
+            if (i == 0) {
+                cell.setCellValue("鍒惰〃浜哄憳锛�");
+            } else if (i == 6) {
+                cell.setCellValue("鍒惰〃浜哄憳锛�");
+            }
+            cell.setCellStyle(styles.get("text"));
+        }
 
-        Cell creatorCell2 = creatorRow.createCell(6);
-        creatorCell2.setCellValue("鍒惰〃浜哄憳锛�");
-        creatorCell2.setCellStyle(styles.get("text"));
-
+        // 瀹℃牳浜哄憳琛�
         Row checkerRow = sheet.createRow(startRow + 2);
-        Cell checkerCell = checkerRow.createCell(0);
-        checkerCell.setCellValue("瀹℃牳浜哄憳锛�");
-        checkerCell.setCellStyle(styles.get("text"));
+        for (int i = 0; i <= 9; i++) {
+            Cell cell = checkerRow.createCell(i);
+            if (i == 0) {
+                cell.setCellValue("瀹℃牳浜哄憳锛�");
+            } else if (i == 6) {
+                cell.setCellValue("瀹℃牳浜哄憳锛�");
+            }
+            cell.setCellStyle(styles.get("text"));
+        }
 
-        Cell checkerCell2 = checkerRow.createCell(6);
-        checkerCell2.setCellValue("瀹℃牳浜哄憳锛�");
-        checkerCell2.setCellStyle(styles.get("text"));
-
+        // 澶嶆牳浜哄憳琛�
         Row reviewerRow = sheet.createRow(startRow + 3);
-        Cell reviewerCell = reviewerRow.createCell(0);
-        reviewerCell.setCellValue("澶嶆牳浜哄憳锛�");
-        reviewerCell.setCellStyle(styles.get("text"));
+        for (int i = 0; i <= 9; i++) {
+            Cell cell = reviewerRow.createCell(i);
+            if (i == 0) {
+                cell.setCellValue("澶嶆牳浜哄憳锛�");
+            } else if (i == 6) {
+                cell.setCellValue("澶嶆牳浜哄憳锛�");
+            }
+            cell.setCellStyle(styles.get("text"));
+        }
 
-        Cell reviewerCell2 = reviewerRow.createCell(6);
-        reviewerCell2.setCellValue("澶嶆牳浜哄憳锛�");
-        reviewerCell2.setCellStyle(styles.get("text"));
-
+        // 鐩栫珷琛�
         Row stampRow = sheet.createRow(startRow + 4);
-        Cell stampCell = stampRow.createCell(0);
-        stampCell.setCellValue("鐩栫珷锛�");
-        stampCell.setCellStyle(styles.get("text"));
+        for (int i = 0; i <= 9; i++) {
+            Cell cell = stampRow.createCell(i);
+            if (i == 0) {
+                cell.setCellValue("鐩栫珷锛�");
+            } else if (i == 6) {
+                cell.setCellValue("鐩栫珷锛�");
+            }
+            cell.setCellStyle(styles.get("text"));
+        }
 
-        Cell stampCell2 = stampRow.createCell(6);
-        stampCell2.setCellValue("鐩栫珷锛�");
-        stampCell2.setCellStyle(styles.get("text"));
-
+        // 鏃ユ湡琛�
         Row dateRow = sheet.createRow(startRow + 5);
-        Cell dateCell = dateRow.createCell(0);
-        dateCell.setCellValue("鏃ユ湡锛�2026骞�  鏈�  鏃�");
-        dateCell.setCellStyle(styles.get("text"));
-
-        Cell dateCell2 = dateRow.createCell(6);
-        dateCell2.setCellValue("鏃ユ湡锛�2026骞�  鏈�  鏃�");
-        dateCell2.setCellStyle(styles.get("text"));
+        for (int i = 0; i <= 9; i++) {
+            Cell cell = dateRow.createCell(i);
+            if (i == 0) {
+                cell.setCellValue("鏃ユ湡锛�2026骞�  鏈�  鏃�");
+            } else if (i == 6) {
+                cell.setCellValue("鏃ユ湡锛�2026骞�  鏈�  鏃�");
+            }
+            cell.setCellStyle(styles.get("text"));
+        }
     }
 }
+

--
Gitblit v1.8.0