wu
2024-11-12 ca1ae93196be366e707647c42e3039512a2cf45f
springboot-vue3/src/main/java/com/example/springboot/service/HomeService.java
@@ -21,6 +21,7 @@
import com.example.springboot.entity.GlassInfo;
import com.example.springboot.entity.MeasureSetting;
import com.example.springboot.entity.Queue;
import com.example.springboot.mapper.GlassInfoMapper;
import com.example.springboot.mapper.MeasureSettingMapper;
import com.example.springboot.mapper.QueueMapper;
@@ -41,14 +42,23 @@
        List<GlassInfo> Results = new ArrayList<GlassInfo>();
        // 获取匹配设置
        MeasureSetting MeasureSetting = MeasureSettingMapper.SelectMeasureSetting(line);
        System.out.println("获取匹配设置:"+MeasureSetting);
        if (height > 0 && width > 0 && MeasureSetting != null) {
            // 有效参数 请求=1 长/宽>0
            double maxheight = height + MeasureSetting.getErrorHeight();
            double minheight = height - MeasureSetting.getErrorHeight();
            double maxwidth = width + MeasureSetting.getErrorWidth();
            double minwidth = width - MeasureSetting.getErrorWidth();
            // 查询当前测量数据
            List<GlassInfo> GlassInfos = GlassInfoMapper.selectGlassInfos(maxwidth, minwidth, maxheight, minheight);
            Integer Thickness = MeasureSetting.getThickness();
            String Films = MeasureSetting.getFilms();
            // 查询当前测量数据
            List<GlassInfo> GlassInfos = GlassInfoMapper.selectGlassInfos(maxwidth, minwidth, maxheight, minheight,Thickness,Films);
            System.out.println("厚度"+Thickness+"膜"+Films);
            System.out.println("GlassInfos数量:"+GlassInfos.size());
            if(Thickness==0||Films==""){
                System.out.println("厚度"+Thickness+"膜"+Films);
                return null;
            }
            List types = new ArrayList<>();
            for (int i = 0; i < GlassInfos.size(); i++) {
                Integer glasstype = GlassInfos.get(i).getGlasstype();
@@ -63,29 +73,35 @@
    // 匹配逻辑
    public boolean Normal(double width, double height, String line) {
        List<Queue> ErrowQueues= QueueMapper.selectErrorQueues();
        if (ErrowQueues.size()>0) {
            System.out.println("有匹配失败数据未去除");
            return false;
        }
        //查询当前领取的任务
        List<GlassInfo> Result = NormalGlassInfo(width, height, "1");
        System.out.println("Result:"+Result);
        if (Result.size() == 1) {
            // 匹配成功 就一种类型 添加数据
            GlassInfo GlassInfo = Result.get(0);
            QueueMapper.insert(GlassInfo.getGlassid(), width, height, 1);
            int  insertCount=QueueMapper.insert(GlassInfo.getId(), width, height, 1);
            GlassInfoMapper.updatemeasurenumber(GlassInfo.getId());
            System.out.println("匹配成功");
            
            // S7control.getinstance().WriteWord(plcmes.getPlcParameter("GaToMES").getAddress(),
            // (short) 1);
            System.out.println("添加条数:"+insertCount);
            System.out.println("匹配成功");
            System.out.println(GlassInfo.getGlassid());
            return true;
        } else if (Result.size() > 1) {
            // 匹配失败 匹配到多条符合的数据 添加数据
            QueueMapper.insert(null, width, height, 2);
            QueueMapper.insertMatchFailure(width, height, 0);
            System.out.println("匹配失败");
            return false;
        } else {
            // 匹配失败 未找到符合的数据 添加数据
            QueueMapper.insert(null, width, height, 3);
            QueueMapper.insertMatchFailure(width, height, -1);
            System.out.println("未找到符合的数据");
            return false;
        }
        return false;
    }
    // Execl表格 传入文件路径
@@ -93,6 +109,10 @@
        try {
            // 创建文件对象
            File file = new File(filename);
            if (!file.exists()) {
                System.out.println("文件不存在! "+filename);
                return new ArrayList<>();
            }
            // 创建文件输入流对象
            FileInputStream inputStream = new FileInputStream(file);
            // 创建工作簿对象