Explorar el Código

Merge branch '围栏-V1.0'

Simon hace 2 años
padre
commit
64c8cfeb43
Se han modificado 20 ficheros con 1157 adiciones y 298 borrados
  1. 4 0
      ruoyi-admin/pom.xml
  2. 110 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TAdministrativeDivisionsController.java
  3. 4 16
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TDeviceListController.java
  4. 8 1
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TElectronicFenceController.java
  5. 12 17
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TRegionController.java
  6. 126 0
      ruoyi-system/src/main/java/com/ruoyi/system/domain/TAdministrativeDivisions.java
  7. 53 0
      ruoyi-system/src/main/java/com/ruoyi/system/domain/TRegionVo.java
  8. 96 0
      ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/AdministrativeDivisionsVo.java
  9. 102 0
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/TAdministrativeDivisionsMapper.java
  10. 9 9
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/TFacilityMapper.java
  11. 44 9
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/TRegionMapper.java
  12. 70 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/ITAdministrativeDivisionsService.java
  13. 9 17
      ruoyi-system/src/main/java/com/ruoyi/system/service/ITDeviceListService.java
  14. 7 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/ITRegionService.java
  15. 170 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TAdministrativeDivisionsServiceImpl.java
  16. 53 124
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TDeviceListServiceImpl.java
  17. 41 23
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRegionServiceImpl.java
  18. 121 0
      ruoyi-system/src/main/resources/mapper/system/TAdministrativeDivisionsMapper.xml
  19. 28 44
      ruoyi-system/src/main/resources/mapper/system/TFacilityMapper.xml
  20. 90 38
      ruoyi-system/src/main/resources/mapper/system/TRegionMapper.xml

+ 4 - 0
ruoyi-admin/pom.xml

@@ -67,6 +67,10 @@
             <artifactId>fastjson2</artifactId>
             <version>2.0.39</version>
         </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
 
 
     </dependencies>

+ 110 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TAdministrativeDivisionsController.java

@@ -0,0 +1,110 @@
+package com.ruoyi.web.controller.system;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import com.ruoyi.system.domain.vo.AdministrativeDivisionsVo;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.system.domain.TAdministrativeDivisions;
+import com.ruoyi.system.service.ITAdministrativeDivisionsService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 【请填写功能名称】Controller
+ *
+ * @author ruoyi
+ * @date 2023-09-20
+ */
+@RestController
+@RequestMapping("/system/divisions")
+public class TAdministrativeDivisionsController extends BaseController {
+    @Autowired
+    private ITAdministrativeDivisionsService tAdministrativeDivisionsService;
+
+    /**
+     * 查询【请填写功能名称】列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:divisions:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TAdministrativeDivisions tAdministrativeDivisions) {
+        startPage();
+        List<TAdministrativeDivisions> list = tAdministrativeDivisionsService.selectTAdministrativeDivisionsList(tAdministrativeDivisions);
+        return getDataTable(list);
+    }
+
+    /**
+     * 查询【请填写功能名称】列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:divisions:tempList')")
+    @GetMapping("/temp/list")
+    public TableDataInfo tempList(TAdministrativeDivisions tAdministrativeDivisions) {
+        startPage();
+        List<AdministrativeDivisionsVo> list = tAdministrativeDivisionsService.selectTAdministrativeDivisionsVoList(tAdministrativeDivisions);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出【请填写功能名称】列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:divisions:export')")
+    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, TAdministrativeDivisions tAdministrativeDivisions) {
+        List<TAdministrativeDivisions> list = tAdministrativeDivisionsService.selectTAdministrativeDivisionsList(tAdministrativeDivisions);
+        ExcelUtil<TAdministrativeDivisions> util = new ExcelUtil<TAdministrativeDivisions>(TAdministrativeDivisions.class);
+        util.exportExcel(response, list, "【请填写功能名称】数据");
+    }
+
+    /**
+     * 获取【请填写功能名称】详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:divisions:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
+        return success(tAdministrativeDivisionsService.selectTAdministrativeDivisionsById(id));
+    }
+
+    /**
+     * 新增【请填写功能名称】
+     */
+    @PreAuthorize("@ss.hasPermi('system:divisions:add')")
+    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TAdministrativeDivisions tAdministrativeDivisions) {
+        return toAjax(tAdministrativeDivisionsService.insertTAdministrativeDivisions(tAdministrativeDivisions));
+    }
+
+    /**
+     * 修改【请填写功能名称】
+     */
+    @PreAuthorize("@ss.hasPermi('system:divisions:edit')")
+    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TAdministrativeDivisions tAdministrativeDivisions) {
+        return toAjax(tAdministrativeDivisionsService.updateTAdministrativeDivisions(tAdministrativeDivisions));
+    }
+
+    /**
+     * 删除【请填写功能名称】
+     */
+    @PreAuthorize("@ss.hasPermi('system:divisions:remove')")
+    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
+        return toAjax(tAdministrativeDivisionsService.deleteTAdministrativeDivisionsByIds(ids));
+    }
+}

+ 4 - 16
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TDeviceListController.java

@@ -6,7 +6,6 @@ import javax.servlet.http.HttpServletResponse;
 
 import com.alibaba.fastjson2.JSONObject;
 import com.ruoyi.system.domain.TServiceManage;
-import com.ruoyi.system.domain.TUserProfile;
 import com.ruoyi.system.domain.dto.*;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -112,31 +111,20 @@ public class TDeviceListController extends BaseController
         util.importTemplateExcel(response, "设备列表模板");
     }
 
-//    /**
-//     * 导入
-//     */
-//    @Log(title = "设备列表", businessType = BusinessType.IMPORT)
-//    @PostMapping("/importData")
-//    @ResponseBody
-//    public AjaxResult importData(MultipartFile file) throws Exception
-//    {
-//        ExcelUtil<TDeviceList> util = new ExcelUtil<TDeviceList>(TDeviceList.class);
-//        List<TDeviceList> tDeviceLists = util.importExcel(file.getInputStream());
-//        String message = tDeviceListService.importTDeviceList(tDeviceLists);
-//        return AjaxResult.success(message);
-//    }
     /**
      * 导入
      */
     @Log(title = "设备列表", businessType = BusinessType.IMPORT)
     @PostMapping("/importData")
     @ResponseBody
