package com.ruoyi.common.thread.sems;


import com.ruoyi.project.sems.domain.TSpecdevYlrq;
import com.ruoyi.project.sems.service.ITSpecdevYlrqService;
import org.xhtmlrenderer.swing.DelegatingUserAgent;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class SpecOverLifeThead implements Runnable {
    private ITSpecdevYlrqService specdevYlrqService;


    public SpecOverLifeThead( ITSpecdevYlrqService specdevYlrqService) {
       this.specdevYlrqService = specdevYlrqService;
    }

    /*
    */
    @Override
    public void run() {
        List<TSpecdevYlrq> list = specdevYlrqService.list();
        for (TSpecdevYlrq t: list
             ) {
            String bigStr;
            try {
                bigStr = new BigDecimal(t.getDesYear()).toString();
            } catch (Exception e) {
                bigStr = "20";
            }
            try {
                Date sub = t.getSubmitdate();
                Date now = new Date();
                SimpleDateFormat f = new SimpleDateFormat("yyyy");
                String subStr = f.format(sub);
                String nowStr = f.format(now);
                System.out.println("nowStr:"+nowStr + "subStr:"+ subStr + "bigStr:"+bigStr);
                if (new BigDecimal(bigStr).compareTo( new BigDecimal(nowStr).subtract(new BigDecimal(subStr))) == 1){
                    t.setIsOverlife("否");
                }else {
                    t.setIsOverlife("是");
                }
                specdevYlrqService.updateTSpecdevYlrq(t);
            }catch (Exception e) {
                continue;
            }
        }

    }





}
