From e961d2daa7f0fab9257ec411491cb23ab8a6c919 Mon Sep 17 00:00:00 2001
From: wzp <2040239371@qq.com>
Date: 星期四, 22 五月 2025 17:42:55 +0800
Subject: [PATCH] fix: 修复地址不显示的问题

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ServiceOrderController.java |  308 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 297 insertions(+), 11 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ServiceOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ServiceOrderController.java
index 9482e69..ce9308b 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ServiceOrderController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ServiceOrderController.java
@@ -1,6 +1,22 @@
 package com.ruoyi.web.controller.system;
 
 import java.util.List;
+import java.util.Objects;
+import java.text.SimpleDateFormat;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.math.BigDecimal;
+
+import com.ruoyi.common.annotation.Anonymous;
+import com.ruoyi.common.annotation.DataSource;
+import com.ruoyi.common.constant.HttpStatus;
+
+import com.ruoyi.common.enums.DataSourceType;
+import com.ruoyi.system.domain.*;
+import com.ruoyi.system.service.IDispatchOrdService;
+import com.ruoyi.system.service.IPayInfoService;
+import com.ruoyi.system.service.ITbOrdersService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
@@ -18,24 +34,30 @@
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.system.domain.ServiceOrder;
 import com.ruoyi.system.service.IServiceOrderService;
-import com.ruoyi.framework.datasource.annotation.DataSource;
-import com.ruoyi.framework.datasource.DataSourceType;
+
 
 import javax.servlet.http.HttpServletResponse;
 
 /**
  * 鏈嶅姟璁㈠崟 淇℃伅鎿嶄綔澶勭悊
- * 
+ *
  * @author ruoyi
  */
 @RestController
 @RequestMapping("/system/order")
