Browse Source

#视频轮播配置功能

zhongwei
yang_shj 3 months ago
parent
commit
e141d8335c
  1. 25
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/VideoCarouselEntity.java
  2. 32
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/StationVideoCarouselVO.java
  3. 19
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/StationVideoConfigPointVO.java
  4. 24
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/StationVideoConfigVO.java
  5. 13
      hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java
  6. 43
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoCarouselController.java
  7. 13
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoCarouselMapper.java
  8. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoCarouselMapper.xml
  9. 14
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/VideoCarouselService.java
  10. 102
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/VideoCarouselServiceImpl.java

25
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/VideoCarouselEntity.java

@ -0,0 +1,25 @@
package com.hnac.hzims.operational.station.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springblade.core.tenant.mp.TenantEntity;
/**
* @author ysj
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("hzims_station_video_carousel")
public class VideoCarouselEntity extends TenantEntity {
@ApiModelProperty("视频保存配置ID")
private String carouselId;
@ApiModelProperty("视频保存名称")
private String carouselName;
}

32
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/StationVideoCarouselVO.java

@ -0,0 +1,32 @@
package com.hnac.hzims.operational.station.vo;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
@ApiModel("视频轮播配置响应对象")
public class StationVideoCarouselVO {
@ApiModelProperty("站点ID")
private String stationId;
@ApiModelProperty("站点名称")
private String stationName;
@ApiModelProperty("视频保存配置ID")
private String carouselId;
@ApiModelProperty("视频保存名称")
private String carouselName;
@ApiModelProperty("视频播放记录")
private List<StationVideoTypeEntity> videoTypes;
}

19
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/StationVideoConfigPointVO.java

@ -0,0 +1,19 @@
package com.hnac.hzims.operational.station.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
@ApiModel("视频轮播配置响应对象")
public class StationVideoConfigPointVO {
@ApiModelProperty("视频点位id")
private Long id;
@ApiModelProperty("视频点位名称")
private String name;
}

24
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/StationVideoConfigVO.java

@ -0,0 +1,24 @@
package com.hnac.hzims.operational.station.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
@ApiModel("视频轮播配置响应对象")
public class StationVideoConfigVO {
@ApiModelProperty("站点ID")
private String name;
@ApiModelProperty("站点名称")
private String layout;
@ApiModelProperty("视频保存配置ID")
private List<StationVideoConfigPointVO> stations;
}

13
hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java

@ -122,11 +122,9 @@ public class HistoryDeviceServiceImpl implements IHistoryDeviceService {
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new ArrayList<>();
}
return result.getData().stream().peek(fac->{
fac.setName(Arrays.stream(fac.getName().split("\\."))
.reduce((first, second) -> second)
.orElse(fac.getName()));
}).collect(Collectors.toList());
return result.getData().stream().peek(fac-> fac.setName(Arrays.stream(fac.getName().split("\\."))
.reduce((first, second) -> second)
.orElse(fac.getName()))).collect(Collectors.toList());
}
/**
@ -282,14 +280,13 @@ public class HistoryDeviceServiceImpl implements IHistoryDeviceService {
if(!tabulations.isSuccess() || CollectionUtil.isEmpty(tabulations.getData())){
return new ArrayList<>();
}
return tabulations.getData().stream().map(tabulation->{
return tabulations.getData().stream().peek(tabulation->{
Map<String,Object> map = JSONObject.parseObject(JSONObject.toJSONString(tabulation.get("attr")),Map.class);
String key = map.get("id").toString();
String name = param.getAttrs().get(key);
map.put("name",name);
tabulation.put("attr",map);
return tabulation;
}).collect(Collectors.toList());
}).collect(Collectors.toList());
}

43
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoCarouselController.java

@ -0,0 +1,43 @@
package com.hnac.hzims.operational.station.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.station.entity.VideoCarouselEntity;
import com.hnac.hzims.operational.station.service.VideoCarouselService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
/**
* @author ysj
*/
@RestController
@RequestMapping("/station/carouselRecord")
@RequiredArgsConstructor
@Api(value = "站点视频轮播保存记录", tags = "视频轮播保存记录")
public class StationVideoCarouselController extends BladeController {
private final VideoCarouselService videoCarouselService;
@PostMapping("/submit")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "新增或修改站点视频轮播保存记录", notes = "传入VideoRecordEntity")
public R submit(@Valid @RequestBody VideoCarouselEntity entity) {
return R.status(videoCarouselService.submit(entity));
}
@GetMapping("/query")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "查询站点视频轮播保存记录", notes = "传入VideoRecordEntity")
public R query(@RequestParam("stationId") String stationId,
@RequestParam("userId") String userId) {
return R.data(videoCarouselService.videoCarousel(stationId,userId));
}
}

