111
This commit is contained in:
1 parent
81eca8933a
commit
345f906c35
540 files changed
+494222
-90
No files matched your search
@@ -0,0 +1,108 @@
|
||||
package com.luqj.gis.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
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.luqj.gis.domain.GisRegion;
|
||||
import com.luqj.gis.service.IGisRegionService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 区域Controller
|
||||
*
|
||||
* @author luqj
|
||||
* @date 2021-07-24
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/gis/region")
|
||||
public class GisRegionController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IGisRegionService gisRegionService;
|
||||
|
||||
/**
|
||||
* 查询区域列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('gis:region:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(GisRegion gisRegion)
|
||||
{
|
||||
startPage();
|
||||
List<GisRegion> list = gisRegionService.selectGisRegionList(gisRegion);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出区域列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('gis:region:export')")
|
||||
@Log(title = "区域", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(GisRegion gisRegion)
|
||||
{
|
||||
List<GisRegion> list = gisRegionService.selectGisRegionList(gisRegion);
|
||||
ExcelUtil<GisRegion> util = new ExcelUtil<GisRegion>(GisRegion.class);
|
||||
return util.exportExcel(list, "region");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取区域详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('gis:region:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return AjaxResult.success(gisRegionService.selectGisRegionById(id));
|
||||
}
|
||||
@GetMapping("/treeselect")
|
||||
public AjaxResult treeselect(GisRegion gisRegion)
|
||||
{
|
||||
List<GisRegion> depts = gisRegionService.selectGisRegionList(gisRegion);
|
||||
return AjaxResult.success(gisRegionService.buildGisTreeSelect(depts));
|
||||
}
|
||||
@GetMapping("/select-by-types")
|
||||
public AjaxResult selectByTypes(@RequestParam() List<Integer> types)
|
||||
{
|
||||
List<GisRegion> gisRegions = gisRegionService.selectUserByTypes(types);
|
||||
return AjaxResult.success(gisRegionService.buildGisTreeSelectNoRoot(gisRegions));
|
||||
}
|
||||
/**
|
||||
* 新增区域
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('gis:region:add')")
|
||||
@Log(title = "区域", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody GisRegion gisRegion)
|
||||
{
|
||||
return toAjax(gisRegionService.insertGisRegion(gisRegion));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改区域
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('gis:region:edit')")
|
||||
@Log(title = "区域", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody GisRegion gisRegion)
|
||||
{
|
||||
return toAjax(gisRegionService.updateGisRegion(gisRegion));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除区域
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('gis:region:remove')")
|
||||
@Log(title = "区域", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(gisRegionService.deleteGisRegionByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
package com.luqj.gis.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
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;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 区域对象 gis_region
|
||||
*
|
||||
* @author luqj
|
||||
* @date 2021-07-24
|
||||
*/
|
||||
public class GisRegion extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
private Long id;
|
||||
|
||||
/** 区域名称 */
|
||||
@Excel(name = "区域名称")
|
||||
private String name;
|
||||
|
||||
/** 父节点Id */
|
||||
@Excel(name = "父节点Id")
|
||||
private Long parentId;
|
||||
|
||||
/** 短名称 */
|
||||
@Excel(name = "短名称")
|
||||
private String shortName;
|
||||
|
||||
/** 区域类型:0国家,1省份,2市,3县区 */
|
||||
@Excel(name = "区域类型:0国家,1省份,2市,3县区")
|
||||
private Integer type;
|
||||
|
||||
/** 区号 */
|
||||
@Excel(name = "区号")
|
||||
private String cityCode;
|
||||
|
||||
/** 邮编 */
|
||||
@Excel(name = "邮编")
|
||||
private String zipCode;
|
||||
|
||||
/** 合并名称 */
|
||||
@Excel(name = "合并名称")
|
||||
private String mergerName;
|
||||
|
||||
/** 经度 */
|
||||
@Excel(name = "经度")
|
||||
private BigDecimal longitude;
|
||||
|
||||
/** 纬度 */
|
||||
@Excel(name = "纬度")
|
||||
private BigDecimal latitude;
|
||||
|
||||
/** 区域编码 */
|
||||
@Excel(name = "区域编码")
|
||||
private String code;
|
||||
|
||||
/** 0 开通 1未开通 */
|
||||
@Excel(name = "0 开通 1未开通")
|
||||
private Integer isOpen;
|
||||
|
||||
/** 大区:如华南 */
|
||||
@Excel(name = "大区:如华南")
|
||||
private String bigArea;
|
||||
|
||||
/** 是否默认区:1-是,0否 */
|
||||
@Excel(name = "是否默认区:1-是,0否")
|
||||
private Integer isDefault;
|
||||
|
||||
/** 城市编码 */
|
||||
@Excel(name = "城市编码")
|
||||
private Long adCode;
|
||||
|
||||
private List<GisRegion> children = new ArrayList<GisRegion>();;
|
||||
|
||||
public List<GisRegion> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<GisRegion> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
public void setParentId(Long parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Long getParentId()
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
public void setShortName(String shortName)
|
||||
{
|
||||
this.shortName = shortName;
|
||||
}
|
||||
|
||||
public String getShortName()
|
||||
{
|
||||
return shortName;
|
||||
}
|
||||
public void setType(Integer type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Integer getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
public void setCityCode(String cityCode)
|
||||
{
|
||||
this.cityCode = cityCode;
|
||||
}
|
||||
|
||||
public String getCityCode()
|
||||
{
|
||||
return cityCode;
|
||||
}
|
||||
public void setZipCode(String zipCode)
|
||||
{
|
||||
this.zipCode = zipCode;
|
||||
}
|
||||
|
||||
public String getZipCode()
|
||||
{
|
||||
return zipCode;
|
||||
}
|
||||
public void setMergerName(String mergerName)
|
||||
{
|
||||
this.mergerName = mergerName;
|
||||
}
|
||||
|
||||
public String getMergerName()
|
||||
{
|
||||
return mergerName;
|
||||
}
|
||||
public void setLongitude(BigDecimal longitude)
|
||||
{
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public BigDecimal getLongitude()
|
||||
{
|
||||
return longitude;
|
||||
}
|
||||
public void setLatitude(BigDecimal latitude)
|
||||
{
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public BigDecimal getLatitude()
|
||||
{
|
||||
return latitude;
|
||||
}
|
||||
public void setCode(String code)
|
||||
{
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
public void setIsOpen(Integer isOpen)
|
||||
{
|
||||
this.isOpen = isOpen;
|
||||
}
|
||||
|
||||
public Integer getIsOpen()
|
||||
{
|
||||
return isOpen;
|
||||
}
|
||||
public void setBigArea(String bigArea)
|
||||
{
|
||||
this.bigArea = bigArea;
|
||||
}
|
||||
|
||||
public String getBigArea()
|
||||
{
|
||||
return bigArea;
|
||||
}
|
||||
public void setIsDefault(Integer isDefault)
|
||||
{
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
|
||||
public Integer getIsDefault()
|
||||
{
|
||||
return isDefault;
|
||||
}
|
||||
public void setAdCode(Long adCode)
|
||||
{
|
||||
this.adCode = adCode;
|
||||
}
|
||||
|
||||
public Long getAdCode()
|
||||
{
|
||||
return adCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("name", getName())
|
||||
.append("parentId", getParentId())
|
||||
.append("shortName", getShortName())
|
||||
.append("type", getType())
|
||||
.append("cityCode", getCityCode())
|
||||
.append("zipCode", getZipCode())
|
||||
.append("mergerName", getMergerName())
|
||||
.append("longitude", getLongitude())
|
||||
.append("latitude", getLatitude())
|
||||
.append("code", getCode())
|
||||
.append("isOpen", getIsOpen())
|
||||
.append("bigArea", getBigArea())
|
||||
.append("isDefault", getIsDefault())
|
||||
.append("adCode", getAdCode())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
package com.luqj.gis.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
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;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* 区域对象 gis_region
|
||||
*
|
||||
* @author luqj
|
||||
* @date 2021-07-24
|
||||
*/
|
||||
@TableName(value = "gis_region")
|
||||
public class GisRegionPlus implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
private Long id;
|
||||
/** 区域名称 */
|
||||
@Excel(name = "区域名称")
|
||||
private String name;
|
||||
/** 父节点Id */
|
||||
@Excel(name = "父节点Id")
|
||||
private Long parentId;
|
||||
/** 短名称 */
|
||||
@Excel(name = "短名称")
|
||||
private String shortName;
|
||||
/** 区域类型:0国家,1省份,2市,3县区 */
|
||||
@Excel(name = "区域类型:0国家,1省份,2市,3县区")
|
||||
private Integer type;
|
||||
/** 区号 */
|
||||
@Excel(name = "区号")
|
||||
private String cityCode;
|
||||
/** 邮编 */
|
||||
@Excel(name = "邮编")
|
||||
private String zipCode;
|
||||
/** 合并名称 */
|
||||
@Excel(name = "合并名称")
|
||||
private String mergerName;
|
||||
/** 经度 */
|
||||
@Excel(name = "经度")
|
||||
private BigDecimal longitude;
|
||||
/** 纬度 */
|
||||
@Excel(name = "纬度")
|
||||
private BigDecimal latitude;
|
||||
/** 区域编码 */
|
||||
@Excel(name = "区域编码")
|
||||
private String code;
|
||||
/** 0 开通 1未开通 */
|
||||
@Excel(name = "0 开通 1未开通")
|
||||
private Integer isOpen;
|
||||
/** 大区:如华南 */
|
||||
@Excel(name = "大区:如华南")
|
||||
private String bigArea;
|
||||
/** 是否默认区:1-是,0否 */
|
||||
@Excel(name = "是否默认区:1-是,0否")
|
||||
private Integer isDefault;
|
||||
/** 城市编码 */
|
||||
@Excel(name = "城市编码")
|
||||
private Long adCode;
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
public void setParentId(Long parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Long getParentId()
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
public void setShortName(String shortName)
|
||||
{
|
||||
this.shortName = shortName;
|
||||
}
|
||||
|
||||
public String getShortName()
|
||||
{
|
||||
return shortName;
|
||||
}
|
||||
public void setType(Integer type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Integer getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
public void setCityCode(String cityCode)
|
||||
{
|
||||
this.cityCode = cityCode;
|
||||
}
|
||||
|
||||
public String getCityCode()
|
||||
{
|
||||
return cityCode;
|
||||
}
|
||||
public void setZipCode(String zipCode)
|
||||
{
|
||||
this.zipCode = zipCode;
|
||||
}
|
||||
|
||||
public String getZipCode()
|
||||
{
|
||||
return zipCode;
|
||||
}
|
||||
public void setMergerName(String mergerName)
|
||||
{
|
||||
this.mergerName = mergerName;
|
||||
}
|
||||
|
||||
public String getMergerName()
|
||||
{
|
||||
return mergerName;
|
||||
}
|
||||
public void setLongitude(BigDecimal longitude)
|
||||
{
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public BigDecimal getLongitude()
|
||||
{
|
||||
return longitude;
|
||||
}
|
||||
public void setLatitude(BigDecimal latitude)
|
||||
{
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public BigDecimal getLatitude()
|
||||
{
|
||||
return latitude;
|
||||
}
|
||||
public void setCode(String code)
|
||||
{
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
public void setIsOpen(Integer isOpen)
|
||||
{
|
||||
this.isOpen = isOpen;
|
||||
}
|
||||
|
||||
public Integer getIsOpen()
|
||||
{
|
||||
return isOpen;
|
||||
}
|
||||
public void setBigArea(String bigArea)
|
||||
{
|
||||
this.bigArea = bigArea;
|
||||
}
|
||||
|
||||
public String getBigArea()
|
||||
{
|
||||
return bigArea;
|
||||
}
|
||||
public void setIsDefault(Integer isDefault)
|
||||
{
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
|
||||
public Integer getIsDefault()
|
||||
{
|
||||
return isDefault;
|
||||
}
|
||||
public void setAdCode(Long adCode)
|
||||
{
|
||||
this.adCode = adCode;
|
||||
}
|
||||
|
||||
public Long getAdCode()
|
||||
{
|
||||
return adCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("name", getName())
|
||||
.append("parentId", getParentId())
|
||||
.append("shortName", getShortName())
|
||||
.append("type", getType())
|
||||
.append("cityCode", getCityCode())
|
||||
.append("zipCode", getZipCode())
|
||||
.append("mergerName", getMergerName())
|
||||
.append("longitude", getLongitude())
|
||||
.append("latitude", getLatitude())
|
||||
.append("code", getCode())
|
||||
.append("isOpen", getIsOpen())
|
||||
.append("bigArea", getBigArea())
|
||||
.append("isDefault", getIsDefault())
|
||||
.append("adCode", getAdCode())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.luqj.gis.domain;
|
||||
|
||||
import com.ruoyi.common.core.domain.TreeSelect;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GisTreeSelect extends TreeSelect {
|
||||
private Long value;
|
||||
public GisTreeSelect(GisRegion gisRegion)
|
||||
{
|
||||
this.id = gisRegion.getId();
|
||||
this.value = gisRegion.getId();
|
||||
this.label = gisRegion.getName();
|
||||
this.children = gisRegion.getChildren().stream().map(GisTreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Long getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Long value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.luqj.gis.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.luqj.gis.domain.GisRegion;
|
||||
import com.luqj.gis.domain.GisRegionPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 区域Mapper接口
|
||||
*
|
||||
* @author luqj
|
||||
* @date 2021-07-24
|
||||
*/
|
||||
public interface GisRegionMapper extends BaseMapper<GisRegionPlus> {
|
||||
/**
|
||||
* 查询区域
|
||||
*
|
||||
* @param id 区域ID
|
||||
* @return 区域
|
||||
*/
|
||||
public GisRegion selectGisRegionById(Long id);
|
||||
|
||||
/**
|
||||
* 查询区域列表
|
||||
*
|
||||
* @param gisRegion 区域
|
||||
* @return 区域集合
|
||||
*/
|
||||
public List<GisRegion> selectGisRegionList(GisRegion gisRegion);
|
||||
|
||||
/**
|
||||
* 新增区域
|
||||
*
|
||||
* @param gisRegion 区域
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertGisRegion(GisRegion gisRegion);
|
||||
|
||||
/**
|
||||
* 修改区域
|
||||
*
|
||||
* @param gisRegion 区域
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateGisRegion(GisRegion gisRegion);
|
||||
|
||||
/**
|
||||
* 删除区域
|
||||
*
|
||||
* @param id 区域ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGisRegionById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除区域
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGisRegionByIds(Long[] ids);
|
||||
|
||||
List<GisRegion> selectUserByTypes(@Param("types") List<Integer> types);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.luqj.gis.service;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import com.luqj.gis.domain.GisRegion;
|
||||
import com.luqj.gis.domain.GisRegionPlus;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.luqj.gis.domain.GisTreeSelect;
|
||||
|
||||
/**
|
||||
* 区域Service接口
|
||||
*
|
||||
* @author luqj
|
||||
* @date 2021-07-24
|
||||
*/
|
||||
public interface IGisRegionService extends IService<GisRegionPlus>
|
||||
{
|
||||
/**
|
||||
* 查询区域
|
||||
*
|
||||
* @param id 区域ID
|
||||
* @return 区域
|
||||
*/
|
||||
public GisRegion selectGisRegionById(Long id);
|
||||
|
||||
/**
|
||||
* 查询区域列表
|
||||
*
|
||||
* @param gisRegion 区域
|
||||
* @return 区域集合
|
||||
*/
|
||||
public List<GisRegion> selectGisRegionList(GisRegion gisRegion);
|
||||
|
||||
List<GisTreeSelect> buildGisTreeSelect(List<GisRegion> gisRegions);
|
||||
|
||||
List<GisTreeSelect> buildGisTreeSelectNoRoot(List<GisRegion> gisRegions);
|
||||
|
||||
List<GisRegion> selectUserByTypes(List<Integer> types);
|
||||
/**
|
||||
* 新增区域
|
||||
*
|
||||
* @param gisRegion 区域
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertGisRegion(GisRegion gisRegion);
|
||||
|
||||
/**
|
||||
* 修改区域
|
||||
*
|
||||
* @param gisRegion 区域
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateGisRegion(GisRegion gisRegion);
|
||||
|
||||
/**
|
||||
* 批量删除区域
|
||||
*
|
||||
* @param ids 需要删除的区域ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGisRegionByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除区域信息
|
||||
*
|
||||
* @param id 区域ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGisRegionById(Long id);
|
||||
|
||||
List<GisRegionPlus> getByIds(List<Long> ids, SFunction<GisRegionPlus, ?>... columns);
|
||||
|
||||
GisRegionPlus getById(Long id, SFunction<GisRegionPlus, ?>... columns);
|
||||
|
||||
Map<Long, GisRegionPlus> getMapByIds(List<Long> ids, SFunction<GisRegionPlus, ?>... columns);
|
||||
|
||||
List<GisRegionPlus> getByIds(List<Long> ids);
|
||||
|
||||
Map<Long, GisRegionPlus> getMapByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* @param field sum 字段
|
||||
* @param where 条件
|
||||
* @param tClass 返回类型
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
<T> T sum(String field, String where, Class<T> tClass);
|
||||
|
||||
Long count(String where);
|
||||
|
||||
<T> List<T> countByGroupBy(String select, String where, String groupby, Class<T> tClass);
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
package com.luqj.gis.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.luqj.gis.domain.GisTreeSelect;
|
||||
import com.ruoyi.common.core.domain.TreeSelect;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.luqj.gis.mapper.GisRegionMapper;
|
||||
import com.luqj.gis.domain.GisRegion;
|
||||
import com.luqj.gis.domain.GisRegionPlus;
|
||||
import com.luqj.gis.service.IGisRegionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
/**
|
||||
* 区域Service业务层处理
|
||||
*
|
||||
* @author luqj
|
||||
* @date 2021-07-24
|
||||
*/
|
||||
@Service
|
||||
public class GisRegionServiceImpl extends ServiceImpl<GisRegionMapper, GisRegionPlus> implements IGisRegionService
|
||||
{
|
||||
@Autowired
|
||||
private GisRegionMapper gisRegionMapper;
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Override
|
||||
public List<GisRegionPlus> getByIds(List<Long> ids, SFunction<GisRegionPlus, ?>... columns) {
|
||||
LambdaQueryWrapper<GisRegionPlus> lambdaQueryWrapper = new LambdaQueryWrapper<GisRegionPlus>()
|
||||
.select(columns).in(GisRegionPlus::getId, ids);
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GisRegionPlus getById(Long id, SFunction<GisRegionPlus, ?>... columns) {
|
||||
LambdaQueryWrapper<GisRegionPlus> lambdaQueryWrapper = new LambdaQueryWrapper<GisRegionPlus>()
|
||||
.select(columns).eq(GisRegionPlus::getId, id);
|
||||
return baseMapper.selectOne(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, GisRegionPlus> getMapByIds(List<Long> ids, SFunction<GisRegionPlus, ?>... columns) {
|
||||
List<GisRegionPlus> list = this.getByIds(ids, columns);
|
||||
Map<Long, GisRegionPlus> map = new HashMap<>();
|
||||
for (GisRegionPlus item : list) {
|
||||
map.put(item.getId(), item);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, GisRegionPlus> getMapByIds(List<Long> ids) {
|
||||
List<GisRegionPlus> list = this.getByIds(ids);
|
||||
Map<Long, GisRegionPlus> map = new HashMap<>();
|
||||
for (GisRegionPlus item : list) {
|
||||
map.put(item.getId(), item);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GisRegionPlus> getByIds(List<Long> ids) {
|
||||
LambdaQueryWrapper<GisRegionPlus> lambdaQueryWrapper = new LambdaQueryWrapper<GisRegionPlus>().in(GisRegionPlus::getId, ids);
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
public <T> T sum(String field, String where, Class<T> tClass) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("select ");
|
||||
stringBuffer.append(" sum(" + field + ") as total ");
|
||||
stringBuffer.append(" from gis_region ");
|
||||
if (StringUtils.isNotBlank(where)) {
|
||||
stringBuffer.append(" where ");
|
||||
stringBuffer.append(where);
|
||||
}
|
||||
T result = jdbcTemplate.queryForObject(stringBuffer.toString(), tClass);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Long count(String where) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("select ");
|
||||
stringBuffer.append(" count(1)");
|
||||
stringBuffer.append(" from ");
|
||||
stringBuffer.append(" gis_region ");
|
||||
if (StringUtils.isNotBlank(where)) {
|
||||
stringBuffer.append(" where ");
|
||||
stringBuffer.append(where);
|
||||
}
|
||||
Long result = jdbcTemplate.queryForObject(stringBuffer.toString(), Long.class);
|
||||
return result;
|
||||
}
|
||||
|
||||
public <T> List<T> countByGroupBy(String select, String where, String groupby, Class<T> tClass) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("select ");
|
||||
stringBuffer.append(select);
|
||||
stringBuffer.append(" from ");
|
||||
stringBuffer.append(" gis_region ");
|
||||
if (StringUtils.isNotBlank(where)) {
|
||||
stringBuffer.append(" where ");
|
||||
stringBuffer.append(where);
|
||||
}
|
||||
stringBuffer.append(" group by ");
|
||||
stringBuffer.append(groupby);
|
||||
List result = jdbcTemplate.queryForList(stringBuffer.toString());
|
||||
List<T> tList = JSONArray.parseArray(JSONArray.toJSONString(result), tClass);
|
||||
return tList;
|
||||
}
|
||||
/**
|
||||
* 查询区域
|
||||
*
|
||||
* @param id 区域ID
|
||||
* @return 区域
|
||||
*/
|
||||
@Override
|
||||
public GisRegion selectGisRegionById(Long id)
|
||||
{
|
||||
return gisRegionMapper.selectGisRegionById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询区域列表
|
||||
*
|
||||
* @param gisRegion 区域
|
||||
* @return 区域
|
||||
*/
|
||||
@Override
|
||||
public List<GisRegion> selectGisRegionList(GisRegion gisRegion)
|
||||
{
|
||||
return gisRegionMapper.selectGisRegionList(gisRegion);
|
||||
}
|
||||
|
||||
public List<GisRegion> selectUserByTypes(List<Integer> types)
|
||||
{
|
||||
return gisRegionMapper.selectUserByTypes(types);
|
||||
}
|
||||
public List<GisTreeSelect> buildGisTreeSelect(List<GisRegion> gisRegions)
|
||||
{
|
||||
List<GisRegion> deptTrees = buildGisTree(gisRegions);
|
||||
GisRegion com =new GisRegion();
|
||||
com.setId(0L);
|
||||
com.setName("根目录");
|
||||
com.setChildren(deptTrees);
|
||||
List<GisRegion> pc = new ArrayList<>();
|
||||
for(GisRegion c:deptTrees){
|
||||
if(c.getParentId() == 0L){
|
||||
pc.add(c);
|
||||
}
|
||||
}
|
||||
com.setChildren(pc);
|
||||
return Arrays.asList(com).stream().map(GisTreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<GisTreeSelect> buildGisTreeSelectNoRoot(List<GisRegion> gisRegions)
|
||||
{
|
||||
List<GisRegion> deptTrees = buildGisTree(gisRegions);
|
||||
return deptTrees.stream().map(GisTreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
/**
|
||||
* 递归列表
|
||||
*/
|
||||
private void recursionFn(List<GisRegion> list, GisRegion t)
|
||||
{
|
||||
// 得到子节点列表
|
||||
List<GisRegion> childList = getChildList(list, t);
|
||||
t.setChildren(childList);
|
||||
for (GisRegion tChild : childList)
|
||||
{
|
||||
if (hasChild(list, tChild))
|
||||
{
|
||||
recursionFn(list, tChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 得到子节点列表
|
||||
*/
|
||||
private List<GisRegion> getChildList(List<GisRegion> list, GisRegion t)
|
||||
{
|
||||
List<GisRegion> tlist = new ArrayList<GisRegion>();
|
||||
Iterator<GisRegion> it = list.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
GisRegion n = (GisRegion) it.next();
|
||||
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getId().longValue())
|
||||
{
|
||||
tlist.add(n);
|
||||
}
|
||||
}
|
||||
return tlist;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有子节点
|
||||
*/
|
||||
private boolean hasChild(List<GisRegion> list, GisRegion t)
|
||||
{
|
||||
return getChildList(list, t).size() > 0 ? true : false;
|
||||
}
|
||||
public List<GisRegion> buildGisTree(List<GisRegion> depts)
|
||||
{
|
||||
List<GisRegion> returnList = new ArrayList<GisRegion>();
|
||||
List<Long> tempList = new ArrayList<Long>();
|
||||
for (GisRegion dept : depts)
|
||||
{
|
||||
tempList.add(dept.getId());
|
||||
}
|
||||
for (Iterator<GisRegion> iterator = depts.iterator(); iterator.hasNext();)
|
||||
{
|
||||
GisRegion dept = (GisRegion) iterator.next();
|
||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||
if (!tempList.contains(dept.getParentId()))
|
||||
{
|
||||
recursionFn(depts, dept);
|
||||
returnList.add(dept);
|
||||
}
|
||||
}
|
||||
if (returnList.isEmpty())
|
||||
{
|
||||
returnList = depts;
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
/**
|
||||
* 新增区域
|
||||
*
|
||||
* @param gisRegion 区域
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertGisRegion(GisRegion gisRegion)
|
||||
{
|
||||
return gisRegionMapper.insertGisRegion(gisRegion);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改区域
|
||||
*
|
||||
* @param gisRegion 区域
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateGisRegion(GisRegion gisRegion)
|
||||
{
|
||||
return gisRegionMapper.updateGisRegion(gisRegion);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除区域
|
||||
*
|
||||
* @param ids 需要删除的区域ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteGisRegionByIds(Long[] ids)
|
||||
{
|
||||
return gisRegionMapper.deleteGisRegionByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除区域信息
|
||||
*
|
||||
* @param id 区域ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteGisRegionById(Long id)
|
||||
{
|
||||
return gisRegionMapper.deleteGisRegionById(id);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user