修改项目数据拦截器逻辑,站点相关,项目相关,机构相关接口逻辑完善
This commit is contained in:
@ -29,7 +29,9 @@
|
||||
<version>1.5.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fastbee</groupId>
|
||||
<artifactId>fastbee-system-service</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,6 +1,8 @@
|
||||
package com.fastbee.ggroup.domain.dto;
|
||||
|
||||
|
||||
import com.fastbee.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -27,4 +29,8 @@ private static final long serialVersionUID = 1L;
|
||||
|
||||
private String parentId;//父节点id
|
||||
|
||||
private String areaCode;//区域编码
|
||||
|
||||
private String fullAreaCode;//完整区域编码
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
package com.fastbee.ggroup.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
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.holder.ProjectHolder;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.common.utils.json.JsonUtils;
|
||||
import com.fastbee.ggroup.domain.GGroups;
|
||||
import com.fastbee.ggroup.domain.GSiteGroups;
|
||||
import com.fastbee.ggroup.domain.GSites;
|
||||
@ -12,6 +15,7 @@ import com.fastbee.ggroup.domain.vo.GGroupSiteVo;
|
||||
import com.fastbee.ggroup.mapper.GGroupsMapper;
|
||||
import com.fastbee.ggroup.mapper.GSiteGroupsMapper;
|
||||
import com.fastbee.ggroup.service.IGGroupsService;
|
||||
import com.fastbee.system.mapper.SysDeptMapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -34,9 +38,12 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
|
||||
private final GSiteGroupsMapper gSiteGroupsMapper;
|
||||
|
||||
public GGroupsServiceImpl(GGroupsMapper gGroupsMapper, GSiteGroupsMapper gSiteGroupsMapper) {
|
||||
private final SysDeptMapper sysDeptMapper;
|
||||
|
||||
public GGroupsServiceImpl(GGroupsMapper gGroupsMapper, GSiteGroupsMapper gSiteGroupsMapper, SysDeptMapper sysDeptMapper) {
|
||||
this.gGroupsMapper = gGroupsMapper;
|
||||
this.gSiteGroupsMapper = gSiteGroupsMapper;
|
||||
this.sysDeptMapper = sysDeptMapper;
|
||||
}
|
||||
|
||||
|
||||
@ -79,6 +86,7 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
*/
|
||||
@Override
|
||||
public List<GGroupSiteVo> selectGGroupsListSites(GGroups gGroups) {
|
||||
|
||||
MPJLambdaWrapper<GSiteGroups> gSiteGroupsMPJLambdaWrapper = new MPJLambdaWrapper<GSiteGroups>()
|
||||
.select(GSiteGroups::getId, GSiteGroups::getParentId, GSiteGroups::getSiteId)
|
||||
// .select(GGroups::getName)//起个别名
|
||||
@ -89,7 +97,29 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
.leftJoin(GSites.class, GSites::getId, GSiteGroups::getSiteId)
|
||||
.eq(GSiteGroups::getParentId, gGroups.getParentId())
|
||||
.like(StringUtils.isNotBlank(gGroups.getSearchValue()), GSites::getName, gGroups.getSearchValue());
|
||||
return gSiteGroupsMapper.selectJoinList(GGroupSiteVo.class,gSiteGroupsMPJLambdaWrapper);
|
||||
List<GGroupSiteVo> gGroupSiteVos = gSiteGroupsMapper.selectJoinList(GGroupSiteVo.class, gSiteGroupsMPJLambdaWrapper);
|
||||
gSiteGroupsMapper.selectJoinList(GGroupSiteVo.class,gSiteGroupsMPJLambdaWrapper);
|
||||
//查询该机构下的行政区划列表
|
||||
SysDept sysDept = new LambdaQueryChainWrapper<>(sysDeptMapper)
|
||||
.select(SysDept::getDeptId, SysDept::getProvinceCode, SysDept::getCityCode, SysDept::getCountyCode, SysDept::getTownCode, SysDept::getVillageCode)
|
||||
.eq(SysDept::getDeptId, ProjectHolder.getProjectInfo().getProjectDeptId())
|
||||
.one();
|
||||
if(Objects.isNull(sysDept)){
|
||||
throw new ServiceException("未查询到机构信息");
|
||||
}
|
||||
List<Long> adcodeList = new ArrayList<>();
|
||||
adcodeList.addAll(JsonUtils.parseArray(sysDept.getProvinceCode(), Long.class));
|
||||
adcodeList.addAll(JsonUtils.parseArray(sysDept.getCityCode(), Long.class));
|
||||
adcodeList.addAll(JsonUtils.parseArray(sysDept.getCountyCode(), Long.class));
|
||||
adcodeList.addAll(JsonUtils.parseArray(sysDept.getTownCode(), Long.class));
|
||||
adcodeList.addAll(JsonUtils.parseArray(sysDept.getVillageCode(), Long.class));
|
||||
//根据区域代码过滤站点
|
||||
if(Objects.nonNull(adcodeList) && !adcodeList.isEmpty()){
|
||||
gGroupSiteVos = gGroupSiteVos
|
||||
.stream()
|
||||
.filter(gGroupSiteVo -> adcodeList.contains(Long.valueOf(gGroupSiteVo.getAreaCode()))).collect(Collectors.toList());
|
||||
}
|
||||
return gGroupSiteVos;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -151,9 +151,9 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
JSONArray jsonArray = JSONUtil.parseArray(coordinates);
|
||||
//判断数组每个元素必须为经度或纬度
|
||||
for (Object o : jsonArray) {
|
||||
/* if(isLongitudeOrLatitude(o.toString())){
|
||||
if(!isLongitudeOrLatitude(o.toString())){
|
||||
throw new ServiceException("coordinates数组元素必须为经度或纬度!");
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
int startIndex = space.indexOf("/profile/upload/");
|
||||
@ -169,8 +169,8 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
* @param str 经纬度字符串
|
||||
* @return true 或 false
|
||||
*/
|
||||
private boolean isLongitudeOrLatitude(String str) {
|
||||
String regex = "^[-+]?\\d{1,3}(\\.\\d+)?$"; // 修改了正则表达式的格式,允许有或无小数部分
|
||||
private static boolean isLongitudeOrLatitude(String str) {
|
||||
String regex = "^[-+]?\\d{1,3}(\\.\\d+)?$"; // 正则表达式,匹配经度或纬度格式
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
|
||||
@ -178,10 +178,19 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
return matcher.matches() && isValueInRange(str);
|
||||
}
|
||||
|
||||
private boolean isValueInRange(String str) {
|
||||
double value = Double.parseDouble(str);
|
||||
return value >= -180 && value <= 180; // 经度范围
|
||||
// 如果需要判断纬度,则再添加一行判断逻辑:else if (value >= -90 && value <= 90) return true; 或者根据需要合并到一行判断中。
|
||||
/**
|
||||
* 判断值是否在经纬度范围内
|
||||
* @param str 经纬度字符串表示的值
|
||||
* @return true 如果值在范围内,false 否则
|
||||
*/
|
||||
private static boolean isValueInRange(String str) {
|
||||
try {
|
||||
double value = Double.parseDouble(str);
|
||||
return value >= -180 && value <= 180; // 经度范围
|
||||
} catch (NumberFormatException e) {
|
||||
// 字符串无法转换为数字,认为不在范围内
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user