新增站点json文件校验逻辑补充,查询项目详情接口修改等
This commit is contained in:
@ -9,6 +9,9 @@ import javax.validation.constraints.Size;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.fastbee.common.core.domain.BaseEntity;
|
||||
@ -18,7 +21,9 @@ import com.fastbee.common.core.domain.BaseEntity;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "SysDept", description = "部门表 sys_dept")
|
||||
@Data
|
||||
public class SysDept extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -96,14 +101,6 @@ public class SysDept extends BaseEntity
|
||||
*/
|
||||
private Integer deptType;
|
||||
|
||||
public Boolean getShowOwner() {
|
||||
return showOwner;
|
||||
}
|
||||
|
||||
public void setShowOwner(Boolean showOwner) {
|
||||
this.showOwner = showOwner;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否显示自己
|
||||
*/
|
||||
@ -112,85 +109,9 @@ public class SysDept extends BaseEntity
|
||||
/**
|
||||
* 管理员姓名
|
||||
*/
|
||||
|
||||
private String deptUserName;
|
||||
|
||||
public String getDeptUserName() {
|
||||
return deptUserName;
|
||||
}
|
||||
|
||||
public void setDeptUserName(String deptUserName) {
|
||||
this.deptUserName = deptUserName;
|
||||
}
|
||||
|
||||
public Integer getDeptType() {
|
||||
return deptType;
|
||||
}
|
||||
|
||||
public void setDeptType(Integer deptType) {
|
||||
this.deptType = deptType;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getConfirmPassword() {
|
||||
return confirmPassword;
|
||||
}
|
||||
|
||||
public void setConfirmPassword(String confirmPassword) {
|
||||
this.confirmPassword = confirmPassword;
|
||||
}
|
||||
|
||||
public Long getDeptUserId() {
|
||||
return deptUserId;
|
||||
}
|
||||
|
||||
public void setDeptUserId(Long deptUserId) {
|
||||
this.deptUserId = deptUserId;
|
||||
}
|
||||
|
||||
public Long getDeptId()
|
||||
{
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(Long deptId)
|
||||
{
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
public Long getParentId()
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public String getAncestors()
|
||||
{
|
||||
return ancestors;
|
||||
}
|
||||
|
||||
public void setAncestors(String ancestors)
|
||||
{
|
||||
this.ancestors = ancestors;
|
||||
}
|
||||
|
||||
@NotBlank(message = "部门名称不能为空")
|
||||
@Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
|
||||
@ -199,43 +120,18 @@ public class SysDept extends BaseEntity
|
||||
return deptName;
|
||||
}
|
||||
|
||||
public void setDeptName(String deptName)
|
||||
{
|
||||
this.deptName = deptName;
|
||||
}
|
||||
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
public Integer getOrderNum()
|
||||
{
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
public void setOrderNum(Integer orderNum)
|
||||
{
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public String getLeader()
|
||||
{
|
||||
return leader;
|
||||
}
|
||||
|
||||
public void setLeader(String leader)
|
||||
{
|
||||
this.leader = leader;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
|
||||
public String getPhone()
|
||||
{
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone)
|
||||
{
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||
public String getEmail()
|
||||
@ -243,69 +139,6 @@ public class SysDept extends BaseEntity
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email)
|
||||
{
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(String delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getParentName()
|
||||
{
|
||||
return parentName;
|
||||
}
|
||||
|
||||
public void setParentName(String parentName)
|
||||
{
|
||||
this.parentName = parentName;
|
||||
}
|
||||
|
||||
public List<SysDept> getChildren()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<SysDept> children)
|
||||
{
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("deptId", getDeptId())
|
||||
.append("deptUserId", getDeptUserId())
|
||||
.append("parentId", getParentId())
|
||||
.append("ancestors", getAncestors())
|
||||
.append("deptName", getDeptName())
|
||||
.append("orderNum", getOrderNum())
|
||||
.append("leader", getLeader())
|
||||
.append("phone", getPhone())
|
||||
.append("email", getEmail())
|
||||
.append("status", getStatus())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -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