wu
2023-09-13 b6901c795d8640776818e7d2be6a3396b4a2f535
springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java
@@ -34,18 +34,26 @@
        int prcid = cageout.getPrcId();// prcid
        int prcid2;
        int ids;
        int cages;
        int cells;
        double glasswidth = cageout.getGlassWidth();
        // 判断玻璃内外片
        if (tier == 2) {
            // 判断玻璃可直接出片时
            // 修改数据库笼子表(出片)
            spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 0);
            spianMapper.Inserttask(1, 0,cageout.getId(),1000 );//新增任务
            datas.add((short) prcid);
            datas.add((short) 1000);
            datas.add((short) 1);
            datas.add((short) 1);
            spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度
            spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 0);//清除格子玻璃信息
            S7control.getinstance().WriteWord(adddresslist, datas);
            spianMapper.Updatetask(1, 1);//完成任务
            return Result.success(datas);
        } else {
            // 获取格子的玻璃数量
@@ -57,7 +65,11 @@
                datas.add((short) 1000);
                datas.add((short) 1);
                datas.add((short) 1);
                spianMapper.Inserttask(1, 0,cageout.getId(),1000 );//新增任务
                spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度
                spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 0);//清除格子玻璃信息
                S7control.getinstance().WriteWord(adddresslist, datas);
                spianMapper.Updatetask(1, 1);//完成任务
                return Result.success("状态为0,直接出片");
            } else {
                // 玻璃需要调拨时,判断属于哪个半区的笼子
@@ -69,9 +81,15 @@
                    // 获取调拨位置进行调拨
                    prcid2 = cagecell.getPrcId();// 调拨目标位PRCID
                    ids = cagecell.getId();// 调拨目标位ID
                    cages=cagecell.getCage();//调拨目标位笼子
                    cells=cagecell.getCell();//调拨目标位格子
                    spianMapper.Inserttask(2, 0,cageout.getId(),ids );//新增调度任务
                    // 更换玻璃的笼子
                    spianMapper.UpdataAddCage1(glasswidth, cages, cells);//减少新格子宽度
                    spianMapper.UpdateDBCage(ids, cage, cell);// 将原格子数据更新到新格子里
                    spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 0);// 清除原格子数据
                    // 填入调拨数据
                    datas.add((short) prcid);// 调拨外片起始位置
                    datas.add((short) prcid2);
@@ -79,15 +97,19 @@
                    datas.add((short) 1);
                    // 传输mes数据,坐标,数据
                    S7control.getinstance().WriteWord(adddresslist, datas);
                    spianMapper.Updatetask(1, 2);//完成任务
                    datas.clear(); // 清空整个列表
                    // 判断调拨结束后再次出片,填入出片数据
                    datas.add((short) prcid);
                    datas.add((short) 1000);
                    datas.add((short) 1);
                    datas.add((short) 1);
                    spianMapper.Inserttask(2, 0,cageout.getId(),1000 );//新增出片任务
                    spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 0);// 清除原格子数据
                    spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度
                    S7control.getinstance().WriteWord(adddresslist, datas);
                    // 修改数据库笼子表(出片)
                    spianMapper.Updatetask(1, 1);//完成任务
                    return Result.success(cagecell); // 调拨位置的参数内容
                } else {// 笼子号大于5时
@@ -98,16 +120,20 @@
                    // 获取调拨位置进行调拨
                    prcid2 = cagecell.getPrcId();// 调拨目标位prcID
                    ids = cagecell.getId();// 调拨目标位ID
                    cages=cagecell.getCage();//调拨目标位笼子
                    cells=cagecell.getCell();//调拨目标位格子
                    // 填入调拨数据
                    datas.add((short) prcid);
                    datas.add((short) prcid2);
                    datas.add((short) 2);
                    datas.add((short) 1);
                    spianMapper.Inserttask(2, 0,cageout.getId(),ids );//新增调度任务
                    // 转移原调拨格子数据
                    spianMapper.UpdataAddCage1(glasswidth, cages, cells);//减少新格子宽度
                    spianMapper.UpdateDBCage(ids, cage, cell);// 将原格子数据更新到新格子里
                    spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 0);// 清除原格子数据
                    // 传输mes数据,坐标,数据
                    S7control.getinstance().WriteWord(adddresslist, datas);
                    spianMapper.Updatetask(1, 2);//完成任务
                    datas.clear(); // 清空整个列表
                    // 判断调拨结束后再次出片
                    // 填入出片数据
@@ -115,7 +141,11 @@
                    datas.add((short) 1000);
                    datas.add((short) 1);
                    datas.add((short) 1);
                    spianMapper.Inserttask(2, 0,cageout.getId(),1000 );//新增出片任务
                    spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 0);// 清除原格子数据出片
                    spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度
                    S7control.getinstance().WriteWord(adddresslist, datas);
                    spianMapper.Updatetask(1, 1);//完成任务
                    return Result.success(cagecell); // 调拨位置的参数内容
                }
@@ -137,10 +167,9 @@
        int tiers;
        int prctier;
        Glass glasslist = spianMapper.selectGlass(glassid);
        if (glasslist == null) {
            return (300);
        }
        double widths = glasslist.getWidth();
        Short orderids = glasslist.getOrderId();
