检测站点基本接口
This commit is contained in:
@ -68,11 +68,11 @@ public class GSiteInfoController extends BaseController
|
||||
* 获取站点基础信息详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ggroup:info:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
@GetMapping(value = "/{siteId}")
|
||||
@ApiOperation("获取站点基础信息详细信息")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
public AjaxResult getInfo(@PathVariable("siteId") Long siteId)
|
||||
{
|
||||
return success(gSiteInfoService.selectGSiteInfoById(id));
|
||||
return AjaxResult.success(gSiteInfoService.selectGSiteInfoById(siteId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,7 +146,7 @@ public class GGroupsServiceImpl implements IGGroupsService
|
||||
*/
|
||||
@Override
|
||||
public int insertGGroups(GGroups gGroups)
|
||||
{
|
||||
{ //TODO 同一个父节点下组名不能重复
|
||||
gGroups.setCreateTime(DateUtils.getNowDate());
|
||||
return gGroupsMapper.insertGGroups(gGroups);
|
||||
}
|
||||
|
@ -1,7 +1,13 @@
|
||||
package com.fastbee.ggroup.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.common.utils.ValidationUtils;
|
||||
import com.fastbee.ggroup.domain.GSites;
|
||||
import com.fastbee.ggroup.mapper.GSitesMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fastbee.ggroup.mapper.GSiteInfoMapper;
|
||||
@ -20,6 +26,9 @@ public class GSiteInfoServiceImpl implements IGSiteInfoService
|
||||
@Autowired
|
||||
private GSiteInfoMapper gSiteInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private GSitesMapper gSitesMapper;
|
||||
|
||||
/**
|
||||
* 查询站点基础信息
|
||||
*
|
||||
@ -66,6 +75,19 @@ public class GSiteInfoServiceImpl implements IGSiteInfoService
|
||||
@Override
|
||||
public int updateGSiteInfo(GSiteInfo gSiteInfo)
|
||||
{
|
||||
//参数校验
|
||||
if(Objects.isNull(gSiteInfo.getSiteId())){
|
||||
throw new ServiceException("站点ID(siteId)字段不能为空!");
|
||||
}
|
||||
if(!ValidationUtils.isMobile(gSiteInfo.getManagerPhone())){
|
||||
throw new ServiceException("站点管理员手机号(managerPhone)格式不正确!");
|
||||
}
|
||||
//检查是否有该条数据
|
||||
if(Objects.isNull(gSiteInfoMapper.selectGSiteInfoById(gSiteInfo.getSiteId()))){
|
||||
//没有该条数据,则新增
|
||||
gSiteInfo.setCreateTime(DateUtils.getNowDate());
|
||||
return insertGSiteInfo(gSiteInfo);
|
||||
}
|
||||
gSiteInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
return gSiteInfoMapper.updateGSiteInfo(gSiteInfo);
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ 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;
|
||||
@ -22,6 +21,7 @@ import com.fastbee.ggroup.domain.dto.GSitesSelectDto;
|
||||
import com.fastbee.ggroup.mapper.GSiteGroupsMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -89,6 +89,10 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
if (Objects.nonNull(sameNameSite)) {
|
||||
throw new ServiceException("站点名称重复!");
|
||||
}
|
||||
//未上传站点地图json数据
|
||||
if(StringUtils.isBlank(gGroupSiteDto.getIcon())){
|
||||
throw new ServiceException("请上传站点地图json数据!");
|
||||
}
|
||||
//设置坐标值等信息
|
||||
getReadJsonFileContent(gSites);
|
||||
//插入站点表
|
||||
@ -106,8 +110,8 @@ public class GSitesServiceImpl extends ServiceImpl<GSiteGroupsMapper,GSiteGroups
|
||||
private void getReadJsonFileContent(GSites gSites) {
|
||||
String json;
|
||||
try {
|
||||
//TODO: 文件路径拼接优化
|
||||
InputStream i = Files.newInputStream(new File(RuoYiConfig.getProfile() + gSites.getSpace().substring(15)).toPath());
|
||||
//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)) {
|
||||
|
@ -63,7 +63,7 @@
|
||||
|
||||
<select id="selectGSiteInfoById" parameterType="Long" resultMap="GSiteInfoResult">
|
||||
<include refid="selectGSiteInfoVo"/>
|
||||
where id = #{id}
|
||||
where site_id = #{siteId}
|
||||
</select>
|
||||
|
||||
<insert id="insertGSiteInfo" parameterType="GSiteInfo" useGeneratedKeys="true" keyProperty="id">
|
||||
|
Reference in New Issue
Block a user