WarningJob.java 2.99 KB
package com.subsidy.jobs;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.subsidy.mapper.ClassMemberMappingMapper;
import com.subsidy.mapper.VodDictMapper;
import com.subsidy.mapper.VodPlayHistoryMapper;
import com.subsidy.model.ClassMemberMappingDO;
import com.subsidy.util.SMSUtils;
import com.subsidy.vo.vod.VodPlayStateVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Component
public class WarningJob {

    /**
     * 每天定时查看是否有问题数据,有问题的话并发送短信
     */
    @Autowired
    private VodPlayHistoryMapper vodPlayHistoryMapper;

    @Autowired
    private ClassMemberMappingMapper classMemberMappingMapper;

    @Autowired
    private VodDictMapper vodDictMapper;

    @Autowired
    private SMSUtils smsUtils;

    @Value("${spring.profiles.active}")
    private String env;

//    /**
//     * 11点钟有错误数据 发短信
//     */
//    @Scheduled(cron = "0 0 23 * * ?")
//    public void classBaseInfo(){
//        if ("prod".equals(env)) {
//
//            List<Long> result = new ArrayList<>();
//
//            //查看当天产生视频学习的班级
//            List<Long> classIds = vodPlayHistoryMapper.dailyVodRecord();
//            for (Long classId : classIds) {
//
//                List<ClassMemberMappingDO> classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper<ClassMemberMappingDO>()
//                        .lambda()
//                        .eq(ClassMemberMappingDO::getClassId, classId));
//                for (ClassMemberMappingDO classMemberMappingDO : classMemberMappingDOS) {
//                    List<VodPlayStateVO> vodPlayStateVOS = vodDictMapper.testPlays(classMemberMappingDO.getMemberId(), Long.valueOf(classId));
//                    for (int i = 0; i < vodPlayStateVOS.size() - 1; i++) {
//                        VodPlayStateVO vodPlayStateVO = vodPlayStateVOS.get(i + 1); //后面
//                        VodPlayStateVO vodPlayStateVO1 = vodPlayStateVOS.get(i);    //前面
//                        if (vodPlayStateVO1.getEndDate().getTime() > vodPlayStateVO.getStartDate().getTime()) {
//                            if (!result.contains(vodPlayStateVO1.getClassId())){
//                                result.add(vodPlayStateVO.getClassId());
//                            }
//                        }
//                    }
//                }
//            }
//
//            if (result.size()>0){
//                List<String> telephones = Arrays.asList(new String[]{"15201936167", "18201963812"});
//                for (String telephone : telephones){
//                    smsUtils.sendWarning("SMS_460945631", telephone, result.toString());
//                }
//            }
//        }
//    }


}