package com.ruoyi.zdsz.task;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.common.utils.GetBeanUtil;
import com.ruoyi.zdsz.domain.ZEngineeringCivil;
import com.ruoyi.zdsz.domain.bo.ZEngineeringNodeBo;
import com.ruoyi.zdsz.mapper.ZEngineeringCivilMapper;
import com.ruoyi.zdsz.service.IZEngineeringNodeService;

import java.util.concurrent.CountDownLatch;

/**
 * 审核通过后将照片保存至指定目录task
 */
public class photoTask implements  Runnable{

    private IZEngineeringNodeService izEngineeringNodeService;
    //    private List<ZEngineeringCivil> zEngineeringCivilList;
    private ZEngineeringNodeBo zEngineeringNodeBo;
    private  String userId;
    private CountDownLatch countDownLatch;
    private ZEngineeringCivilMapper baseMapper;
    private LambdaQueryWrapper<ZEngineeringCivil> lqw ;
    private Page page;

    public  photoTask(ZEngineeringNodeBo zEngineeringNodeBo, CountDownLatch countDownLatch, Page page, LambdaQueryWrapper lqw )
    {
//        this.zEngineeringCivilList=zEngineeringCivilList;
        this.zEngineeringNodeBo=zEngineeringNodeBo;
        this.izEngineeringNodeService= GetBeanUtil.getApplicationContext().getBean(IZEngineeringNodeService.class);
        this.baseMapper= GetBeanUtil.getApplicationContext().getBean(ZEngineeringCivilMapper.class);
        this.userId= LoginHelper.getLoginUser().getUsername().toString();
        this.countDownLatch=countDownLatch;
        this.lqw = lqw;
        this.page=page;
    }
    @Override
    public void run() {
//        if (zEngineeringCivilList.size()>0)
//        {
        Page<ZEngineeringCivil> page1=baseMapper.selectPage(page, lqw);
        //izEngineeringNodeService.batchReview(page1.getRecords(),zEngineeringNodeBo,userId);
        izEngineeringNodeService.Civilinsert(page1.getRecords(),zEngineeringNodeBo,userId);
        //countDownLatch.countDown();//发出线程任务完成的信号

    }
}
