wu
2024-01-17 89f70f154bf778afb0d5b45455f1a0929aec4817
springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java
@@ -29,11 +29,19 @@
        double minwidth = 0;
        north_glass_buffer1 glasslist = spianMapper.selectGlass(glassid); // 获取玻璃参数
        //如果没有此id时
        if (glasslist == null) {
            return (300);
        }
        //判断是否还有进片任务未完成的
        int cagestate=spianMapper.SelectCageState(2);
        //有进片任务未完成时返回不进片
        if(cagestate>0){
            return (300);
        }
        double widths = glasslist.getglasslengthmm();
        String orderids = glasslist.getordernumber();
        String FrameBarcode = glasslist.getFrameBarcode();
        List<String> adddresslist = new ArrayList<>();
        adddresslist.add("DB105.0");// 进片车起始位置
@@ -46,7 +54,11 @@
        // String orderid="A001";
        // 获取订单相关度最高的笼子排序
        List<StorageCage> storageCage = spianMapper.selectAll(orderids.toString());
        List<StorageCage> storageCage = spianMapper.selectAllFbarcode(FrameBarcode);
        if (storageCage.size() == 0) {
            storageCage = spianMapper.selectAll(orderids, FrameBarcode);
        }
        if (storageCage == null) {
            return (400);
        }
@@ -55,6 +67,11 @@
            cage1 = storageCage2.getCage();
            // 判断该笼子号相邻最大的空格数
            int cages = spianMapper.selectCage(cage1);
            // 如果相邻笼子没有空格,或者有正在执行的出片任务时返回400
            if (cages == 0) {
                return (400);
            }
            StorageCage cages1;
            // 判断是否是第二片需要加间隔物
            prctier = spianMapper.selectsum(cage1, storageCage2.getCell());// 传给prc的格子内玻璃数
@@ -90,7 +107,7 @@
                    spianMapper.UpdataAddCage1(widths, cage1, cells);// 减少格子宽度
                    spianMapper.Inserttask(0, 0, 1000, ids, glassid.toString(), prctier);// 新增任务
                    S7control.getinstance().WriteWord(adddresslist, datas);
                    System.out.println("出片任务|" + datas);
                    System.out.println("进片任务|" + datas);
                } else {
                    // 数据库修改笼子表新增一条玻璃
@@ -99,7 +116,7 @@
                    spianMapper.UpdataAddCage1(widths, cage1, cells);// 减少格子宽度
                    spianMapper.Inserttask(0, 0, 1000, ids, glassid.toString(), prctier);// 新增任务
                    S7control.getinstance().WriteWord(adddresslist, datas);
                    System.out.println("出片任务|" + datas);
                    System.out.println("进片任务|" + datas);
                    // S7control.getinstance().WriteByte("DB105.16",glassid);
                }
@@ -138,6 +155,7 @@
        int cages;
        int cells;
        double glasswidth = cageout.getGlassWidth();
        // 判断玻璃内外片
        if (tier == 2) {
            int state = spianMapper.selectGlassState(cage, cell);// 获取格子数量
@@ -147,9 +165,9 @@
            datas.add((short) 1000);
            datas.add((short) state);
            datas.add((short) 1);
            spianMapper.OverOutSlice(glassid, 1);// 更新出片队列任务状态为进行中
            spianMapper.OverOutSlice(glassid.toString(), 1, 0);// 更新出片队列任务状态为进行中
            spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度
            spianMapper.UpdataGlassCageState(glassid, 3);// 更改笼子表的玻璃状态
            spianMapper.UpdataGlassCageState(glassid.toString(), 3);// 更改笼子表的玻璃状态
            spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid, state);// 新增任务
            // int state = spianMapper.selectGlassState(cage, cell);//获取格子数量
@@ -172,11 +190,11 @@
                datas.add((short) 1000);
                datas.add((short) 1);
                datas.add((short) 1);
                spianMapper.OverOutSlice(glassid, 1);// 更新出片队列任务状态为进行中
                spianMapper.OverOutSlice(glassid.toString(), 1, 0);// 更新出片队列任务状态为进行中
                spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid, 1);// 新增任务
                spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度
                spianMapper.UpdataGlassCageState(glassid, 3);// 更改笼子表的玻璃状态
                spianMapper.OverOutSlice(glassid, 1);// 更新出片队列任务
                System.out.println("出片任务|" + datas);
                outmesid(glassid, "DB105.34");// 派发出片ID
                S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务
