package com.huimv.learn;


import com.baomidou.mybatisplus.core.InjectorResolver;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.huimv.CloudPlatformApplication;
import com.huimv.modular.eartagdata.entity.EartagData;
import com.huimv.modular.eartagdata.mapper.EartagDataMapper;
import com.huimv.modular.eartagregister.entity.EartagRegister;
import com.huimv.modular.eartagregister.mapper.EartagRegisterMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;


//需要加上启动类的
@SpringBootTest(classes = CloudPlatformApplication.class)
public class test001 {

    @Autowired
    private EartagRegisterMapper eartagRegisterMapper   ;

    @Autowired
    private EartagDataMapper eartagDataMapper;

    //删除di 28页的数据
   /* @Test
    public void findAll() {

        for (Long i = 133202200001001L; i < 133202200001071L; i++) {
            QueryWrapper<EartagData> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("eartag_no", String.valueOf(i));
            List<EartagData> eartagData = eartagDataMapper.selectList(queryWrapper);
            for (EartagData eartagDatum : eartagData) {
                System.out.println(eartagDatum + "删除了的啊");
            }
            eartagDataMapper.delete(queryWrapper);

        }
    }*/
//////  133 1082 0290 0394
    /*    @Test
        public void test () {
            String eartags = "904478904500903578904254903824904436895307899472900257904502904340903513901302903013900431903356904908903657903467904931903375908793903550901132904190903301895756904352904187904351896475904146901061897838904246901071904339902201904376904281898015896321896694903211901219895789901102903289903150896197903193903335904387896204904340901126907624903630904906904348904682904653904631904809904646906314902334901103903425901188904133899539900884904286904227904881901038904296900087903640903895906249901268901187903343904658904598904795904695904722903900901240901278904365904446904182904916904194900004903744";

            for (int i = 0; i < 100; i++) {

                String location = "33--" + (i + 1);
                EartagRegister eartagRegister = eartagRegisterMapper.selectOne(new QueryWrapper<EartagRegister>().eq("location", location));
                                          //133108202  sout

                eartagRegister.setEartagNo("133108202" + eartags.substring(i * 6, (i + 1) * 6));

                System.out.println("添加+133108202" + eartags.substring(i * 6, (i + 1) * 6)+"location"+location);
                eartagRegisterMapper.updateById(eartagRegister);
            }
        }*/
/*
    @Test
    public void test001 () {
        String baseNo = "13310820289";
        String eartags = "7450742274457481748274207451752574107412741674987507755674417508747275777460738173997443741674057404746274317459753175817474748075017464744673847374737874137425757574287437745474777467744975337518751075787536750264117492737674337444756174666326615562507342622562266232628662416227623361816147751762657350756075466292621262596214630062485661627961566238567861886175622062997301728761486234626956516302\n" +
                "\n";

        for (int i = 0; i < 100; i++)                                                                                                  { String location = "50--" + (i + 1);
            EartagRegister eartagRegister = eartagRegisterMapper.selectOne(new QueryWrapper<EartagRegister>().eq("location", location));
            //133108202  sout
            eartagRegister.setEartagNo(baseNo + eartags.substring(i * 4, (i + 1) * 4));
            System.out.println("添加+13310820289" + eartags.substring(i * 4, (i + 1) * 4)+"location"+location);
            eartagRegisterMapper.updateById(eartagRegister);


        }
    }*/

    @Test
    public void test003 () {


        for (int i = 1; i <= 5000; i++) {

            EartagRegister eartagRegister = eartagRegisterMapper.selectOne(new QueryWrapper<EartagRegister>().eq("id", i));
            String[] as = eartagRegister.getLocation().split("--");
            eartagRegister.setStage(Integer.valueOf( as[0]));
            System.out.println("在修改第"+eartagRegister.getLocation());
            eartagRegisterMapper.updateById(eartagRegister);
        }

    }
    }