Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
c1a8e34152
@ -86,7 +86,7 @@ public class SysDistrictController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取行政区划详细信息
|
* 根据id获取行政区划详细信息
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:district:query')")
|
@PreAuthorize("@ss.hasPermi('system:district:query')")
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
@ -95,6 +95,16 @@ public class SysDistrictController extends BaseController
|
|||||||
{
|
{
|
||||||
return success(sysDistrictService.selectSysDistrictById(id));
|
return success(sysDistrictService.selectSysDistrictById(id));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 根据地区代码获取行政区划详细信息
|
||||||
|
*/
|
||||||
|
|
||||||
|
@GetMapping(value = "/by-code/{areaCode}")
|
||||||
|
@ApiOperation("获取行政区划详细信息")
|
||||||
|
public AjaxResult getInfoByCode(@PathVariable("areaCode") Long areaCode)
|
||||||
|
{
|
||||||
|
return success(sysDistrictService.selectSysDistrictByCode(areaCode));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增行政区划
|
* 新增行政区划
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.fastbee.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门行政级别级别常量
|
||||||
|
* 用于判断部门管理账号是管理县、镇、村的加载对应区域轮廓
|
||||||
|
*/
|
||||||
|
public class DepartmentAdministrationLevelConstant {
|
||||||
|
public static final Integer PROVINCE = 1;//省级
|
||||||
|
public static final Integer CITY = 2;//市级
|
||||||
|
public static final Integer COUNTY = 3;//县级
|
||||||
|
public static final Integer TOWN = 4;//镇级
|
||||||
|
public static final Integer VILLAGE = 5;//村级
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.fastbee.common.utils.json;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
public class JsonStrUtil {
|
||||||
|
/**
|
||||||
|
*判断一个json数组为空
|
||||||
|
*/
|
||||||
|
public static boolean isEmptyArray(String jsonArrayStr) {
|
||||||
|
if(StringUtils.isBlank(jsonArrayStr)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(JSONUtil.parseArray(jsonArrayStr).isEmpty()){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*判断一个json数组|非空
|
||||||
|
*/
|
||||||
|
public static boolean nonEmptyArray(String jsonArrayStr) {
|
||||||
|
if(StringUtils.isBlank(jsonArrayStr)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(JSONUtil.parseArray(jsonArrayStr).isEmpty()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -132,21 +132,22 @@ public class ProjectController extends BaseController
|
|||||||
return toAjax(projectService.deleteProjectByProjectIds(projectIds));
|
return toAjax(projectService.deleteProjectByProjectIds(projectIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取未绑定项目的机构列表
|
|
||||||
*/
|
|
||||||
@GetMapping("/unbindDeptList")
|
|
||||||
@ApiOperation("获取未绑定项目的机构列表")
|
|
||||||
public AjaxResult getUnbindProjectDeptList(){
|
|
||||||
return success(projectService.getUnbindDeptList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询项目的行政区划树状列表
|
* 查询项目管理机构的当前管理的行政区划树状列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/areaTree")
|
@GetMapping("/areaTree")
|
||||||
@ApiOperation("查询项目的行政区划树状列表")
|
@ApiOperation("查询项目管理机构的当前管理的行政区划树状列表")
|
||||||
public AjaxResult getProjectAreaTree(@Param("projectId") Long deptId,@Param("startLevel") Integer startLevel){
|
public AjaxResult getProjectAreaTree(@Param("projectId") Long deptId,@Param("startLevel") Integer startLevel, @Param("isDeptHold") Integer isDeptHold){
|
||||||
return success(projectService.getProjectAreaTree(deptId, startLevel));
|
return success(projectService.getProjectAreaTree(deptId, startLevel, isDeptHold));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 查询项目管理机构管理的最高行政区划级别下的全部行政区划的树状列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/areaTreeTop")
|
||||||
|
@ApiOperation("查询项目管理机构管理的最高行政区划级别下的全部行政区划的树状列表")
|
||||||
|
public AjaxResult getProjectAreaTreeTop(@Param("projectId") Long deptId,@Param("startLevel") Integer startLevel){
|
||||||
|
return success(projectService.getProjectAreaTreeAll(deptId, startLevel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,14 +135,9 @@ public class GGroupsServiceImpl implements IGGroupsService
|
|||||||
List<GGroupSiteVo> gGroupSiteAllList = selectGGroupsAllListSites(new GGroups());
|
List<GGroupSiteVo> gGroupSiteAllList = selectGGroupsAllListSites(new GGroups());
|
||||||
//根据区域代码过滤站点
|
//根据区域代码过滤站点
|
||||||
if(Objects.nonNull(areaCodeList) && !areaCodeList.isEmpty()){
|
if(Objects.nonNull(areaCodeList) && !areaCodeList.isEmpty()){
|
||||||
System.err.println("开始过滤站点");
|
|
||||||
System.err.println(areaCodeList);
|
|
||||||
System.err.println("过滤前站点");
|
|
||||||
System.err.println(gGroupSiteAllList);
|
|
||||||
gGroupSiteAllList = gGroupSiteAllList.stream()
|
gGroupSiteAllList = gGroupSiteAllList.stream()
|
||||||
.filter(site -> areaCodeList.contains(site.getAreaCode())).collect(Collectors.toList());
|
.filter(site -> areaCodeList.contains(site.getAreaCode())).collect(Collectors.toList());
|
||||||
System.err.println("过滤后的站点");
|
|
||||||
System.err.println(gGroupSiteAllList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (GGroups group : groupsList) {
|
for (GGroups group : groupsList) {
|
||||||
@ -250,14 +245,17 @@ public class GGroupsServiceImpl implements IGGroupsService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<?> selectGGroupsAndSitesList(GGroups gGroups) {
|
public List<?> selectGGroupsAndSitesList(GGroups gGroups) {
|
||||||
|
//超级管理员不显示
|
||||||
|
if(ProjectHolder.getProjectInfo().getProjectIdList().isEmpty()){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
//查询项目下的全部站点
|
//查询项目下的全部站点
|
||||||
List<GGroups> groupSiteTreeList = new LambdaQueryChainWrapper<>(gGroupsMapper)
|
List<GGroups> groupSiteTreeList = new LambdaQueryChainWrapper<>(gGroupsMapper)
|
||||||
.select(GGroups::getId, GGroups::getName, GGroups::getParentId, GGroups::getIcon,GGroups::getTag,
|
.select(GGroups::getId, GGroups::getName, GGroups::getParentId, GGroups::getIcon,GGroups::getTag,
|
||||||
GGroups::getSpace, GGroups::getSpaceValue, GGroups::getProjectId)
|
GGroups::getSpace, GGroups::getSpaceValue, GGroups::getProjectId)
|
||||||
//根据站点标签过滤
|
//根据站点标签过滤
|
||||||
.eq(Objects.nonNull(gGroups.getTag()), GGroups::getTag, gGroups.getTag())
|
.eq(Objects.nonNull(gGroups.getTag()), GGroups::getTag, gGroups.getTag())
|
||||||
.in(!ProjectHolder.getProjectInfo().getProjectIdList().isEmpty(),GGroups::getProjectId,
|
.in(GGroups::getProjectId, ProjectHolder.getProjectInfo().getProjectIdList())
|
||||||
ProjectHolder.getProjectInfo().getProjectIdList())
|
|
||||||
.list();
|
.list();
|
||||||
|
|
||||||
//构建组和站点树状列表
|
//构建组和站点树状列表
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.fastbee.project.domain.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ProjectLoginBaseInfo {
|
||||||
|
|
||||||
|
// 项目ID
|
||||||
|
private Long projectId;
|
||||||
|
// 项目ID集合
|
||||||
|
private String projectIds;
|
||||||
|
// 项目名称
|
||||||
|
private String projectName;
|
||||||
|
// 项目级别
|
||||||
|
private String projectLevel;
|
||||||
|
// 项目行政区划编码
|
||||||
|
private String projectAreaCode;
|
||||||
|
//部门级别
|
||||||
|
private String deptAreaLevel;
|
||||||
|
//部门行政区划编码
|
||||||
|
private String deptAreaCode;
|
||||||
|
// 项目的行政区划在地图上的轮廓json数据
|
||||||
|
private String mapOutline;
|
||||||
|
// 项目的行政区划在地图上的轮廓json文件url
|
||||||
|
private String mapOutlineUrl;
|
||||||
|
// 项目的行政区划中心点经度
|
||||||
|
private BigDecimal longitude;
|
||||||
|
// 项目的行政区划中心点纬度
|
||||||
|
private BigDecimal latitude;
|
||||||
|
}
|
@ -2,6 +2,7 @@ package com.fastbee.project.service;
|
|||||||
|
|
||||||
import com.fastbee.common.core.domain.entity.SysDept;
|
import com.fastbee.common.core.domain.entity.SysDept;
|
||||||
import com.fastbee.project.domain.Project;
|
import com.fastbee.project.domain.Project;
|
||||||
|
import com.fastbee.project.domain.vo.ProjectLoginBaseInfo;
|
||||||
import com.fastbee.system.domain.SysDistrict;
|
import com.fastbee.system.domain.SysDistrict;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -48,9 +49,9 @@ public interface IProjectService
|
|||||||
int updateProject(Project project);
|
int updateProject(Project project);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除项目
|
* 删除项目
|
||||||
*
|
*
|
||||||
* @param projectIds 需要删除的项目主键集合
|
* @param projectId 需要删除的项目主键集合
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int deleteProjectByProjectIds(Long projectId);
|
int deleteProjectByProjectIds(Long projectId);
|
||||||
@ -60,13 +61,8 @@ public interface IProjectService
|
|||||||
/**
|
/**
|
||||||
* 获取管理员所管理的项目id以及子项目id列表
|
* 获取管理员所管理的项目id以及子项目id列表
|
||||||
*/
|
*/
|
||||||
Map<String,Object> selectProjectByUserId(Long userId);
|
ProjectLoginBaseInfo selectProjectByUserId(Long userId);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取未绑定项目的部门列表
|
|
||||||
* @return 部门列表
|
|
||||||
*/
|
|
||||||
List<SysDept> getUnbindDeptList();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询管理员可管理项目下拉框列表
|
* 查询管理员可管理项目下拉框列表
|
||||||
@ -75,8 +71,11 @@ public interface IProjectService
|
|||||||
List<Project> selectAdminProjectList();
|
List<Project> selectAdminProjectList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取项目行政区域列表
|
* 查询项目管理机构的当前管理的行政区划树状列表
|
||||||
* @return 行政区域列表
|
* @return 行政区域列表
|
||||||
*/
|
*/
|
||||||
List<SysDistrict> getProjectAreaTree(Long deptId,Integer startLevel);
|
List<SysDistrict> getProjectAreaTree(Long deptId,Integer startLevel,Integer isDeptHold);
|
||||||
|
|
||||||
|
List<SysDistrict> getProjectAreaTreeAll(Long deptId, Integer startLevel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package com.fastbee.project.service.impl;
|
package com.fastbee.project.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
|
||||||
import cn.hutool.json.JSONArray;
|
import cn.hutool.json.JSONArray;
|
||||||
import cn.hutool.json.JSONException;
|
import cn.hutool.json.JSONException;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
||||||
|
import com.fastbee.common.constant.DepartmentAdministrationLevelConstant;
|
||||||
import com.fastbee.common.constant.ProjectLevelConstant;
|
import com.fastbee.common.constant.ProjectLevelConstant;
|
||||||
import com.fastbee.common.core.domain.entity.SysDept;
|
import com.fastbee.common.core.domain.entity.SysDept;
|
||||||
import com.fastbee.common.core.domain.entity.SysMenu;
|
import com.fastbee.common.core.domain.entity.SysMenu;
|
||||||
@ -14,11 +14,12 @@ import com.fastbee.common.core.domain.entity.SysUser;
|
|||||||
import com.fastbee.common.exception.ServiceException;
|
import com.fastbee.common.exception.ServiceException;
|
||||||
import com.fastbee.common.holder.ProjectHolder;
|
import com.fastbee.common.holder.ProjectHolder;
|
||||||
import com.fastbee.common.utils.DateUtils;
|
import com.fastbee.common.utils.DateUtils;
|
||||||
import com.fastbee.framework.web.domain.server.Sys;
|
import com.fastbee.common.utils.json.JsonStrUtil;
|
||||||
import com.fastbee.iot.model.RegisterUserInput;
|
import com.fastbee.iot.model.RegisterUserInput;
|
||||||
import com.fastbee.iot.model.RegisterUserOutput;
|
import com.fastbee.iot.model.RegisterUserOutput;
|
||||||
import com.fastbee.iot.service.IToolService;
|
import com.fastbee.iot.service.IToolService;
|
||||||
import com.fastbee.project.domain.Project;
|
import com.fastbee.project.domain.Project;
|
||||||
|
import com.fastbee.project.domain.vo.ProjectLoginBaseInfo;
|
||||||
import com.fastbee.project.mapper.ProjectMapper;
|
import com.fastbee.project.mapper.ProjectMapper;
|
||||||
import com.fastbee.project.service.IProjectService;
|
import com.fastbee.project.service.IProjectService;
|
||||||
|
|
||||||
@ -146,6 +147,10 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
newSysDept.setDeptType(3);
|
newSysDept.setDeptType(3);
|
||||||
//设置机构领导
|
//设置机构领导
|
||||||
newSysDept.setLeader("hanzhen");
|
newSysDept.setLeader("hanzhen");
|
||||||
|
//设置默认的机构行政级别
|
||||||
|
newSysDept.setAdministrativeLevel(3);
|
||||||
|
//设置机构所属项目id
|
||||||
|
|
||||||
|
|
||||||
//设置机构型行政区域信息
|
//设置机构型行政区域信息
|
||||||
newSysDept.setAdministrativeAreaCode(Objects.nonNull(project.getAdministrativeAreaCode())?project.getAdministrativeAreaCode():null);
|
newSysDept.setAdministrativeAreaCode(Objects.nonNull(project.getAdministrativeAreaCode())?project.getAdministrativeAreaCode():null);
|
||||||
@ -165,8 +170,7 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
List<SysMenu> sysMenuList = sysMenuService.selectMenuList(new SysMenu(), sysDept.getDeptUserId());
|
List<SysMenu> sysMenuList = sysMenuService.selectMenuList(new SysMenu(), sysDept.getDeptUserId());
|
||||||
Long[] menuIdList = sysMenuList.stream().map(SysMenu::getMenuId)
|
Long[] menuIdList = sysMenuList.stream().map(SysMenu::getMenuId)
|
||||||
.filter(menuId-> menuId!=3469L&&menuId!=3L&&menuId!=2L)
|
.filter(menuId-> menuId!=3469L&&menuId!=3L&&menuId!=2L)
|
||||||
.
|
.toArray(Long[]::new);
|
||||||
toArray(Long[]::new);
|
|
||||||
SysRole sysRole = new SysRole();
|
SysRole sysRole = new SysRole();
|
||||||
sysRole.setRoleName("管理员");
|
sysRole.setRoleName("管理员");
|
||||||
sysRole.setRoleKey("manager");
|
sysRole.setRoleKey("manager");
|
||||||
@ -195,7 +199,17 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
project.setDeptId(newSysDept.getDeptId());
|
project.setDeptId(newSysDept.getDeptId());
|
||||||
project.setDeptName(project.getProjectName());
|
project.setDeptName(project.getProjectName());
|
||||||
project.setCreateTime(DateUtils.getNowDate());
|
project.setCreateTime(DateUtils.getNowDate());
|
||||||
return projectMapper.insertProject(project);
|
if(projectMapper.insertProject(project)<1){
|
||||||
|
throw new ServiceException("项目创建失败!");
|
||||||
|
}
|
||||||
|
boolean updatedSysDept = new LambdaUpdateChainWrapper<>(sysDeptMapper)
|
||||||
|
.set(SysDept::getProjectId, project.getId())
|
||||||
|
.eq(SysDept::getDeptId, newSysDept.getDeptId())
|
||||||
|
.update();
|
||||||
|
if(!updatedSysDept){
|
||||||
|
throw new ServiceException("机构与项目关联失败!");
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -328,7 +342,8 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
* 获取管理员所管理的项目id以及子项目id列表,行政区划等
|
* 获取管理员所管理的项目id以及子项目id列表,行政区划等
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> selectProjectByUserId(Long userId) {
|
public ProjectLoginBaseInfo selectProjectByUserId(Long userId) {
|
||||||
|
//TODO 优化为连表查
|
||||||
//查询用户所属机构
|
//查询用户所属机构
|
||||||
SysUser sysUser = new LambdaQueryChainWrapper<>(sysUserMapper)
|
SysUser sysUser = new LambdaQueryChainWrapper<>(sysUserMapper)
|
||||||
.select(SysUser::getUserId, SysUser::getDeptId)
|
.select(SysUser::getUserId, SysUser::getDeptId)
|
||||||
@ -353,71 +368,68 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询项目对应行政区划的地图轮廓数据
|
|
||||||
LambdaQueryChainWrapper<SysDistrict> sysDistrictLambdaQueryChainWrapper = new LambdaQueryChainWrapper<>(sysDistrictMapper)
|
|
||||||
.select(SysDistrict::getMapOutline, SysDistrict::getMapOutlineUrl, SysDistrict::getLng, SysDistrict::getLat);
|
|
||||||
if(sysDept.getAdministrativeLevel() == 3){
|
|
||||||
sysDistrictLambdaQueryChainWrapper.eq(SysDistrict::getAdcode, JSONUtil.parseArray(sysDept.getCountyCode()).get(0));
|
|
||||||
}
|
|
||||||
if(sysDept.getAdministrativeLevel() == 4){
|
|
||||||
sysDistrictLambdaQueryChainWrapper.eq(SysDistrict::getAdcode, JSONUtil.parseArray(sysDept.getTownCode()).get(0));
|
|
||||||
}
|
|
||||||
if(sysDept.getAdministrativeLevel() == 5){
|
|
||||||
sysDistrictLambdaQueryChainWrapper.eq(SysDistrict::getAdcode, JSONUtil.parseArray(sysDept.getVillageCode()).get(0));
|
|
||||||
}
|
|
||||||
List<SysDistrict> sysDistrictList = sysDistrictLambdaQueryChainWrapper
|
|
||||||
.list();
|
|
||||||
|
|
||||||
HashMap<String , Object> map = new HashMap<>();
|
ProjectLoginBaseInfo projectLoginBaseInfo = new ProjectLoginBaseInfo();
|
||||||
ArrayList<Long> projectIds = new ArrayList<>();
|
//查询项目对应行政区划的地图轮廓数据,根据部门的账号的行政等级字段来判断是县、镇、村。
|
||||||
projectIds.add(project.getId());
|
List<SysDistrict> sysDistrictList = getSysDistrictByDeptAdministrativeLevel(sysDept,projectLoginBaseInfo);
|
||||||
map.put("projectIds",projectIds.toString());
|
//设置项目id列表
|
||||||
map.put("projectId",project.getId());
|
projectLoginBaseInfo.setProjectIds(Collections.singletonList(project.getId()).toString());
|
||||||
map.put("projectName", project.getProjectName());
|
//设置项目id
|
||||||
|
projectLoginBaseInfo.setProjectId(project.getId());
|
||||||
|
//设置项目名称
|
||||||
|
projectLoginBaseInfo.setProjectName(project.getProjectName());
|
||||||
|
|
||||||
//根据项目级别获取对应的行政区划编码
|
//根据项目级别获取对应的行政区划编码
|
||||||
if(project.getLevel().equals("市级")){
|
if(project.getLevel().equals("市级")){
|
||||||
map.put("projectLevel", ProjectLevelConstant.LEVEL_CITY);
|
projectLoginBaseInfo.setProjectLevel(ProjectLevelConstant.LEVEL_CITY);
|
||||||
map.put("projectAreaCode", JSONUtil.parseArray(project.getCityCode()).get(0));
|
projectLoginBaseInfo.setProjectAreaCode(JSONUtil.parseArray(project.getCityCode()).get(0).toString());
|
||||||
}
|
}
|
||||||
if(project.getLevel().equals("县级")){
|
if(project.getLevel().equals("县级")){
|
||||||
map.put("projectLevel", ProjectLevelConstant.LEVEL_COUNTY);
|
projectLoginBaseInfo.setProjectLevel(ProjectLevelConstant.LEVEL_COUNTY);
|
||||||
map.put("projectAreaCode",JSONUtil.parseArray(project.getCountyCode()).get(0));
|
projectLoginBaseInfo.setProjectAreaCode(JSONUtil.parseArray(project.getCountyCode()).get(0).toString());
|
||||||
}
|
}
|
||||||
|
//设置项目部门行政级别
|
||||||
|
projectLoginBaseInfo.setDeptAreaLevel(String.valueOf(sysDept.getAdministrativeLevel()));
|
||||||
|
|
||||||
|
|
||||||
if(!sysDistrictList.isEmpty()){
|
if(!sysDistrictList.isEmpty()){
|
||||||
//项目的行政区划在地图上的轮廓json数据
|
//项目的行政区划在地图上的轮廓json数据
|
||||||
map.put("mapOutline",sysDistrictList.get(0).getMapOutline());
|
projectLoginBaseInfo.setMapOutline(sysDistrictList.get(0).getMapOutline());
|
||||||
//项目的行政区划在地图上的轮廓json文件url
|
//项目的行政区划在地图上的轮廓json文件url
|
||||||
map.put("mapOutlineUrl",sysDistrictList.get(0).getMapOutlineUrl());
|
projectLoginBaseInfo.setMapOutlineUrl(sysDistrictList.get(0).getMapOutlineUrl());
|
||||||
//项目的行政区划中心点经纬度
|
//项目的行政区划中心点经纬度
|
||||||
map.put("longitude",sysDistrictList.get(0).getLng());
|
projectLoginBaseInfo.setLongitude(sysDistrictList.get(0).getLng());
|
||||||
map.put("latitude",sysDistrictList.get(0).getLat());
|
projectLoginBaseInfo.setLatitude(sysDistrictList.get(0).getLat());
|
||||||
}
|
}
|
||||||
return map;
|
return projectLoginBaseInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询未绑定项目的部门列表
|
* 根据部门账号的行政等级字段来判断是县、镇、村。并查询对应行政区划信息
|
||||||
|
* @param sysDept 部门账号
|
||||||
|
* @return 行政区划信息
|
||||||
*/
|
*/
|
||||||
@Override
|
private List<SysDistrict> getSysDistrictByDeptAdministrativeLevel(SysDept sysDept,ProjectLoginBaseInfo projectLoginBaseInfo) {
|
||||||
public List<SysDept> getUnbindDeptList() {
|
LambdaQueryChainWrapper<SysDistrict> sysDistrictLambdaQueryChainWrapper = new LambdaQueryChainWrapper<>(sysDistrictMapper)
|
||||||
//查询所有机构
|
.select(SysDistrict::getMapOutline, SysDistrict::getMapOutlineUrl, SysDistrict::getLng, SysDistrict::getLat);
|
||||||
List<SysDept> sysDeptList = new LambdaQueryChainWrapper<>(sysDeptMapper)
|
if(Objects.equals(sysDept.getAdministrativeLevel(), DepartmentAdministrationLevelConstant.COUNTY)){
|
||||||
.select(SysDept::getDeptId, SysDept::getDeptName)
|
sysDistrictLambdaQueryChainWrapper.eq(SysDistrict::getAdcode, JSONUtil.parseArray(sysDept.getCountyCode()).get(0));
|
||||||
|
projectLoginBaseInfo.setDeptAreaCode(JSONUtil.parseArray(sysDept.getCountyCode()).get(0).toString());
|
||||||
|
}
|
||||||
|
else if(Objects.equals(sysDept.getAdministrativeLevel(), DepartmentAdministrationLevelConstant.TOWN)){
|
||||||
|
sysDistrictLambdaQueryChainWrapper.eq(SysDistrict::getAdcode, JSONUtil.parseArray(sysDept.getTownCode()).get(0));
|
||||||
|
projectLoginBaseInfo.setDeptAreaCode(JSONUtil.parseArray(sysDept.getTownCode()).get(0).toString());
|
||||||
|
}
|
||||||
|
else if(Objects.equals(sysDept.getAdministrativeLevel(), DepartmentAdministrationLevelConstant.VILLAGE)){
|
||||||
|
sysDistrictLambdaQueryChainWrapper.eq(SysDistrict::getAdcode, JSONUtil.parseArray(sysDept.getVillageCode()).get(0));
|
||||||
|
projectLoginBaseInfo.setDeptAreaCode(JSONUtil.parseArray(sysDept.getVillageCode()).get(0).toString());
|
||||||
|
}
|
||||||
|
return sysDistrictLambdaQueryChainWrapper
|
||||||
.list();
|
.list();
|
||||||
//查询所有项目
|
|
||||||
List<Project> projectList = new LambdaQueryChainWrapper<>(projectMapper)
|
|
||||||
.select(Project::getId, Project::getDeptId)
|
|
||||||
.list();
|
|
||||||
//遍历项目,把已绑定项目的机构从机构列表中移除
|
|
||||||
for (Project project : projectList) {
|
|
||||||
if (Objects.nonNull(project.getDeptId())) {
|
|
||||||
sysDeptList.removeIf(sysDept -> sysDept.getDeptId().equals(project.getDeptId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sysDeptList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询管理员可管理项目下拉框列表
|
* 查询管理员可管理项目下拉框列表
|
||||||
*/
|
*/
|
||||||
@ -444,30 +456,127 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
}
|
}
|
||||||
return projectList;
|
return projectList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询项目的行政区划树状列表
|
* 查询项目管理机构管理的最高行政区划级别下的全部行政区划的树状列表
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SysDistrict> getProjectAreaTree(Long deptId,Integer startLevel) {
|
public List<SysDistrict> getProjectAreaTreeAll(Long deptId, Integer startLevel) {
|
||||||
|
//处理超级管理员情况
|
||||||
|
if(deptId==100){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
//参数校验
|
//参数校验
|
||||||
if(startLevel>5||startLevel<1){
|
if(startLevel>5||startLevel<1){
|
||||||
throw new ServiceException("超出行政级别查询范围(1~5级)!");
|
throw new ServiceException("超出行政级别查询范围(1~5级)!");
|
||||||
}
|
}
|
||||||
//查询项目的行政区划信息
|
//查询项目管理部门的行政区划信息
|
||||||
|
SysDept sysDept = new LambdaQueryChainWrapper<>(sysDeptMapper)
|
||||||
|
.select(SysDept::getDeptId,SysDept::getProvinceCode, SysDept::getCityCode, SysDept::getCountyCode,
|
||||||
|
SysDept::getTownCode, SysDept::getVillageCode,SysDept::getAdministrativeLevel)
|
||||||
|
.eq(SysDept::getDeptId, deptId)
|
||||||
|
.one();
|
||||||
|
if (Objects.isNull(sysDept)) {
|
||||||
|
throw new ServiceException("未查询到项目管理机构信息!");
|
||||||
|
}
|
||||||
|
//查询省、市、县行政区划信息
|
||||||
|
LambdaQueryChainWrapper<SysDistrict> aboveSysDistrictLambdaQueryChainWrapper = new LambdaQueryChainWrapper<>(sysDistrictMapper).select(SysDistrict::getId,SysDistrict::getAdcode,SysDistrict::getLevel,SysDistrict::getName,SysDistrict::getFullName,SysDistrict::getParentId);
|
||||||
|
LambdaQueryChainWrapper<SysDistrict> belowSysDistrictLambdaQueryChainWrapper = new LambdaQueryChainWrapper<>(sysDistrictMapper).select(SysDistrict::getId, SysDistrict::getAdcode, SysDistrict::getLevel, SysDistrict::getName,SysDistrict::getFullName, SysDistrict::getParentId);
|
||||||
|
|
||||||
|
List<Object> queryInAdcodeList = new ArrayList<>();
|
||||||
|
List<Integer> queryInLevelList = new ArrayList<>();
|
||||||
|
//县级管理机构
|
||||||
|
if(Objects.equals(sysDept.getAdministrativeLevel(), DepartmentAdministrationLevelConstant.COUNTY)){
|
||||||
|
//添加省代码
|
||||||
|
if(JsonStrUtil.nonEmptyArray(sysDept.getProvinceCode())){
|
||||||
|
queryInAdcodeList.add(JSONUtil.parseArray(sysDept.getProvinceCode()).get(0));
|
||||||
|
}
|
||||||
|
//添加市代码
|
||||||
|
if(JsonStrUtil.nonEmptyArray(sysDept.getCityCode())){
|
||||||
|
queryInAdcodeList.add(JSONUtil.parseArray(sysDept.getCityCode()).get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加县代码
|
||||||
|
if(JsonStrUtil.nonEmptyArray(sysDept.getCountyCode())){
|
||||||
|
queryInAdcodeList.add(JSONUtil.parseArray(sysDept.getCountyCode()).get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
//县级查镇、村级别行政区划
|
||||||
|
queryInLevelList.add(DepartmentAdministrationLevelConstant.TOWN);
|
||||||
|
queryInLevelList.add(DepartmentAdministrationLevelConstant.VILLAGE);
|
||||||
|
|
||||||
|
}
|
||||||
|
//镇级管理机构
|
||||||
|
else if(Objects.equals(sysDept.getAdministrativeLevel(), DepartmentAdministrationLevelConstant.TOWN)){
|
||||||
|
//添加省代码
|
||||||
|
if(JsonStrUtil.nonEmptyArray(sysDept.getProvinceCode())){
|
||||||
|
queryInAdcodeList.add(JSONUtil.parseArray(sysDept.getProvinceCode()).get(0));
|
||||||
|
}
|
||||||
|
//添加市代码
|
||||||
|
if(JsonStrUtil.nonEmptyArray(sysDept.getCityCode())){
|
||||||
|
queryInAdcodeList.add(JSONUtil.parseArray(sysDept.getCityCode()).get(0));
|
||||||
|
}
|
||||||
|
//添加县代码
|
||||||
|
if(JsonStrUtil.nonEmptyArray(sysDept.getCountyCode())){
|
||||||
|
queryInAdcodeList.add(JSONUtil.parseArray(sysDept.getCountyCode()).get(0));
|
||||||
|
}
|
||||||
|
//添加镇代码
|
||||||
|
if(JsonStrUtil.nonEmptyArray(sysDept.getTownCode())){
|
||||||
|
queryInAdcodeList.add(JSONUtil.parseArray(sysDept.getTownCode()).get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
//镇级查村级别行政区划
|
||||||
|
queryInLevelList.add(DepartmentAdministrationLevelConstant.VILLAGE);
|
||||||
|
|
||||||
|
}
|
||||||
|
//先根据项目机构行政管理级别查上层的行政区划信息
|
||||||
|
List<SysDistrict> aboveSysDistrictList = aboveSysDistrictLambdaQueryChainWrapper
|
||||||
|
.in(SysDistrict::getAdcode, queryInAdcodeList)
|
||||||
|
.list();
|
||||||
|
//根据行政区划级别查询下级行政区划信息
|
||||||
|
List<SysDistrict> belowSysDistrictList = belowSysDistrictLambdaQueryChainWrapper
|
||||||
|
.in(!queryInLevelList.isEmpty(),SysDistrict::getLevel, queryInLevelList)
|
||||||
|
.list();
|
||||||
|
//合并
|
||||||
|
List<SysDistrict> allSysDistrictList= new ArrayList<>();
|
||||||
|
allSysDistrictList.addAll(aboveSysDistrictList);
|
||||||
|
allSysDistrictList.addAll(belowSysDistrictList);
|
||||||
|
List<SysDistrict> sysDistricts = buildTree(allSysDistrictList);
|
||||||
|
//过滤一下不需要的数据
|
||||||
|
return Collections.singletonList(sysDistricts.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询项目管理机构的当前管理的行政区划树状列表
|
||||||
|
* @param deptId 机构id
|
||||||
|
* @param startLevel 行政区划其实展示级别
|
||||||
|
* @param isDeptHold 是否只展示机构所管辖的行政区划
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysDistrict> getProjectAreaTree(Long deptId,Integer startLevel,Integer isDeptHold) {
|
||||||
|
startLevel= Objects.isNull(startLevel)?1:startLevel;
|
||||||
|
//处理超级管理员情况
|
||||||
|
// if(deptId==100){
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
if(startLevel>5||startLevel<1){
|
||||||
|
throw new ServiceException("超出行政级别查询范围(1~5级)!");
|
||||||
|
}
|
||||||
|
//查询项目管理部门的行政区划信息
|
||||||
SysDept sysDept = new LambdaQueryChainWrapper<>(sysDeptMapper)
|
SysDept sysDept = new LambdaQueryChainWrapper<>(sysDeptMapper)
|
||||||
.select(SysDept::getDeptId,SysDept::getProvinceCode, SysDept::getCityCode, SysDept::getCountyCode,
|
.select(SysDept::getDeptId,SysDept::getProvinceCode, SysDept::getCityCode, SysDept::getCountyCode,
|
||||||
SysDept::getTownCode, SysDept::getVillageCode)
|
SysDept::getTownCode, SysDept::getVillageCode)
|
||||||
.eq(SysDept::getDeptId, deptId)
|
.eq(SysDept::getDeptId, deptId)
|
||||||
.one();
|
.one();
|
||||||
if (Objects.isNull(sysDept)) {
|
if (Objects.isNull(sysDept)) {
|
||||||
// throw new ServiceException("项目不存在");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
//判断项目的省、市、县、镇、村行政区划列表数据不为null
|
//校验项目的省、市、县、镇、村行政区划列表数据完整性
|
||||||
isProvinceCodeBlank(sysDept);
|
checkAreaCodeNonBlank(sysDept);
|
||||||
|
|
||||||
List<Object> administrativeCodeList = getTownAndvillageCodeList(sysDept,startLevel);
|
|
||||||
|
|
||||||
|
List<Object> administrativeCodeList = getProjectDeptAreaCodeList(sysDept,startLevel);
|
||||||
//查询项目所属县下面的所有镇、村行政区划列表
|
//查询项目所属县下面的所有镇、村行政区划列表
|
||||||
List<SysDistrict> projectDistrictList;
|
List<SysDistrict> projectDistrictList;
|
||||||
LambdaQueryChainWrapper<SysDistrict> sysDistrictLambdaQueryChainWrapper = new LambdaQueryChainWrapper<>(sysDistrictMapper)
|
LambdaQueryChainWrapper<SysDistrict> sysDistrictLambdaQueryChainWrapper = new LambdaQueryChainWrapper<>(sysDistrictMapper)
|
||||||
@ -475,7 +584,6 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
SysDistrict::getLevel, SysDistrict::getFullName, SysDistrict::getName
|
SysDistrict::getLevel, SysDistrict::getFullName, SysDistrict::getName
|
||||||
, SysDistrict::getLng, SysDistrict::getLat,SysDistrict::getMapOutline,SysDistrict::getMapOutlineUrl);
|
, SysDistrict::getLng, SysDistrict::getLat,SysDistrict::getMapOutline,SysDistrict::getMapOutlineUrl);
|
||||||
|
|
||||||
//限制行政区划级别
|
|
||||||
projectDistrictList = sysDistrictLambdaQueryChainWrapper
|
projectDistrictList = sysDistrictLambdaQueryChainWrapper
|
||||||
.in(!administrativeCodeList.isEmpty(),SysDistrict::getAdcode,administrativeCodeList)
|
.in(!administrativeCodeList.isEmpty(),SysDistrict::getAdcode,administrativeCodeList)
|
||||||
.list();
|
.list();
|
||||||
@ -484,14 +592,21 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
return buildTree(projectDistrictList);
|
return buildTree(projectDistrictList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Object> getTownAndvillageCodeList(SysDept sysDept,Integer startLevel) {
|
|
||||||
// if(sysDept.getDeptId().toString().equals("100")){
|
/**
|
||||||
// return new ArrayList<>();
|
* 获取项目所管辖行政区划代码列表
|
||||||
// }
|
* 业务规则:一个项目最大管辖行政区划为县/区级,下的若干镇和村
|
||||||
//查询项目的省、市、县、镇、村行政区划列表数据
|
* 即一个项目只能选择一个县/区,下的若干镇和村
|
||||||
//目前项目下面的镇或者村都可以多选划分成一个项目
|
* @param sysDept 项目信息
|
||||||
//找到项目行政区划开始多选的级别
|
* @param startLevel 行政区划开始展示级别,对于河南省开封市尉氏县的项目,一般startLevel=3,会返回----尉氏县、县下的镇、镇下的村的行政区划代码
|
||||||
//判断省是否多选
|
* 对于河南省开封市尉氏县的项目,若startLevel=2,会返回----开封市、尉氏县、县下的镇、镇下的村的行政区划代码
|
||||||
|
* 对于河南省开封市尉氏县的项目,若startLevel=1,会返回----河南省、开封市、尉氏县、县下的镇、镇下的村的行政区划代码
|
||||||
|
* 对于河南省开封市尉氏县的项目,若startLevel=4,会返回----县下的镇、镇下的村的行政区划代码
|
||||||
|
* 对于河南省开封市尉氏县的项目,若startLevel=5,会返回----镇下的村的行政区划代码
|
||||||
|
*/
|
||||||
|
private List<Object> getProjectDeptAreaCodeList(SysDept sysDept,Integer startLevel) {
|
||||||
|
|
||||||
|
//项目的行政区划里面只能有一个省、市、县,也就是说项目为县级别建设
|
||||||
JSONArray provinceCodeList = JSONUtil.parseArray(sysDept.getProvinceCode());
|
JSONArray provinceCodeList = JSONUtil.parseArray(sysDept.getProvinceCode());
|
||||||
//判断集合中的元素值都相等则说明省未多选
|
//判断集合中的元素值都相等则说明省未多选
|
||||||
if (!provinceCodeList.stream().allMatch(provinceCode -> provinceCode.equals(provinceCodeList.get(0)))) {
|
if (!provinceCodeList.stream().allMatch(provinceCode -> provinceCode.equals(provinceCodeList.get(0)))) {
|
||||||
@ -499,7 +614,6 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
}
|
}
|
||||||
//省去重
|
//省去重
|
||||||
List<Object> distinctProvinceCodeList = provinceCodeList.stream().distinct().collect(Collectors.toList());
|
List<Object> distinctProvinceCodeList = provinceCodeList.stream().distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
//判断市是否多选
|
//判断市是否多选
|
||||||
JSONArray cityCodeList = JSONUtil.parseArray(sysDept.getCityCode());
|
JSONArray cityCodeList = JSONUtil.parseArray(sysDept.getCityCode());
|
||||||
//判断集合中的元素值都相等则说明市未多选
|
//判断集合中的元素值都相等则说明市未多选
|
||||||
@ -508,7 +622,6 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
}
|
}
|
||||||
//市去重
|
//市去重
|
||||||
List<Object> distinctCityCodeList = cityCodeList.stream().distinct().collect(Collectors.toList());
|
List<Object> distinctCityCodeList = cityCodeList.stream().distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
//判断县是否多选
|
//判断县是否多选
|
||||||
JSONArray countyCodeList = JSONUtil.parseArray(sysDept.getCountyCode());
|
JSONArray countyCodeList = JSONUtil.parseArray(sysDept.getCountyCode());
|
||||||
//判断集合中的元素值都相等则说明县未多选
|
//判断集合中的元素值都相等则说明县未多选
|
||||||
@ -517,7 +630,6 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
}
|
}
|
||||||
//县去重
|
//县去重
|
||||||
List<Object> distinctcCountyCodeList= countyCodeList.stream().distinct().collect(Collectors.toList());
|
List<Object> distinctcCountyCodeList= countyCodeList.stream().distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
//判断镇是否多选
|
//判断镇是否多选
|
||||||
JSONArray townCodeList = JSONUtil.parseArray(sysDept.getTownCode());
|
JSONArray townCodeList = JSONUtil.parseArray(sysDept.getTownCode());
|
||||||
//判断集合中的元素值都相等则说明镇未多选
|
//判断集合中的元素值都相等则说明镇未多选
|
||||||
@ -528,9 +640,9 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
|
|
||||||
//合并省、市、县、镇、村行政区划代码集合
|
//合并省、市、县、镇、村行政区划代码集合
|
||||||
List<Object> administrativeCodeList = new ArrayList<>();
|
List<Object> administrativeCodeList = new ArrayList<>();
|
||||||
|
//根据startLevel的值来合并省、市、县、镇、村行政区划代码集合
|
||||||
int[] startLevels = {1, 2, 3, 4, 5};
|
int[] startLevels = {1, 2, 3, 4, 5};
|
||||||
List<List<Object>> distinctCodeLists = Arrays.asList(distinctProvinceCodeList, distinctCityCodeList, distinctcCountyCodeList, distinctTownCodeList, villageCodeList);
|
List<List<Object>> distinctCodeLists = Arrays.asList(distinctProvinceCodeList, distinctCityCodeList, distinctcCountyCodeList, distinctTownCodeList, villageCodeList);
|
||||||
|
|
||||||
for (int i = 0; i < startLevels.length; i++) {
|
for (int i = 0; i < startLevels.length; i++) {
|
||||||
if (startLevel <= startLevels[i]) {
|
if (startLevel <= startLevels[i]) {
|
||||||
for (int j = i; j < distinctCodeLists.size(); j++) {
|
for (int j = i; j < distinctCodeLists.size(); j++) {
|
||||||
@ -539,12 +651,10 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// System.err.println("合并后镇、村行政区划代码");
|
|
||||||
// System.err.println(administrativeCodeList);
|
|
||||||
return administrativeCodeList;
|
return administrativeCodeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void isProvinceCodeBlank(SysDept sysDept) {
|
private void checkAreaCodeNonBlank(SysDept sysDept) {
|
||||||
if(sysDept.getDeptId().toString().equals("100")){
|
if(sysDept.getDeptId().toString().equals("100")){
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
@ -566,6 +676,7 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<SysDistrict> buildTree(List<SysDistrict> SysDistricts) {
|
private List<SysDistrict> buildTree(List<SysDistrict> SysDistricts) {
|
||||||
|
//给所有行政区划建立键值对
|
||||||
Map<Long, SysDistrict> map = new HashMap<>();
|
Map<Long, SysDistrict> map = new HashMap<>();
|
||||||
List<SysDistrict> roots = new ArrayList<>();
|
List<SysDistrict> roots = new ArrayList<>();
|
||||||
for (SysDistrict sysDistrict : SysDistricts) {
|
for (SysDistrict sysDistrict : SysDistricts) {
|
||||||
@ -590,36 +701,5 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
return roots;
|
return roots;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询当前项目及其子项目的id列表
|
|
||||||
* @param projectId 当前项目id
|
|
||||||
* @return 当前项目及其子项目的id列表
|
|
||||||
*/
|
|
||||||
public List<Long> getAllProjects(Long projectId) {
|
|
||||||
List<Long> allProjects = new ArrayList<>();
|
|
||||||
|
|
||||||
// 查询当前项目
|
|
||||||
Project currentProject = new LambdaQueryChainWrapper<>(projectMapper)
|
|
||||||
.select(Project::getId, Project::getProjectName)
|
|
||||||
.eq(Project::getId, projectId)
|
|
||||||
.one();
|
|
||||||
|
|
||||||
if (currentProject != null) {
|
|
||||||
allProjects.add(currentProject.getId());
|
|
||||||
|
|
||||||
// 查询当前项目的子项目
|
|
||||||
List<Project> children = new LambdaQueryChainWrapper<>(projectMapper)
|
|
||||||
.select(Project::getId, Project::getProjectName)
|
|
||||||
.eq(Project::getParentId, projectId)
|
|
||||||
.list();
|
|
||||||
|
|
||||||
// 递归查询子项目
|
|
||||||
for (Project child : children) {
|
|
||||||
allProjects.addAll(getAllProjects(child.getId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return allProjects;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,4 +60,7 @@ public interface SysDistrictMapper extends BaseMapper<SysDistrict>
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteSysDistrictByIds(Long[] ids);
|
public int deleteSysDistrictByIds(Long[] ids);
|
||||||
|
|
||||||
|
SysDistrict selectSysDistrictByCode(Long areaCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -66,4 +66,6 @@ public interface ISysDistrictService
|
|||||||
*/
|
*/
|
||||||
List<SysDistrict> selectSysDistrictTreeByCode(Long areaCode);
|
List<SysDistrict> selectSysDistrictTreeByCode(Long areaCode);
|
||||||
|
|
||||||
|
SysDistrict selectSysDistrictByCode(Long areaCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -289,9 +289,6 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||||||
//单个行政区划代码列表
|
//单个行政区划代码列表
|
||||||
JSONArray administrativeArea = JSONUtil.parseArray(item);
|
JSONArray administrativeArea = JSONUtil.parseArray(item);
|
||||||
//拆解出每个行政区划代码里面的镇或村
|
//拆解出每个行政区划代码里面的镇或村
|
||||||
// if(administrativeArea.size()!=5){
|
|
||||||
// throw new ServiceException("项目行政区域代码多选列表的元素长度必须为5,到达村级别!");
|
|
||||||
// }
|
|
||||||
//保存项目省代码列表
|
//保存项目省代码列表
|
||||||
provincialCodeList.add(administrativeArea.get(0).toString());
|
provincialCodeList.add(administrativeArea.get(0).toString());
|
||||||
//保存项目市代码列表
|
//保存项目市代码列表
|
||||||
|
@ -41,6 +41,7 @@ public class SysDistrictServiceImpl implements ISysDistrictService
|
|||||||
@Override
|
@Override
|
||||||
public SysDistrict selectSysDistrictById(Long id)
|
public SysDistrict selectSysDistrictById(Long id)
|
||||||
{
|
{
|
||||||
|
|
||||||
return sysDistrictMapper.selectSysDistrictById(id);
|
return sysDistrictMapper.selectSysDistrictById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,6 +203,14 @@ public class SysDistrictServiceImpl implements ISysDistrictService
|
|||||||
return Collections.singletonList(sysDistricts.get(0));
|
return Collections.singletonList(sysDistricts.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据地区代码获取行政区划信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SysDistrict selectSysDistrictByCode(Long areaCode) {
|
||||||
|
return sysDistrictMapper.selectSysDistrictByCode(areaCode);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询行政区划树状列表
|
* 查询行政区划树状列表
|
||||||
*/
|
*/
|
||||||
|
@ -41,6 +41,9 @@
|
|||||||
<include refid="selectSysDistrictVo"/>
|
<include refid="selectSysDistrictVo"/>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectSysDistrictByCode" resultType="com.fastbee.system.domain.SysDistrict">
|
||||||
|
<include refid="selectSysDistrictVo"/> where adcode = #{code}
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertSysDistrict" parameterType="SysDistrict" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertSysDistrict" parameterType="SysDistrict" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into sys_district
|
insert into sys_district
|
||||||
|
Loading…
x
Reference in New Issue
Block a user