@@ -186,7 +204,7 @@
            } else {
                // 玻璃需要调拨时,判断属于哪个半区的笼子
                if (cage < 6) {
                    StorageCage cagecell = spianMapper.selectGlassCage(cage, glasswidth, 0, 6);
                    StorageCage cagecell = spianMapper.selectGlassCage(cage, glasswidth, 0, 6, cell);
                    if (cagecell == null) {
                        return (300);
                    }
@@ -202,14 +220,12 @@
                    datas.add((short) 2);
                    datas.add((short) 1);
                    // 更换玻璃的笼子
                    spianMapper.UpdataGlassCageState(glassid, 3);// 更改笼子表的玻璃状态
                    String glassids = spianMapper.SelectGlassid(cage, cell); // 获取被调拨的玻璃id
                    spianMapper.UpdataGlassCageState(glassids, 3);// 更改笼子表的玻璃状态
                    spianMapper.UpdateDBCage(ids, cage, cell, 2);// 将原格子数据更新到新格子里
                    spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 减少新格子宽度
                    spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度
                    //spianMapper.UpdataGlassCageState(glassids, 3);// 更改笼子表的玻璃状态
                    spianMapper.Inserttask(2, 0, cageout.getId(), ids, glassid, 2);// 新增调度任务
                    // spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid);// 新增出片任务
                    spianMapper.Inserttask(2, 0, cageout.getId(), ids, glassids, 2);// 新增调度任务
                    // 传输mes数据,坐标,数据
                    System.out.println("出片任务|" + datas);
                    S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务
@@ -218,7 +234,7 @@
                    return (200); // 结束
                } else {// 笼子号大于5时
                    StorageCage cagecell = spianMapper.selectGlassCage(cage, glasswidth, 5, 11);
                    StorageCage cagecell = spianMapper.selectGlassCage(cage, glasswidth, 5, 11, cell);
                    if (cagecell == null) {
                        return (300);
                    }
@@ -233,12 +249,12 @@
                    datas.add((short) 2);
                    datas.add((short) 1);
                    String glassids = spianMapper.SelectGlassid(cage, cell); // 获取被调拨的玻璃id
                    spianMapper.UpdataGlassCageState(glassid, 3);// 更改笼子表的玻璃状态
                    spianMapper.Inserttask(2, 0, cageout.getId() + 1, ids, glassid, 2);// 新增调度任务
                    spianMapper.UpdataGlassCageState(glassids, 3);// 更改笼子表的玻璃状态
                    spianMapper.Inserttask(2, 0, cageout.getId() + 1, ids, glassids, 2);// 新增调度任务
                    // spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid);// 新增出片任务
                    spianMapper.UpdateDBCage(ids, cage, cell, 2);// 将原格子数据更新到新格子里
                    spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 减少新格子宽度
                    spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度
                    spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度
                    // 传输mes数据,坐标,数据
                    System.out.println("出片任务|" + datas);
                    S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务
@@ -299,20 +315,20 @@
    // 根据玻璃id完成在进行中的任务
    public void overtask(String glassid) {
        spianMapper.UpdatetaskOut(glassid); // 完成上一次出片或者进片任务
        spianMapper.OverOutSlice(glassid, 2);// 完成出片队列任务
        spianMapper.UpdataGlassCage(glassid, 0);// 清除出片格子玻璃信息
        spianMapper.UpdateCageOver(glassid, 0);// 更改笼子表出片状态
        spianMapper.UpdateCageadd(glassid,1);
        String barcode = spianMapper.SelectBarcode(glassid);// 获取该玻璃的铝框id
        spianMapper.UpdateAddQueue(glassid);// 把进片的玻璃更新到出片队列中
        if (barcode != null) {
            int barcodeState = spianMapper.SelectOverState(barcode);// 获取该铝框的状态
            if (barcodeState == 2) {// 当该铝框所有的玻璃都是完成状态时删除在出片队列的数据
                spianMapper.DeleteQueue(barcode);
            }
        }
        spianMapper.UpdatetaskOut(glassid.toString());// 完成上一次 出片或者进片任务
        spianMapper.OverOutSlice(glassid.toString(), 2, 1);// 完成出片队列任务
        spianMapper.UpdataGlassCage(glassid.toString(), 0);// 清除出片格子玻璃信息
        spianMapper.UpdateCageOver(glassid.toString(), 0);// 更改笼子表出片状态
        spianMapper.UpdateCageadd(glassid.toString(), 1);// 更改笼子表进片状态
        String barcode = spianMapper.SelectBarcode(glassid.toString());// 获取该玻璃的铝框id
        spianMapper.UpdateAddQueue(glassid.toString());// 把进片的玻璃更新到出片队列中
        // if (barcode != null) {
        // int barcodeState = spianMapper.SelectOverState(barcode);// 获取该铝框的状态
        // if (barcodeState == 0) {// 当该铝框所有的玻璃都是完成状态时删除在出片队列的数据
        // spianMapper.DeleteQueue(barcode);
        // }
        // }
    }
}