PicSceneProgressServiceImpl.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package com.fdkankan.scene.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  4. import com.fdkankan.common.constant.ErrorCode;
  5. import com.fdkankan.common.constant.RebuildResult;
  6. import com.fdkankan.common.constant.RecStatus;
  7. import com.fdkankan.common.constant.TbStatus;
  8. import com.fdkankan.common.exception.BusinessException;
  9. import com.fdkankan.common.response.ResultData;
  10. import com.fdkankan.scene.entity.PicSceneProgress;
  11. import com.fdkankan.scene.entity.ScenePro;
  12. import com.fdkankan.scene.mapper.IPicSceneProgressMapper;
  13. import com.fdkankan.scene.service.IPicSceneProgressService;
  14. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  15. import com.fdkankan.scene.service.ISceneProService;
  16. import com.fdkankan.scene.vo.RebuildVedioSceneParamVO;
  17. import com.fdkankan.scene.vo.VideoSceneProgressVO;
  18. import org.apache.commons.lang3.StringUtils;
  19. import org.springframework.beans.BeanUtils;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.stereotype.Service;
  22. import java.util.Calendar;
  23. import java.util.List;
  24. /**
  25. * <p>
  26. * 视频重算进度 服务实现类
  27. * </p>
  28. *
  29. * @author
  30. * @since 2022-01-14
  31. */
  32. @Service
  33. public class PicSceneProgressServiceImpl extends ServiceImpl<IPicSceneProgressMapper, PicSceneProgress> implements IPicSceneProgressService {
  34. @Autowired
  35. ISceneProService sceneProService;
  36. @Override
  37. public VideoSceneProgressVO findPicSceneProgress(RebuildVedioSceneParamVO param) {
  38. List<PicSceneProgress> list = this.list(
  39. new LambdaQueryWrapper<PicSceneProgress>()
  40. .eq(PicSceneProgress::getTbStatus, TbStatus.VALID.code())
  41. .eq(PicSceneProgress::getNum, param.getNum()));
  42. VideoSceneProgressVO videoSceneProgressVO = new VideoSceneProgressVO();
  43. if(list == null || list.size()<=0){
  44. return videoSceneProgressVO;
  45. }
  46. BeanUtils.copyProperties(list.get(0), videoSceneProgressVO);
  47. //更新访问量
  48. this.updatePageView(param.getNum());
  49. return videoSceneProgressVO;
  50. }
  51. @Override
  52. public void updateProgressRec(RebuildVedioSceneParamVO param) {
  53. this.update(new LambdaUpdateWrapper<PicSceneProgress>()
  54. .set(PicSceneProgress::getTbStatus, TbStatus.DELETE.code())
  55. .eq(PicSceneProgress::getNum, param.getNum()));
  56. }
  57. @Override
  58. public PicSceneProgress findrebuildVideoProgressDetail(String num,String panId) {
  59. PicSceneProgress picSceneProgress = this.getOne(new LambdaQueryWrapper<PicSceneProgress>()
  60. .eq(PicSceneProgress::getTbStatus, TbStatus.VALID.code())
  61. .eq(PicSceneProgress::getNum, num));
  62. return picSceneProgress;
  63. }
  64. @Override
  65. public void updateProgress(String num, String panId, Integer status) {
  66. this.update(new LambdaUpdateWrapper<PicSceneProgress>()
  67. .set(PicSceneProgress::getRebuildResult, status)
  68. .set(PicSceneProgress::getRebuildEndTime, Calendar.getInstance().getTime())
  69. .eq(PicSceneProgress::getNum, num)
  70. .eq(PicSceneProgress::getTbStatus, RecStatus.VALID.code()));
  71. }
  72. @Override
  73. public void updatePageView(String sceneCode) {
  74. this.update(new LambdaUpdateWrapper<PicSceneProgress>()
  75. .set(PicSceneProgress::getRebuildResult, RebuildResult.POLLED.code())
  76. .eq(PicSceneProgress::getNum, sceneCode)
  77. .eq(PicSceneProgress::getTbStatus, RecStatus.VALID.code())
  78. .eq(PicSceneProgress::getRebuildResult, RebuildResult.SUCCESS.code()));
  79. }
  80. public ResultData rebuildPicSceneProgress(RebuildVedioSceneParamVO param) throws Exception {
  81. if(StringUtils.isEmpty(param.getNum())){
  82. throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
  83. }
  84. ScenePro sceneProEntity = sceneProService.findBySceneNum(param.getNum());
  85. if(null == sceneProEntity){
  86. throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
  87. }
  88. VideoSceneProgressVO picSceneProgress =this.findPicSceneProgress(param);
  89. return ResultData.ok(picSceneProgress.getRebuildResult());
  90. }
  91. }