项目管理添加与机构关联逻辑,bug修复等
This commit is contained in:
parent
a5c5d88b46
commit
a8faa7cdeb
@ -0,0 +1,120 @@
|
||||
package com.fastbee.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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.fastbee.common.annotation.Log;
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.enums.BusinessType;
|
||||
import com.fastbee.system.domain.SysDistrict;
|
||||
import com.fastbee.system.service.ISysDistrictService;
|
||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
||||
import com.fastbee.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 行政区划Controller
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-10-18
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/district")
|
||||
@Api(tags = "行政区划")
|
||||
public class SysDistrictController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysDistrictService sysDistrictService;
|
||||
|
||||
/**
|
||||
* 查询行政区划树状列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:district:list')")
|
||||
@GetMapping("/tree")
|
||||
@ApiOperation("查询行政区划树状列表")
|
||||
public AjaxResult tree(){
|
||||
return success(sysDistrictService.selectSysDistrictTree());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询行政区划列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:district:list')")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询行政区划列表")
|
||||
public TableDataInfo list(SysDistrict sysDistrict)
|
||||
{
|
||||
startPage();
|
||||
List<SysDistrict> list = sysDistrictService.selectSysDistrictList(sysDistrict);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出行政区划列表
|
||||
*/
|
||||
@ApiOperation("导出行政区划列表")
|
||||
@PreAuthorize("@ss.hasPermi('system:district:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysDistrict sysDistrict)
|
||||
{
|
||||
List<SysDistrict> list = sysDistrictService.selectSysDistrictList(sysDistrict);
|
||||
ExcelUtil<SysDistrict> util = new ExcelUtil<SysDistrict>(SysDistrict.class);
|
||||
util.exportExcel(response, list, "行政区划数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取行政区划详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:district:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiOperation("获取行政区划详细信息")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(sysDistrictService.selectSysDistrictById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增行政区划
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:district:add')")
|
||||
@PostMapping
|
||||
@ApiOperation("新增行政区划")
|
||||
public AjaxResult add(@RequestBody SysDistrict sysDistrict)
|
||||
{
|
||||
return toAjax(sysDistrictService.insertSysDistrict(sysDistrict));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改行政区划
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:district:edit')")
|
||||
@PutMapping
|
||||
@ApiOperation("修改行政区划")
|
||||
public AjaxResult edit(@RequestBody SysDistrict sysDistrict)
|
||||
{
|
||||
return toAjax(sysDistrictService.updateSysDistrict(sysDistrict));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除行政区划
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:district:remove')")
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除行政区划")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(sysDistrictService.deleteSysDistrictByIds(ids));
|
||||
}
|
||||
}
|
@ -4,6 +4,8 @@ package com.fastbee.data.controller.project;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.fastbee.common.annotation.Log;
|
||||
import com.fastbee.common.enums.BusinessType;
|
||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
||||
import com.fastbee.project.domain.Project;
|
||||
import com.fastbee.project.service.IProjectService;
|
||||
@ -65,6 +67,7 @@ public class ProjectController extends BaseController
|
||||
*/
|
||||
@ApiOperation("导出项目列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:project:export')")
|
||||
@Log(title = "巡检路线", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Project project)
|
||||
{
|
||||
@ -116,4 +119,13 @@ public class ProjectController extends BaseController
|
||||
{
|
||||
return toAjax(projectService.deleteProjectByProjectIds(projectIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未绑定项目的机构列表
|
||||
*/
|
||||
@GetMapping("/unbindDeptList")
|
||||
@ApiOperation("获取未绑定项目的机构列表")
|
||||
public AjaxResult getUnbindProjectDeptList(){
|
||||
return success(projectService.getUnbindDeptList());
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.fastbee.ggroup.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.extra.ssh.JschUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
@ -15,9 +14,6 @@ import com.fastbee.ggroup.mapper.GGroupsMapper;
|
||||
import com.fastbee.ggroup.mapper.GSiteGroupsMapper;
|
||||
import com.fastbee.ggroup.mapper.GSitesMapper;
|
||||
import com.fastbee.ggroup.service.IGGroupsService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.yulichang.query.MPJLambdaQueryWrapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -31,7 +27,7 @@ import java.util.stream.Collectors;
|
||||
* 组Service业务层处理
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-09-27
|
||||
* @date 2024-09-27
|
||||
*/
|
||||
@Service
|
||||
public class GGroupsServiceImpl implements IGGroupsService
|
||||
@ -39,8 +35,6 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
@Autowired
|
||||
private GGroupsMapper gGroupsMapper;
|
||||
|
||||
@Autowired
|
||||
private GSitesMapper gSitesMapper;
|
||||
|
||||
@Autowired
|
||||
private GSiteGroupsMapper gSiteGroupsMapper;
|
||||
@ -74,7 +68,6 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
GGroups::getOrderNum, GGroups::getSpace)
|
||||
.in(GGroups::getProjectId, ProjectHolder.getProjectInfo().getProjectIdList())
|
||||
.list();
|
||||
|
||||
return buildTree(list);
|
||||
}
|
||||
|
||||
@ -94,7 +87,6 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
.leftJoin(GSites.class, GSites::getId, GSiteGroups::getSiteId)
|
||||
.eq(GSiteGroups::getParentId, gGroups.getParentId())
|
||||
.like(StringUtils.isNotBlank(gGroups.getName()), GGroups::getName, gGroups.getName());
|
||||
;
|
||||
return gSiteGroupsMapper.selectJoinList(GGroupSiteVo.class,gSiteGroupsMPJLambdaWrapper);
|
||||
}
|
||||
|
||||
@ -165,7 +157,11 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
*/
|
||||
@Override
|
||||
public int insertGGroups(GGroups gGroups)
|
||||
{ //同一个父节点下组名不能重复
|
||||
{
|
||||
//判断所属项目
|
||||
|
||||
|
||||
//同一个父节点下组名不能重复
|
||||
GGroups duplicateName=gGroupsMapper.selectOne(new LambdaQueryWrapper<GGroups>()
|
||||
.select(GGroups::getId)
|
||||
.eq(GGroups::getName, gGroups.getName().trim())
|
||||
@ -239,15 +235,13 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
.in(GGroups::getProjectId, ProjectHolder.getProjectInfo().getProjectIdList())
|
||||
.list();
|
||||
System.err.println(ProjectHolder.getProjectInfo());
|
||||
ProjectHolder.getProjectInfo().getProjectIdList().forEach(System.err::println);
|
||||
list.forEach(System.err::println);
|
||||
List<GGroups> gGroupsList = buildTreeSite(list);
|
||||
List<List<GGroups>> listList = gGroupsList.stream().map(gGroups1 -> {
|
||||
//组的树状结构外层数组元素套一层数组
|
||||
return gGroupsList.stream().map(gGroups1 -> {
|
||||
List<GGroups> list1 = new ArrayList<>();
|
||||
list1.add(gGroups1);
|
||||
return list1;
|
||||
}).collect(Collectors.toList());
|
||||
//组的树状结构
|
||||
return listList;
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
}
|
||||
//未上传站点地图json数据
|
||||
if(StringUtils.isBlank(gGroupSiteDto.getIcon())){
|
||||
throw new ServiceException("请上传站点地图json数据!");
|
||||
throw new ServiceException("请选择站点图标!");
|
||||
}
|
||||
//设置坐标值等信息
|
||||
getReadJsonFileContent(gSites);
|
||||
@ -116,9 +116,14 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
//TODO 路径优化
|
||||
//发起http请求获取json数据
|
||||
String space = gSites.getSpace();
|
||||
if(Objects.isNull(space)){
|
||||
if(StringUtils.isBlank(space)){
|
||||
throw new ServiceException("请上传站点地图json数据!");
|
||||
}
|
||||
//判断space是否是完整url还是相对url
|
||||
if(!(space.contains("http://") || space.contains("https://"))){
|
||||
//如果是相对url则代表未修改
|
||||
return;
|
||||
}
|
||||
String jsonData = HttpUtil.get(space);
|
||||
System.err.println("获取到json:"+jsonData);
|
||||
|
||||
|
@ -23,6 +23,10 @@
|
||||
<groupId>com.fastbee</groupId>
|
||||
<artifactId>fastbee-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fastbee</groupId>
|
||||
<artifactId>fastbee-system-service</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@ -11,7 +11,7 @@ import com.fastbee.common.core.domain.BaseEntity;
|
||||
* 项目对象 project
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-10-17
|
||||
* @date 2024-10-18
|
||||
*/
|
||||
@ApiModel(value = "Project",description = "项目 project")
|
||||
@Data
|
||||
@ -106,4 +106,19 @@ public class Project extends BaseEntity
|
||||
@ApiModelProperty("父项目id")
|
||||
private Long parentId;
|
||||
|
||||
/** 所属机构id */
|
||||
@Excel(name = "所属机构id")
|
||||
@ApiModelProperty("所属机构id")
|
||||
private Long deptId;
|
||||
|
||||
/** 行政区域代码 */
|
||||
@Excel(name = "行政区域代码")
|
||||
@ApiModelProperty("行政区域代码")
|
||||
private String administrativeAreaCode;
|
||||
|
||||
/** 项目所属机构名称 */
|
||||
@Excel(name = "项目所属机构名称")
|
||||
@ApiModelProperty("项目所属机构名称")
|
||||
private String deptName;
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.fastbee.project.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import com.fastbee.project.domain.Project;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -12,7 +13,7 @@ import java.util.List;
|
||||
* @author kerwincui
|
||||
* @date 2024-10-17
|
||||
*/
|
||||
public interface ProjectMapper extends BaseMapper<Project>
|
||||
public interface ProjectMapper extends MPJBaseMapper<Project>
|
||||
{
|
||||
/**
|
||||
* 查询项目
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.fastbee.project.service;
|
||||
|
||||
import com.fastbee.common.core.domain.entity.SysDept;
|
||||
import com.fastbee.project.domain.Project;
|
||||
|
||||
import java.util.List;
|
||||
@ -63,4 +64,10 @@ public interface IProjectService
|
||||
|
||||
Map<String,Object> selectProjectByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 获取未绑定项目的部门列表
|
||||
* @return 部门列表
|
||||
*/
|
||||
List<SysDept> getUnbindDeptList();
|
||||
|
||||
}
|
||||
|
@ -2,12 +2,14 @@ package com.fastbee.project.service.impl;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.fastbee.common.core.domain.entity.SysDept;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.project.domain.Project;
|
||||
import com.fastbee.project.mapper.ProjectMapper;
|
||||
import com.fastbee.project.service.IProjectService;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import com.fastbee.system.mapper.SysDeptMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -17,7 +19,7 @@ import java.util.*;
|
||||
* 项目Service业务层处理
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-09-26
|
||||
* @date 2024-09-26
|
||||
*/
|
||||
@Service
|
||||
public class ProjectServiceImpl implements IProjectService
|
||||
@ -25,6 +27,9 @@ public class ProjectServiceImpl implements IProjectService
|
||||
@Autowired
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
@Autowired
|
||||
private SysDeptMapper sysDeptMapper;
|
||||
|
||||
/**
|
||||
* 查询项目
|
||||
*
|
||||
@ -57,7 +62,12 @@ public class ProjectServiceImpl implements IProjectService
|
||||
*/
|
||||
@Override
|
||||
public int insertProject(Project project)
|
||||
{
|
||||
{ //判断选择的机构下是否已经绑定项目
|
||||
Project one = new LambdaQueryChainWrapper<>(projectMapper).select(Project::getProjectId, Project::getProjectName)
|
||||
.eq(Project::getDeptId, project.getDeptId()).one();
|
||||
if(Objects.nonNull(one)){
|
||||
throw new ServiceException("该机构下已经存在项目");
|
||||
}
|
||||
project.setCreateTime(DateUtils.getNowDate());
|
||||
return projectMapper.insertProject(project);
|
||||
}
|
||||
@ -71,6 +81,15 @@ public class ProjectServiceImpl implements IProjectService
|
||||
@Override
|
||||
public int updateProject(Project project)
|
||||
{
|
||||
//判断选择的机构下是否已经绑定项目
|
||||
Project one = new LambdaQueryChainWrapper<>(projectMapper).select(Project::getProjectId, Project::getProjectName,Project::getDeptId)
|
||||
.eq(Project::getDeptId, project.getDeptId()).one();
|
||||
if(Objects.isNull(one)){
|
||||
throw new ServiceException("项目不存在!");
|
||||
}
|
||||
if(!one.getDeptId().equals(project.getDeptId())){
|
||||
throw new ServiceException("非法修改项目机构!");
|
||||
}
|
||||
project.setUpdateTime(DateUtils.getNowDate());
|
||||
return projectMapper.updateProject(project);
|
||||
}
|
||||
@ -126,6 +145,29 @@ public class ProjectServiceImpl implements IProjectService
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询未绑定项目的部门列表
|
||||
* @return 部门列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysDept> getUnbindDeptList() {
|
||||
//查询所有机构
|
||||
List<SysDept> sysDeptList = new LambdaQueryChainWrapper<>(sysDeptMapper)
|
||||
.select(SysDept::getDeptId, SysDept::getDeptName)
|
||||
.list();
|
||||
//查询所有项目
|
||||
List<Project> projectList = new LambdaQueryChainWrapper<>(projectMapper)
|
||||
.select(Project::getProjectId, Project::getDeptId)
|
||||
.list();
|
||||
//遍历项目,把已绑定项目的机构从机构列表中移除
|
||||
for (Project project : projectList) {
|
||||
if (Objects.nonNull(project.getDeptId()))
|
||||
sysDeptList.removeIf(sysDept -> sysDept.getDeptId().equals(project.getDeptId()));
|
||||
}
|
||||
|
||||
return sysDeptList;
|
||||
}
|
||||
|
||||
public List<Long> getAllProjects(Long projectId) {
|
||||
List<Long> allProjects = new ArrayList<>();
|
||||
|
||||
|
@ -27,10 +27,13 @@
|
||||
<result property="tenantName" column="tenant_name" />
|
||||
<result property="ownerId" column="owner_id" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
<result property="administrativeAreaCode" column="administrative_area_code" />
|
||||
<result property="deptName" column="dept_name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectProjectVo">
|
||||
select project_id, project_name, sys_show_name, central_coordinates, scope, administrative_area, owner, logo, image, video_introduction, remark, p_params, introduce, del_flag, create_time, create_by, update_time, remarks, tenant_id, tenant_name, owner_id, parent_id from project
|
||||
select project_id, project_name, sys_show_name, central_coordinates, scope, administrative_area, owner, logo, image, video_introduction, remark, p_params, introduce, del_flag, create_time, create_by, update_time, remarks, tenant_id, tenant_name, owner_id, parent_id, dept_id, administrative_area_code, dept_name from project
|
||||
</sql>
|
||||
|
||||
<select id="selectProjectList" parameterType="Project" resultMap="ProjectResult">
|
||||
@ -52,6 +55,9 @@
|
||||
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
|
||||
<if test="ownerId != null "> and owner_id = #{ownerId}</if>
|
||||
<if test="parentId != null "> and parent_id = #{parentId}</if>
|
||||
<if test="deptId != null "> and dept_id = #{deptId}</if>
|
||||
<if test="administrativeAreaCode != null and administrativeAreaCode != ''"> and administrative_area_code = #{administrativeAreaCode}</if>
|
||||
<if test="deptName != null and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@ -85,6 +91,9 @@
|
||||
<if test="tenantName != null">tenant_name,</if>
|
||||
<if test="ownerId != null">owner_id,</if>
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
<if test="administrativeAreaCode != null">administrative_area_code,</if>
|
||||
<if test="deptName != null">dept_name,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="projectId != null">#{projectId},</if>
|
||||
@ -109,6 +118,9 @@
|
||||
<if test="tenantName != null">#{tenantName},</if>
|
||||
<if test="ownerId != null">#{ownerId},</if>
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
<if test="administrativeAreaCode != null">#{administrativeAreaCode},</if>
|
||||
<if test="deptName != null">#{deptName},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@ -136,6 +148,9 @@
|
||||
<if test="tenantName != null">tenant_name = #{tenantName},</if>
|
||||
<if test="ownerId != null">owner_id = #{ownerId},</if>
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
<if test="deptId != null">dept_id = #{deptId},</if>
|
||||
<if test="administrativeAreaCode != null">administrative_area_code = #{administrativeAreaCode},</if>
|
||||
<if test="deptName != null">dept_name = #{deptName},</if>
|
||||
</trim>
|
||||
where project_id = #{projectId}
|
||||
</update>
|
||||
|
@ -0,0 +1,70 @@
|
||||
package com.fastbee.system.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.fastbee.common.annotation.Excel;
|
||||
import com.fastbee.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 行政区划对象 sys_district
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-10-18
|
||||
*/
|
||||
@ApiModel(value = "SysDistrict",description = "行政区划 sys_district")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysDistrict extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** */
|
||||
private Long id;
|
||||
|
||||
/** 城市id */
|
||||
@Excel(name = "城市id")
|
||||
@ApiModelProperty("城市id")
|
||||
private Long adcode;
|
||||
|
||||
/** 省市级别 */
|
||||
@Excel(name = "省市级别")
|
||||
@ApiModelProperty("省市级别")
|
||||
private Long level;
|
||||
|
||||
/** 父级id */
|
||||
@Excel(name = "父级id")
|
||||
@ApiModelProperty("父级id")
|
||||
private Long parentId;
|
||||
|
||||
/** 简称 */
|
||||
@Excel(name = "简称")
|
||||
@ApiModelProperty("简称")
|
||||
private String name;
|
||||
|
||||
/** 全称 */
|
||||
@Excel(name = "全称")
|
||||
@ApiModelProperty("全称")
|
||||
private String fullName;
|
||||
|
||||
/** 经度 */
|
||||
@Excel(name = "经度")
|
||||
@ApiModelProperty("经度")
|
||||
private BigDecimal lng;
|
||||
|
||||
/** 纬度 */
|
||||
@Excel(name = "纬度")
|
||||
@ApiModelProperty("纬度")
|
||||
private BigDecimal lat;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
private List<SysDistrict> children;
|
||||
}
|
@ -2,7 +2,7 @@ package com.fastbee.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fastbee.system.domain.SysRoleDept;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.fastbee.common.core.domain.entity.SysDept;
|
||||
|
||||
@ -11,7 +11,7 @@ import com.fastbee.common.core.domain.entity.SysDept;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysDeptMapper
|
||||
public interface SysDeptMapper extends MPJBaseMapper<SysDept>
|
||||
{
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
|
@ -0,0 +1,63 @@
|
||||
package com.fastbee.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fastbee.system.domain.SysDistrict;
|
||||
|
||||
/**
|
||||
* 行政区划Mapper接口
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-10-18
|
||||
*/
|
||||
public interface SysDistrictMapper extends BaseMapper<SysDistrict>
|
||||
{
|
||||
/**
|
||||
* 查询行政区划
|
||||
*
|
||||
* @param id 行政区划主键
|
||||
* @return 行政区划
|
||||
*/
|
||||
public SysDistrict selectSysDistrictById(Long id);
|
||||
|
||||
/**
|
||||
* 查询行政区划列表
|
||||
*
|
||||
* @param sysDistrict 行政区划
|
||||
* @return 行政区划集合
|
||||
*/
|
||||
public List<SysDistrict> selectSysDistrictList(SysDistrict sysDistrict);
|
||||
|
||||
/**
|
||||
* 新增行政区划
|
||||
*
|
||||
* @param sysDistrict 行政区划
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysDistrict(SysDistrict sysDistrict);
|
||||
|
||||
/**
|
||||
* 修改行政区划
|
||||
*
|
||||
* @param sysDistrict 行政区划
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysDistrict(SysDistrict sysDistrict);
|
||||
|
||||
/**
|
||||
* 删除行政区划
|
||||
*
|
||||
* @param id 行政区划主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysDistrictById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除行政区划
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysDistrictByIds(Long[] ids);
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.fastbee.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.fastbee.system.domain.SysDistrict;
|
||||
|
||||
/**
|
||||
* 行政区划Service接口
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-10-18
|
||||
*/
|
||||
public interface ISysDistrictService
|
||||
{
|
||||
/**
|
||||
* 查询行政区划
|
||||
*
|
||||
* @param id 行政区划主键
|
||||
* @return 行政区划
|
||||
*/
|
||||
public SysDistrict selectSysDistrictById(Long id);
|
||||
|
||||
/**
|
||||
* 查询行政区划列表
|
||||
*
|
||||
* @param sysDistrict 行政区划
|
||||
* @return 行政区划集合
|
||||
*/
|
||||
public List<SysDistrict> selectSysDistrictList(SysDistrict sysDistrict);
|
||||
|
||||
/**
|
||||
* 新增行政区划
|
||||
*
|
||||
* @param sysDistrict 行政区划
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysDistrict(SysDistrict sysDistrict);
|
||||
|
||||
/**
|
||||
* 修改行政区划
|
||||
*
|
||||
* @param sysDistrict 行政区划
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysDistrict(SysDistrict sysDistrict);
|
||||
|
||||
/**
|
||||
* 批量删除行政区划
|
||||
*
|
||||
* @param ids 需要删除的行政区划主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysDistrictByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除行政区划信息
|
||||
*
|
||||
* @param id 行政区划主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysDistrictById(Long id);
|
||||
|
||||
List<SysDistrict> selectSysDistrictTree();
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
package com.fastbee.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fastbee.system.mapper.SysDistrictMapper;
|
||||
import com.fastbee.system.domain.SysDistrict;
|
||||
import com.fastbee.system.service.ISysDistrictService;
|
||||
|
||||
|
||||
/**
|
||||
* 行政区划Service业务层处理
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-10-18
|
||||
*/
|
||||
@Service
|
||||
public class SysDistrictServiceImpl implements ISysDistrictService
|
||||
{
|
||||
@Autowired
|
||||
private SysDistrictMapper sysDistrictMapper;
|
||||
|
||||
/**
|
||||
* 查询行政区划
|
||||
*
|
||||
* @param id 行政区划主键
|
||||
* @return 行政区划
|
||||
*/
|
||||
@Override
|
||||
public SysDistrict selectSysDistrictById(Long id)
|
||||
{
|
||||
return sysDistrictMapper.selectSysDistrictById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询行政区划列表
|
||||
*
|
||||
* @param sysDistrict 行政区划
|
||||
* @return 行政区划
|
||||
*/
|
||||
@Override
|
||||
public List<SysDistrict> selectSysDistrictList(SysDistrict sysDistrict)
|
||||
{
|
||||
return sysDistrictMapper.selectSysDistrictList(sysDistrict);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增行政区划
|
||||
*
|
||||
* @param sysDistrict 行政区划
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysDistrict(SysDistrict sysDistrict)
|
||||
{
|
||||
return sysDistrictMapper.insertSysDistrict(sysDistrict);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改行政区划
|
||||
*
|
||||
* @param sysDistrict 行政区划
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysDistrict(SysDistrict sysDistrict)
|
||||
{
|
||||
return sysDistrictMapper.updateSysDistrict(sysDistrict);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除行政区划
|
||||
*
|
||||
* @param ids 需要删除的行政区划主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysDistrictByIds(Long[] ids)
|
||||
{
|
||||
return sysDistrictMapper.deleteSysDistrictByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除行政区划信息
|
||||
*
|
||||
* @param id 行政区划主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysDistrictById(Long id)
|
||||
{
|
||||
return sysDistrictMapper.deleteSysDistrictById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询行政区划树状列表
|
||||
* @return 树状列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysDistrict> selectSysDistrictTree() {
|
||||
List<SysDistrict> sysDistrictList = new LambdaQueryChainWrapper<>(sysDistrictMapper)
|
||||
.select(SysDistrict::getId, SysDistrict::getParentId, SysDistrict::getName, SysDistrict::getAdcode,
|
||||
SysDistrict::getLevel, SysDistrict::getFullName, SysDistrict::getName
|
||||
, SysDistrict::getLng, SysDistrict::getLat)
|
||||
.list();
|
||||
return buildTree(sysDistrictList);
|
||||
|
||||
}
|
||||
|
||||
private List<SysDistrict> buildTree(List<SysDistrict> SysDistricts) {
|
||||
Map<Long, SysDistrict> map = new HashMap<>();
|
||||
List<SysDistrict> roots = new ArrayList<>();
|
||||
for (SysDistrict sysDistrict : SysDistricts) {
|
||||
map.put(sysDistrict.getAdcode(), sysDistrict);
|
||||
}
|
||||
return getDistricts(SysDistricts, map, roots);
|
||||
}
|
||||
|
||||
private List<SysDistrict> getDistricts(List<SysDistrict> SysDistricts, Map<Long, SysDistrict> map, List<SysDistrict> roots) {
|
||||
for (SysDistrict sysDistrict : SysDistricts) {
|
||||
Long parentId = sysDistrict.getParentId();
|
||||
if (parentId == null || !map.containsKey(parentId)) {
|
||||
roots.add(sysDistrict);
|
||||
} else {
|
||||
SysDistrict parent = map.get(parentId);
|
||||
if (parent.getChildren() == null) {
|
||||
parent.setChildren(new ArrayList<>());
|
||||
}
|
||||
parent.getChildren().add(sysDistrict);
|
||||
}
|
||||
}
|
||||
return roots;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
<?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.fastbee.system.mapper.SysDistrictMapper">
|
||||
|
||||
<resultMap type="SysDistrict" id="SysDistrictResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="adcode" column="adcode" />
|
||||
<result property="level" column="level" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="fullName" column="full_name" />
|
||||
<result property="lng" column="lng" />
|
||||
<result property="lat" column="lat" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSysDistrictVo">
|
||||
select id, adcode, level, parent_id, name, full_name, lng, lat, del_flag from sys_district
|
||||
</sql>
|
||||
|
||||
<select id="selectSysDistrictList" parameterType="SysDistrict" resultMap="SysDistrictResult">
|
||||
<include refid="selectSysDistrictVo"/>
|
||||
<where>
|
||||
<if test="adcode != null "> and adcode = #{adcode}</if>
|
||||
<if test="level != null "> and level = #{level}</if>
|
||||
<if test="parentId != null "> and parent_id = #{parentId}</if>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="fullName != null and fullName != ''"> and full_name like concat('%', #{fullName}, '%')</if>
|
||||
<if test="lng != null "> and lng = #{lng}</if>
|
||||
<if test="lat != null "> and lat = #{lat}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSysDistrictById" parameterType="Long" resultMap="SysDistrictResult">
|
||||
<include refid="selectSysDistrictVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertSysDistrict" parameterType="SysDistrict" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sys_district
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="adcode != null">adcode,</if>
|
||||
<if test="level != null">level,</if>
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
<if test="name != null">name,</if>
|
||||
<if test="fullName != null">full_name,</if>
|
||||
<if test="lng != null">lng,</if>
|
||||
<if test="lat != null">lat,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="adcode != null">#{adcode},</if>
|
||||
<if test="level != null">#{level},</if>
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="fullName != null">#{fullName},</if>
|
||||
<if test="lng != null">#{lng},</if>
|
||||
<if test="lat != null">#{lat},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSysDistrict" parameterType="SysDistrict">
|
||||
update sys_district
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="adcode != null">adcode = #{adcode},</if>
|
||||
<if test="level != null">level = #{level},</if>
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="fullName != null">full_name = #{fullName},</if>
|
||||
<if test="lng != null">lng = #{lng},</if>
|
||||
<if test="lat != null">lat = #{lat},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSysDistrictById" parameterType="Long">
|
||||
delete from sys_district where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSysDistrictByIds" parameterType="String">
|
||||
delete from sys_district where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user