package com.pqs9900.util;

import com.njcn.utils.ClearPathUtil;
import com.pqs9900.service.configuration.ManaDeviceService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

public class TranslateThread extends Thread {
    private Homeostasis homeostasis;
    private ManaDeviceService manaDeviceService;

    public TranslateThread(Homeostasis homeostasis, ManaDeviceService manaDeviceService) {
        this.homeostasis = homeostasis;
        this.manaDeviceService = manaDeviceService;
    }

    public static class data {
        private String path;
        private float ct1;
        private float pt1;
        private float ct2;
        private float pt2;
        private int id;
        private int ptType;
        private String name;

        public int getPtType() {
            return ptType;
        }

        public void setPtType(int ptType) {
            this.ptType = ptType;
        }

        public float getCt1() {
            return ct1;
        }

        public void setCt1(float ct1) {
            this.ct1 = ct1;
        }

        public float getPt1() {
            return pt1;
        }

        public void setPt1(float pt1) {
            this.pt1 = pt1;
        }

        public float getCt2() {
            return ct2;
        }

        public void setCt2(float ct2) {
            this.ct2 = ct2;
        }

        public float getPt2() {
            return pt2;
        }

        public void setPt2(float pt2) {
            this.pt2 = pt2;
        }

        public String getPath() {
            return path;
        }

        public void setPath(String path) {
            this.path = path;
        }

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

    @Override
    public void run() {
        List<data> list = manaDeviceService.getDataInfo();//获取基本信息传入解析函数

        for (data d : list) { //更新该条记录为解析中
            manaDeviceService.updateOFFlog(null, null, null, 4, d.getName(), d.getId(), new Date(), 0, 0, null);
        }

        for (data d : list) {
            float pt = d.getPt1() / d.getPt2();
            float ct = d.getCt1() / d.getCt2();
            homeostasis.AnalyseFileView(d.getPath(), pt, ct, d.getId(), d.getPtType(),d.getName());
        }
    }
}
