新增图例接口添加查重逻辑,添加站点接口修改json文件校验逻辑等,其他修改等
This commit is contained in:
@ -22,7 +22,6 @@ import java.util.Map;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "GGroups",description = "组 g_groups")
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class GGroups extends BaseEntity
|
||||
@ -73,19 +72,19 @@ private static final long serialVersionUID = 1L;
|
||||
/** 显示顺序 */
|
||||
private Integer orderNum;
|
||||
|
||||
/** 祖级列表 */
|
||||
private String ancestors;
|
||||
|
||||
|
||||
/** 子组 */
|
||||
private List<GGroups> children = new ArrayList<>();
|
||||
|
||||
|
||||
private List<GGroupSiteVo>childrenSite = new ArrayList<>();
|
||||
|
||||
/**节点类型:0组,1站点 */
|
||||
private Integer nodeType= 0;
|
||||
|
||||
/**节点类型为1时使用 站点id */
|
||||
private Long siteId;
|
||||
|
||||
/**站点类型 */
|
||||
private String siteType;
|
||||
|
||||
}
|
@ -16,7 +16,6 @@ import lombok.experimental.SuperBuilder;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "GLegend",description = "图例 g_legend")
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class GLegend extends BaseEntity
|
||||
@ -31,14 +30,10 @@ public class GLegend extends BaseEntity
|
||||
@ApiModelProperty("图标")
|
||||
private String icon;
|
||||
|
||||
/** 类型 */
|
||||
@Excel(name = "类型")
|
||||
@ApiModelProperty("类型")
|
||||
private Long type;
|
||||
|
||||
/** 图标名称 */
|
||||
@Excel(name = "图标名称")
|
||||
@ApiModelProperty("图标名称")
|
||||
/** 图例名称 */
|
||||
@Excel(name = "图例名称")
|
||||
@ApiModelProperty("图例名称")
|
||||
private String name;
|
||||
|
||||
/** 项目id */
|
||||
@ -46,4 +41,10 @@ public class GLegend extends BaseEntity
|
||||
@ApiModelProperty("项目id")
|
||||
private Long projectId;
|
||||
|
||||
/** 类别 */
|
||||
private String category;
|
||||
|
||||
/**图例描述 */
|
||||
private String description;
|
||||
|
||||
}
|
||||
|
@ -1,46 +0,0 @@
|
||||
package com.fastbee.ggroup.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.fastbee.common.annotation.Excel;
|
||||
import com.fastbee.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 图例类型对象 g_legend_type
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-10-09
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "GLegendType",description = "图例类型 g_legend_type")
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class GLegendType extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键id */
|
||||
private Long id;
|
||||
|
||||
/** 图例类型名称 */
|
||||
@Excel(name = "图例类型名称")
|
||||
@ApiModelProperty("图例类型名称")
|
||||
private String typeName;
|
||||
|
||||
/** 图例类型描述 */
|
||||
@Excel(name = "图例类型描述")
|
||||
@ApiModelProperty("图例类型描述")
|
||||
private String description;
|
||||
|
||||
/** 类别 */
|
||||
@Excel(name = "类别")
|
||||
@ApiModelProperty("类别")
|
||||
private String category;
|
||||
|
||||
}
|
@ -20,7 +20,6 @@ import com.fastbee.common.core.domain.BaseEntity;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "GSiteGroups",description = "站点组关系 g_site_groups")
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class GSiteGroups extends BaseEntity
|
||||
|
@ -19,7 +19,6 @@ import com.fastbee.common.core.domain.BaseEntity;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "GSiteInfo",description = "站点基础信息 g_site_info")
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class GSiteInfo extends BaseEntity
|
||||
|
@ -20,7 +20,6 @@ import java.util.Map;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "GSites",description = "站点 g_sites")
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class GSites extends BaseEntity
|
||||
|
@ -14,5 +14,6 @@ public class GGroupSiteVo {
|
||||
private String space; // 对应 gs.space
|
||||
private String spaceValue; // 对应 gs.space
|
||||
|
||||
|
||||
// Getter 和 Setter
|
||||
}
|
||||
|
@ -1,62 +0,0 @@
|
||||
package com.fastbee.ggroup.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.fastbee.ggroup.domain.GLegendType;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
|
||||
/**
|
||||
* 图例类型Mapper接口
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-10-09
|
||||
*/
|
||||
public interface GLegendTypeMapper extends MPJBaseMapper<GLegendType>
|
||||
{
|
||||
/**
|
||||
* 查询图例类型
|
||||
*
|
||||
* @param id 图例类型主键
|
||||
* @return 图例类型
|
||||
*/
|
||||
public GLegendType selectGLegendTypeById(Long id);
|
||||
|
||||
/**
|
||||
* 查询图例类型列表
|
||||
*
|
||||
* @param gLegendType 图例类型
|
||||
* @return 图例类型集合
|
||||
*/
|
||||
public List<GLegendType> selectGLegendTypeList(GLegendType gLegendType);
|
||||
|
||||
/**
|
||||
* 新增图例类型
|
||||
*
|
||||
* @param gLegendType 图例类型
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertGLegendType(GLegendType gLegendType);
|
||||
|
||||
/**
|
||||
* 修改图例类型
|
||||
*
|
||||
* @param gLegendType 图例类型
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateGLegendType(GLegendType gLegendType);
|
||||
|
||||
/**
|
||||
* 删除图例类型
|
||||
*
|
||||
* @param id 图例类型主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGLegendTypeById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除图例类型
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGLegendTypeByIds(Long[] ids);
|
||||
}
|
@ -20,7 +20,7 @@ public interface IGLegendService
|
||||
* @param id 图例主键
|
||||
* @return 图例
|
||||
*/
|
||||
public GLegendDto selectGLegendById(Long id);
|
||||
public GLegend selectGLegendById(Long id);
|
||||
|
||||
/**
|
||||
* 查询/搜索图例列表
|
||||
@ -28,7 +28,7 @@ public interface IGLegendService
|
||||
* @param gLegend 图例
|
||||
* @return 图例集合
|
||||
*/
|
||||
public List<GLegendDto> selectGLegendList(GLegend gLegend);
|
||||
public List<GLegend> selectGLegendList(GLegend gLegend);
|
||||
|
||||
/**
|
||||
* 新增图例
|
||||
@ -44,7 +44,7 @@ public interface IGLegendService
|
||||
* @param gLegend 图例
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateGLegend(GLegendUpdateDto gLegend);
|
||||
public int updateGLegend(GLegend gLegend);
|
||||
|
||||
/**
|
||||
* 批量删除图例
|
||||
|
@ -1,65 +0,0 @@
|
||||
package com.fastbee.ggroup.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fastbee.ggroup.domain.GLegendType;
|
||||
|
||||
/**
|
||||
* 图例类型Service接口
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-10-09
|
||||
*/
|
||||
public interface IGLegendTypeService
|
||||
{
|
||||
/**
|
||||
* 查询图例类型
|
||||
*
|
||||
* @param id 图例类型主键
|
||||
* @return 图例类型
|
||||
*/
|
||||
public GLegendType selectGLegendTypeById(Long id);
|
||||
|
||||
/**
|
||||
* 查询图例类型列表
|
||||
*
|
||||
* @param gLegendType 图例类型
|
||||
* @return 图例类型集合
|
||||
*/
|
||||
public List<GLegendType> selectGLegendTypeList(GLegendType gLegendType);
|
||||
|
||||
/**
|
||||
* 新增图例类型
|
||||
*
|
||||
* @param gLegendType 图例类型
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertGLegendType(GLegendType gLegendType);
|
||||
|
||||
/**
|
||||
* 修改图例类型
|
||||
*
|
||||
* @param gLegendType 图例类型
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateGLegendType(GLegendType gLegendType);
|
||||
|
||||
/**
|
||||
* 批量删除图例类型
|
||||
*
|
||||
* @param ids 需要删除的图例类型主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGLegendTypeByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除图例类型信息
|
||||
*
|
||||
* @param id 图例类型主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGLegendTypeById(Long id);
|
||||
|
||||
|
||||
}
|
@ -2,7 +2,9 @@ package com.fastbee.ggroup.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.extra.ssh.JschUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.ggroup.domain.GGroups;
|
||||
import com.fastbee.ggroup.domain.GSiteGroups;
|
||||
@ -19,11 +21,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
@ -38,11 +36,6 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
@Autowired
|
||||
private GGroupsMapper gGroupsMapper;
|
||||
|
||||
@Autowired
|
||||
private GSitesMapper gSitesMapper;
|
||||
|
||||
@Autowired
|
||||
private GSiteGroupsMapper gSiteGroupsMapper;
|
||||
|
||||
/**
|
||||
* 查询组
|
||||
@ -116,21 +109,22 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
for (GGroups group : groupsList) {
|
||||
//查询组的直接子站点列表
|
||||
//TODO 优化为查询出所有站点列表,内存中处理
|
||||
List<GGroupSiteVo> gGroupSiteVoList = gGroupsMapper.selectGGroupsSiteList(GGroups.builder()
|
||||
.parentId(group.getId())
|
||||
.build());
|
||||
GGroups gGroups = new GGroups();
|
||||
gGroups.setParentId(group.getId());
|
||||
List<GGroupSiteVo> gGroupSiteVoList = gGroupsMapper.selectGGroupsSiteList(gGroups);
|
||||
//将子站点列表添加到组对象中
|
||||
List<GGroups> childrenList= group.getChildren();
|
||||
gGroupSiteVoList.forEach(site->{
|
||||
childrenList.add(GGroups.builder()
|
||||
.id(site.getId())
|
||||
.name(site.getName())
|
||||
.icon(site.getIcon())
|
||||
.space(site.getSpace())
|
||||
.spaceValue(site.getSpaceValue())
|
||||
.nodeType(1)
|
||||
.siteId(site.getId())
|
||||
.build());
|
||||
GGroups gGroups1 = new GGroups();
|
||||
gGroups1.setId(site.getId());
|
||||
gGroups1.setName(site.getName());
|
||||
gGroups1.setSiteType(site.getType());
|
||||
gGroups1.setIcon(site.getIcon());
|
||||
gGroups1.setSpace(site.getSpace());
|
||||
gGroups1.setSpaceValue(site.getSpaceValue());
|
||||
gGroups1.setNodeType(1);
|
||||
gGroups1.setSiteId(site.getId());
|
||||
childrenList.add(gGroups1);
|
||||
});
|
||||
map.put(group.getId(), group);
|
||||
}
|
||||
@ -146,7 +140,15 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
*/
|
||||
@Override
|
||||
public int insertGGroups(GGroups gGroups)
|
||||
{ //TODO 同一个父节点下组名不能重复
|
||||
{ //同一个父节点下组名不能重复
|
||||
GGroups duplicateName=gGroupsMapper.selectOne(new LambdaQueryWrapper<GGroups>()
|
||||
.select(GGroups::getId)
|
||||
.eq(GGroups::getName, gGroups.getName().trim())
|
||||
.eq(GGroups::getParentId, gGroups.getParentId())
|
||||
);
|
||||
if(Objects.nonNull(duplicateName)){
|
||||
throw new ServiceException("组名已存在!");
|
||||
}
|
||||
gGroups.setCreateTime(DateUtils.getNowDate());
|
||||
return gGroupsMapper.insertGGroups(gGroups);
|
||||
}
|
||||
@ -160,6 +162,15 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
@Override
|
||||
public int updateGGroups(GGroups gGroups)
|
||||
{
|
||||
//同一个父节点下组名不能重复
|
||||
GGroups duplicateName=gGroupsMapper.selectOne(new LambdaQueryWrapper<GGroups>()
|
||||
.select(GGroups::getId)
|
||||
.eq(GGroups::getName, gGroups.getName().trim())
|
||||
.eq(GGroups::getParentId, gGroups.getParentId())
|
||||
.ne(GGroups::getId, gGroups.getId()));
|
||||
if(Objects.nonNull(duplicateName)){
|
||||
throw new ServiceException("组名已存在!");
|
||||
}
|
||||
gGroups.setUpdateTime(DateUtils.getNowDate());
|
||||
return gGroupsMapper.updateGGroups(gGroups);
|
||||
}
|
||||
|
@ -5,13 +5,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.ggroup.domain.GLegendType;
|
||||
import com.fastbee.ggroup.domain.dto.GLegendUpdateDto;
|
||||
import com.fastbee.ggroup.domain.dto.GLegendCateGoryDto;
|
||||
import com.fastbee.ggroup.domain.dto.GLegendDto;
|
||||
import com.fastbee.ggroup.mapper.GLegendTypeMapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -19,7 +16,6 @@ import org.springframework.stereotype.Service;
|
||||
import com.fastbee.ggroup.mapper.GLegendMapper;
|
||||
import com.fastbee.ggroup.domain.GLegend;
|
||||
import com.fastbee.ggroup.service.IGLegendService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 图例Service业务层处理
|
||||
@ -34,8 +30,6 @@ public class GLegendServiceImpl implements IGLegendService
|
||||
@Autowired
|
||||
private GLegendMapper gLegendMapper;
|
||||
|
||||
@Autowired
|
||||
private GLegendTypeMapper gLegendTypeMapper;
|
||||
|
||||
/**
|
||||
* 查询图例
|
||||
@ -44,12 +38,10 @@ public class GLegendServiceImpl implements IGLegendService
|
||||
* @return 图例
|
||||
*/
|
||||
@Override
|
||||
public GLegendDto selectGLegendById(Long id)
|
||||
public GLegend selectGLegendById(Long id)
|
||||
{
|
||||
return gLegendMapper.selectJoinOne(GLegendDto.class,new MPJLambdaWrapper<GLegend>()
|
||||
.select(GLegend::getId,GLegend::getIcon,GLegend::getType,GLegend::getName)
|
||||
.select(GLegendType::getTypeName,GLegendType::getCategory)
|
||||
.leftJoin(GLegendType.class,GLegendType::getId,GLegend::getType)
|
||||
return gLegendMapper.selectOne(new LambdaQueryWrapper<GLegend>()
|
||||
.select(GLegend::getId,GLegend::getIcon,GLegend::getName,GLegend::getCategory)
|
||||
.eq(GLegend::getId,id));
|
||||
}
|
||||
|
||||
@ -59,14 +51,11 @@ public class GLegendServiceImpl implements IGLegendService
|
||||
* @return 图例
|
||||
*/
|
||||
@Override
|
||||
public List<GLegendDto> selectGLegendList(GLegend gLegend) {
|
||||
return gLegendMapper.selectJoinList(GLegendDto.class, new MPJLambdaWrapper<GLegend>()
|
||||
.select(GLegend::getId, GLegend::getIcon, GLegend::getType, GLegend::getName)
|
||||
.select(GLegendType::getTypeName, GLegendType::getCategory)
|
||||
.leftJoin(GLegendType.class, GLegendType::getId, GLegend::getType)
|
||||
.like(StringUtils.isNotBlank(gLegend.getSearchValue()),
|
||||
GLegend::getName, StringUtils.isNotBlank(gLegend.getSearchValue()) ?
|
||||
gLegend.getSearchValue() : null));
|
||||
public List<GLegend> selectGLegendList(GLegend gLegend) {
|
||||
return new LambdaQueryChainWrapper<>(gLegendMapper)
|
||||
.select(GLegend::getId,GLegend::getIcon,GLegend::getName,GLegend::getCategory)
|
||||
.like(StringUtils.isNotBlank(gLegend.getSearchValue()), GLegend::getName, gLegend.getSearchValue())
|
||||
.list();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,6 +67,12 @@ public class GLegendServiceImpl implements IGLegendService
|
||||
@Override
|
||||
public int insertGLegend(GLegend gLegend)
|
||||
{
|
||||
//图例名称不能重复
|
||||
if(!new LambdaQueryChainWrapper<>(gLegendMapper)
|
||||
.select(GLegend::getId,GLegend::getName)
|
||||
.eq(GLegend::getName,gLegend.getName().trim()).list().isEmpty()){
|
||||
throw new ServiceException("图例名称已存在!");
|
||||
}
|
||||
return gLegendMapper.insertGLegend(gLegend);
|
||||
}
|
||||
|
||||
@ -88,21 +83,16 @@ public class GLegendServiceImpl implements IGLegendService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateGLegend(GLegendUpdateDto gLegend)
|
||||
public int updateGLegend(GLegend gLegend)
|
||||
{
|
||||
return (gLegendTypeMapper.updateGLegendType(GLegendType.builder()
|
||||
.id( gLegend.getType())
|
||||
.category(gLegend.getCategory())
|
||||
.updateTime(DateUtils.getNowDate())
|
||||
.build())==1&&
|
||||
gLegendMapper.updateGLegend( GLegend.builder()
|
||||
.id(gLegend.getId())
|
||||
.icon(gLegend.getIcon())
|
||||
.name(gLegend.getName())
|
||||
.type(gLegend.getType())
|
||||
.updateTime(DateUtils.getNowDate())
|
||||
.build())==1)?1:0;
|
||||
//图例名称不能重复
|
||||
if(!new LambdaQueryChainWrapper<>(gLegendMapper)
|
||||
.select(GLegend::getId,GLegend::getName)
|
||||
.eq(GLegend::getName,gLegend.getName().trim()).ne(GLegend::getId,gLegend.getId()).list().isEmpty()){
|
||||
throw new ServiceException("图例名称已存在!");
|
||||
}
|
||||
gLegend.setUpdateTime(DateUtils.getNowDate());
|
||||
return gLegendMapper.updateGLegend(gLegend);
|
||||
}
|
||||
/**
|
||||
* 批量删除图例
|
||||
@ -134,21 +124,17 @@ public class GLegendServiceImpl implements IGLegendService
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> getLegendListByCategory() {
|
||||
// 按照类别分组,并生成结果列表
|
||||
return gLegendMapper.selectJoinList(GLegendCateGoryDto.class, new MPJLambdaWrapper<GLegend>()
|
||||
.select(GLegend::getIcon, GLegend::getName)
|
||||
.select(GLegendType::getTypeName, GLegendType::getCategory)
|
||||
.leftJoin(GLegendType.class, GLegendType::getId, GLegend::getType)).stream()
|
||||
.collect(Collectors.groupingBy(GLegendCateGoryDto::getCategory))
|
||||
return new LambdaQueryChainWrapper<>(gLegendMapper)
|
||||
.select(GLegend::getId,GLegend::getIcon, GLegend::getName,GLegend::getCategory)
|
||||
.list().stream()
|
||||
.collect(Collectors.groupingBy(GLegend::getCategory))
|
||||
.entrySet().stream()
|
||||
.map(entry -> {
|
||||
Map<String, Object> itemMap = new HashMap<>();
|
||||
itemMap.put("category", entry.getKey());
|
||||
itemMap.put("list", entry.getValue());
|
||||
return itemMap;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
Map<String, Object> itemMap = new HashMap<>();
|
||||
itemMap.put("category", entry.getKey());
|
||||
itemMap.put("list", entry.getValue());
|
||||
return itemMap;
|
||||
}
|
||||
).collect((Collectors.toList()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,103 +0,0 @@
|
||||
package com.fastbee.ggroup.service.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.ggroup.enums.SiteTypeCategoryEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fastbee.ggroup.mapper.GLegendTypeMapper;
|
||||
import com.fastbee.ggroup.domain.GLegendType;
|
||||
import com.fastbee.ggroup.service.IGLegendTypeService;
|
||||
|
||||
/**
|
||||
* 图例类型Service业务层处理
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-10-09
|
||||
*/
|
||||
@Service
|
||||
public class GLegendTypeServiceImpl implements IGLegendTypeService
|
||||
{
|
||||
@Autowired
|
||||
private GLegendTypeMapper gLegendTypeMapper;
|
||||
|
||||
/**
|
||||
* 查询图例类型
|
||||
*
|
||||
* @param id 图例类型主键
|
||||
* @return 图例类型
|
||||
*/
|
||||
@Override
|
||||
public GLegendType selectGLegendTypeById(Long id)
|
||||
{
|
||||
return gLegendTypeMapper.selectGLegendTypeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询图例类型列表
|
||||
*
|
||||
* @param gLegendType 图例类型
|
||||
* @return 图例类型
|
||||
*/
|
||||
@Override
|
||||
public List<GLegendType> selectGLegendTypeList(GLegendType gLegendType)
|
||||
{
|
||||
return gLegendTypeMapper.selectGLegendTypeList(gLegendType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增图例类型
|
||||
*
|
||||
* @param gLegendType 图例类型
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertGLegendType(GLegendType gLegendType)
|
||||
{
|
||||
gLegendType.setCreateTime(DateUtils.getNowDate());
|
||||
return gLegendTypeMapper.insertGLegendType(gLegendType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改图例类型
|
||||
*
|
||||
* @param gLegendType 图例类型
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateGLegendType(GLegendType gLegendType)
|
||||
{
|
||||
gLegendType.setUpdateTime(DateUtils.getNowDate());
|
||||
return gLegendTypeMapper.updateGLegendType(gLegendType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除图例类型
|
||||
*
|
||||
* @param ids 需要删除的图例类型主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteGLegendTypeByIds(Long[] ids)
|
||||
{
|
||||
return gLegendTypeMapper.deleteGLegendTypeByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除图例类型信息
|
||||
*
|
||||
* @param id 图例类型主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteGLegendTypeById(Long id)
|
||||
{
|
||||
return gLegendTypeMapper.deleteGLegendTypeById(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -26,8 +26,6 @@ public class GSiteInfoServiceImpl implements IGSiteInfoService
|
||||
@Autowired
|
||||
private GSiteInfoMapper gSiteInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private GSitesMapper gSitesMapper;
|
||||
|
||||
/**
|
||||
* 查询站点基础信息
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.fastbee.ggroup.service.impl;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
@ -8,10 +9,12 @@ import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONException;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fastbee.common.config.RuoYiConfig;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.ggroup.domain.GSiteGroups;
|
||||
import com.fastbee.ggroup.domain.dto.GGroupSiteDto;
|
||||
@ -95,12 +98,13 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
}
|
||||
//设置坐标值等信息
|
||||
getReadJsonFileContent(gSites);
|
||||
//插入站点表
|
||||
// 插入站点表
|
||||
int inserted = gSitesMapper.insert(gSites);
|
||||
gGroupSiteDto.setSiteId(gSites.getId());
|
||||
//插入关系表
|
||||
int inserted1 = gSiteGroupsMapper.insertGSiteGroups(gGroupSiteDto);
|
||||
return inserted == 1 && inserted1 == 1 ? 1 : 0;
|
||||
// return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,18 +113,30 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
*/
|
||||
private void getReadJsonFileContent(GSites gSites) {
|
||||
String json;
|
||||
try {
|
||||
//TODO 路径优化
|
||||
InputStream i = Files.newInputStream(new File("C:\\home\\soft\\hzwmiot\\uploadPath" + gSites.getSpace().substring(8)).toPath());
|
||||
json = IOUtils.toString(i, StandardCharsets.UTF_8);
|
||||
//校验json格式是否正确
|
||||
if (!isValidJson(json)) {
|
||||
throw new ServiceException("json格式不正确!");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
//TODO 路径优化
|
||||
//发起http请求获取json数据
|
||||
String space = gSites.getSpace();
|
||||
if(Objects.isNull(space)){
|
||||
throw new ServiceException("请上传站点地图json数据!");
|
||||
}
|
||||
gSites.setSpaceValue(json);
|
||||
String jsonData = HttpUtil.get(space);
|
||||
System.err.println("获取到json:"+jsonData);
|
||||
|
||||
//读取文件内容
|
||||
if (Objects.isNull(jsonData)) {
|
||||
throw new ServiceException("上传站点地图json数据为空!");
|
||||
}
|
||||
//校验json格式是否正确
|
||||
if (!isValidJson(jsonData)) {
|
||||
throw new ServiceException("json格式不正确!");
|
||||
}
|
||||
int startIndex = space.indexOf("/profile/upload/");
|
||||
// System.err.println("路径匹配截取开始下标:"+startIndex);
|
||||
String relativeUrl = space.substring(startIndex);
|
||||
// System.err.println("相对路径:"+relativeUrl);
|
||||
gSites.setSpace(relativeUrl);
|
||||
gSites.setSpaceValue(jsonData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -191,7 +207,11 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
public int relateGroup(GGroupSiteRelateDto gGroupSiteRelateDto) {
|
||||
return super.saveBatch(gGroupSiteRelateDto.getSiteIds()
|
||||
.stream()
|
||||
.map(siteId -> GSiteGroups.builder().siteId(siteId).build())
|
||||
.map(siteId -> {
|
||||
GSiteGroups gSiteGroups = new GSiteGroups();
|
||||
gSiteGroups.setSiteId(siteId);
|
||||
return gSiteGroups;
|
||||
})
|
||||
.collect(Collectors.toList())
|
||||
.stream()
|
||||
.peek(item -> {
|
||||
|
Reference in New Issue
Block a user