这些代码,都还是可以优化的…
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.BetweenFormater;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.google.common.collect.Lists;
import com.querydsl.core.BooleanBuilder;
import com.wondertek.oes.commons.utils.ResultBean;
import com.wondertek.oes.workbench.commons.enums.MemberEnum;
import com.wondertek.oes.workbench.commons.enums.NodeResultEnum;
import com.wondertek.oes.workbench.commons.enums.YesOrNoEnum;
import com.wondertek.oes.workbench.commons.model.*;
import com.wondertek.oes.workbench.manage.dto.dto.*;
import com.wondertek.oes.workbench.manage.feign.OesSubpApi;
import com.wondertek.oes.workbench.manage.repository.*;
import com.wondertek.oes.workbench.manage.repository.customize.EnRepositoryCustom;
import com.wondertek.oes.workbench.manage.service.BaseQueryService;
import com.wondertek.oes.workbench.manage.service.ButtonService;
import com.wondertek.oes.workbench.manage.vo.VideoRecordVo;
import com.wondertek.oes.workbench.manage.vo.baseQuery.*;
import com.wondertek.oes.workbench.manage.vo.wait.ProductPackagesVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.*;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.persistence.criteria.Predicate;
import javax.transaction.Transactional;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
@Service
@Transactional
@Slf4j
public class BaseQueryServiceImpl implements BaseQueryService {
@Resource
private VideoRecordRepository videoRecordRepository;
@Resource
private AuditRecordRepository auditRecordRepository;
@Resource
private TranscodeRepository transcodeRepository;
@Resource
private SyncInfoRepository syncInfoRepository;
@Resource
private SubpInfoRepository subpInfoRepository;
@Resource
private PublishInfoRepository publishInfoRepository;
@Resource
private BrocInfoRepository brocInfoRepository;
@Resource
private MoveInfoRepository moveInfoRepository;
@Resource
private OesSubpApi oesSubpApi;
@Resource
private LocationInfoRepository locationInfoRepository;
@Resource
private EnRepositoryCustom repositoryCustom;
@Autowired
private ButtonService buttonService;
/**
* 视屏生产记录
*
* @param videoRecordDto 页面传参
* @param page 页面传参
* @param rows 页面传参
* @param sord 页面传参
* @param sidx 页面传参
* @return Page<VideoRecordVo>
*/
@Override
public Page<VideoRecordVo> findAll(VideoRecordDto videoRecordDto, int page, int rows, String sord, String sidx) {
if (StrUtil.isBlankIfStr(sidx)) {
sidx = "produceId";
}
PageRequest pageRequest = PageRequest.of(page - 1, rows, Sort.by(Sort.Order.asc(sidx), Sort.Order.desc("collectTime")));
Page<ColVideo> all = videoRecordRepository.findAll((Specification<ColVideo>) (root, query, cb) -> {
List<Predicate> predicates = Lists.newArrayList();
predicates.add(cb.equal(root.get("groupId"), videoRecordDto.getGroupId()));
if (!StrUtil.isBlankIfStr(videoRecordDto.getVideoName())) {
predicates.add(cb.like(root.get("videoName"), "%" + videoRecordDto.getVideoName() + "%"));
}
if (!StrUtil.isBlankIfStr(videoRecordDto.getProduceStatus())) {
predicates.add(cb.equal(root.get("produceStatus"), videoRecordDto.getProduceStatus()));
}
if (!StrUtil.isBlankIfStr(videoRecordDto.getDistributeStatus())) {
predicates.add(cb.equal(root.get("distributeStatus"), videoRecordDto.getDistributeStatus()));
}
if (!StrUtil.isBlankIfStr(videoRecordDto.getDisPlatform())) {
predicates.add(cb.like(root.get("disPlatform"), "%" + videoRecordDto.getDisPlatform() + "%"));
}
return cb.and(predicates.toArray(new Predicate[0]));
}, pageRequest);
Page<VideoRecordVo> vos = all.map(e -> JSONUtil.toBean(JSONUtil.toJsonStr(e), VideoRecordVo.class));
vos.map(e -> {
if (NodeResultEnum.DistStatus.FAILED.getKey().equals(e.getDistributeStatus())) {
e.setIsOperate(this.buttonService.charge("2", videoRecordDto.getGroupId(), MemberEnum.ButtonType.PRODUCE.getType()));
} else {
e.setIsOperate(YesOrNoEnum.NO.getCode());
}
return e;
}
);
return vos;
}
/**
* 转码记录
*
* @param transcodeDto 页面传参
* @param page 页面传参
* @param rows 页面传参
* @param sord 页面传参
* @param sidx 页面传参
* @return Page<TranscodeRecordVo>
*/
@Override
public Page<TranscodeRecordVo> findAll(TranscodeDto transcodeDto, int page, int rows, String sord, String sidx) {
if (StrUtil.isBlankIfStr(sidx)) {
sidx = "transcodeId";
}
PageRequest pageRequest = PageRequest.of(page - 1, rows, Sort.by(Sort.Order.asc(sidx), Sort.Order.desc("collectTime")));
Page<Transcode> all = transcodeRepository.findAll((Specification<Transcode>) (root, query, cb) -> {
List<Predicate> predicates = Lists.newArrayList();
predicates.add(cb.equal(root.get("groupId"), transcodeDto.getGroupId()));
if (!StrUtil.isBlankIfStr(transcodeDto.getAssetId())) {
predicates.add(cb.equal(root.get("assetId"), transcodeDto.getAssetId()));
}
if (!StrUtil.isBlankIfStr(transcodeDto.getAssetName())) {
predicates.add(cb.like(root.get("assetName"), "%" + transcodeDto.getAssetName() + "%"));
}
if (!StrUtil.isBlankIfStr(transcodeDto.getTranscodeStatus())) {
predicates.add(cb.equal(root.get("transcodeStatus"), transcodeDto.getTranscodeStatus()));
}
if (!StrUtil.isBlankIfStr(transcodeDto.getFromStartTime())) {
predicates.add(cb.greaterThanOrEqualTo(root.get("endTime"), transcodeDto.getFromStartTime()));
}
if (!StrUtil.isBlankIfStr(transcodeDto.getToEndTime())) {
predicates.add(cb.lessThanOrEqualTo(root.get("endTime"), transcodeDto.getToEndTime()));
}
return cb.and(predicates.toArray(new Predicate[0]));
}, pageRequest);
ArrayList<TranscodeRecordVo> list = Lists.newArrayList();
all.getContent().forEach(e -> {
TranscodeRecordVo vo = new TranscodeRecordVo();
BeanUtil.copyProperties(e, vo);
list.add(vo);
});
list.forEach(e -> {
if (NodeResultEnum.TranscodeStatus.STARTED.getKey().equals(e.getTranscodeStatus())) {
e.setTransTime(DateUtil.formatBetween(ChronoUnit.MILLIS.between(e.getStartTime(), LocalDateTime.now()), BetweenFormater.Level.SECOND));
} else {
e.setTransTime(DateUtil.formatBetween(ChronoUnit.MILLIS.between(e.getStartTime(), e.getEndTime()), BetweenFormater.Level.SECOND));
}
if (NodeResultEnum.TranscodeStatus.FAILED.getKey().equals(e.getTranscodeStatus())) {
e.setIsOperate(YesOrNoEnum.YES.getCode());
} else {
e.setIsOperate(YesOrNoEnum.NO.getCode());
}
});
return new PageImpl<>(list, all.getPageable(), all.getTotalElements());
}
/**
* 审核记录
*
* @param auditDto 页面传参
* @param page 页面传参
* @param rows 页面传参
* @param sord 页面传参
* @param sidx 页面传参
* @return Page<AuditRecordVo>
*/
@Override
public Page<AuditRecordVo> findAll(AuditDto auditDto, int page, int rows, String sord, String sidx) {
if (StrUtil.isBlankIfStr(sidx)) {
sidx = "auditInfoId";
}
PageRequest pageRequest = PageRequest.of(page - 1, rows, Sort.by(Sort.Order.asc(sidx), Sort.Order.desc("collectTime")));
Page<AuditInfo> all = auditRecordRepository.findAll((Specification<AuditInfo>) (root, query, cb) -> {
List<Predicate> predicates = Lists.newArrayList();
predicates.add(cb.equal(root.get("groupId"), auditDto.getGroupId()));
if (!StrUtil.isBlankIfStr(auditDto.getAssetId())) {
predicates.add(cb.equal(root.get("assetId"), auditDto.getAssetId()));
}
if (!StrUtil.isBlankIfStr(auditDto.getAssetName())) {
predicates.add(cb.like(root.get("assetName"), "%" + auditDto.getAssetName() + "%"));
}
if (!StrUtil.isBlankIfStr(auditDto.getAuditStatus())) {
predicates.add(cb.equal(root.get("auditStatus"), auditDto.getAuditStatus()));
}
if (!StrUtil.isBlankIfStr(auditDto.getAuditResult())) {
predicates.add(cb.equal(root.get("auditResult"), auditDto.getAuditResult()));
}
return cb.and(predicates.toArray(new Predicate[0]));
}, pageRequest);
ArrayList<AuditRecordVo> list = Lists.newArrayList();
all.getContent().forEach(e -> {
AuditRecordVo vo = new AuditRecordVo();
BeanUtil.copyProperties(e, vo);
list.add(vo);
});
list.forEach(e -> {
if (NodeResultEnum.AuditStatus.FAILED.getKey().equals(e.getAuditStatus())) {
e.setIsOperate(this.buttonService.charge("2", auditDto.getGroupId(), MemberEnum.ButtonType.SUBMIT.getType()));
} else {
e.setIsOperate(YesOrNoEnum.NO.getCode());
}
}
);
return new PageImpl<AuditRecordVo>(list, all.getPageable(), all.getTotalElements());
}
/**
* 同步记录
*
* @param dto 页面传参
* @param page 页面传参
* @param rows 页面传参
* @param sord 页面传参
* @param sidx 页面传参
* @return Page<SyncRecordVo>
*/
@Override
public Page<SyncRecordVo> findAll(SyncRecordDto dto, int page, int rows, String sord, String sidx) {
if (StrUtil.isBlankIfStr(sidx)) {
sidx = "assetId";
}
PageRequest pageRequest = PageRequest.of(page - 1, rows, Sort.by(Sort.Order.asc(sidx), Sort.Order.desc("collectTime")));
Page<SyncInfo> all = syncInfoRepository.findAll((Specification<SyncInfo>) (root, query, cb) -> {
List<Predicate> predicates = Lists.newArrayList();
predicates.add(cb.equal(root.get("groupId"), dto.getGroupId()));
if (!StrUtil.isBlankIfStr(dto.getAssetId())) {
predicates.add(cb.equal(root.get("assetId"), dto.getAssetId()));
}
if (!StrUtil.isBlankIfStr(dto.getAssetName())) {
predicates.add(cb.like(root.get("assetName"), "%" + dto.getAssetName() + "%"));
}
if (!StrUtil.isBlankIfStr(dto.getSyncStatus())) {
predicates.add(cb.equal(root.get("syncStatus"), dto.getSyncStatus()));
}
if (!StrUtil.isBlankIfStr(dto.getFromStartTime())) {
predicates.add(cb.greaterThanOrEqualTo(root.get("endTime"), dto.getFromStartTime()));
}
if (!StrUtil.isBlankIfStr(dto.getToEndTime())) {
predicates.add(cb.lessThanOrEqualTo(root.get("endTime"), dto.getToEndTime()));
}
return cb.and(predicates.toArray(new Predicate[0]));
}, pageRequest);
List<SyncRecordVo> list = Lists.newArrayList();
all.getContent().forEach(s -> {
SyncRecordVo vo = new SyncRecordVo();
BeanUtil.copyProperties(s, vo);
list.add(vo);
});
// 计算同步时间,根据同步状态
list.forEach(e -> {
if (NodeResultEnum.SyncStatus.STARTED.getKey().equals(e.getSyncStatus())) {
e.setSyncTime(DateUtil.formatBetween(ChronoUnit.MILLIS.between(e.getStartTime(), LocalDateTime.now()), BetweenFormater.Level.SECOND));
} else {
e.setSyncTime(DateUtil.formatBetween(ChronoUnit.MILLIS.between(e.getStartTime(), e.getEndTime()), BetweenFormater.Level.SECOND));
}
if (NodeResultEnum.SyncStatus.FAILED.getKey().equals(e.getSyncStatus())) {
e.setIsOperate(YesOrNoEnum.YES.getCode());
} else {
e.setIsOperate(YesOrNoEnum.NO.getCode());
}
});
return new PageImpl<>(list, all.getPageable(), all.getTotalElements());
}
/**
* 分包批价记录
*
* @param dto 页面传参
* @param page 页面传参
* @param rows 页面传参
* @param sord 页面传参
* @param sidx 页面传参
* @return Page<SubpRecordVo>
*/
@Override
public Page<SubpRecordVo> findAll(SubpInfo dto, int page, int rows, String sord, String sidx) {
if (StrUtil.isBlankIfStr(sidx)) {
sidx = "assetId";
}
PageRequest pageRequest = PageRequest.of(page - 1, rows, Sort.by(Sort.Order.asc(sidx), Sort.Order.desc("collectTime")));
Page<SubpInfo> all = subpInfoRepository.findAll((Specification<SubpInfo>) (root, query, cb) -> {
List<Predicate> predicates = Lists.newArrayList();
predicates.add(cb.equal(root.get("groupId"), dto.getGroupId()));
if (!StrUtil.isBlankIfStr(dto.getAssetId())) {
predicates.add(cb.equal(root.get("assetId"), dto.getAssetId()));
}
if (!StrUtil.isBlankIfStr(dto.getAssetName())) {
predicates.add(cb.like(root.get("assetName"), "%" + dto.getAssetName() + "%"));
}
if (!StrUtil.isBlankIfStr(dto.getProgramId())) {
predicates.add(cb.equal(root.get("programId"), dto.getProgramId()));
}
return cb.and(predicates.toArray(new Predicate[0]));
}, pageRequest);
return all.map(e -> JSONUtil.toBean(JSONUtil.toJsonStr(e), SubpRecordVo.class));
}
/**
* 播控记录
*
* @param dto 页面传参
* @param page 页面传参
* @param rows 页面传参
* @param sord 页面传参
* @param sidx 页面传参
* @return Page<BrocRecordVo>
*/
@Override
public Page<BrocRecordVo> findAll(BrocRecordDto dto, int page, int rows, String sord, String sidx) {
if (StrUtil.isBlankIfStr(sidx)) {
sidx = "assetId";
}
PageRequest pageRequest = PageRequest.of(page - 1, rows, Sort.by(Sort.Order.asc(sidx), Sort.Order.desc("collectTime")));
Page<BrocInfo> all = brocInfoRepository.findAll((Specification<BrocInfo>) (root, query, cb) -> {
List<Predicate> predicates = Lists.newArrayList();
predicates.add(cb.equal(root.get("groupId"), dto.getGroupId()));
if (!StrUtil.isBlankIfStr(dto.getAssetId())) {
predicates.add(cb.equal(root.get("assetId"), dto.getAssetId()));
}
if (!StrUtil.isBlankIfStr(dto.getProgramId())) {
predicates.add(cb.equal(root.get("programId"), dto.getProgramId()));
}
if (!StrUtil.isBlankIfStr(dto.getBrocInfoId())) {
predicates.add(cb.equal(root.get("brocInfoId"), dto.getBrocInfoId()));
}
if (!StrUtil.isBlankIfStr(dto.getAssetName())) {
predicates.add(cb.like(root.get("assetName"), "%" + dto.getAssetName() + "%"));
}
if (!StrUtil.isBlankIfStr(dto.getBrocPartyName())) {
predicates.add(cb.like(root.get("brocPartyName"), "%" + dto.getBrocPartyName() + "%"));
}
if (!StrUtil.isBlankIfStr(dto.getBroadcastStatus())) {
predicates.add(cb.equal(root.get("broadcastStatus"), dto.getBroadcastStatus()));
}
if (!StrUtil.isBlankIfStr(dto.getContentId())) {
predicates.add(cb.equal(root.get("contentId"), dto.getContentId()));
}
if (!StrUtil.isBlankIfStr(dto.getOperator())) {
predicates.add(cb.equal(root.get("operator"), dto.getOperator()));
}
return cb.and(predicates.toArray(new Predicate[0]));
}, pageRequest);
return all.map(e -> JSONUtil.toBean(JSONUtil.toJsonStr(e), BrocRecordVo.class));
}
/**
* 发布记录
*
* @param dto 页面传参
* @param page 页面传参
* @param rows 页面传参
* @param sord 页面传参
* @param sidx 页面传参
* @return Page<PublishRecordVo>
*/
@Override
public Page<PublishRecordVo> findAll(PublishInfo dto, int page, int rows, String sord, String sidx) {
if (StrUtil.isBlankIfStr(sidx)) {
sidx = "publishInfoId";
}
PageRequest pageRequest = PageRequest.of(page - 1, rows, Sort.by(Sort.Order.asc(sidx), Sort.Order.desc("collectTime")));
Page<PublishInfo> all = publishInfoRepository.findAll((Specification<PublishInfo>) (root, query, cb) -> {
List<Predicate> predicates = Lists.newArrayList();
predicates.add(cb.equal(root.get("groupId"), dto.getGroupId()));
if (!StrUtil.isBlankIfStr(dto.getAssetId())) {
predicates.add(cb.equal(root.get("assetId"), dto.getAssetId()));
}
if (!StrUtil.isBlankIfStr(dto.getAssetName())) {
predicates.add(cb.like(root.get("assetName"), "%" + dto.getAssetName() + "%"));
}
if (!StrUtil.isBlankIfStr(dto.getProgramId())) {
predicates.add(cb.equal(root.get("programId"), dto.getProgramId()));
}
if (!StrUtil.isBlankIfStr(dto.getPublishStatus())) {
predicates.add(cb.equal(root.get("publishStatus"), dto.getPublishStatus()));
}
return cb.and(predicates.toArray(new Predicate[0]));
}, pageRequest);
ArrayList<PublishRecordVo> list = Lists.newArrayList();
all.getContent().forEach(e -> {
PublishRecordVo vo = new PublishRecordVo();
BeanUtil.copyProperties(e, vo);
list.add(vo);
});
list.forEach(e -> {
if (NodeResultEnum.PublishStatus.FAILED.getKey().equals(e.getPublishStatus())) {
e.setIsOperate(YesOrNoEnum.YES.getCode());
} else {
e.setIsOperate(YesOrNoEnum.NO.getCode());
}
});
return new PageImpl<>(list, all.getPageable(), all.getTotalElements());
}
/**
* 搬迁记录
*
* @param dto 页面传参
* @param page 页面传参
* @param rows 页面传参
* @param sord 页面传参
* @param sidx 页面传参
* @return Page<moveRecordVo>
*/
@Override
public Page<MoveRecordVo> findAll(MoveRecordDto dto, int page, int rows, String sord, String sidx) {
if (StrUtil.isBlankIfStr(sidx)) {
sidx = "moveInfoId";
}
PageRequest pageRequest = PageRequest.of(page - 1, rows, Sort.by(Sort.Order.asc(sidx), Sort.Order.desc("collectTime")));
Page<MoveInfo> all = moveInfoRepository.findAll((Specification<MoveInfo>) (root, query, cb) -> {
List<Predicate> predicates = Lists.newArrayList();
predicates.add(cb.equal(root.get("groupId"), dto.getGroupId()));
if (!StrUtil.isBlankIfStr(dto.getAssetId())) {
predicates.add(cb.equal(root.get("assetId"), dto.getAssetId()));
}
if (!StrUtil.isBlankIfStr(dto.getAssetName())) {
predicates.add(cb.like(root.get("assetName"), "%" + dto.getAssetName() + "%"));
}
if (!StrUtil.isBlankIfStr(dto.getMoveStatus())) {
predicates.add(cb.equal(root.get("moveStatus"), dto.getMoveStatus()));
}
if (!StrUtil.isBlankIfStr(dto.getFromStartTime())) {
predicates.add(cb.greaterThanOrEqualTo(root.get("startTime"), dto.getFromStartTime()));
}
if (!StrUtil.isBlankIfStr(dto.getToEndTime())) {
predicates.add(cb.lessThanOrEqualTo(root.get("startTime"), dto.getToEndTime()));
}
return cb.and(predicates.toArray(new Predicate[0]));
}, pageRequest);
Page<MoveRecordVo> map = all.map(e -> new MoveRecordVo(e));
// 计算搬迁用时,根据搬迁状态
map.forEach(e -> {
if (NodeResultEnum.MoveStatus.STARTED.getKey().equals(e.getMoveStatus())) {
e.setMoveTime(DateUtil.formatBetween(ChronoUnit.MILLIS.between(e.getStartTime(), LocalDateTime.now()), BetweenFormater.Level.SECOND));
} else {
e.setMoveTime(DateUtil.formatBetween(ChronoUnit.MILLIS.between(e.getStartTime(), e.getEndTime()), BetweenFormater.Level.SECOND));
}
if (NodeResultEnum.MoveStatus.FAILED.getKey().equals(e.getMoveStatus())) {
e.setIsOperate(YesOrNoEnum.YES.getCode());
} else {
e.setIsOperate(YesOrNoEnum.NO.getCode());
}
});
// ArrayList<MoveRecordVo> list = Lists.newArrayList();
// all.getContent().forEach(e -> {
// MoveRecordVo vo = new MoveRecordVo();
// BeanUtil.copyProperties(e, vo);
// list.add(vo);
// });
//
// // 计算搬迁用时,根据搬迁状态
// list.forEach(e -> {
// if (NodeResultEnum.MoveStatus.STARTED.getKey().equals(e.getMoveStatus())) {
// e.setMoveTime(DateUtil.formatBetween(ChronoUnit.MILLIS.between(e.getStartTime(), LocalDateTime.now()), BetweenFormater.Level.SECOND));
// }else{
// e.setMoveTime(DateUtil.formatBetween(ChronoUnit.MILLIS.between(e.getStartTime(), e.getEndTime()), BetweenFormater.Level.SECOND));
// }
// if (NodeResultEnum.MoveStatus.FAILED.getKey().equals(e.getMoveStatus())) {
// e.setIsOperate(YesOrNoEnum.YES.getCode());
// } else {
// e.setIsOperate(YesOrNoEnum.NO.getCode());
// }
// });
// return new PageImpl<>(list, pageRequest, list.size());
return map;
}
/**
* 商品包列表查询
*
* @param username 用户
* @param productId 产品ID
* @return List<ProductPackagesVo>
*/
@Override
public List<ProductPackagesVo> findProductPackages(String username, Long productId) {
ResultBean productPackages = oesSubpApi.getProductPackages(username, productId);
return (List<ProductPackagesVo>) productPackages.getResult();
}
/**
* 展现运营查询
*
* @param dto 前端传参
* @param page 前端传参
* @param rows 前端传参
* @param sord 前端传参
* @param sidx 前端传参
* @return Page<AssetPageVo>
*/
@Override
public Page<AssetPageVo> findAssetPage(AssetRecordDto dto, int page, int rows, String sord, String sidx) {
if (StrUtil.isBlankIfStr(sidx)) {
sidx = "assetId";
}
PageRequest pageRequest = PageRequest.of(page - 1, rows, Sort.by(Sort.Order.asc(sidx), Sort.Order.desc("collectTime")));
BooleanBuilder booleanBuilder = this.getBooleanBuilder(dto);
return repositoryCustom.AssetPageList(booleanBuilder, pageRequest);
}
/**
* 展现运营详情页展示
*
* @param groupId 工作组编号
* @param programId 节目编号
* @return AssetShowVo
*/
@Override
public AssetShowVo findAssetInfo(Long groupId, Long programId) {
AssetInfoVo assetInfoVo = repositoryCustom.AssetRecordInfo(groupId, programId);
List<LocationInfo> all = locationInfoRepository.findByPid(programId);
return new AssetShowVo().setAssetInfoVo(assetInfoVo).setLocationInfo(all);
}
/**
* mcn 记录列表查询
*
* @param dto 前端入参
* @param page 前端入参
* @param rows 前端入参
* @param sord 前端入参
* @param sidx 前端入参
* @return Page<McnRecordVo>
*/
@Override
public Page<McnRecordVo> findAll(McnRecordDto dto, int page, int rows, String sord, String sidx) {
if (StrUtil.isBlankIfStr(sidx)) {
sidx = "mcnInfoId";
}
PageRequest pageRequest = PageRequest.of(page - 1, rows, Sort.by(Sort.Order.asc(sidx), Sort.Order.desc("collectTime")));
BooleanBuilder booleanBuilder = this.getBooleanBuilder(dto);
return repositoryCustom.McnRecordList(booleanBuilder, pageRequest);
}
/**
* mcn运营详情查询
*
* @param groupId 工作组编号
* @param programId 节目编号
* @return McnRecordVo
*/
@Override
public McnRecordVo findMcnInfo(Long groupId, Long programId) {
List<McnRecordVo> info = repositoryCustom.McnRecordInfo(groupId, programId);
return info.size() > 0 ? info.get(0) : null;
}
/**
* 提取方法,动态条件
*
* @param dto
* @return
*/
public BooleanBuilder getBooleanBuilder(McnRecordDto dto) {
QMcnInfo m = QMcnInfo.mcnInfo;
QSubpInfo s = QSubpInfo.subpInfo;
BooleanBuilder booleanBuilder = new BooleanBuilder();
booleanBuilder.and(m.groupId.eq(dto.getGroupId()));
booleanBuilder.and(m.groupId.eq(dto.getGroupId()));
if (!StrUtil.isBlankIfStr(dto.getAssetId())) {
booleanBuilder.and(m.assetId.eq(dto.getAssetId()));
}
if (!StrUtil.isBlankIfStr(dto.getProgramId())) {
booleanBuilder.and(m.programId.eq(dto.getProgramId()));
}
if (!StrUtil.isBlankIfStr(dto.getDisposeChannel())) {
booleanBuilder.and(m.disposeChannel.eq(dto.getDisposeChannel()));
}
if (!StrUtil.isBlankIfStr(dto.getFromStartTime())) {
booleanBuilder.and(m.startTime.goe(dto.getFromStartTime()));
}
if (!StrUtil.isBlankIfStr(dto.getToEndTime())) {
booleanBuilder.and(m.startTime.loe(dto.getToEndTime()));
}
if (!StrUtil.isBlankIfStr(dto.getContentId())) {
booleanBuilder.and(s.contentId.eq(dto.getContentId()));
}
if (!StrUtil.isBlankIfStr(dto.getAssetName())) {
booleanBuilder.and(s.assetName.like("%" + dto.getAssetName() + "%"));
}
return booleanBuilder;
}
/**
* 抽取方法
*
* @param dto 入参
* @return BooleanBuilder
*/
public BooleanBuilder getBooleanBuilder(AssetRecordDto dto) {
QCatalogInfo ca = QCatalogInfo.catalogInfo;
QPublishInfo pub = QPublishInfo.publishInfo;
BooleanBuilder booleanBuilder = new BooleanBuilder();
booleanBuilder.and(ca.groupId.eq(dto.getGroupId()));
booleanBuilder.and(pub.publishStatus.eq(NodeResultEnum.PublishStatus.FINISHED.getKey()));
if (!StrUtil.isBlankIfStr(dto.getAssetId())) {
booleanBuilder.and(ca.assetId.eq(dto.getAssetId()));
}
if (!StrUtil.isBlankIfStr(dto.getProgramId())) {
booleanBuilder.and(pub.programId.eq(dto.getProgramId()));
}
if (!StrUtil.isBlankIfStr(dto.getAssetName())) {
booleanBuilder.and(ca.assetName.like("%" + dto.getAssetName() + "%"));
}
if (!StrUtil.isBlankIfStr(dto.getProductId())) {
booleanBuilder.and(pub.productId.eq(dto.getProductId()));
}
if (!StrUtil.isBlankIfStr(dto.getProductName())) {
booleanBuilder.and(pub.productName.like("%" + dto.getProductName() + "%"));
}
return booleanBuilder;
}
}