-@DataSource(DataSourceType.SQLSERVER)
 public class ServiceOrderController extends BaseController {
     @Autowired
     private IServiceOrderService serviceOrderService;
+
+    @Autowired
+    private ITbOrdersService tbOrdersService;
+
+    @Autowired
+    private IDispatchOrdService dispatchOrdService;
+
+    @Autowired
+    private IPayInfoService payInfoService;
 
     /**
      * 鑾峰彇鏈嶅姟璁㈠崟鍒楄〃
@@ -43,9 +65,17 @@
     @PreAuthorize("@ss.hasPermi('system:order:list')")
     @GetMapping("/list")
     public TableDataInfo list(ServiceOrder serviceOrder) {
-        startPage();
+        // 鑾峰彇鎬绘暟
+        int total = serviceOrderService.selectServiceOrderCount(serviceOrder);
+        // 鑾峰彇鍒嗛〉鏁版嵁
         List<ServiceOrder> list = serviceOrderService.selectServiceOrderList(serviceOrder);
-        return getDataTable(list);
+        // 璁剧疆鎬绘暟
+        TableDataInfo rspData = new TableDataInfo();
+        rspData.setCode(HttpStatus.SUCCESS);
+        rspData.setMsg("鏌ヨ鎴愬姛");
+        rspData.setRows(list);
+        rspData.setTotal(total);
+        return rspData;
     }
 
     @Log(title = "鏈嶅姟璁㈠崟", businessType = BusinessType.EXPORT)
@@ -60,14 +90,266 @@
     /**
      * 鏍规嵁鏈嶅姟璁㈠崟缂栧彿鑾峰彇璇︾粏淇℃伅
      */
-    @PreAuthorize("@ss.hasPermi('system:order:query')")
+
+    @Anonymous(needSign = true)
     @GetMapping(value = "/{serviceOrdId}")
     public AjaxResult getInfo(@PathVariable Long serviceOrdId) {
-        return success(serviceOrderService.selectServiceOrderById(serviceOrdId));
+        TbOrders orderDetail = tbOrdersService.selectTbOrdersByOrderID(serviceOrdId);
+
+        if(orderDetail==null){
+            return AjaxResult.error("璁㈠崟涓嶅瓨鍦�");
+        }
+
+        //鏌ヨ鏈嶅姟鍗�
+        ServiceOrder mingServiceOrder = serviceOrderService.selectServiceOrderById(Long.valueOf(orderDetail.getServiceOrdID()));
+
+        DispatchOrd dispatchOrd = dispatchOrdService.selectDispatchOrdByServiceOrdIDDt(mingServiceOrder.getServiceOrdId().toString());
+
+        Map<String, Object> data = new HashMap<>();
+        
+        // 鏋勫缓璁㈠崟鍩烘湰淇℃伅
+        Map<String, Object> orderInfo = new HashMap<>();
+        orderInfo.put("OrderID", orderDetail.getOrderID());
+        
+        // 鏍煎紡鍖栨椂闂�
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        
+        // 鏍煎紡鍖栧垱寤烘椂闂�
+        String formattedCreateTime = orderDetail.getCreateTime() != null ? 
+            dateFormat.format(orderDetail.getCreateTime()) : "";
+        orderInfo.put("orderTime", formattedCreateTime);
+        
+        // 鏍煎紡鍖栭绾︽椂闂�
+        String formattedBookingTime = orderDetail.getBookingDate() != null ? 
+            dateFormat.format(orderDetail.getBookingDate()) : "";
+        orderInfo.put("appointmentTime", formattedBookingTime);
+
+
+
+
+        if(dispatchOrd!=null) {
+            //瑕佹煡璇㈣皟搴﹀崟
+            // 鏍煎紡鍖栬皟搴︽椂闂�
+            String formattedDispatchTime = dispatchOrd.getDispatchOrdStartDate() != null ?
+                    dateFormat.format(dispatchOrd.getDispatchOrdStartDate()) : "";
+            orderInfo.put("dispatchTime", formattedDispatchTime);
+        }
+        
+        // 璁㈠崟鐘舵�佽浆鎹㈤�昏緫
+        String orderStatus;
+        if (mingServiceOrder.getServiceOrdState() == 4) {
+            orderStatus = "宸插彇娑�";
+        } else if (mingServiceOrder.getServiceOrdState() == 3) {
+            orderStatus = "宸茶皟搴�";
+        } else if (mingServiceOrder.getServiceOrdTraTxnPrice().compareTo(BigDecimal.ZERO) > 0 
+                && mingServiceOrder.getServiceOrdState() <= 1) {
+            orderStatus = "鍜ㄨ鍗�";
+        } else if (mingServiceOrder.getServiceOrdTraTxnPrice().compareTo(BigDecimal.ZERO) > 0 
+                && mingServiceOrder.getServiceOrdState() != 4) {
+            orderStatus = "宸叉姤浠�";
+        } else {
+            orderStatus = "鍜ㄨ鍗�";
+        }
+        
+        orderInfo.put("orderStatus", orderStatus);
+        orderInfo.put("orderSource","骞夸氦闆嗗洟");
+        orderInfo.put("externalNo",orderDetail.getServiceOrdNo());
+
+        if(orderStatus.contains("璋冨害")){
+            orderInfo.put("documentStatus", "璋冨害鍗�");
+        }
+        else{
+            orderInfo.put("documentStatus", "鍜ㄨ鍗�");
+        }
+
+        orderInfo.put("price",mingServiceOrder.getServiceOrdTraTxnPrice());//浠锋牸
+        
+        // 鏋勫缓鎮h�呬俊鎭�
+        Map<String, Object> patientInfo = new HashMap<>();
+        patientInfo.put("contactName", orderDetail.getLinkPerson());
+        patientInfo.put("contactPhone", orderDetail.getLinkTel());
+        patientInfo.put("patientName", orderDetail.getPatientName());
+        patientInfo.put("patientAge", orderDetail.getAge());
+        // 鎬у埆杞崲锛�1鏄敺锛屽叾浠栨槸濂�
+        patientInfo.put("patientGender", "1".equals(orderDetail.getSex()) ? "鐢�" : "濂�");
+        patientInfo.put("patientWeight", orderDetail.getKg());
+        
+        // 鏋勫缓鏈嶅姟淇℃伅
+        Map<String, Object> serviceInfo = new HashMap<>();
+        serviceInfo.put("startAddress", orderDetail.getLocalAddress());
+        serviceInfo.put("startLocation", orderDetail.getLocalLongitude() + "," + orderDetail.getLocalLatitude());
+        serviceInfo.put("endAddress", orderDetail.getSendAddress());
+        serviceInfo.put("endLocation", orderDetail.getSendLongitude() + "," + orderDetail.getSendLatitude());
+        serviceInfo.put("distance", orderDetail.getBookingKM());
+        serviceInfo.put("liftService", orderDetail.getLiftingCode());
+        serviceInfo.put("liftFloor", orderDetail.getLiftingFloor());
+
+
+        //鏋勫缓璋冨害淇℃伅
+        Map<String, Object> dispatchInfo = new HashMap<>();
+        if(dispatchOrd!=null){
+            String dispatchOAEntourage = dispatchOrd.getDispatchOrd_OAEntourage();
+            String dispatchOAName = dispatchOrd.getDispatchOrd_OAName();
+            
+            if (dispatchOAEntourage != null && dispatchOAName != null) {
+                String[] entourages = dispatchOAEntourage.split(",");
+                String[] names = dispatchOAName.split(",");
+                
+                // 鐢ㄤ簬瀛樺偍涓嶅悓瑙掕壊鐨勪汉鍛�
+                Map<String, StringBuilder> roleMap = new HashMap<>();
+                roleMap.put("driver", new StringBuilder());
+                roleMap.put("doctor", new StringBuilder());
+                roleMap.put("nurse", new StringBuilder());
+                
+                // 閬嶅巻鎵惧嚭瀵瑰簲瑙掕壊鐨勪汉鍛�
+                for (int i = 0; i < Math.min(entourages.length, names.length); i++) {
+                    String role = entourages[i].trim();
+                    String name = names[i].trim();
+                    
+                    switch(role) {
+                        case "鍙告満":
+                            appendName(roleMap.get("driver"), name);
+                            break;
+                        case "鍖荤敓":
+                            appendName(roleMap.get("doctor"), name);
+                            break;
+                        case "鎶ゅ+":
+                            appendName(roleMap.get("nurse"), name);
+                            break;
+                    }
+                }
+                
+                // 灏嗘敹闆嗗埌鐨勪汉鍛樹俊鎭斁鍏ispatchInfo
+                dispatchInfo.put("driver", roleMap.get("driver").toString());
+                dispatchInfo.put("doctor", roleMap.get("doctor").toString());
+                dispatchInfo.put("nurse", roleMap.get("nurse").toString());
+
+                //璋冨害鏃堕棿
+                String formattedDispatchTime = dispatchOrd.getDispatchOrdStartDate() != null ?
+                    dateFormat.format(dispatchOrd.getDispatchOrdStartDate()) : "";
+                dispatchInfo.put("dispatchTime", formattedDispatchTime);
+
+                dispatchInfo.put("dispatchStatus","宸茶皟搴�");
+            }
+
+
+            //杞︾墝鍙�
+            String carLicense = dispatchOrdService.selectCarLicenseByCarId(Integer.valueOf(dispatchOrd.getDispatchOrdCarID()));
+            dispatchInfo.put("carLicense", carLicense);
+        }
+
+        //鐥呬汉鎯呭喌
+        Map<String, Object> medicalInfo = new HashMap<>();
+        medicalInfo.put("hasConsciousness", orderDetail.getSense());
+        medicalInfo.put("complaint",orderDetail.getComplaint());
+        
+        //鏉′欢
+        List<DictionaryCondition> conditions = dispatchOrdService.selectDictionaryConditions();
+        List<Integer> conditionIds = dispatchOrdService.selectConditionIdsByServiceOrdCoId(Long.valueOf(orderDetail.getServiceOrdID()));
+
+        String patientCondition = "";//鐥呬汉鎯呭喌
+        String useVentilator = "";//浣跨敤鍛煎惛鏈�
+        for(DictionaryCondition condition : conditions){
+
+            if(conditionIds.contains(condition.getVID())){
+                patientCondition += condition.getVOrder2() + ": " + condition.getVtext() + ";   ";
+            }
+
+            if(condition.getVOrder2().contains("鍛煎惛鏈�")){
+                useVentilator = condition.getVtext();
+            }
+        }
+
+        medicalInfo.put("patientCondition", patientCondition);
+        medicalInfo.put("useVentilator", useVentilator);
+
+
+        List<PayInfo> payInfoList = new ArrayList<>();
+        if(serviceOrdId==88801)
+        {
+            //娴嬭瘯鏁版嵁
+            payInfoList = payInfoService.selectPayInfoByServiceOrdIDDt("1016302788");//娴嬭瘯浣跨敤
+        }
+        else{
+            payInfoList = payInfoService.selectPayInfoByServiceOrdIDDt(orderDetail.getServiceOrdID()); //姝e紡浣跨敤
+        }
+
+
+        //鍏朵粬淇℃伅
+        Map<String, Object> otherInfo = new HashMap<>();
+        //璇勪环
+        otherInfo.put("serviceOrdVisit", Objects.toString(mingServiceOrder.getServiceOrdVisit(), "-"));
+
+        //鐭ユ儏鍚屾剰涔�
+        List<String> imageUrls = new ArrayList<>();//娴嬭瘯浣跨敤
+
+        if(serviceOrdId==88801)
+        {
+            //娴嬭瘯鏁版嵁  
+            imageUrls.add("https://sys.966120.com.cn/upload/202505/3016127678_3VhEv_VVql2K6eM9tS9uXgKv8fm7vaKtrSFCiP0SraTgz2qe1isgvIuUrqSNv-XgEvdC5kFUxeyrn_wz8Mfc2Sg.jpg");
+            imageUrls.add("https://sys.966120.com.cn/upload/202505/3016127678_3cDOPpqc_fzEJ-dHz8lq5aIx3tsnmEtossC6F5VCi2vj6sBwkuzOx4g1RcsWnQ3XNua7COADksYI1rHnbizccOw.jpg");
+            otherInfo.put("imageUrls", imageUrls);
+        }
+        else{
+            imageUrls = dispatchOrdService.selectImageUrlsByDOrdIDDt(orderDetail.getServiceOrdID());  //姝e紡浣跨敤
+            otherInfo.put("imageUrls", imageUrls);
+        }
+
+        //鍙戠エ鑾峰彇
+        Map<String, Object> invoiceInfo = new HashMap<>();
+
+        if(serviceOrdId==88801)
+        {
+            //娴嬭瘯鏁版嵁
+            invoiceInfo = payInfoService.selectLatestInvoiceInfo("1016302788");
+        }
+        else{
+            invoiceInfo = payInfoService.selectLatestInvoiceInfo(orderDetail.getServiceOrdID()); //姝e紡浣跨敤
+        }
+
+        String invoiceStatus = "";
+        if (invoiceInfo != null && invoiceInfo.get("AuditStatus") != null) {
+            switch (String.valueOf(invoiceInfo.get("AuditStatus"))) {
+                case "0":
+                    invoiceStatus = "鏈鐞�";
+                    break;
+                case "1":
+                    invoiceStatus = "寤跺悗澶勭悊";
+                    break;
+                case "3":
+                    invoiceStatus = "宸插紑绁�";
+                    break;
+                case "4":
+                    invoiceStatus = "鍙栨秷鐢宠";
+                    break;
+            }
+            otherInfo.put("invoiceStatus",invoiceInfo.get("InvoiceMakeout")+"-"+invoiceStatus);
+        }
+        
+
+
+        data.put("orderInfo", orderInfo);
+        data.put("patientInfo", patientInfo);
+        data.put("serviceInfo", serviceInfo);
+        data.put("medicalInfo", medicalInfo); // 鏆傛椂涓虹┖
+        data.put("dispatchInfo", dispatchInfo);  // 鏇存柊涓哄寘鍚汉鍛樹俊鎭殑dispatchInfo
+        data.put("paymentInfo", payInfoList); // 鏆傛椂涓虹┖
+        data.put("otherInfo", otherInfo);
+        
+        
+        return AjaxResult.success(data);
     }
 
-    /**
-     * 鏂板鏈嶅姟璁㈠崟
+    // 娣诲姞杈呭姪鏂规硶鏉ュ鐞嗗悕瀛楃殑鎷兼帴
+    private void appendName(StringBuilder sb, String name) {
+        if (sb.length() > 0) {
+            sb.append(",");
+        }
+        sb.append(name);
+    }
+
+    /*
+    鏂板璁㈠崟
      */
     @PreAuthorize("@ss.hasPermi('system:order:add')")
     @Log(title = "鏈嶅姟璁㈠崟", businessType = BusinessType.INSERT)
@@ -95,4 +377,8 @@
     public AjaxResult remove(@PathVariable Long[] serviceOrdIds) {
         return toAjax(serviceOrderService.deleteServiceOrderByIds(serviceOrdIds));
     }
+
+
+
+
 } 
\ No newline at end of file

--
Gitblit v1.9.1