查询站点和组树状列表接口按行政区过滤逻辑,行政区接口逻辑完善等
This commit is contained in:
@ -63,6 +63,8 @@ private static final long serialVersionUID = 1L;
|
||||
|
||||
private String spaceValue;
|
||||
|
||||
//------------------------------------------------拓展业务字段--------------------------------------------
|
||||
|
||||
/** 父菜单名称 */
|
||||
private String parentName;
|
||||
|
||||
@ -84,5 +86,8 @@ private static final long serialVersionUID = 1L;
|
||||
/**站点类型 */
|
||||
private String siteType;
|
||||
|
||||
/**站点名称行政区划代码 */
|
||||
private List<String> areaCodeList;
|
||||
|
||||
|
||||
}
|
@ -15,7 +15,7 @@ import java.util.Map;
|
||||
* 站点对象 g_sites
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-09-29
|
||||
* @date 2024-09-29
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "GSites", description = "站点 g_sites")
|
||||
@ -71,4 +71,14 @@ public class GSites extends BaseEntity {
|
||||
|
||||
/** 类型id(即图例id) */
|
||||
private Long typeId;
|
||||
|
||||
/** 行政区划代码 */
|
||||
@Excel(name = "行政区划代码")
|
||||
@ApiModelProperty("行政区划代码")
|
||||
private String areaCode;
|
||||
|
||||
/** 完整行政区划代码一般为[县code,镇code,村code] */
|
||||
@Excel(name = "完整行政区划代码一般为[县code,镇code,村code]")
|
||||
@ApiModelProperty("完整行政区划代码一般为[县code,镇code,村code]")
|
||||
private String fullAreaCode;
|
||||
}
|
@ -13,5 +13,7 @@ public class GGroupSiteDto {
|
||||
private String space; // 站点空间
|
||||
private Integer orderNum;// 排序
|
||||
private Long projectId;//项目id
|
||||
private String areaCode;//区域编码
|
||||
private String fullAreaCode;//完整区域编码
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ public class GGroupSiteVo {
|
||||
private String type; // 对应 gs.type
|
||||
private String space; // 对应 gs.space
|
||||
private String spaceValue; // 对应 gs.space
|
||||
private String areaCode;// 对应 gs.area_code
|
||||
|
||||
|
||||
// Getter 和 Setter
|
||||
|
@ -125,15 +125,24 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
/**
|
||||
* 构建组和站点树状列表
|
||||
*/
|
||||
private List<GGroups> buildTreeSite(List<GGroups> groupsList) {
|
||||
private List<GGroups> buildTreeSite(List<GGroups> groupsList,List<String> areaCodeList) {
|
||||
// 构建一个Map,用于存储每个组对象:id->组对象
|
||||
Map<Long, GGroups> map = new HashMap<>();
|
||||
//根组列表
|
||||
List<GGroups> roots = new ArrayList<>();
|
||||
//所有站点列表
|
||||
List<GGroupSiteVo> gGroupSiteAllList = selectGGroupsAllListSites(new GGroups());
|
||||
// System.err.println("当前项目下所有站点:");
|
||||
// gGroupSiteAllList.forEach(System.err::println);
|
||||
//根据区域代码过滤站点
|
||||
if(Objects.nonNull(areaCodeList) && !areaCodeList.isEmpty()){
|
||||
System.err.println("开始过滤站点");
|
||||
System.err.println(areaCodeList);
|
||||
System.err.println("过滤前站点");
|
||||
System.err.println(gGroupSiteAllList);
|
||||
gGroupSiteAllList = gGroupSiteAllList.stream()
|
||||
.filter(site -> areaCodeList.contains(site.getAreaCode())).collect(Collectors.toList());
|
||||
System.err.println("过滤后的站点");
|
||||
System.err.println(gGroupSiteAllList);
|
||||
}
|
||||
|
||||
for (GGroups group : groupsList) {
|
||||
//查询组的直接子站点列表
|
||||
@ -166,7 +175,7 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
public List<GGroupSiteVo> selectGGroupsAllListSites(GGroups gGroups) {
|
||||
MPJLambdaWrapper<GSiteGroups> gSiteGroupsMPJLambdaWrapper = new MPJLambdaWrapper<GSiteGroups>()
|
||||
.select(GSiteGroups::getId, GSiteGroups::getParentId, GSiteGroups::getSiteId)
|
||||
.select(GSites::getName, GSites::getIcon, GSites::getType, GSites::getSpace, GSites::getSpaceValue)
|
||||
.select(GSites::getName, GSites::getIcon, GSites::getType, GSites::getSpace, GSites::getSpaceValue,GSites::getAreaCode)
|
||||
.leftJoin(GGroups.class, GGroups::getId, GSiteGroups::getParentId)
|
||||
.leftJoin(GSites.class, GSites::getId, GSiteGroups::getSiteId)
|
||||
.in(!ProjectHolder.getProjectInfo().getProjectIdList().isEmpty(),GGroups::getProjectId,ProjectHolder.getProjectInfo().getProjectIdList());
|
||||
@ -198,7 +207,6 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
|
||||
/**
|
||||
* 修改组
|
||||
*
|
||||
* @param gGroups 组
|
||||
* @return 结果
|
||||
*/
|
||||
@ -223,7 +231,6 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
|
||||
/**
|
||||
* 删除组信息
|
||||
*
|
||||
* @param id 组主键
|
||||
* @return 结果
|
||||
*/
|
||||
@ -241,14 +248,18 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
*/
|
||||
@Override
|
||||
public List<?> selectGGroupsAndSitesList(GGroups gGroups) {
|
||||
//查询项目下的全部站点
|
||||
List<GGroups> groupSiteTreeList = new LambdaQueryChainWrapper<>(gGroupsMapper)
|
||||
.select(GGroups::getId, GGroups::getName, GGroups::getParentId, GGroups::getIcon,GGroups::getTag,
|
||||
GGroups::getSpace, GGroups::getSpaceValue, GGroups::getProjectId)
|
||||
//根据站点标签过滤
|
||||
.eq(Objects.nonNull(gGroups.getTag()), GGroups::getTag, gGroups.getTag())
|
||||
.in(!ProjectHolder.getProjectInfo().getProjectIdList().isEmpty(),GGroups::getProjectId,
|
||||
ProjectHolder.getProjectInfo().getProjectIdList())
|
||||
.list();
|
||||
List<GGroups> gGroupsList = buildTreeSite(groupSiteTreeList);
|
||||
|
||||
//构建组和站点树状列表
|
||||
List<GGroups> gGroupsList = buildTreeSite(groupSiteTreeList,gGroups.getAreaCodeList());
|
||||
//组的树状结构外层数组元素套一层数组:方便前端数据渲染
|
||||
return gGroupsList.stream().map(gGroups1 -> {
|
||||
List<GGroups> list1 = new ArrayList<>();
|
||||
|
@ -83,12 +83,23 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
if (Objects.nonNull(sameNameSite)) {
|
||||
throw new ServiceException("站点名称重复!");
|
||||
}
|
||||
//是否选择行政区域
|
||||
if (StringUtils.isBlank(gGroupSiteDto.getAreaCode())) {
|
||||
throw new ServiceException("请选择行政区域!");
|
||||
}
|
||||
if(StringUtils.isBlank(gGroupSiteDto.getFullAreaCode())){
|
||||
throw new ServiceException("请提交行政区域完整编码!");
|
||||
}
|
||||
//未上传站点地图json数据
|
||||
if(StringUtils.isBlank(gGroupSiteDto.getIcon())){
|
||||
throw new ServiceException("请选择站点图标!");
|
||||
}
|
||||
//设置坐标值等信息
|
||||
getReadJsonFileContent(gSites);
|
||||
//设置行政区域编码
|
||||
gSites.setAreaCode(gGroupSiteDto.getAreaCode());
|
||||
//设置行政区域完整编码
|
||||
gSites.setFullAreaCode(gGroupSiteDto.getFullAreaCode());
|
||||
//插入站点表
|
||||
int inserted = gSitesMapper.insert(gSites);
|
||||
gGroupSiteDto.setSiteId(gSites.getId());
|
||||
@ -163,6 +174,7 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
if (Objects.nonNull(sameNameSite)) {
|
||||
throw new ServiceException("站点名称重复!");
|
||||
}
|
||||
|
||||
GSites sites = new GSites();
|
||||
BeanUtils.copyProperties(gSitesEditDto, sites);
|
||||
//读取文件内容
|
||||
|
Reference in New Issue
Block a user