|
|
@@ -0,0 +1,117 @@
|
|
|
+package cn.tr.module.airway.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.tr.core.exception.TRExcCode;
|
|
|
+import cn.tr.module.airway.dto.AliOSSInitiateMultipartUploadDTO;
|
|
|
+import cn.tr.module.api.sys.storage.SysStorageApi;
|
|
|
+import cn.tr.module.api.sys.tenant.SysTenantApi;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import cn.tr.core.exception.ServiceException;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import cn.tr.module.airway.repository.BizVideoRepository;
|
|
|
+import cn.tr.module.airway.po.BizVideoPO;
|
|
|
+import cn.tr.module.airway.dto.BizVideoDTO;
|
|
|
+import cn.tr.module.airway.dto.BizVideoQueryDTO;
|
|
|
+import java.util.*;
|
|
|
+import cn.tr.module.airway.service.IBizVideoService;
|
|
|
+import cn.tr.module.airway.mapper.BizVideoMapper;
|
|
|
+/**
|
|
|
+ * 影像视频Service接口实现类
|
|
|
+ *
|
|
|
+ * @author lf
|
|
|
+ * @date 2025/06/30 13:43
|
|
|
+ **/
|
|
|
+@Service
|
|
|
+public class BizVideoServiceImpl implements IBizVideoService {
|
|
|
+ @Autowired
|
|
|
+ private BizVideoRepository baseRepository;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysTenantApi sysTenantApi;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysStorageApi storageApi;
|
|
|
+ /**
|
|
|
+ * 根据条件查询影像视频
|
|
|
+ * @param query 查询参数
|
|
|
+ * @author lf
|
|
|
+ * @date 2025/06/30 13:43
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<BizVideoDTO> selectBizVideoList(BizVideoQueryDTO query){
|
|
|
+ return BizVideoMapper.INSTANCE.convertDtoList(
|
|
|
+ baseRepository.selectList(new LambdaQueryWrapper<BizVideoPO>()
|
|
|
+ )
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据id查询影像视频
|
|
|
+ * @param id 主键id
|
|
|
+ * @author lf
|
|
|
+ * @date 2025/06/30 13:43
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public BizVideoDTO selectBizVideoById(String id){
|
|
|
+ return BizVideoMapper.INSTANCE.convertDto(baseRepository.selectById(id));
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑影像视频
|
|
|
+ * @param source 编辑实体类
|
|
|
+ * @author lf
|
|
|
+ * @date 2025/06/30 13:43
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public boolean updateBizVideoById(BizVideoDTO source){
|
|
|
+ return baseRepository.updateById(BizVideoMapper.INSTANCE.convertPO(source))!=0;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增影像视频
|
|
|
+ * @param source 新增实体类
|
|
|
+ * @author lf
|
|
|
+ * @date 2025/06/30 13:43
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean insertBizVideo(BizVideoDTO source){
|
|
|
+ return baseRepository.insert(BizVideoMapper.INSTANCE.convertPO(source))!=0;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除影像视频详情
|
|
|
+ * @param ids 删除主键集合
|
|
|
+ * @author lf
|
|
|
+ * @date 2025/06/30 13:43
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public int removeBizVideoByIds(Collection<String> ids){
|
|
|
+ if(CollectionUtil.isEmpty(ids)){
|
|
|
+ throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,"请选择要删除的数据");
|
|
|
+ }
|
|
|
+ return baseRepository.deleteBatchIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public String generationInitiateMultipartUpload(AliOSSInitiateMultipartUploadDTO source) {
|
|
|
+ BizVideoPO videoPo = baseRepository.selectOne(new LambdaQueryWrapper<BizVideoPO>()
|
|
|
+ .eq(BizVideoPO::getContentMd5, source.getContentMd5())
|
|
|
+ .eq(BizVideoPO::getDeviceCode, source.getDeviceCode())
|
|
|
+ .eq(BizVideoPO::getTenantId, source.getHospitalId())
|
|
|
+ .last("limit 1"));
|
|
|
+ if(ObjectUtil.isNotNull(videoPo)){
|
|
|
+ return videoPo.getUploadId();
|
|
|
+ }
|
|
|
+ videoPo = new BizVideoPO();
|
|
|
+ baseRepository.insert(videoPo);
|
|
|
+ String filename=source.getHospitalCode()+"/"+source.getDeviceCode()+"/"+source.getFilename();
|
|
|
+ return storageApi.generationInitiateMultipartUpload(filename);
|
|
|
+ }
|
|
|
+}
|