package com.huimv.modular.eartagregister.controller;

import com.huimv.modular.collectorregister.mapper.CollectorRegisterMapper;
import com.huimv.modular.eartagregister.entity.EartagRegister;
import com.huimv.modular.eartagregister.service.EartagRegisterService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Map;

/**
 * @Project : huimv.shiwan
 * @Package : com.huimv.modular.eartagregister.controller
 * @Description : TODO
 * @Author : yuxuexuan
 * @Create : 2022/7/18 0018 16:30
 **/
@SpringBootTest
public class TestAdd {
    @Autowired
    private EartagRegisterService eartagRegisterService;

    //手动添加
    @Test
    public void test() {
        for (int  i = 2241 ;i <= 3740 ; i++){
            EartagRegister byId = eartagRegisterService.getById(i +100 );
            byId.setEartagNo("13302810393"+getStrId(i));
            eartagRegisterService.updateById(byId);
        }
    }

    private String getStrId(Integer id) {
        StringBuilder strId = new StringBuilder(id + "");
        for (int  i = strId.length() ;i <  4; i++){
            strId.insert(0, "0");

        }
        return strId.toString();
    }

    @Test
    public void test1() {
        String eartag ="1153120111991169120511651118119711071132113911511110120411261113111711441143119611151135116011521155119111711194110511721122110811281101115711811147115411611182";
        int length = eartag.length() /4;

        for (int  i = 0 ;i <= length ; i++){
            System.out.println( i);
            String substring = eartag.substring(i * 4, i*4 + 4);
            System.out.println(substring);
            EartagRegister byId = eartagRegisterService.getById(2301+i);

            byId.setEartagNo("13320220000"+substring);
            eartagRegisterService.updateById(byId);
        }
    }


}
