|
@@ -9,6 +9,7 @@ import com.usky.sas.domain.SasMapDevice;
|
|
|
import com.usky.sas.domain.SasMaps;
|
|
import com.usky.sas.domain.SasMaps;
|
|
|
import com.usky.sas.domain.SasDevice;
|
|
import com.usky.sas.domain.SasDevice;
|
|
|
import com.usky.sas.domain.SasPic;
|
|
import com.usky.sas.domain.SasPic;
|
|
|
|
|
+import com.usky.sas.domain.SasPicSource;
|
|
|
import com.usky.sas.enums.SystemTypeCodeEnum;
|
|
import com.usky.sas.enums.SystemTypeCodeEnum;
|
|
|
import com.usky.sas.mapper.SasMapDeviceMapper;
|
|
import com.usky.sas.mapper.SasMapDeviceMapper;
|
|
|
import com.usky.sas.mapper.SasMapsMapper;
|
|
import com.usky.sas.mapper.SasMapsMapper;
|
|
@@ -16,6 +17,8 @@ import com.usky.sas.mapper.SasPicMapper;
|
|
|
import com.usky.sas.mapper.SasDeviceMapper;
|
|
import com.usky.sas.mapper.SasDeviceMapper;
|
|
|
import com.usky.sas.common.util.GetIpUtils;
|
|
import com.usky.sas.common.util.GetIpUtils;
|
|
|
import com.usky.sas.service.SasMapService;
|
|
import com.usky.sas.service.SasMapService;
|
|
|
|
|
+import com.usky.sas.service.SasPicService;
|
|
|
|
|
+import com.usky.sas.service.SasPicSourceService;
|
|
|
import com.usky.sas.service.vo.MapDeviceBindRequest;
|
|
import com.usky.sas.service.vo.MapDeviceBindRequest;
|
|
|
import com.usky.sas.service.vo.MapListItem;
|
|
import com.usky.sas.service.vo.MapListItem;
|
|
|
import com.usky.sas.service.vo.MapPageRequest;
|
|
import com.usky.sas.service.vo.MapPageRequest;
|
|
@@ -23,11 +26,17 @@ import com.usky.sas.service.vo.MapSaveRequest;
|
|
|
import com.usky.sas.service.vo.MapSaveWithDevicesRequest;
|
|
import com.usky.sas.service.vo.MapSaveWithDevicesRequest;
|
|
|
import com.usky.sas.service.vo.MapTreeItem;
|
|
import com.usky.sas.service.vo.MapTreeItem;
|
|
|
import com.usky.sas.service.vo.MapInfoVo;
|
|
import com.usky.sas.service.vo.MapInfoVo;
|
|
|
|
|
+import com.usky.sas.service.vo.PicAddRequest;
|
|
|
|
|
+import com.usky.sas.service.vo.PicSourceInfo;
|
|
|
|
|
+import com.usky.sas.service.vo.PicSourcePageRequest;
|
|
|
|
|
+import com.usky.sas.service.vo.PicSourceUpdateRequest;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import com.usky.common.core.exception.BusinessException;
|
|
|
|
|
+
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
@@ -52,6 +61,12 @@ public class SasMapServiceImpl extends AbstractCrudService<SasMapsMapper, SasMap
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private SasDeviceMapper sasDeviceMapper;
|
|
private SasDeviceMapper sasDeviceMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SasPicService sasPicService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SasPicSourceService sasPicSourceService;
|
|
|
|
|
+
|
|
|
@Value("${server.protocol:http}")
|
|
@Value("${server.protocol:http}")
|
|
|
private String protocol;
|
|
private String protocol;
|
|
|
|
|
|
|
@@ -62,9 +77,12 @@ public class SasMapServiceImpl extends AbstractCrudService<SasMapsMapper, SasMap
|
|
|
public CommonPage<MapListItem> page(MapPageRequest request) {
|
|
public CommonPage<MapListItem> page(MapPageRequest request) {
|
|
|
IPage<SasMaps> page = new Page<>(request.getCurrent(), request.getSize());
|
|
IPage<SasMaps> page = new Page<>(request.getCurrent(), request.getSize());
|
|
|
LambdaQueryWrapper<SasMaps> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<SasMaps> wrapper = new LambdaQueryWrapper<>();
|
|
|
- if (request.getParentId() != null) {
|
|
|
|
|
|
|
+ if (request.getParentId() != null && !request.getParentId().isEmpty()) {
|
|
|
wrapper.eq(SasMaps::getParentId, request.getParentId());
|
|
wrapper.eq(SasMaps::getParentId, request.getParentId());
|
|
|
}
|
|
}
|
|
|
|
|
+ if (request.getMapId() != null && !request.getMapId().isEmpty()) {
|
|
|
|
|
+ wrapper.eq(SasMaps::getId, request.getMapId());
|
|
|
|
|
+ }
|
|
|
wrapper.orderByDesc(SasMaps::getCreateTime);
|
|
wrapper.orderByDesc(SasMaps::getCreateTime);
|
|
|
page = this.page(page, wrapper);
|
|
page = this.page(page, wrapper);
|
|
|
|
|
|
|
@@ -96,16 +114,48 @@ public class SasMapServiceImpl extends AbstractCrudService<SasMapsMapper, SasMap
|
|
|
item.setBackImgId(map.getBackImgId());
|
|
item.setBackImgId(map.getBackImgId());
|
|
|
item.setCreateTime(map.getCreateTime());
|
|
item.setCreateTime(map.getCreateTime());
|
|
|
item.setUpdateTime(map.getUpdateTime());
|
|
item.setUpdateTime(map.getUpdateTime());
|
|
|
|
|
+ if (map.getBackImgId() != null && !map.getBackImgId().isEmpty()) {
|
|
|
|
|
+ SasPic backPic = sasPicMapper.selectById(map.getBackImgId());
|
|
|
|
|
+ if (backPic != null) {
|
|
|
|
|
+ String baseUrl = protocol + "://" + GetIpUtils.getServerIP() + ":" + port;
|
|
|
|
|
+ String path = (backPic.getUrl() != null ? backPic.getUrl() : "") + (backPic.getPath() != null ? backPic.getPath() : "");
|
|
|
|
|
+ item.setBackImgUrl(baseUrl + path);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
List<SasMapDevice> devices = deviceGroup.getOrDefault(map.getId(), Collections.emptyList());
|
|
List<SasMapDevice> devices = deviceGroup.getOrDefault(map.getId(), Collections.emptyList());
|
|
|
List<MapListItem.MapDeviceItem> deviceItems = devices.stream().map(d -> {
|
|
List<MapListItem.MapDeviceItem> deviceItems = devices.stream().map(d -> {
|
|
|
MapListItem.MapDeviceItem di = new MapListItem.MapDeviceItem();
|
|
MapListItem.MapDeviceItem di = new MapListItem.MapDeviceItem();
|
|
|
di.setId(d.getId());
|
|
di.setId(d.getId());
|
|
|
di.setDeviceId(d.getDeviceId());
|
|
di.setDeviceId(d.getDeviceId());
|
|
|
|
|
+ di.setMapId(d.getMapId());
|
|
|
|
|
+ di.setImgId(d.getImgId());
|
|
|
di.setDeviceName(d.getText());
|
|
di.setDeviceName(d.getText());
|
|
|
di.setType(d.getType());
|
|
di.setType(d.getType());
|
|
|
di.setX(d.getX() != null ? d.getX().doubleValue() : null);
|
|
di.setX(d.getX() != null ? d.getX().doubleValue() : null);
|
|
|
di.setY(d.getY() != null ? d.getY().doubleValue() : null);
|
|
di.setY(d.getY() != null ? d.getY().doubleValue() : null);
|
|
|
|
|
+ if (d.getImgId() != null && !d.getImgId().isEmpty()) {
|
|
|
|
|
+ SasPic imgPic = sasPicMapper.selectById(d.getImgId());
|
|
|
|
|
+ if (imgPic != null) {
|
|
|
|
|
+ String baseUrl = protocol + "://" + GetIpUtils.getServerIP() + ":" + port;
|
|
|
|
|
+ String path = (imgPic.getUrl() != null ? imgPic.getUrl() : "") + (imgPic.getPath() != null ? imgPic.getPath() : "");
|
|
|
|
|
+ di.setImgUrl(baseUrl + path);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ SasDevice device = sasDeviceMapper.selectById(d.getDeviceId());
|
|
|
|
|
+ if (device != null) {
|
|
|
|
|
+ MapListItem.DeviceInfoVo deviceInfo = new MapListItem.DeviceInfoVo();
|
|
|
|
|
+ deviceInfo.setId(device.getId());
|
|
|
|
|
+ deviceInfo.setDeviceId(device.getDeviceId());
|
|
|
|
|
+ deviceInfo.setChannel(device.getChannel());
|
|
|
|
|
+ deviceInfo.setIpAddr(device.getIpAddr());
|
|
|
|
|
+ deviceInfo.setPort(device.getPort());
|
|
|
|
|
+ deviceInfo.setAddress(device.getAddress());
|
|
|
|
|
+ deviceInfo.setNote(device.getNote());
|
|
|
|
|
+ SystemTypeCodeEnum typeEnum = SystemTypeCodeEnum.getByCode(device.getDeviceType());
|
|
|
|
|
+ deviceInfo.setDeviceType(typeEnum != null ? typeEnum.getMessage() : null);
|
|
|
|
|
+ di.setDeviceInfo(deviceInfo);
|
|
|
|
|
+ }
|
|
|
return di;
|
|
return di;
|
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
|
item.setDevices(deviceItems);
|
|
item.setDevices(deviceItems);
|
|
@@ -435,6 +485,114 @@ public class SasMapServiceImpl extends AbstractCrudService<SasMapsMapper, SasMap
|
|
|
return vo;
|
|
return vo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String addPic(PicAddRequest request) {
|
|
|
|
|
+ if (request == null || request.getUrl() == null || request.getUrl().isEmpty()) {
|
|
|
|
|
+ throw new BusinessException("图片地址 url 为必填");
|
|
|
|
|
+ }
|
|
|
|
|
+ SasPic pic = new SasPic();
|
|
|
|
|
+ pic.setId(UUID.randomUUID().toString());
|
|
|
|
|
+ pic.setUrl(request.getUrl());
|
|
|
|
|
+ pic.setPath(request.getPath());
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+ pic.setCreateTime(now);
|
|
|
|
|
+ pic.setUpdateTime(now);
|
|
|
|
|
+ sasPicService.save(pic);
|
|
|
|
|
+
|
|
|
|
|
+ SasPicSource picSource = new SasPicSource();
|
|
|
|
|
+ picSource.setId(UUID.randomUUID().toString());
|
|
|
|
|
+ picSource.setPicId(pic.getId());
|
|
|
|
|
+ picSource.setName(request.getName());
|
|
|
|
|
+ picSource.setRemark(request.getRemark());
|
|
|
|
|
+ picSource.setPicType(request.getPicType());
|
|
|
|
|
+ picSource.setSubtype(request.getSubtype());
|
|
|
|
|
+ picSource.setTag(request.getTag());
|
|
|
|
|
+ picSource.setCreateTime(now);
|
|
|
|
|
+ picSource.setUpdateTime(now);
|
|
|
|
|
+ sasPicSourceService.save(picSource);
|
|
|
|
|
+
|
|
|
|
|
+ return pic.getId();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CommonPage<PicSourceInfo> getPicSource(PicSourcePageRequest request) {
|
|
|
|
|
+ if (request == null) {
|
|
|
|
|
+ request = new PicSourcePageRequest();
|
|
|
|
|
+ }
|
|
|
|
|
+ Page<SasPicSource> page = new Page<>(
|
|
|
|
|
+ request.getCurrent() != null ? request.getCurrent() : 1L,
|
|
|
|
|
+ request.getSize() != null ? request.getSize() : 10L);
|
|
|
|
|
+ LambdaQueryWrapper<SasPicSource> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.eq(request.getPicType() != null, SasPicSource::getPicType, request.getPicType());
|
|
|
|
|
+ com.baomidou.mybatisplus.core.metadata.IPage<SasPicSource> sourcePage = sasPicSourceService.page(page, wrapper);
|
|
|
|
|
+ List<PicSourceInfo> list = sourcePage.getRecords().stream().map(picSource -> {
|
|
|
|
|
+ PicSourceInfo info = new PicSourceInfo();
|
|
|
|
|
+ BeanUtils.copyProperties(picSource, info);
|
|
|
|
|
+ if (picSource.getPicId() != null && !picSource.getPicId().isEmpty()) {
|
|
|
|
|
+ SasPic pic = sasPicService.getById(picSource.getPicId());
|
|
|
|
|
+ if (pic != null) {
|
|
|
|
|
+ String path = (pic.getUrl() != null ? pic.getUrl() : "") + (pic.getPath() != null ? pic.getPath() : "");
|
|
|
|
|
+ info.setPicUrl(path);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return info;
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
+ return new CommonPage<>(list, sourcePage.getTotal(), sourcePage.getCurrent(), sourcePage.getSize());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void updatePicSource(String id, PicSourceUpdateRequest request) {
|
|
|
|
|
+ if (id == null || id.isEmpty()) {
|
|
|
|
|
+ throw new BusinessException("图片资源 id 不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ SasPicSource picSource = sasPicSourceService.getById(id);
|
|
|
|
|
+ if (picSource == null) {
|
|
|
|
|
+ throw new BusinessException("图片资源不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request != null) {
|
|
|
|
|
+ if (request.getName() != null) {
|
|
|
|
|
+ picSource.setName(request.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request.getRemark() != null) {
|
|
|
|
|
+ picSource.setRemark(request.getRemark());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request.getPicType() != null) {
|
|
|
|
|
+ picSource.setPicType(request.getPicType());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request.getSubtype() != null) {
|
|
|
|
|
+ picSource.setSubtype(request.getSubtype());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request.getTag() != null) {
|
|
|
|
|
+ picSource.setTag(request.getTag());
|
|
|
|
|
+ }
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+ picSource.setUpdateTime(now);
|
|
|
|
|
+ sasPicSourceService.updateById(picSource);
|
|
|
|
|
+
|
|
|
|
|
+ if ((request.getUrl() != null || request.getPath() != null) && picSource.getPicId() != null && !picSource.getPicId().isEmpty()) {
|
|
|
|
|
+ SasPic pic = sasPicService.getById(picSource.getPicId());
|
|
|
|
|
+ if (pic != null) {
|
|
|
|
|
+ if (request.getUrl() != null) {
|
|
|
|
|
+ pic.setUrl(request.getUrl());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request.getPath() != null) {
|
|
|
|
|
+ pic.setPath(request.getPath());
|
|
|
|
|
+ }
|
|
|
|
|
+ pic.setUpdateTime(now);
|
|
|
|
|
+ sasPicService.updateById(pic);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void deletePicSource(String id) {
|
|
|
|
|
+ if (id == null || id.isEmpty()) {
|
|
|
|
|
+ throw new BusinessException("图片资源 id 不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ sasPicSourceService.removeById(id);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 递归删除地图及其子地图,同时删除绑定设备
|
|
* 递归删除地图及其子地图,同时删除绑定设备
|
|
|
*/
|
|
*/
|