package net.vtstar.zhongtong.avi.gateway.painting.job;

import lombok.extern.slf4j.Slf4j;
import net.vtstar.zhongtong.avi.gateway.painting.mapper.RotaryRollerBedMapper;
import net.vtstar.zhongtong.avi.global.constant.Constant;
import net.vtstar.zhongtong.avi.utils.EquipDataUtil;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 旋转辊床重置数据JOB
 */
@Slf4j
@Component
public class RotaryRollerBedRestartJob extends QuartzJobBean {

    @Resource(name = "redisTemplate")
    protected ValueOperations testValueOperations;

    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        String keyW = EquipDataUtil.getTestValueKey(Constant.ROTARY_ROLLER_BED_W);
        String keyP1 = EquipDataUtil.getTestValueKey(Constant.ROTARY_ROLLER_BED_P1);
        String keyP2 = EquipDataUtil.getTestValueKey(Constant.ROTARY_ROLLER_BED_P2);
        String keyC = EquipDataUtil.getTestValueKey(Constant.ROTARY_ROLLER_BED_C);
        if (testValueOperations.get(keyW) != null){
            testValueOperations.set(keyW, 0);
        }
        if (testValueOperations.get(keyP1) != null){
            testValueOperations.set(keyP1, 0);
        }
        if (testValueOperations.get(keyP2) != null){
            testValueOperations.set(keyP2, 0);
        }
        if (testValueOperations.get(keyC) != null){
            testValueOperations.set(keyC, 0);
        }
    }
}
