From e141d8335ce9178b352c18ed865006a11f17112d Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 6 Sep 2024 10:29:24 +0800 Subject: [PATCH] =?UTF-8?q?#=E8=A7=86=E9=A2=91=E8=BD=AE=E6=92=AD=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../station/entity/VideoCarouselEntity.java | 25 +++++ .../station/vo/StationVideoCarouselVO.java | 32 +++++++ .../station/vo/StationVideoConfigPointVO.java | 19 ++++ .../station/vo/StationVideoConfigVO.java | 24 +++++ .../service/impl/HistoryDeviceServiceImpl.java | 13 +-- .../controller/StationVideoCarouselController.java | 43 +++++++++ .../station/mapper/VideoCarouselMapper.java | 13 +++ .../station/mapper/VideoCarouselMapper.xml | 6 ++ .../station/service/VideoCarouselService.java | 14 +++ .../service/impl/VideoCarouselServiceImpl.java | 102 +++++++++++++++++++++ 10 files changed, 283 insertions(+), 8 deletions(-) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/VideoCarouselEntity.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/StationVideoCarouselVO.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/StationVideoConfigPointVO.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/StationVideoConfigVO.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoCarouselController.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoCarouselMapper.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoCarouselMapper.xml create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/VideoCarouselService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/VideoCarouselServiceImpl.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/VideoCarouselEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/VideoCarouselEntity.java new file mode 100644 index 0000000..a13ba06 --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/StationVideoCarouselVO.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/StationVideoCarouselVO.java new file mode 100644 index 0000000..f7400ac --- /dev/null +++ b/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 videoTypes; + +} \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/StationVideoConfigPointVO.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/StationVideoConfigPointVO.java new file mode 100644 index 0000000..f59d3ec --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/StationVideoConfigVO.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/StationVideoConfigVO.java new file mode 100644 index 0000000..3291083 --- /dev/null +++ b/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 stations; +} \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java index 319439b..68f830b 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java +++ b/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 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()); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoCarouselController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoCarouselController.java new file mode 100644 index 0000000..1aa6824 --- /dev/null +++ b/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)); + } + + +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoCarouselMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoCarouselMapper.java new file mode 100644 index 0000000..981f519 --- /dev/null +++ b/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 { + +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoCarouselMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoCarouselMapper.xml new file mode 100644 index 0000000..8582ee1 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoCarouselMapper.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/VideoCarouselService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/VideoCarouselService.java new file mode 100644 index 0000000..543d060 --- /dev/null +++ b/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 { + boolean submit(VideoCarouselEntity entity); + + StationVideoCarouselVO videoCarousel(String stationId, String userId); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/VideoCarouselServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/VideoCarouselServiceImpl.java new file mode 100644 index 0000000..28423f4 --- /dev/null +++ b/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 implements VideoCarouselService { + + private final VideoConfigService videoConfigService; + + private final IStationVideoTypeService stationVideoTypeService; + + /** + * 视频配置记录提交 + * @param entity + * @return + */ + @Override + public boolean submit(VideoCarouselEntity entity) { + // 根据用户,站点查询历史配置记录 + VideoCarouselEntity videoCarousel = this.getOne(Wrappers.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.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 childs = JSONObject.parseArray(config.getConfigEntity(),StationVideoConfigVO.class); + if(CollectionUtil.isEmpty(childs)){ + return carousel; + } + List 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; + } +} \ No newline at end of file