13
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoCarouselMapper.java

@ -0,0 +1,13 @@
package com.hnac.hzims.operational.station.mapper;
import com.hnac.hzims.operational.station.entity.VideoCarouselEntity;
import com.hnac.hzims.operational.station.entity.VideoRecordEntity;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
/**
* @author ysj
*/
public interface VideoCarouselMapper extends UserDataScopeBaseMapper<VideoCarouselEntity> {
}

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoCarouselMapper.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.operational.station.mapper.VideoCarouselMapper">
</mapper>

14
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/VideoCarouselService.java

@ -0,0 +1,14 @@
package com.hnac.hzims.operational.station.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.operational.station.entity.VideoCarouselEntity;
import com.hnac.hzims.operational.station.vo.StationVideoCarouselVO;
/**
* @author ysj
*/
public interface VideoCarouselService extends IService<VideoCarouselEntity> {
boolean submit(VideoCarouselEntity entity);
StationVideoCarouselVO videoCarousel(String stationId, String userId);
}

102
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/VideoCarouselServiceImpl.java

@ -0,0 +1,102 @@
package com.hnac.hzims.operational.station.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.entity.VideoCarouselEntity;
import com.hnac.hzims.operational.station.entity.VideoConfigEntity;
import com.hnac.hzims.operational.station.entity.VideoRecordEntity;
import com.hnac.hzims.operational.station.mapper.VideoCarouselMapper;
import com.hnac.hzims.operational.station.service.IStationVideoTypeService;
import com.hnac.hzims.operational.station.service.VideoCarouselService;
import com.hnac.hzims.operational.station.service.VideoConfigService;
import com.hnac.hzims.operational.station.vo.StationVideoCarouselVO;
import com.hnac.hzims.operational.station.vo.StationVideoConfigVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @author 86187
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class VideoCarouselServiceImpl extends ServiceImpl<VideoCarouselMapper, VideoCarouselEntity> implements VideoCarouselService {
private final VideoConfigService videoConfigService;
private final IStationVideoTypeService stationVideoTypeService;
/**
* 视频配置记录提交
* @param entity
* @return
*/
@Override
public boolean submit(VideoCarouselEntity entity) {
// 根据用户,站点查询历史配置记录
VideoCarouselEntity videoCarousel = this.getOne(Wrappers.<VideoCarouselEntity>lambdaQuery()
.eq(VideoCarouselEntity::getCreateUser,AuthUtil.getUserId())
);
if(ObjectUtils.isEmpty(videoCarousel)){
return this.save(entity);
}
entity.setId(videoCarousel.getId());
return this.updateById(entity);
}
/**
* 查询视频轮播保存记录
* @param stationId
* @param userId
* @return
*/
@Override
public StationVideoCarouselVO videoCarousel(String stationId, String userId) {
VideoCarouselEntity videoCarousel = this.getOne(Wrappers.<VideoCarouselEntity>lambdaQuery()
.eq(VideoCarouselEntity::getCreateUser,userId)
);
if(ObjectUtil.isEmpty(videoCarousel)){
return new StationVideoCarouselVO();
}
StationVideoCarouselVO carousel = new StationVideoCarouselVO();
carousel.setCarouselId(videoCarousel.getCarouselId());
carousel.setCarouselName(videoCarousel.getCarouselName());
// 查询视频轮播记录
VideoConfigEntity config = videoConfigService.getById(carousel.getCarouselId());
if(ObjectUtil.isEmpty(config)){
return carousel;
}
List<StationVideoConfigVO> childs = JSONObject.parseArray(config.getConfigEntity(),StationVideoConfigVO.class);
if(CollectionUtil.isEmpty(childs)){
return carousel;
}
List<StationVideoTypeEntity> videoTypes = new ArrayList<>();
childs.forEach(child->{
if(CollectionUtil.isEmpty(childs)){
return;
}
child.getStations().forEach(station->{
StationVideoTypeEntity videoType = stationVideoTypeService.getById(station.getId());
if(ObjectUtil.isEmpty(videoType)){
return;
}
videoTypes.add(videoType);
});
});
carousel.setVideoTypes(videoTypes);
return carousel;
}
}
Loading…
Cancel
Save