-    public AjaxResult importDataV2(MultipartFile file) throws Exception {
+    public AjaxResult importData(MultipartFile file) throws Exception
+    {
         ExcelUtil<TDeviceList> util = new ExcelUtil<TDeviceList>(TDeviceList.class);
         List<TDeviceList> tDeviceLists = util.importExcel(file.getInputStream());
-        String message = tDeviceListService.importTDeviceListV2(tDeviceLists);
+        String message = tDeviceListService.importTDeviceList(tDeviceLists);
         return AjaxResult.success(message);
     }
+
     /**
      * 查询心率列表
      */

+ 8 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TElectronicFenceController.java

@@ -1,13 +1,21 @@
 package com.ruoyi.web.controller.system;
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.system.domain.to.AMapBaseTo;
 import com.ruoyi.system.domain.vo.AMapFenceVo;
 import com.ruoyi.system.domain.vo.ElectronicFenceVo;
+import org.junit.Test;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.ResourceUtils;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -49,7 +57,6 @@ public class TElectronicFenceController extends BaseController {
         return getDataTable(list);
     }
 
-
     /**
      * 查询【请填写功能名称】列表
      */

+ 12 - 17
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TRegionController.java

@@ -2,6 +2,7 @@ package com.ruoyi.web.controller.system;
 
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -23,14 +24,13 @@ import com.ruoyi.common.core.page.TableDataInfo;
 
 /**
  * 行政区域Controller
- * 
+ *
  * @author zhengjie
  * @date 2023-08-15
  */
 @RestController
 @RequestMapping("/system/region")
-public class TRegionController extends BaseController
-{
+public class TRegionController extends BaseController {
     @Autowired
     private ITRegionService tRegionService;
 
@@ -39,10 +39,10 @@ public class TRegionController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:region:list')")
     @GetMapping("/list")
-    public TableDataInfo list(TRegion tRegion)
-    {
+    public TableDataInfo list(TRegion tRegion) {
         startPage();
-        List<TRegion> list = tRegionService.selectTRegionList(tRegion);
+//        List<TRegion> list = tRegionService.selectTRegionList(tRegion);
+        List<TRegion> list = tRegionService.selectTRegionListV2(tRegion);
         return getDataTable(list);
     }
 
@@ -52,8 +52,7 @@ public class TRegionController extends BaseController
     @PreAuthorize("@ss.hasPermi('system:region:export')")
     @Log(title = "行政区域", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, TRegion tRegion)
-    {
+    public void export(HttpServletResponse response, TRegion tRegion) {
         List<TRegion> list = tRegionService.selectTRegionList(tRegion);
         ExcelUtil<TRegion> util = new ExcelUtil<TRegion>(TRegion.class);
         util.exportExcel(response, list, "行政区域数据");
@@ -64,8 +63,7 @@ public class TRegionController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:region:query')")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Integer id)
-    {
+    public AjaxResult getInfo(@PathVariable("id") Integer id) {
         return success(tRegionService.selectTRegionById(id));
     }
 
@@ -75,8 +73,7 @@ public class TRegionController extends BaseController
     @PreAuthorize("@ss.hasPermi('system:region:add')")
     @Log(title = "行政区域", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody TRegion tRegion)
-    {
+    public AjaxResult add(@RequestBody TRegion tRegion) {
         return toAjax(tRegionService.insertTRegion(tRegion));
     }
 
@@ -86,8 +83,7 @@ public class TRegionController extends BaseController
     @PreAuthorize("@ss.hasPermi('system:region:edit')")
     @Log(title = "行政区域", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody TRegion tRegion)
-    {
+    public AjaxResult edit(@RequestBody TRegion tRegion) {
         return toAjax(tRegionService.updateTRegion(tRegion));
     }
 
@@ -96,9 +92,8 @@ public class TRegionController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:region:remove')")
     @Log(title = "行政区域", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable Integer[] ids)
-    {
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Integer[] ids) {
         return toAjax(tRegionService.deleteTRegionByIds(ids));
     }
 }

+ 126 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/TAdministrativeDivisions.java

@@ -0,0 +1,126 @@
+package com.ruoyi.system.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 【请填写功能名称】对象 t_administrative_divisions
+ *
+ * @author ruoyi
+ * @date 2023-09-20
+ */
+public class TAdministrativeDivisions extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * $column.columnComment
+     */
+    private Long id;
+
+    /**
+     * 区域代码
+     */
+    @Excel(name = "区域代码")
+    private Long code;
+
+    /**
+     * 区域名称
+     */
+    @Excel(name = "区域名称")
+    private String name;
+
+    /**
+     * 乡级代码(镇)
+     */
+    @Excel(name = "乡级代码", readConverterExp = "镇=")
+    private Long streetCode;
+
+    /**
+     * 县级代码(区)
+     */
+    @Excel(name = "县级代码", readConverterExp = "区=")
+    private Long areaCode;
+
+    /**
+     * 地级代码(市)
+     */
+    @Excel(name = "地级代码", readConverterExp = "市=")
+    private Long cityCode;
+
+    /**
+     * 省级代码
+     */
+    @Excel(name = "省级代码")
+    private Long provinceCode;
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setCode(Long code) {
+        this.code = code;
+    }
+
+    public Long getCode() {
+        return code;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setStreetCode(Long streetCode) {
+        this.streetCode = streetCode;
+    }
+
+    public Long getStreetCode() {
+        return streetCode;
+    }
+
+    public void setAreaCode(Long areaCode) {
+        this.areaCode = areaCode;
+    }
+
+    public Long getAreaCode() {
+        return areaCode;
+    }
+
+    public void setCityCode(Long cityCode) {
+        this.cityCode = cityCode;
+    }
+
+    public Long getCityCode() {
+        return cityCode;
+    }
+
+    public void setProvinceCode(Long provinceCode) {
+        this.provinceCode = provinceCode;
+    }
+
+    public Long getProvinceCode() {
+        return provinceCode;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("id", getId())
+                .append("code", getCode())
+                .append("name", getName())
+                .append("streetCode", getStreetCode())
+                .append("areaCode", getAreaCode())
+                .append("cityCode", getCityCode())
+                .append("provinceCode", getProvinceCode())
+                .toString();
+    }
+}

+ 53 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/TRegionVo.java

@@ -0,0 +1,53 @@
+package com.ruoyi.system.domain;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.StringJoiner;
+
+/**
+ * @ClassName: TRegionVo
+ * @Author: 于学智
+ * @Description:
+ * @CreateDate: 2023/9/19 17:29
+ * @Version: 1.0
+ * @E-mail:18722650553@139.com
+ * @Link:https://github.com/18722650553
+ */
+public class TRegionVo implements Serializable {
+    private String code;
+    private String name;
+    private List<TRegionVo> child;
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public List<TRegionVo> getChild() {
+        return child;
+    }
+
+    public void setChild(List<TRegionVo> child) {
+        this.child = child;
+    }
+
+    @Override
+    public String toString() {
+        return new StringJoiner(", ", TRegionVo.class.getSimpleName() + "[", "]")
+                .add("code='" + code + "'")
+                .add("name='" + name + "'")
+                .add("child=" + child)
+                .toString();
+    }
+}

+ 96 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/AdministrativeDivisionsVo.java

@@ -0,0 +1,96 @@
+package com.ruoyi.system.domain.vo;
+
+import com.ruoyi.common.annotation.Excel;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.StringJoiner;
+
+/**
+ * @ClassName: AdministrativeDivisionsVo
+ * @Author: 于学智
+ * @Description:
+ * @CreateDate: 2023/9/20 15:17
+ * @Version: 1.0
+ * @E-mail:18722650553@139.com
+ * @Link:https://github.com/18722650553
+ */
+public class AdministrativeDivisionsVo implements Serializable {
+    /**
+     * $column.columnComment
+     */
+    private Long id;
+
+    /**
+     * 区域代码
+     */
+    @Excel(name = "区域代码")
+    private Long code;
+
+    /**
+     * 区域名称
+     */
+    @Excel(name = "区域名称")
+    private String name;
+    /**
+     * 父级ID
+     */
+    @Excel(name = "父级ID")
+    private Long parentId;
+    /**
+     * 子区域
+     */
+    @Excel(name = "子区域")
+    private List<AdministrativeDivisionsVo> child;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getCode() {
+        return code;
+    }
+
+    public void setCode(Long code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Long getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(Long parentId) {
+        this.parentId = parentId;
+    }
+
+    public List<AdministrativeDivisionsVo> getChild() {
+        return child;
+    }
+
+    public void setChild(List<AdministrativeDivisionsVo> child) {
+        this.child = child;
+    }
+
+    @Override
+    public String toString() {
+        return new StringJoiner(", ", AdministrativeDivisionsVo.class.getSimpleName() + "[", "]")
+                .add("id=" + id)
+                .add("code=" + code)
+                .add("name='" + name + "'")
+                .add("parentId=" + parentId)
+                .add("child=" + child)
+                .toString();
+    }
+}

+ 102 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TAdministrativeDivisionsMapper.java

@@ -0,0 +1,102 @@
+package com.ruoyi.system.mapper;
+
+import java.util.List;
+
+import com.ruoyi.system.domain.TAdministrativeDivisions;
+
+/**
+ * 城市五级表Mapper接口
+ *
+ * @author ruoyi
+ * @date 2023-09-20
+ */
+public interface TAdministrativeDivisionsMapper {
+    /**
+     * 查询城市五级表
+     *
+     * @param id 城市五级表主键
+     * @return 城市五级表
+     */
+    public TAdministrativeDivisions selectTAdministrativeDivisionsById(Long id);
+
+    /**
+     * 查询城市五级表列表
+     *
+     * @param tAdministrativeDivisions 城市五级表
+     * @return 城市五级表集合
+     */
+    public List<TAdministrativeDivisions> selectTAdministrativeDivisionsList(TAdministrativeDivisions tAdministrativeDivisions);
+
+    /**
+     * 新增城市五级表
+     *
+     * @param tAdministrativeDivisions 城市五级表
+     * @return 结果
+     */
+    public int insertTAdministrativeDivisions(TAdministrativeDivisions tAdministrativeDivisions);
+
+    /**
+     * 修改城市五级表
+     *
+     * @param tAdministrativeDivisions 城市五级表
+     * @return 结果
+     */
+    public int updateTAdministrativeDivisions(TAdministrativeDivisions tAdministrativeDivisions);
+
+    /**
+     * 删除城市五级表
+     *
+     * @param id 城市五级表主键
+     * @return 结果
+     */
+    public int deleteTAdministrativeDivisionsById(Long id);
+
+    /**
+     * 批量删除城市五级表
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTAdministrativeDivisionsByIds(Long[] ids);
+
+    /**
+     * 查询所有省份
+     *
+     * @return
+     */
+    List<TAdministrativeDivisions> selectTAdministrativeDivisionsProvinceAllList();
+
+
+    /**
+     * 查询所有地级(市)
+     *
+     * @param provinceCode 省级代码
+     * @return
+     */
+    List<TAdministrativeDivisions> selectTAdministrativeDivisionsListByProvinceCode(Long provinceCode);
+
+    /**
+     * 查询所有县级(区)
+     *
+     * @param cityCode 地级代码(市)
+     * @return
+     */
+    List<TAdministrativeDivisions> selectTAdministrativeDivisionsListByCityCode(Long cityCode);
+
+    /**
+     * 查询所有乡级(镇)
+     *
+     * @param areaCode 县级代码(区)
+     * @return
+     */
+    List<TAdministrativeDivisions> selectTAdministrativeDivisionsListByAreaCode(Long areaCode);
+
+    /**
+     * 查询所有居委会
+     *
+     * @param streetCode 乡级代码(镇)
+     * @return
+     */
+    List<TAdministrativeDivisions> selectTAdministrativeDivisionsListByStreetCode(Long streetCode);
+
+}

+ 9 - 9
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TFacilityMapper.java

@@ -4,19 +4,19 @@ import java.util.List;
 
 import com.ruoyi.common.annotation.DataSource;
 import com.ruoyi.common.enums.DataSourceType;
-import com.ruoyi.system.domain.TDeviceList;
 import com.ruoyi.system.domain.TFacility;
 
 /**
  * 手环设备Mapper接口
- *
+ * 
  * @author zhengjie
  * @date 2023-08-12
  */
-public interface TFacilityMapper {
+public interface TFacilityMapper 
+{
     /**
      * 查询手环设备
-     *
+     * 
      * @param id 手环设备主键
      * @return 手环设备
      */
@@ -38,7 +38,7 @@ public interface TFacilityMapper {
 
     /**
      * 查询手环设备列表
-     *
+     * 
      * @param tFacility 手环设备
      * @return 手环设备集合
      */
@@ -46,7 +46,7 @@ public interface TFacilityMapper {
 
     /**
      * 新增手环设备
-     *
+     * 
      * @param tFacility 手环设备
      * @return 结果
      */
@@ -54,7 +54,7 @@ public interface TFacilityMapper {
 
     /**
      * 修改手环设备
-     *
+     * 
      * @param tFacility 手环设备
      * @return 结果
      */
@@ -62,7 +62,7 @@ public interface TFacilityMapper {
 
     /**
      * 删除手环设备
-     *
+     * 
      * @param id 手环设备主键
      * @return 结果
      */
@@ -70,7 +70,7 @@ public interface TFacilityMapper {
 
     /**
      * 批量删除手环设备
-     *
+     * 
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */

+ 44 - 9
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TRegionMapper.java

@@ -5,18 +5,18 @@ import java.util.List;
 import com.ruoyi.common.annotation.DataSource;
 import com.ruoyi.common.enums.DataSourceType;
 import com.ruoyi.system.domain.TRegion;
+import com.ruoyi.system.domain.TRegionVo;
 
 /**
  * 行政区域Mapper接口
- * 
+ *
  * @author zhengjie
  * @date 2023-08-15
  */
-public interface TRegionMapper 
-{
+public interface TRegionMapper {
     /**
      * 查询行政区域
-     * 
+     *
      * @param id 行政区域主键
      * @return 行政区域
      */
@@ -32,15 +32,50 @@ public interface TRegionMapper
 
     /**
      * 查询行政区域列表
-     * 
+     *
      * @param tRegion 行政区域
      * @return 行政区域集合
      */
     public List<TRegion> selectTRegionList(TRegion tRegion);
 
+    /**
+     * 查询行政区域列表-省
+     *
+     * @return 行政区域集合
+     */
+    public List<TRegionVo> selectTRegionListV1();
+
+    /**
+     * 查询行政区域列表-市
+     *
+     * @return 行政区域集合
+     */
+    public List<TRegionVo> selectTRegionListV2(String province_code);
+
+    /**
+     * 查询行政区域列表-区
+     *
+     * @return 行政区域集合
+     */
+    public List<TRegionVo> selectTRegionListV3(String city_code);
+
+    /**
+     * 查询行政区域列表-办事处
+     *
+     * @return 行政区域集合
+     */
+    public List<TRegionVo> selectTRegionListV4(String county_code);
+
+    /**
+     * 查询行政区域列表-居委会
+     *
+     * @return 行政区域集合
+     */
+    public List<TRegionVo> selectTRegionListV5(String town_code);
+
     /**
      * 新增行政区域
-     * 
+     *
      * @param tRegion 行政区域
      * @return 结果
      */
@@ -48,7 +83,7 @@ public interface TRegionMapper
 
     /**
      * 修改行政区域
-     * 
+     *
      * @param tRegion 行政区域
      * @return 结果
      */
@@ -56,7 +91,7 @@ public interface TRegionMapper
 
     /**
      * 删除行政区域
-     * 
+     *
      * @param id 行政区域主键
      * @return 结果
      */
@@ -64,7 +99,7 @@ public interface TRegionMapper
 
     /**
      * 批量删除行政区域
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */

+ 70 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ITAdministrativeDivisionsService.java

@@ -0,0 +1,70 @@
+package com.ruoyi.system.service;
+
+import java.util.List;
+
+import com.ruoyi.system.domain.TAdministrativeDivisions;
+import com.ruoyi.system.domain.vo.AdministrativeDivisionsVo;
+
+/**
+ * 【请填写功能名称】Service接口
+ *
+ * @author ruoyi
+ * @date 2023-09-20
+ */
+public interface ITAdministrativeDivisionsService {
+    /**
+     * 查询【请填写功能名称】
+     *
+     * @param id 【请填写功能名称】主键
+     * @return 【请填写功能名称】
+     */
+    public TAdministrativeDivisions selectTAdministrativeDivisionsById(Long id);
+
+    /**
+     * 查询【请填写功能名称】列表
+     *
+     * @param tAdministrativeDivisions 【请填写功能名称】
+     * @return 【请填写功能名称】集合
+     */
+    public List<TAdministrativeDivisions> selectTAdministrativeDivisionsList(TAdministrativeDivisions tAdministrativeDivisions);
+
+    /**
+     * 查询【请填写功能名称】列表
+     *
+     * @param tAdministrativeDivisions 【请填写功能名称】
+     * @return 【请填写功能名称】集合
+     */
+    public List<AdministrativeDivisionsVo> selectTAdministrativeDivisionsVoList(TAdministrativeDivisions tAdministrativeDivisions);
+
+    /**
+     * 新增【请填写功能名称】
+     *
+     * @param tAdministrativeDivisions 【请填写功能名称】
+     * @return 结果
+     */
+    public int insertTAdministrativeDivisions(TAdministrativeDivisions tAdministrativeDivisions);
+
+    /**
+     * 修改【请填写功能名称】
+     *
+     * @param tAdministrativeDivisions 【请填写功能名称】
+     * @return 结果
+     */
+    public int updateTAdministrativeDivisions(TAdministrativeDivisions tAdministrativeDivisions);
+
+    /**
+     * 批量删除【请填写功能名称】
+     *
+     * @param ids 需要删除的【请填写功能名称】主键集合
+     * @return 结果
+     */
+    public int deleteTAdministrativeDivisionsByIds(Long[] ids);
+
+    /**
+     * 删除【请填写功能名称】信息
+     *
+     * @param id 【请填写功能名称】主键
+     * @return 结果
+     */
+    public int deleteTAdministrativeDivisionsById(Long id);
+}

+ 9 - 17
ruoyi-system/src/main/java/com/ruoyi/system/service/ITDeviceListService.java

@@ -1,21 +1,21 @@
 package com.ruoyi.system.service;
 
 import java.util.List;
-
 import com.ruoyi.system.domain.TDeviceList;
 import com.ruoyi.system.domain.TServiceManage;
 import com.ruoyi.system.domain.dto.*;
 
 /**
  * 设备列Service接口
- *
+ * 
  * @author zhengjie
  * @date 2023-08-30
  */
-public interface ITDeviceListService {
+public interface ITDeviceListService 
+{
     /**
      * 查询设备列
-     *
+     * 
      * @param id 设备列主键
      * @return 设备列
      */
@@ -23,7 +23,7 @@ public interface ITDeviceListService {
 
     /**
      * 查询设备列列表
-     *
+     * 
      * @param tDeviceList 设备列
      * @return 设备列集合
      */
@@ -93,17 +93,9 @@ public interface ITDeviceListService {
      */
     public String importTDeviceList(List<TDeviceList> tDeviceLists);
 
-    /**
-     * 导入设备列表数据
-     *
-     * @param tDeviceLists 设备列表列表
-     * @return 结果
-     */
-    public String importTDeviceListV2(List<TDeviceList> tDeviceLists);
-
     /**
      * 新增设备列
-     *
+     * 
      * @param tDeviceList 设备列
      * @return 结果
      */
@@ -111,7 +103,7 @@ public interface ITDeviceListService {
 
     /**
      * 修改设备列
-     *
+     * 
      * @param tDeviceList 设备列
      * @return 结果
      */
@@ -119,7 +111,7 @@ public interface ITDeviceListService {
 
     /**
      * 批量删除设备列
-     *
+     * 
      * @param ids 需要删除的设备列主键集合
      * @return 结果
      */
@@ -127,7 +119,7 @@ public interface ITDeviceListService {
 
     /**
      * 删除设备列信息
-     *
+     * 
      * @param id 设备列主键
      * @return 结果
      */

+ 7 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ITRegionService.java

@@ -26,6 +26,13 @@ public interface ITRegionService
      * @return 行政区域集合
      */
     public List<TRegion> selectTRegionList(TRegion tRegion);
+    /**
+     * 查询行政区域列表
+     *
+     * @param tRegion 行政区域
+     * @return 行政区域集合
+     */
+    public List<TRegion> selectTRegionListV2(TRegion tRegion);
 
     /**
      * 新增行政区域

+ 170 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TAdministrativeDivisionsServiceImpl.java

@@ -0,0 +1,170 @@
+package com.ruoyi.system.service.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import com.ruoyi.system.domain.vo.AdministrativeDivisionsVo;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.system.mapper.TAdministrativeDivisionsMapper;
+import com.ruoyi.system.domain.TAdministrativeDivisions;
+import com.ruoyi.system.service.ITAdministrativeDivisionsService;
+
+/**
+ * 【请填写功能名称】Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2023-09-20
+ */
+@Service
+public class TAdministrativeDivisionsServiceImpl implements ITAdministrativeDivisionsService {
+    @Autowired
+    private TAdministrativeDivisionsMapper tAdministrativeDivisionsMapper;
+
+    /**
+     * 查询【请填写功能名称】
+     *
+     * @param id 【请填写功能名称】主键
+     * @return 【请填写功能名称】
+     */
+    @Override
+    public TAdministrativeDivisions selectTAdministrativeDivisionsById(Long id) {
+        return tAdministrativeDivisionsMapper.selectTAdministrativeDivisionsById(id);
+    }
+
+    /**
+     * 查询【请填写功能名称】列表
+     *
+     * @param tAdministrativeDivisions 【请填写功能名称】
+     * @return 【请填写功能名称】
+     */
+    @Override
+    public List<TAdministrativeDivisions> selectTAdministrativeDivisionsList(TAdministrativeDivisions tAdministrativeDivisions) {
+        //查询
+        return tAdministrativeDivisionsMapper.selectTAdministrativeDivisionsList(tAdministrativeDivisions);
+    }
+
+    @Override
+    public List<AdministrativeDivisionsVo> selectTAdministrativeDivisionsVoList(TAdministrativeDivisions tAdministrativeDivisions) {
+        List<AdministrativeDivisionsVo> divisionsVos = new ArrayList<>();
+        //查询所有省份List
+        List<TAdministrativeDivisions> provinceList = tAdministrativeDivisionsMapper.selectTAdministrativeDivisionsProvinceAllList();
+        if (provinceList != null && !provinceList.isEmpty()) {
+            divisionsVos = provinceList.subList(0, 2).stream()
+                    .map(provinceEntity -> {
+                        AdministrativeDivisionsVo provinceVo = new AdministrativeDivisionsVo();
+                        BeanUtils.copyProperties(provinceEntity, provinceVo);
+                        List<AdministrativeDivisionsVo> cityVos = new ArrayList<>();
+                        if (provinceVo.getCode() != null) {
+                            //查询所有市List
+                            List<TAdministrativeDivisions> cityList = tAdministrativeDivisionsMapper.selectTAdministrativeDivisionsListByProvinceCode(provinceVo.getCode());
+                            if (cityList != null && !cityList.isEmpty()) {
+                                cityVos = cityList.subList(0, 1).stream()
+                                        .map(cityEntity -> {
+                                            AdministrativeDivisionsVo cityVo = new AdministrativeDivisionsVo();
+                                            BeanUtils.copyProperties(cityEntity, cityVo);
+                                            List<AdministrativeDivisionsVo> areaVos = new ArrayList<>();
+                                            if (cityVo.getCode() != null) {
+                                                //查询所有县级区List
+                                                List<TAdministrativeDivisions> areaList = tAdministrativeDivisionsMapper.selectTAdministrativeDivisionsListByCityCode(cityVo.getCode());
+                                                if (areaList != null && !areaList.isEmpty()) {
+                                                    areaVos = areaList.subList(0, 3).stream()
+                                                            .map(areaEntity -> {
+                                                                AdministrativeDivisionsVo areaVo = new AdministrativeDivisionsVo();
+                                                                BeanUtils.copyProperties(areaEntity, areaVo);
+                                                                List<AdministrativeDivisionsVo> streetVos = new ArrayList<>();
+                                                                if (areaVo.getCode() != null) {
+                                                                    //查询所有乡级镇List
+                                                                    List<TAdministrativeDivisions> streetList = tAdministrativeDivisionsMapper.selectTAdministrativeDivisionsListByAreaCode(areaVo.getCode());
+                                                                    if (streetList != null && !streetList.isEmpty()) {
+                                                                        streetVos = streetList.subList(0, 3).stream()
+                                                                                .map(streetEntity -> {
+                                                                                    AdministrativeDivisionsVo streetVo = new AdministrativeDivisionsVo();
+                                                                                    BeanUtils.copyProperties(streetEntity, streetVo);
+                                                                                    List<AdministrativeDivisionsVo> neighborhoodVos = new ArrayList<>();
+                                                                                    if (streetVo.getCode() != null) {
+                                                                                        //查询所有居委会List
+                                                                                        List<TAdministrativeDivisions> neighborhoodList = tAdministrativeDivisionsMapper.selectTAdministrativeDivisionsListByStreetCode(streetVo.getCode());
+                                                                                        if (neighborhoodList != null && !neighborhoodList.isEmpty()) {
+                                                                                            neighborhoodVos = neighborhoodList.subList(0, 3).stream()
+                                                                                                    .map(neighborhoodEntity -> {
+                                                                                                        AdministrativeDivisionsVo neighborhoodVo = new AdministrativeDivisionsVo();
+                                                                                                        BeanUtils.copyProperties(neighborhoodEntity, neighborhoodVo);
+                                                                                                        neighborhoodVo.setParentId(streetVo.getCode());
+                                                                                                        return neighborhoodVo;
+                                                                                                    }).collect(Collectors.toList());
+                                                                                        }
+                                                                                    }
+                                                                                    streetVo.setChild(neighborhoodVos);
+                                                                                    streetVo.setParentId(areaVo.getCode());
+                                                                                    return streetVo;
+                                                                                }).collect(Collectors.toList());
+                                                                    }
+                                                                }
+                                                                areaVo.setChild(streetVos);
+                                                                areaVo.setParentId(cityVo.getCode());
+                                                                return areaVo;
+                                                            }).collect(Collectors.toList());
+                                                }
+                                                cityVo.setChild(areaVos);
+                                                cityVo.setParentId(cityVo.getCode());
+                                            }
+                                            cityVo.setChild(areaVos);
+                                            cityVo.setParentId(provinceVo.getCode());
+                                            return cityVo;
+                                        }).collect(Collectors.toList());
+                            }
+                        }
+                        provinceVo.setChild(cityVos);
+                        return provinceVo;
+                    }).collect(Collectors.toList());
+        }
+        return divisionsVos;
+    }
+
+    /**
+     * 新增【请填写功能名称】
+     *
+     * @param tAdministrativeDivisions 【请填写功能名称】
+     * @return 结果
+     */
+    @Override
+    public int insertTAdministrativeDivisions(TAdministrativeDivisions tAdministrativeDivisions) {
+        return tAdministrativeDivisionsMapper.insertTAdministrativeDivisions(tAdministrativeDivisions);
+    }
+
+    /**
+     * 修改【请填写功能名称】
+     *
+     * @param tAdministrativeDivisions 【请填写功能名称】
+     * @return 结果
+     */
+    @Override
+    public int updateTAdministrativeDivisions(TAdministrativeDivisions tAdministrativeDivisions) {
+        return tAdministrativeDivisionsMapper.updateTAdministrativeDivisions(tAdministrativeDivisions);
+    }
+
+    /**
+     * 批量删除【请填写功能名称】
+     *
+     * @param ids 需要删除的【请填写功能名称】主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTAdministrativeDivisionsByIds(Long[] ids) {
+        return tAdministrativeDivisionsMapper.deleteTAdministrativeDivisionsByIds(ids);
+    }
+
+    /**
+     * 删除【请填写功能名称】信息
+     *
+     * @param id 【请填写功能名称】主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTAdministrativeDivisionsById(Long id) {
+        return tAdministrativeDivisionsMapper.deleteTAdministrativeDivisionsById(id);
+    }
+}

+ 53 - 124
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TDeviceListServiceImpl.java

@@ -17,16 +17,16 @@ import org.springframework.stereotype.Service;
 import com.ruoyi.system.mapper.TDeviceListMapper;
 import com.ruoyi.system.domain.TDeviceList;
 import com.ruoyi.system.service.ITDeviceListService;
-import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 设备列Service业务层处理
- *
+ * 
  * @author zhengjie
  * @date 2023-08-30
  */
 @Service
-public class TDeviceListServiceImpl implements ITDeviceListService {
+public class TDeviceListServiceImpl implements ITDeviceListService 
+{
     @Autowired
     private TDeviceListMapper tDeviceListMapper;
     @Autowired
@@ -36,23 +36,25 @@ public class TDeviceListServiceImpl implements ITDeviceListService {
 
     /**
      * 查询设备列
-     *
+     * 
      * @param id 设备列主键
      * @return 设备列
      */
     @Override
-    public TDeviceList selectTDeviceListById(Integer id) {
+    public TDeviceList selectTDeviceListById(Integer id)
+    {
         return tDeviceListMapper.selectTDeviceListById(id);
     }
 
     /**
      * 查询设备列列表
-     *
+     * 
      * @param tDeviceList 设备列
      * @return 设备列
      */
     @Override
-    public List<TDeviceList> selectTDeviceListList(TDeviceList tDeviceList) {
+    public List<TDeviceList> selectTDeviceListList(TDeviceList tDeviceList)
+    {
         return tDeviceListMapper.selectTDeviceListList(tDeviceList);
     }
 
@@ -93,19 +95,19 @@ public class TDeviceListServiceImpl implements ITDeviceListService {
 
     /**
      * 新增设备列
-     *
+     * 
      * @param tDeviceList 设备列
      * @return 结果
      */
-    @Transactional
     @Override
-    public int insertTDeviceList(TDeviceList tDeviceList) {
+    public int insertTDeviceList(TDeviceList tDeviceList)
+    {
         TFacility tFacility = new TFacility();
-        if (StringUtils.isNotNull(tDeviceList.getDeviceId())) {
+        if (StringUtils.isNotNull(tDeviceList.getDeviceId())){
             tFacility.setCode(tDeviceList.getDeviceId());
-        } else if (StringUtils.isNotNull(tDeviceList.getSimCode())) {
+        }else if (StringUtils.isNotNull(tDeviceList.getSimCode())){
             tFacility.setTelno(tDeviceList.getSimCode());
-        } else if (StringUtils.isNotNull(tDeviceList.getSerialNumber())) {
+        }else if (StringUtils.isNotNull(tDeviceList.getSerialNumber())){
             tFacility.setIccid(tDeviceList.getSerialNumber());
         }
         tFacility.setCreateTime(DateUtils.getNowDate());
@@ -116,18 +118,19 @@ public class TDeviceListServiceImpl implements ITDeviceListService {
 
     /**
      * 修改设备列
-     *
+     * 
      * @param tDeviceList 设备列
      * @return 结果
      */
     @Override
-    public int updateTDeviceList(TDeviceList tDeviceList) {
+    public int updateTDeviceList(TDeviceList tDeviceList)
+    {
         return tDeviceListMapper.updateTDeviceList(tDeviceList);
     }
 
     /**
      * 批量删除设备列
-     *
+     * 
      * @param ids 需要删除的设备列主键
      * @return 结果
      */
@@ -151,7 +154,7 @@ public class TDeviceListServiceImpl implements ITDeviceListService {
 
     /**
      * 删除设备列信息
-     *
+     * 
      * @param id 设备列主键
      * @return 结果
      */
@@ -168,129 +171,55 @@ public class TDeviceListServiceImpl implements ITDeviceListService {
     @Override
     public String importTDeviceList(List<TDeviceList> tDeviceLists) {
 
-        if (StringUtils.isNull(tDeviceLists) || tDeviceLists.size() == 0) {
+        if (StringUtils.isNull(tDeviceLists) || tDeviceLists.size() == 0)
+        {
             throw new ServiceException("导入设备列表信息数据不能为空!");
         }
         int successNum = 0;
         int failureNum = 0;
         StringBuilder successMsg = new StringBuilder();
         StringBuilder failureMsg = new StringBuilder();
-        for (TDeviceList tDeviceList : tDeviceLists) {
-            try {
+        for (TDeviceList tDeviceList : tDeviceLists)
+        {
+            try
+            {
                 TUserProfile user = tUserProfileMapper.selectTUserProfileBySfzId(tDeviceList.getSfzid());
                 TDeviceList device = tDeviceListMapper.selectTDeviceListListByDeviceId(tDeviceList.getDeviceId());
-                if (StringUtils.isNotNull(user) && StringUtils.isNull(device)) {
+                if (StringUtils.isNotNull(user) && StringUtils.isNull(device))
+                {
                     tDeviceList.setUserid(user.getId());
                     tDeviceList.setSfzid(user.getSfzid());
                     tDeviceList.setTelno(user.getTelOne());
                     this.insertTDeviceList(tDeviceList);
                     successNum++;
                     successMsg.append("<br/>" + successNum + "设备列表信息" + " 导入成功");
-                } else {
+                }
+                else
+                {
                     failureNum++;
                     failureMsg.append("<br/>" + failureNum + "设备列表信息" + " 信息不完整");
                 }
-            } catch (Exception e) {
+            }
+            catch (Exception e)
+            {
                 failureNum++;
                 String msg = "<br/>" + failureNum + "设备列表信息" + " 导入失败:";
                 failureMsg.append(msg + e.getMessage());
             }
         }
-        if (failureNum > 0) {
+        if (failureNum > 0)
+        {
             failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
             throw new ServiceException(failureMsg.toString());
-        } else {
+        }
+        else
+        {
             successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
         }
         return successMsg.toString();
 
     }
 
-    @Transactional
-    @Override
-    public String importTDeviceListV2(List<TDeviceList> tDeviceLists) {
-        if (tDeviceLists == null || tDeviceLists.isEmpty()) {
-            throw new ServiceException("导入设备列表信息数据不能为空!");
-        }
-        //批量导入设备数据
-        for (TDeviceList deviceListEntity : tDeviceLists) {
-            //判断提交数据格式是否正确
-            if (deviceListEntity.getSfzid() == null || deviceListEntity.getSfzid().isEmpty()) {
-                throw new ServiceException("导入设备数信息身份证号格式异常!");
-            }
-            //根据身份证号查询数据库中的用户信息
-            TUserProfile user = tUserProfileMapper.selectTUserProfileBySfzId(deviceListEntity.getSfzid());
-            if (user == null) {
-                //如果表中有该用户则提示
-                StringBuilder stringBuilder = new StringBuilder();
-                stringBuilder.append("导入设备数信息未匹配到用户");
-                //如果有设备标识ID,则提示
-                if (!StringUtils.isEmpty(deviceListEntity.getDeviceId())) {
-                    stringBuilder.append(", 设备标识ID:" + deviceListEntity.getDeviceId());
-                }
-                //如果有设备标识ID,则提示
-                if (!StringUtils.isEmpty(deviceListEntity.getName())) {
-                    stringBuilder.append(", 用户名:" + deviceListEntity.getName());
-                }
-                //如果有身份证号,则提示
-                if (!StringUtils.isEmpty(deviceListEntity.getSfzid())) {
-                    stringBuilder.append(", 身份证号:" + deviceListEntity.getSfzid());
-                }
-                stringBuilder.append("!");
-                throw new ServiceException(stringBuilder.toString());
-            }
-            //根据设备ID查询数据库中的设备信息
-            List<TFacility> facilityList = tFacilityMapper.selectTDeviceListListByDeviceId(deviceListEntity.getDeviceId());
-            if (facilityList != null && !facilityList.isEmpty()) {
-                //如果表中有该用户则提示
-                StringBuilder stringBuilder = new StringBuilder();
-                stringBuilder.append("导入设备信息已存在");
-                //如果有设备标识ID,则提示
-                if (!StringUtils.isEmpty(deviceListEntity.getDeviceId())) {
-                    stringBuilder.append(", 设备标识ID:" + deviceListEntity.getDeviceId());
-                }
-                //如果有设备标识ID,则提示
-                if (!StringUtils.isEmpty(deviceListEntity.getName())) {
-                    stringBuilder.append(", 用户名:" + deviceListEntity.getName());
-                }
-                //如果有身份证号,则提示
-                if (!StringUtils.isEmpty(deviceListEntity.getSfzid())) {
-                    stringBuilder.append(", 身份证号:" + deviceListEntity.getSfzid());
-                }
-                stringBuilder.append("!");
-                throw new ServiceException(stringBuilder.toString());
-            }
-            //根据设备ID查询数据库中的设备信息
-            TDeviceList device = tDeviceListMapper.selectTDeviceListListByDeviceId(deviceListEntity.getDeviceId());
-            if (device != null) {
-                //如果表中有该用户则提示
-                StringBuilder stringBuilder = new StringBuilder();
-                stringBuilder.append("导入设备信息已存在");
-                //如果有设备标识ID,则提示
-                if (!StringUtils.isEmpty(deviceListEntity.getDeviceId())) {
-                    stringBuilder.append(", 设备标识ID:" + deviceListEntity.getDeviceId());
-                }
-                //如果有设备标识ID,则提示
-                if (!StringUtils.isEmpty(deviceListEntity.getName())) {
-                    stringBuilder.append(", 用户名:" + deviceListEntity.getName());
-                }
-                //如果有身份证号,则提示
-                if (!StringUtils.isEmpty(deviceListEntity.getSfzid())) {
-                    stringBuilder.append(", 身份证号:" + deviceListEntity.getSfzid());
-                }
-                stringBuilder.append("!");
-                throw new ServiceException(stringBuilder.toString());
-            }
-            deviceListEntity.setUserid(user.getId());
-            deviceListEntity.setSfzid(user.getSfzid());
-            deviceListEntity.setTelno(user.getTelOne());
-            this.insertTDeviceList(deviceListEntity);
-        }
-        StringBuilder successMsg = new StringBuilder();
-        successMsg.append("恭喜您,数据已全部导入成功!共 " + tDeviceLists.size() + " 条,数据如下:");
-        return successMsg.toString();
-    }
-
     /**
      * 判断报警信息
      *
@@ -298,8 +227,8 @@ public class TDeviceListServiceImpl implements ITDeviceListService {
      * @return 结果
      */
     @Override
-    public String checkMessage(Integer alarm_type) {
-        switch (alarm_type) {
+    public String checkMessage(Integer alarm_type){
+        switch (alarm_type){
             case 16:
                 return "SOS报警";
             case 17:
@@ -323,39 +252,39 @@ public class TDeviceListServiceImpl implements ITDeviceListService {
 
     @Override
     public int deviceValue(CallPoliceDto callPoliceDto) {
-        if (StringUtils.isNotNull(callPoliceDto)) {
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_blood_high_max())) {
+        if (StringUtils.isNotNull(callPoliceDto)){
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_blood_high_max())){
                 tDeviceListMapper.updateTSettingshouhuan_blood_high_max(callPoliceDto.getShouhuan_blood_high_max());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_blood_high_min())) {
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_blood_high_min())){
                 tDeviceListMapper.updateTSettingshouhuan_blood_high_min(callPoliceDto.getShouhuan_blood_high_min());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_blood_low_max())) {
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_blood_low_max())){
                 tDeviceListMapper.updateTSettingshouhuan_blood_low_max(callPoliceDto.getShouhuan_blood_low_max());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_blood_low_min())) {
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_blood_low_min())){
                 tDeviceListMapper.updateTSettingshouhuan_blood_low_min(callPoliceDto.getShouhuan_blood_low_min());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_body_max())) {
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_body_max())){
                 tDeviceListMapper.updateTSettingshouhuan_body_max(callPoliceDto.getShouhuan_body_max());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_body_min())) {
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_body_min())){
                 tDeviceListMapper.updateTSettingshouhuan_body_min(callPoliceDto.getShouhuan_body_min());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_oxygen_max())) {
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_oxygen_max())){
                 tDeviceListMapper.updateTSettingshouhuan_oxygen_max(callPoliceDto.getShouhuan_oxygen_max());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_oxygen_min())) {
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_oxygen_min())){
                 tDeviceListMapper.updateTSettingshouhuan_oxygen_min(callPoliceDto.getShouhuan_oxygen_min());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_heart_max())) {
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_heart_max())){
                 tDeviceListMapper.updateTSettingshouhuan_heart_max(callPoliceDto.getShouhuan_heart_max());
             }
-            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_heart_min())) {
+            if (StringUtils.isNotNull(callPoliceDto.getShouhuan_heart_min())){
                 tDeviceListMapper.updateTSettingshouhuan_heart_min(callPoliceDto.getShouhuan_heart_min());
             }
             return 1;
-        } else {
+        }else{
             return 0;
         }
     }

+ 41 - 23
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRegionServiceImpl.java

@@ -1,8 +1,11 @@
 package com.ruoyi.system.service.impl;
 
 import java.util.List;
+
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.system.domain.TRegionVo;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.SpringApplication;
 import org.springframework.stereotype.Service;
 import com.ruoyi.system.mapper.TRegionMapper;
 import com.ruoyi.system.domain.TRegion;
@@ -10,56 +13,74 @@ import com.ruoyi.system.service.ITRegionService;
 
 /**
  * 行政区域Service业务层处理
- * 
+ *
  * @author zhengjie
  * @date 2023-08-15
  */
 @Service
-public class TRegionServiceImpl implements ITRegionService 
-{
+public class TRegionServiceImpl implements ITRegionService {
     @Autowired
     private TRegionMapper tRegionMapper;
 
     /**
      * 查询行政区域
-     * 
+     *
      * @param id 行政区域主键
      * @return 行政区域
      */
     @Override
-    public TRegion selectTRegionById(Integer id)
-    {
+    public TRegion selectTRegionById(Integer id) {
         return tRegionMapper.selectTRegionById(id);
     }
 
     /**
      * 查询行政区域列表
-     * 
+     *
      * @param tRegion 行政区域
      * @return 行政区域
      */
     @Override
-    public List<TRegion> selectTRegionList(TRegion tRegion)
-    {
+    public List<TRegion> selectTRegionList(TRegion tRegion) {
+        return tRegionMapper.selectTRegionList(tRegion);
+    }
+
+    @Override
+    public List<TRegion> selectTRegionListV2(TRegion tRegion) {
+        List<TRegionVo> list_1 = tRegionMapper.selectTRegionListV1();
+        for (TRegionVo vo_1 : list_1) {
+            List<TRegionVo> list_2 = tRegionMapper.selectTRegionListV2(vo_1.getCode());
+            for (TRegionVo vo_2 : list_2) {
+                List<TRegionVo> list_3 = tRegionMapper.selectTRegionListV3(vo_2.getCode());
+                for (TRegionVo vo_3 : list_3) {
+                    List<TRegionVo> list_4 = tRegionMapper.selectTRegionListV4(vo_3.getCode());
+                    for (TRegionVo vo_4 : list_4) {
+                        List<TRegionVo> list_5 = tRegionMapper.selectTRegionListV5(vo_4.getCode());
+                        vo_4.setChild(list_5);
+                    }
+                    vo_3.setChild(list_4);
+                }
+                vo_2.setChild(list_3);
+            }
+            vo_1.setChild(list_2);
+        }
         return tRegionMapper.selectTRegionList(tRegion);
     }
 
     /**
      * 新增行政区域
-     * 
+     *
      * @param tRegion 行政区域
      * @return 结果
      */
     @Override
-    public int insertTRegion(TRegion tRegion)
-    {
-        if (tRegion.getParentId() == 0){
+    public int insertTRegion(TRegion tRegion) {
+        if (tRegion.getParentId() == 0) {
             TRegion t = tRegionMapper.selectTRegionById(1);
             tRegion.setCreateTime(DateUtils.getNowDate());
             tRegion.setParentId(1);
             tRegion.setAncestors("0,1");
             return tRegionMapper.insertTRegion(tRegion);
-        }else{
+        } else {
             TRegion t = tRegionMapper.selectTRegionById(tRegion.getParentId());
             tRegion.setCreateTime(DateUtils.getNowDate());
             tRegion.setAncestors(t.getAncestors() + "," + tRegion.getParentId());
@@ -69,38 +90,35 @@ public class TRegionServiceImpl implements ITRegionService
 
     /**
      * 修改行政区域
-     * 
+     *
      * @param tRegion 行政区域
      * @return 结果
      */
     @Override
-    public int updateTRegion(TRegion tRegion)
-    {
+    public int updateTRegion(TRegion tRegion) {
         tRegion.setUpdateTime(DateUtils.getNowDate());
         return tRegionMapper.updateTRegion(tRegion);
     }
 
     /**
      * 批量删除行政区域
-     * 
+     *
      * @param ids 需要删除的行政区域主键
      * @return 结果
      */
     @Override
-    public int deleteTRegionByIds(Integer[] ids)
-    {
+    public int deleteTRegionByIds(Integer[] ids) {
         return tRegionMapper.deleteTRegionByIds(ids);
     }
 
     /**
      * 删除行政区域信息
-     * 
+     *
      * @param id 行政区域主键
      * @return 结果
      */
     @Override
-    public int deleteTRegionById(Integer id)
-    {
+    public int deleteTRegionById(Integer id) {
         return tRegionMapper.deleteTRegionById(id);
     }
 }

+ 121 - 0
ruoyi-system/src/main/resources/mapper/system/TAdministrativeDivisionsMapper.xml

@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.system.mapper.TAdministrativeDivisionsMapper">
+
+    <resultMap type="TAdministrativeDivisions" id="TAdministrativeDivisionsResult">
+        <result property="id" column="id"/>
+        <result property="code" column="code"/>
+        <result property="name" column="name"/>
+        <result property="streetCode" column="streetCode"/>
+        <result property="areaCode" column="areaCode"/>
+        <result property="cityCode" column="cityCode"/>
+        <result property="provinceCode" column="provinceCode"/>
+    </resultMap>
+
+    <sql id="selectTAdministrativeDivisionsVo">
+        select id, code, name, streetCode, areaCode, cityCode, provinceCode
+        from t_administrative_divisions
+    </sql>
+
+    <select id="selectTAdministrativeDivisionsList" parameterType="TAdministrativeDivisions"
+            resultMap="TAdministrativeDivisionsResult">
+        <include refid="selectTAdministrativeDivisionsVo"/>
+        <where>
+            <if test="code != null ">and code = #{code}</if>
+            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
+            <if test="streetCode != null ">and streetCode = #{streetCode}</if>
+            <if test="areaCode != null ">and areaCode = #{areaCode}</if>
+            <if test="cityCode != null ">and cityCode = #{cityCode}</if>
+            <if test="provinceCode != null ">and provinceCode = #{provinceCode}</if>
+        </where>
+    </select>
+
+    <select id="selectTAdministrativeDivisionsById" parameterType="Long" resultMap="TAdministrativeDivisionsResult">
+        <include refid="selectTAdministrativeDivisionsVo"/>
+        where id = #{id}
+    </select>
+    <!-- 查询所有省级级(省) -->
+    <select id="selectTAdministrativeDivisionsProvinceAllList" resultMap="TAdministrativeDivisionsResult">
+        <include refid="selectTAdministrativeDivisionsVo"/>
+        where provinceCode is null
+    </select>
+    <!-- 查询所有地级(市) -->
+    <select id="selectTAdministrativeDivisionsListByProvinceCode" parameterType="Long"
+            resultMap="TAdministrativeDivisionsResult">
+        <include refid="selectTAdministrativeDivisionsVo"/>
+        where cityCode is null
+        AND
+        provinceCode = #{provinceCode}
+    </select>
+    <!-- 查询所有县级(区) -->
+    <select id="selectTAdministrativeDivisionsListByCityCode" parameterType="Long"
+            resultMap="TAdministrativeDivisionsResult">
+        <include refid="selectTAdministrativeDivisionsVo"/>
+        where areaCode is null
+        AND
+        cityCode = #{cityCode}
+    </select>
+    <!-- 查询所有乡级(镇) -->
+    <select id="selectTAdministrativeDivisionsListByAreaCode" parameterType="Long"
+            resultMap="TAdministrativeDivisionsResult">
+        <include refid="selectTAdministrativeDivisionsVo"/>
+        where streetCode is null
+        AND
+        areaCode = #{areaCode}
+    </select>
+    <!-- 查询所有居委会 -->
+    <select id="selectTAdministrativeDivisionsListByStreetCode" parameterType="Long"
+            resultMap="TAdministrativeDivisionsResult">
+        <include refid="selectTAdministrativeDivisionsVo"/>
+        where streetCode = #{streetCode}
+    </select>
+
+    <insert id="insertTAdministrativeDivisions" parameterType="TAdministrativeDivisions" useGeneratedKeys="true"
+            keyProperty="id">
+        insert into t_administrative_divisions
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="code != null">code,</if>
+            <if test="name != null and name != ''">name,</if>
+            <if test="streetCode != null">streetCode,</if>
+            <if test="areaCode != null">areaCode,</if>
+            <if test="cityCode != null">cityCode,</if>
+            <if test="provinceCode != null">provinceCode,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="code != null">#{code},</if>
+            <if test="name != null and name != ''">#{name},</if>
+            <if test="streetCode != null">#{streetCode},</if>
+            <if test="areaCode != null">#{areaCode},</if>
+            <if test="cityCode != null">#{cityCode},</if>
+            <if test="provinceCode != null">#{provinceCode},</if>
+        </trim>
+    </insert>
+
+    <update id="updateTAdministrativeDivisions" parameterType="TAdministrativeDivisions">
+        update t_administrative_divisions
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="code != null">code = #{code},</if>
+            <if test="name != null and name != ''">name = #{name},</if>
+            <if test="streetCode != null">streetCode = #{streetCode},</if>
+            <if test="areaCode != null">areaCode = #{areaCode},</if>
+            <if test="cityCode != null">cityCode = #{cityCode},</if>
+            <if test="provinceCode != null">provinceCode = #{provinceCode},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteTAdministrativeDivisionsById" parameterType="Long">
+        delete
+        from t_administrative_divisions
+        where id = #{id}
+    </delete>
+
+    <delete id="deleteTAdministrativeDivisionsByIds" parameterType="String">
+        delete from t_administrative_divisions where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 28 - 44
ruoyi-system/src/main/resources/mapper/system/TFacilityMapper.xml

@@ -1,58 +1,44 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.system.mapper.TFacilityMapper">
-
+    
     <resultMap type="TFacility" id="TFacilityResult">
-        <result property="id" column="id"/>
-        <result property="kind" column="kind"/>
-        <result property="code" column="code"/>
-        <result property="telno" column="telno"/>
-        <result property="comCode" column="com_code"/>
-        <result property="createTime" column="createtime"/>
-        <result property="status" column="status"/>
-        <result property="iccid" column="iccid"/>
-        <result property="puk" column="puk"/>
+        <result property="id"    column="id"    />
+        <result property="kind"    column="kind"    />
+        <result property="code"    column="code"    />
+        <result property="telno"    column="telno"    />
+        <result property="comCode"    column="com_code"    />
+        <result property="createTime"    column="createtime"    />
+        <result property="status"    column="status"    />
+        <result property="iccid"    column="iccid"    />
+        <result property="puk"    column="puk"    />
     </resultMap>
 
     <sql id="selectTFacilityVo">
-        select id,
-               kind,
-               code,
-               telno,
-               com_code,
-               createtime,
-               status,
-               iccid,
-               puk
-        from t_facility
+        select id, kind, code, telno, com_code, createtime, status, iccid, puk from t_facility
     </sql>
 
     <select id="selectTFacilityList" parameterType="TFacility" resultMap="TFacilityResult">
         <include refid="selectTFacilityVo"/>
-        <where>
-            <if test="kind != null ">and kind = #{kind}</if>
-            <if test="code != null  and code != ''">and code = #{code}</if>
-            <if test="telno != null  and telno != ''">and telno = #{telno}</if>
-            <if test="comCode != null  and comCode != ''">and com_code = #{comCode}</if>
-            <if test="createTime != null ">and createtime = #{createTime}</if>
-            <if test="status != null ">and status = #{status}</if>
-            <if test="iccid != null ">and iccid = #{iccid}</if>
-            <if test="puk != null ">and puk = #{puk}</if>
+        <where>  
+            <if test="kind != null "> and kind = #{kind}</if>
+            <if test="code != null  and code != ''"> and code = #{code}</if>
+            <if test="telno != null  and telno != ''"> and telno = #{telno}</if>
+            <if test="comCode != null  and comCode != ''"> and com_code = #{comCode}</if>
+            <if test="createTime != null "> and createtime = #{createTime}</if>
+            <if test="status != null "> and status = #{status}</if>
+            <if test="iccid != null "> and iccid = #{iccid}</if>
+            <if test="puk != null "> and puk = #{puk}</if>
         </where>
     </select>
-
+    
     <select id="selectTFacilityById" parameterType="Long" resultMap="TFacilityResult">
         <include refid="selectTFacilityVo"/>
         where id = #{id}
     </select>
-
-    <select id="selectTDeviceListListByDeviceId" parameterType="string" resultMap="TFacilityResult">
-        <include refid="selectTFacilityVo"/>
-        where code = #{code}
-    </select>
-
+        
     <insert id="insertTFacility" parameterType="TFacility" useGeneratedKeys="true" keyProperty="id">
         insert into t_facility
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -64,7 +50,7 @@
             <if test="status != null">status,</if>
             <if test="iccid != null">iccid,</if>
             <if test="puk != null">puk,</if>
-        </trim>
+         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="kind != null">#{kind},</if>
             <if test="code != null">#{code},</if>
@@ -74,7 +60,7 @@
             <if test="status != null">#{status},</if>
             <if test="iccid != null">#{iccid},</if>
             <if test="puk != null">#{puk},</if>
-        </trim>
+         </trim>
     </insert>
 
     <update id="updateTFacility" parameterType="TFacility">
@@ -93,13 +79,11 @@
     </update>
 
     <delete id="deleteTFacilityById" parameterType="Long">
-        delete
-        from t_facility
-        where id = #{id}
+        delete from t_facility where id = #{id}
     </delete>
 
     <delete id="deleteTFacilityByIds" parameterType="String">
-        delete from t_facility where id in
+        delete from t_facility where id in 
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>

+ 90 - 38
ruoyi-system/src/main/resources/mapper/system/TRegionMapper.xml

@@ -1,49 +1,70 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.system.mapper.TRegionMapper">
-    
+
     <resultMap type="TRegion" id="TRegionResult">
-        <result property="id"    column="id"    />
-        <result property="parentId"    column="parent_id"    />
-        <result property="ancestors"    column="ancestors"    />
-        <result property="deptName"    column="dept_name"    />
-        <result property="deptNum"    column="dept_num"    />
-        <result property="zoneName"    column="zone_name"    />
-        <result property="zoneNum"    column="zone_num"    />
-        <result property="kind"    column="kind"    />
-        <result property="orderNum"    column="order_num"    />
-        <result property="remarks"    column="remarks"    />
-        <result property="gpsLng"    column="gps_lng"    />
-        <result property="gpsLat"    column="gps_lat"    />
-        <result property="createBy"    column="create_by"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="updateBy"    column="update_by"    />
-        <result property="updateTime"    column="update_time"    />
+        <result property="id" column="id"/>
+        <result property="parentId" column="parent_id"/>
+        <result property="ancestors" column="ancestors"/>
+        <result property="deptName" column="dept_name"/>
+        <result property="deptNum" column="dept_num"/>
+        <result property="zoneName" column="zone_name"/>
+        <result property="zoneNum" column="zone_num"/>
+        <result property="kind" column="kind"/>
+        <result property="orderNum" column="order_num"/>
+        <result property="remarks" column="remarks"/>
+        <result property="gpsLng" column="gps_lng"/>
+        <result property="gpsLat" column="gps_lat"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+    </resultMap>
+
+    <resultMap type="TRegionVo" id="TRegionVoResult">
+        <result property="code" column="code"/>
+        <result property="name" column="name"/>
     </resultMap>
 
     <sql id="selectTRegionVo">
-        select id, parent_id, ancestors, dept_name, dept_num, zone_name, zone_num, kind, order_num, remarks, gps_lng, gps_lat, create_by, create_time, update_by, update_time from t_region
+        select id,
+               parent_id,
+               ancestors,
+               dept_name,
+               dept_num,
+               zone_name,
+               zone_num,
+               kind,
+               order_num,
+               remarks,
+               gps_lng,
+               gps_lat,
+               create_by,
+               create_time,
+               update_by,
+               update_time
+        from t_region
     </sql>
 
     <select id="selectTRegionList" parameterType="TRegion" resultMap="TRegionResult">
         <include refid="selectTRegionVo"/>
-        <where>  
-            <if test="parentId != null "> and parent_id = #{parentId}</if>
-            <if test="ancestors != null  and ancestors != ''"> and ancestors = #{ancestors}</if>
-            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
-            <if test="deptNum != null  and deptNum != ''"> and dept_num = #{deptNum}</if>
-            <if test="zoneName != null  and zoneName != ''"> and zone_name like concat('%', #{zoneName}, '%')</if>
-            <if test="zoneNum != null  and zoneNum != ''"> and zone_num = #{zoneNum}</if>
-            <if test="kind != null "> and kind = #{kind}</if>
-            <if test="orderNum != null "> and order_num = #{orderNum}</if>
-            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
-            <if test="gpsLng != null "> and gps_lng = #{gpsLng}</if>
-            <if test="gpsLat != null "> and gps_lat = #{gpsLat}</if>
+        <where>
+            <if test="parentId != null ">and parent_id = #{parentId}</if>
+            <if test="ancestors != null  and ancestors != ''">and ancestors = #{ancestors}</if>
+            <if test="deptName != null  and deptName != ''">and dept_name like concat('%', #{deptName}, '%')</if>
+            <if test="deptNum != null  and deptNum != ''">and dept_num = #{deptNum}</if>
+            <if test="zoneName != null  and zoneName != ''">and zone_name like concat('%', #{zoneName}, '%')</if>
+            <if test="zoneNum != null  and zoneNum != ''">and zone_num = #{zoneNum}</if>
+            <if test="kind != null ">and kind = #{kind}</if>
+            <if test="orderNum != null ">and order_num = #{orderNum}</if>
+            <if test="remarks != null  and remarks != ''">and remarks = #{remarks}</if>
+            <if test="gpsLng != null ">and gps_lng = #{gpsLng}</if>
+            <if test="gpsLat != null ">and gps_lat = #{gpsLat}</if>
         </where>
     </select>
-    
+
     <select id="selectTRegionById" parameterType="Integer" resultMap="TRegionResult">
         <include refid="selectTRegionVo"/>
         where id = #{id}
@@ -53,7 +74,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectTRegionVo"/>
         where parent_id = #{parentId}
     </select>
-        
+    <select id="selectTRegionListV1" resultMap="TRegionVoResult">
+        SELECT DISTINCT SUBSTRING(province_code, 1, 2) AS code,
+                        province_name                  AS name
+        FROM position_village;
+    </select>
+    <select id="selectTRegionListV2" parameterType="string" resultMap="TRegionVoResult">
+        SELECT DISTINCT SUBSTRING(city_code, 1, 4) AS code,
+                        city_name                  AS name
+        FROM position_village
+        WHERE SUBSTRING(position_village.city_code, 1, 2) = #{province_code}
+    </select>
+    <select id="selectTRegionListV3" parameterType="string" resultMap="TRegionVoResult">
+        SELECT DISTINCT SUBSTRING(county_code, 1,6) AS code,
+                        county_name                  AS name
+        FROM position_village
+        WHERE SUBSTRING(position_village.city_code, 1, 4) = #{city_code}
+    </select>
+    <select id="selectTRegionListV4" parameterType="string" resultMap="TRegionVoResult">
+        SELECT DISTINCT SUBSTRING(town_code, 1,8) AS code,
+                        town_name                  AS name
+        FROM position_village
+        WHERE SUBSTRING(position_village.county_code, 1, 6) = #{county_code}
+    </select>
+    <select id="selectTRegionListV5" parameterType="string" resultMap="TRegionVoResult">
+        SELECT DISTINCT SUBSTRING(village_code, 1, 10) AS code,
+                        village_name                   AS name
+        FROM position_village
+        WHERE SUBSTRING(position_village.county_code, 1, 8) = #{county_code}
+    </select>
+
     <insert id="insertTRegion" parameterType="TRegion" useGeneratedKeys="true" keyProperty="id">
         insert into t_region
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -72,7 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">create_time,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="parentId != null">#{parentId},</if>
             <if test="ancestors != null">#{ancestors},</if>
@@ -89,7 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateTRegion" parameterType="TRegion">
@@ -115,11 +165,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteTRegionById" parameterType="Integer">
-        delete from t_region where id = #{id}
+        delete
+        from t_region
+        where id = #{id}
     </delete>
 
     <delete id="deleteTRegionByIds" parameterType="String">
-        delete from t_region where id in 
+        delete from t_region where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>