From cce6c3d3e166887344035c3e244c9d06f382abf7 Mon Sep 17 00:00:00 2001
From: sen <sen@qq.com>
Date: 星期一, 22 十二月 2025 16:28:39 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/cwxt_master' into cwxt_master

---
 tms/src/main/java/com/ruoyi/tms/controller/TmsRegionController.java |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/tms/src/main/java/com/ruoyi/tms/controller/TmsRegionController.java b/tms/src/main/java/com/ruoyi/tms/controller/TmsRegionController.java
index 728d61e..c9aa57e 100644
--- a/tms/src/main/java/com/ruoyi/tms/controller/TmsRegionController.java
+++ b/tms/src/main/java/com/ruoyi/tms/controller/TmsRegionController.java
@@ -1,6 +1,12 @@
 package com.ruoyi.tms.controller;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.tms.domain.vo.AddressVo;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -102,6 +108,57 @@
     {
         return AjaxResult.success(tmsRegionService.selectRegionVoList(code));
     }
+    @GetMapping(value = "/getAddressCode")
+    public AjaxResult getAddressCode(AddressVo addressVo)
+    {
+        Map<String,String> hasMap = new HashMap<>();
+
+        if (StringUtils.isNotEmpty(addressVo.getProvince())){
+            TmsRegion tmsRegion = tmsRegionService.getBaseMapper().selectOne(new LambdaUpdateWrapper<>(TmsRegion.class)
+                    .eq(TmsRegion::getRegionName, addressVo.getProvince())
+                    .last("limit 1")
+            );
+            if (tmsRegion != null){
+                hasMap.put("provinceCode",tmsRegion.getRegionCode());
+                if (StringUtils.isNotEmpty(addressVo.getCity())){
+                    TmsRegion tmsRegion2 = tmsRegionService.getBaseMapper().selectOne(new LambdaUpdateWrapper<>(TmsRegion.class)
+                            .eq(TmsRegion::getRegionName, addressVo.getCity())
+                            .eq(TmsRegion::getParentRegionCode, tmsRegion.getRegionCode())
+                            .last("limit 1")
+                    );
+                    if (tmsRegion2 != null){
+                        hasMap.put("cityCode",tmsRegion2.getRegionCode());
+
+                        if (StringUtils.isNotEmpty(addressVo.getDistrict())){
+                            TmsRegion tmsRegion3= tmsRegionService.getBaseMapper().selectOne(new LambdaUpdateWrapper<>(TmsRegion.class)
+                                    .eq(TmsRegion::getRegionName, addressVo.getDistrict())
+                                    .eq(TmsRegion::getParentRegionCode, tmsRegion2.getRegionCode())
+                                    .last("limit 1")
+                            );
+                            if (tmsRegion3 != null){
+                                hasMap.put("districtCode",tmsRegion3.getRegionCode());
+
+                                if (StringUtils.isNotEmpty(addressVo.getTownship())){
+                                    TmsRegion tmsRegion4 = tmsRegionService.getBaseMapper().selectOne(new LambdaUpdateWrapper<>(TmsRegion.class)
+                                            .eq(TmsRegion::getRegionName, addressVo.getTownship())
+                                            .eq(TmsRegion::getParentRegionCode, tmsRegion3.getRegionCode())
+                                            .last("limit 1")
+                                    );
+                                    if (tmsRegion4 != null){
+                                        hasMap.put("townshipCode",tmsRegion4.getRegionCode());
+                                    }
+                                }
+
+                            }
+                        }
+
+
+                    }
+                }
+            }
+        }
+        return AjaxResult.success(hasMap);
+    }
 
     /**
      * 鏂板琛屾斂鍖哄煙

--
Gitblit v1.8.0