新增站点json文件校验逻辑补充,查询项目详情接口修改等
This commit is contained in:
@ -148,11 +148,11 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
}
|
||||
JSONArray jsonArray = JSONUtil.parseArray(coordinates);
|
||||
//判断数组每个元素必须为经度或纬度
|
||||
// for (Object o : jsonArray) {
|
||||
// if (!(o instanceof Double)) {
|
||||
// throw new ServiceException("coordinates必须只包含经纬度数据!");
|
||||
// }
|
||||
// }
|
||||
for (Object o : jsonArray) {
|
||||
if(isLongitudeOrLatitude(o.toString())){
|
||||
throw new ServiceException("coordinates数组元素必须为经度或纬度!");
|
||||
}
|
||||
}
|
||||
|
||||
int startIndex = space.indexOf("/profile/upload/");
|
||||
String relativeUrl = space.substring(startIndex);
|
||||
@ -161,6 +161,25 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是不是经度或者纬度
|
||||
* @param str 经纬度字符串
|
||||
* @return true or false
|
||||
*/
|
||||
private boolean isLongitudeOrLatitude(String str) {
|
||||
String regex = "^[-+]?\\d{1,3}\\.\\d+$";
|
||||
double value = Double.parseDouble(str);
|
||||
//满足经度值
|
||||
if (value >= -180 && value <= 180) {
|
||||
return true;
|
||||
}
|
||||
//满足纬度值
|
||||
else if (value >= -90 && value <= 90) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改站点
|
||||
|
@ -48,7 +48,7 @@ public class ProjectServiceImpl implements IProjectService
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询项目
|
||||
* 根据主键查询项目
|
||||
*
|
||||
* @param projectId 项目主键
|
||||
* @return 项目
|
||||
@ -56,7 +56,16 @@ public class ProjectServiceImpl implements IProjectService
|
||||
@Override
|
||||
public Project selectProjectByProjectId(Long projectId)
|
||||
{
|
||||
return projectMapper.selectProjectById(projectId);
|
||||
List<Project> projectList = new LambdaQueryChainWrapper<>(projectMapper)
|
||||
.select(Project::getProjectName, Project::getSysShowName, Project::getCentralCoordinates, Project::getScope,
|
||||
Project::getAdministrativeAreaCode, Project::getLevel, Project::getDeptId, Project::getDeptName,
|
||||
Project::getVideoIntroduction, Project::getImage, Project::getLogo, Project::getRemark)
|
||||
.eq(Project::getId, projectId)
|
||||
.list();
|
||||
if(projectList.isEmpty()){
|
||||
throw new ServiceException("项目不存在!");
|
||||
}
|
||||
return projectList.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,6 +97,13 @@ public class ProjectServiceImpl implements IProjectService
|
||||
if(!projectList.isEmpty()){
|
||||
throw new ServiceException("该机构下已经存在项目");
|
||||
}
|
||||
//处理项目行政区划
|
||||
parseAdministrativeDivisionInfo(project);
|
||||
project.setCreateTime(DateUtils.getNowDate());
|
||||
return projectMapper.insertProject(project);
|
||||
}
|
||||
|
||||
private void parseAdministrativeDivisionInfo(Project project) {
|
||||
//项目行政区域处理
|
||||
//拆解项目行政区域代码信息
|
||||
if(StringUtils.isBlank(project.getAdministrativeAreaCode())){
|
||||
@ -136,8 +152,6 @@ public class ProjectServiceImpl implements IProjectService
|
||||
project.setCountyCode(JSONUtil.toJsonStr(countyCodeList));
|
||||
project.setTownCode(JSONUtil.toJsonStr(townCodeList));
|
||||
project.setVillageCode(JSONUtil.toJsonStr(villageCodeList));
|
||||
project.setCreateTime(DateUtils.getNowDate());
|
||||
return projectMapper.insertProject(project);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -171,6 +185,8 @@ public class ProjectServiceImpl implements IProjectService
|
||||
throw new ServiceException("非法修改项目机构!");
|
||||
}
|
||||
project.setUpdateTime(DateUtils.getNowDate());
|
||||
//处理项目行政区划
|
||||
parseAdministrativeDivisionInfo(project);
|
||||
return projectMapper.updateProject(project);
|
||||
}
|
||||
|
||||
@ -185,7 +201,8 @@ public class ProjectServiceImpl implements IProjectService
|
||||
|
||||
|
||||
/**
|
||||
* 获取管理员所管理的项目id以及子项目id列表
|
||||
* 获取项目的一些基本信息
|
||||
* 获取管理员所管理的项目id以及子项目id列表,行政区划等
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> selectProjectByUserId(Long userId) {
|
||||
@ -195,7 +212,6 @@ public class ProjectServiceImpl implements IProjectService
|
||||
.eq(SysUser::getUserId, userId)
|
||||
.one();
|
||||
|
||||
|
||||
//查询该管理员所管理的项目id以及子项目id列表
|
||||
Project project = new LambdaQueryChainWrapper<>(projectMapper)
|
||||
.select(Project::getId, Project::getProjectName,Project::getLevel,Project::getDeptId
|
||||
@ -205,6 +221,14 @@ public class ProjectServiceImpl implements IProjectService
|
||||
if(Objects.isNull(project)){
|
||||
return null;
|
||||
}
|
||||
//查询项目对应行政区划的地图轮廓数据
|
||||
List<SysDistrict> sysDistrictList = new LambdaQueryChainWrapper<>(sysDistrictMapper)
|
||||
.select(SysDistrict::getMapOutline, SysDistrict::getMapOutlineUrl,SysDistrict::getLng,SysDistrict::getLat)
|
||||
.eq(SysDistrict::getAdcode, JSONUtil.parseArray(project.getCountyCode()).get(0))
|
||||
.list();
|
||||
|
||||
|
||||
|
||||
List<Long> projects = getAllProjects(project.getId());
|
||||
//把列表进行Base64编码
|
||||
String projectsBase64 = Base64.encode(projects.toString());
|
||||
@ -212,6 +236,8 @@ public class ProjectServiceImpl implements IProjectService
|
||||
map.put("projectIds",projectsBase64);
|
||||
map.put("projectId",project.getId());
|
||||
map.put("projectName", project.getProjectName());
|
||||
|
||||
//根据项目级别获取对应的行政区划编码
|
||||
if(project.getLevel().equals("市级")){
|
||||
map.put("projectLevel", ProjectLevelConstant.LEVEL_CITY);
|
||||
map.put("projectAreaCode", JSONUtil.parseArray(project.getCityCode()).get(0));
|
||||
@ -219,7 +245,15 @@ public class ProjectServiceImpl implements IProjectService
|
||||
if(project.getLevel().equals("县级")){
|
||||
map.put("projectLevel", ProjectLevelConstant.LEVEL_COUNTY);
|
||||
map.put("projectAreaCode",JSONUtil.parseArray(project.getCountyCode()).get(0));
|
||||
|
||||
}
|
||||
if(!sysDistrictList.isEmpty()){
|
||||
//项目的行政区划在地图上的轮廓json数据
|
||||
map.put("mapOutline",sysDistrictList.get(0).getMapOutline());
|
||||
//项目的行政区划在地图上的轮廓json文件url
|
||||
map.put("mapOutlineUrl",sysDistrictList.get(0).getMapOutlineUrl());
|
||||
//项目的行政区划中心点经纬度
|
||||
map.put("longitude",sysDistrictList.get(0).getLng());
|
||||
map.put("latitude",sysDistrictList.get(0).getLat());
|
||||
}
|
||||
|
||||
return map;
|
||||
@ -418,6 +452,11 @@ public class ProjectServiceImpl implements IProjectService
|
||||
return roots;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前项目及其子项目的id列表
|
||||
* @param projectId 当前项目id
|
||||
* @return 当前项目及其子项目的id列表
|
||||
*/
|
||||
public List<Long> getAllProjects(Long projectId) {
|
||||
List<Long> allProjects = new ArrayList<>();
|
||||
|
||||
|
Reference in New Issue
Block a user