//package com.huimv.admin.timer;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.huimv.admin.common.utils.NumberUtils;
//import com.huimv.admin.entity.ProdFermentData;
//import com.huimv.admin.entity.ProdFermentDevice;
//import com.huimv.admin.mapper.ProdFermentDataMapper;
//import com.huimv.admin.mapper.ProdFermentDeviceMapper;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//
//import java.util.Date;
//import java.util.List;
//
//@Configuration
//@EnableScheduling
//public class FermentTimer {
//    @Autowired
//    private ProdFermentDeviceMapper deviceMapper;
//    @Autowired
//    private ProdFermentDataMapper dataMapper;
//
//    @Scheduled(cron = "0 0/30 * * * ? ")
//    private void getFerment() {
//        QueryWrapper<ProdFermentDevice> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("farm_id", 26);
//        List<ProdFermentDevice> devices = deviceMapper.selectList(queryWrapper);
//        for (ProdFermentDevice device : devices) {
//            String temp = NumberUtils.getNumFloat(20.0, 50.0);//温度20-50
//            String hum = NumberUtils.getNumFloat(50.0, 90.0);//湿度50-90
//            String ph = NumberUtils.getNumFloat(6.5, 7.5);//PH6.5-7.5
//            String o2 = NumberUtils.getNumFloat(50.0, 500.0);//氧气
//            String co2 = NumberUtils.getNumFloat(50.0, 500.0);//二氧化碳
//            ProdFermentData data = new ProdFermentData();
//            data.setDeviceCode(device.getDeviceCode());
//            data.setBuildName(device.getBuildName());
//            data.setFarmId(device.getFarmId());
//            data.setCreateTime(new Date());
//            data.setCo2(co2);
//            data.setHum(hum);
//            data.setPh(ph);
//            data.setO2(o2);
//            data.setTemp(temp);
//            dataMapper.insert(data);
//        }
//
//    }
//}
