DeleteTask.java 2.35 KB
package com.sincere.haikangface.async;

import com.sincere.haikangface.bean.StudentBean;
import com.sincere.haikangface.dao.UserDao;
import com.sincere.haikangface.enums.EnumSzBusinessType;
import com.sincere.haikangface.service.impl.BaseService;
import com.sincere.haikangface.utils.CompressPic;
import com.sincere.haikangface.utils.FileUtils;
import com.sincere.haikangface.xiananDao.SendRecordDao;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CountDownLatch;

/**
 * 多线程执行卡下发
 * @author xuquan
 * @date 2021/01/12 15:56
 */
@Slf4j
public class DeleteTask implements Runnable {

    Integer schoolId;
    Integer roomId;
    Integer type;
    Integer outof;
    UserDao userDao;
    String startTime;
    String endTime;
    SendRecordDao sendRecordDao;
    CountDownLatch begin;
    CountDownLatch end;

    public DeleteTask(UserDao userDao,SendRecordDao sendRecordDao,Integer schoolId,Integer roomId, Integer type,
                      Integer outof,String startTime,String endTime,CountDownLatch begin, CountDownLatch end){
        this.userDao=userDao;
        this.sendRecordDao=sendRecordDao;
        this.schoolId=schoolId;
        this.roomId=roomId;
        this.type=type;
        this.outof=outof;
        this.startTime=startTime;
        this.endTime=endTime;
        this.begin=begin;
        this.end=end;
    }

    @Override
    public void run() {
        try {
            begin.await();
            List<String> studentIds = userDao.queryStudentIdList(schoolId,roomId);
            if(!CollectionUtils.isEmpty(studentIds)){
                for(int i=0;i<=studentIds.size();i++){
                    StudentBean userInfoBean = userDao.getStudentWithid(studentIds.get(i));
                    if(userInfoBean!=null){
                        String cardNum = userInfoBean.getStudent_num();
                        System.out.println(i);
                        sendRecordDao.deleteSS(schoolId,cardNum,type,outof,startTime,endTime);
                    }
                }
            }
        }catch (Exception e){
            log.error("异常,信息:");
        }finally {
            end.countDown();
        }
    }

}