@@ -169,6 +198,11 @@
                tiers = cages1.getTier();// 内外片
                cells = cages1.getCell();// 格子号
                prcid = cages1.getPrcId();// 传给prc的目标地id
                spianMapper.Inserttask(0, 0, 1000, ids);//新增任务
               if (glasslist == null) {
                    return (300);
                }
                prctier = spianMapper.selectsum(cage1, cells);// 传给prc的格子内玻璃数
                // 有合适空格时进片
                if (cages > 1 && cages1.getTier() != null) {
@@ -179,6 +213,8 @@
                    datas.add((short) 1);
                    // 数据库修改笼子表新增一条玻璃
                    spianMapper.UpdataAddCage(orderids, glassid, widths, cage1, cells, ids, 1);
                    spianMapper.UpdataAddCage1(widths, cage1, cells);//减少格子宽度
                    spianMapper.Updatetask(1, 0);//完成任务
                    S7control.getinstance().WriteWord(adddresslist, datas);
                    return (200);
@@ -186,7 +222,7 @@
            }
        }
        return (300);
        return (400);
    }
@@ -207,24 +243,42 @@
        int prcid = cageout.getPrcId();// prcid
        int prcid2;
        int ids;
        int cages;
        int cells;
        double glasswidth = cageout.getGlassWidth();
        // 判断玻璃内外片
        if (tier == 2) {
            // 判断玻璃可直接出片时
            // 修改数据库笼子表(出片)
            spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 0);
            spianMapper.Inserttask(1, 0,cageout.getId(),1000 );//新增任务
            datas.add((short) prcid);
            datas.add((short) 1000);
            datas.add((short) 1);
            datas.add((short) 1);
            spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度
            spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 0);//清除格子玻璃信息
            S7control.getinstance().WriteWord(adddresslist, datas);
            spianMapper.Updatetask(1, 1);//完成任务
            return Result.success(datas);
        } else {
            // 获取格子的玻璃数量
            int state = spianMapper.selectGlassState(cage, cell);
            // 判断内片是否需要调拨
            if (state == 0) {
                spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 0);
                datas.add((short) prcid);
                datas.add((short) 1000);
                datas.add((short) 1);
                datas.add((short) 1);
                spianMapper.Inserttask(1, 0,cageout.getId(),1000 );//新增任务
                spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度
                spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 0);//清除格子玻璃信息
                S7control.getinstance().WriteWord(adddresslist, datas);
                spianMapper.Updatetask(1, 1);//完成任务
                return Result.success("状态为0,直接出片");
            } else {
                // 玻璃需要调拨时,判断属于哪个半区的笼子
@@ -236,9 +290,15 @@
                    // 获取调拨位置进行调拨
                    prcid2 = cagecell.getPrcId();// 调拨目标位PRCID
                    ids = cagecell.getId();// 调拨目标位ID
                    cages=cagecell.getCage();//调拨目标位笼子
                    cells=cagecell.getCell();//调拨目标位格子
                    spianMapper.Inserttask(2, 0,cageout.getId(),ids );//新增调度任务
                    // 更换玻璃的笼子
                    spianMapper.UpdataAddCage1(glasswidth, cages, cells);//减少新格子宽度
                    spianMapper.UpdateDBCage(ids, cage, cell);// 将原格子数据更新到新格子里
                    spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 0);// 清除原格子数据
                    // 填入调拨数据
                    datas.add((short) prcid);// 调拨外片起始位置
                    datas.add((short) prcid2);
@@ -246,15 +306,19 @@
                    datas.add((short) 1);
                    // 传输mes数据,坐标,数据
                    S7control.getinstance().WriteWord(adddresslist, datas);
                    spianMapper.Updatetask(1, 2);//完成任务
                    datas.clear(); // 清空整个列表
                    // 判断调拨结束后再次出片,填入出片数据
                    datas.add((short) prcid);
                    datas.add((short) 1000);
                    datas.add((short) 1);
                    datas.add((short) 1);
                    spianMapper.Inserttask(2, 0,cageout.getId(),1000 );//新增出片任务
                    spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 0);// 清除原格子数据
                    spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度
                    S7control.getinstance().WriteWord(adddresslist, datas);
                    // 修改数据库笼子表(出片)
                    spianMapper.Updatetask(1, 1);//完成任务
                    return Result.success(cagecell); // 调拨位置的参数内容
                } else {// 笼子号大于5时
@@ -265,16 +329,20 @@
                    // 获取调拨位置进行调拨
                    prcid2 = cagecell.getPrcId();// 调拨目标位prcID
                    ids = cagecell.getId();// 调拨目标位ID
                    cages=cagecell.getCage();//调拨目标位笼子
                    cells=cagecell.getCell();//调拨目标位格子
                    // 填入调拨数据
                    datas.add((short) prcid);
                    datas.add((short) prcid2);
                    datas.add((short) 2);
                    datas.add((short) 1);
                    spianMapper.Inserttask(2, 0,cageout.getId(),ids );//新增调度任务
                    // 转移原调拨格子数据
                    spianMapper.UpdataAddCage1(glasswidth, cages, cells);//减少新格子宽度
                    spianMapper.UpdateDBCage(ids, cage, cell);// 将原格子数据更新到新格子里
                    spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 0);// 清除原格子数据
                    // 传输mes数据,坐标,数据
                    S7control.getinstance().WriteWord(adddresslist, datas);
                    spianMapper.Updatetask(1, 2);//完成任务
                    datas.clear(); // 清空整个列表
                    // 判断调拨结束后再次出片
                    // 填入出片数据
@@ -282,7 +350,11 @@
                    datas.add((short) 1000);
                    datas.add((short) 1);
                    datas.add((short) 1);
                    spianMapper.Inserttask(2, 0,cageout.getId(),1000 );//新增出片任务
                    spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 0);// 清除原格子数据出片
                    spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度
                    S7control.getinstance().WriteWord(adddresslist, datas);
                    spianMapper.Updatetask(1, 1);//完成任务
                    return Result.success(cagecell); // 调拨位置的参数内容
                }