ZengTao
2023-11-29 7e540ed41d381f5c511fa13292983a318fbe8242
测试后调整主界面
9个文件已修改
719 ■■■■■ 已修改文件
CanadaMes-ui/src/views/home/index.vue 185 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java 191 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java 111 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/controller/HomeController.java 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/entity/north_glass_buffer1.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/mapper/SpianMapper.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/service/JdbcConnections.java 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CanadaMes-ui/src/views/home/index.vue
@@ -67,17 +67,17 @@
}
.blocks {
    background-image: url('../../img/xmjc.png');
    margin: 0 auto;
    background-repeat: no-repeat;
    background-attachment: local;
    width: 1660px;
    min-height: 55vh;
    width: 1400px;
    max-width: 94vw;
    background-size: 1200px 510px;
    /* max-width: 100vw;
    margin: 0 auto;
    /* width: 1660px;
    max-width: 100vw;
    background-size: 1660px 560px; */
@@ -119,8 +119,8 @@
.orderbutton2 {
    position: absolute;
    left: 1170px;
    top: 70px;
    left: 500px;
    top: -10px;
}
.blocks-img3 {
@@ -185,6 +185,11 @@
.el-dialog {
    width: 90%;
}
/* .el-table td,
.el-table th {
    padding: 0px 0;
} */
</style>
<template>
    <el-container>
@@ -209,11 +214,17 @@
                <el-table :data="this.tasklist1" border style="width: 100%">
                    <el-table-column :width="130" prop="cage" :label="$t('Cage No')"></el-table-column>
                    <el-table-column :width="130" prop="cell" :label="$t('Slot No')"></el-table-column>
                    <el-table-column :width="150" prop="glassId" :label="$t('Outfeed glass barcode')"></el-table-column>
                    <el-table-column :width="130" prop="north_glass_buffer1s.ordernumber" :label="$t('Order No')"></el-table-column>
                    <el-table-column :width="180" prop="glassId" :label="$t('Outfeed glass barcode')"></el-table-column>
                    <el-table-column :width="130" prop="north_glass_buffer1s.ordernumber"
                        :label="$t('Order No')"></el-table-column>
                    <el-table-column prop="north_glass_buffer1s.listnumber" :label="$t('List No')"></el-table-column>
                    <el-table-column prop="north_glass_buffer1s.boxnumber" :label="$t('Box No')"></el-table-column>
                    <el-table-column prop="lengthWidth" :label="$t('Dim')"></el-table-column>
                    <el-table-column :width="130" prop="lengthWidth" :label="$t('Dim')">
                        <template slot-scope='scope'>
                            {{ scope.row.north_glass_buffer1s.glasslength }}*{{ scope.row.north_glass_buffer1s.glassheight
                            }}
                        </template>
                    </el-table-column>
                    <el-table-column :label="$t('Terminate Task')">
                        <template slot-scope='scope'>
                            <el-button type="primary" style="padding: 4px 10px;font-size: 12px;"
@@ -225,13 +236,15 @@
                <el-table :data="this.tasklist2" border style="width: 100%">
                    <el-table-column :width="130" prop="cage" :label="$t('Cage No')"></el-table-column>
                    <el-table-column :width="130" prop="cell" :label="$t('Slot No')"></el-table-column>
                    <el-table-column :width="150" prop="glassId" :labelf="$t('Infeed glass barcode')"></el-table-column>
                    <el-table-column :width="130" prop="north_glass_buffer1s.ordernumber" :label="$t('Order No')"></el-table-column>
                    <el-table-column :width="180" prop="glassId" :label="$t('Infeed glass barcode')"></el-table-column>
                    <el-table-column :width="130" prop="north_glass_buffer1s.ordernumber"
                        :label="$t('Order No')"></el-table-column>
                    <el-table-column prop="north_glass_buffer1s.listnumber" :label="$t('List No')"></el-table-column>
                    <el-table-column prop="north_glass_buffer1s.boxnumber" :label="$t('Box No')"></el-table-column>
                    <el-table-column prop="lengthWidth" :label="$t('Dim')">
                    <el-table-column :width="130" prop="lengthWidth" :label="$t('Dim')">
                        <template slot-scope='scope'>
                            {{ scope.row.north_glass_buffer1s.glasslength }}*{{ scope.row.north_glass_buffer1s.glassheight }}
                            {{ scope.row.north_glass_buffer1s.glasslength }}*{{ scope.row.north_glass_buffer1s.glassheight
                            }}
                        </template>
                    </el-table-column>
@@ -392,12 +405,12 @@
                <el-table-column :width="90" prop="cage" :label="$t('Cage No')"></el-table-column>
                <el-table-column :width="90" prop="cell" :label="$t('Slot No')"></el-table-column>
                <el-table-column :width="55" prop="tier" :label="$t('The Side')"></el-table-column>
                <el-table-column :width="100" prop="glassId" :label="$t('Barcode')"></el-table-column>
                <el-table-column :width="145" prop="glassId" :label="$t('Barcode')"></el-table-column>
                <el-table-column :width="100" prop="orderId" :label="$t('Order No')"></el-table-column>
                <el-table-column :width="100" prop="north_glass_buffer1s.listnumber"
                <el-table-column :width="80" prop="north_glass_buffer1s.listnumber"
                    :label="$t('List No')"></el-table-column>
                <el-table-column :width="100" prop="north_glass_buffer1s.boxnumber" :label="$t('Box No')"></el-table-column>
                <el-table-column :width="170" prop="lengthWidth" :label="$t('Dim')"></el-table-column>
                <el-table-column :width="150" prop="lengthWidth" :label="$t('Dim')"></el-table-column>
                <el-table-column :width="280" :label="$t('Operate')">
                    <template slot-scope='scope'>
                        <el-button type="primary" style="padding: 4px 10px;font-size: 12px;"
@@ -420,11 +433,11 @@
            <el-button type="primary" @click="selectglassinfo()">{{ $t('Query') }}</el-button>
            <el-table :data="GlassInfo.slice((currentPage - 1) * pagesize, currentPage * pagesize)
                " :height="700" border style="width: 100%;overflow: auto;">
                <el-table-column prop="barcode" :label="$t('Barcode')"></el-table-column>
                <el-table-column prop="ordernumber" :label="$t('Order No')"></el-table-column>
                <el-table-column prop="listnumber" :label="$t('List No')"></el-table-column>
                <el-table-column prop="boxnumber" :label="$t('Box No')"></el-table-column>
                <el-table-column prop="frameBarcode" :label="$t('Frame No')"></el-table-column>
                <el-table-column prop="glasslength" :label="$t('Length')"></el-table-column>
                <el-table-column prop="glassheight" :label="$t('Width')"></el-table-column>
            </el-table>
@@ -547,11 +560,11 @@
                    </el-form-item>
                </div>
                <div style="display: flex;justify-content: space-around;">
                    <el-button @click="DeleteQueueGlasss(2)" type="primary" :disabled="disabled1">{{ $t('Clear Current')
                    <el-button @click="DeleteQueueGlasss(2)" type="primary" :disabled="disabled">{{ $t('Clear Current')
                    }}</el-button>
                    <el-button @click="InsertQueueGlass(2)" type="primary" :disabled="disabled1">
                    <el-button @click="InsertQueueGlass(2)" type="primary" :disabled="disabled">
                        {{ $t('Confirm Modification') }}</el-button>
                    <el-button @click="DeleteQueueGlasss(1)" type="primary" :disabled="disabled1">{{ $t('Clear Current')
                    <el-button @click="DeleteQueueGlasss(1)" type="primary" :disabled="disabled">{{ $t('Clear Current')
                    }}</el-button>
                    <el-button @click="InsertQueueGlass(1)" type="primary" :disabled="disabled1">
                        {{ $t('Confirm Modification') }}</el-button>
@@ -576,6 +589,17 @@
                <el-table-column prop="north_glass_buffer1s.glassheight" :label="$t('Width')"></el-table-column>
                <el-table-column :width="280" :label="$t('Operate')">
                    <template slot-scope='scope'>
                        <el-button type="text" size="small" @click="getTopMove(scope.row, scope.$index)"
                            :disabled="scope.$index == 0">
                            置顶
                        </el-button>
                        <el-button type="text" size="small" @click="getUpMove(scope.row, scope.$index)"
                            :disabled="scope.$index == 0">
                            上移
                        </el-button>
                        <el-button type="text" size="small" @click="getDownMove(scope.row, scope.$index)"
                            :disabled="OutSlice.length - 1 == scope.$index">下移
                        </el-button>
                        <el-button type="primary" style="padding: 4px 10px;font-size: 12px;"
                            @click="deleteproductionqueueglass(scope.row.id)">{{ $t('Delete') }}</el-button>
                    </template>
@@ -608,7 +632,7 @@
                        {{ scope.row.out_slice != null ? $t('Yes') : $t('No') }}
                    </template>
                </el-table-column>
                <el-table-column prop="storageCage.tier" :label="$t('In the cage')">
                    <template slot-scope='scope'>
                        {{ scope.row.storageCage != null ? $t('Yes') : $t('No') }}
@@ -616,7 +640,8 @@
                </el-table-column>
                <el-table-column :width="80" :label="$t('Operate')">
                    <template slot-scope='scope'>
                        <el-checkbox label="" :disabled="!(scope.row.storageCage != null&&scope.row.out_slice == null)" :checked="scope.row.isCheck"  @change="CheckBoxchange(scope.row.barcode,$event)"></el-checkbox>
                        <el-checkbox label="" :disabled="!(scope.row.storageCage != null && scope.row.out_slice == null)"
                            :checked="scope.row.isCheck" @change="CheckBoxchange(scope.row.barcode, $event)"></el-checkbox>
                    </template>
                </el-table-column>
            </el-table>
@@ -709,7 +734,6 @@
    methods: {
        init() {
            let viewname = "Home";
            if (typeof (WebSocket) == "undefined") {
                console.log("您的浏览器不支持WebSocket");
            } else {
@@ -743,52 +767,56 @@
                    this.tasklist1 = obj.tasklist1[0];
                    this.tasklist2 = obj.tasklist2[0];
                    this.alarm = obj.alarmmg[0];
                    //出片队列
                    this.OutSlice = obj.listoutslice[0];
                    this.loadglassheight = obj.loadglassheight;
                    if (obj.zhuangtai != null) {
                        this.zhuangtai = obj.zhuangtai[0];
                    }
                    if(this.dialogFormVisible7==true){
                    if (this.dialogFormVisible7 == true) {
                        this.showform7();
                    }
                    // this.glassid1 = obj.queid[0];
                    // if (obj.queid[0] != "" && obj.queid[0] != null && obj.state[0] == 0) {
                    //     this.state = false;
                    //     this.disabled = true;
                    //     this.disabled1 = false;
                    //     this.showform3();
                    // } else if (obj.queid[0] != "" && obj.queid[0] != null && obj.state[0] == 1) {
                    //     this.state = true;
                    //     this.disabled = true;
                    //     this.disabled1 = true;
                    // }
                    // else {
                    //     this.state = true;
                    //     this.disabled = false;
                    //     this.disabled1 = false;
                    // }
                    if (obj.form2 != null && obj.form2 != "") {
                        this.form2 = obj.form2[0];
                    } else {
                        this.form2 = {};
                    }
                    console.log(obj.form3);
                    if (obj.form3 != null && obj.form3 != "" && obj.state[0] == 1) {
                        this.form3 = obj.form3[0];
                    } else {
                        this.form3 = {};
                    }
                    if (obj.form3 != null && obj.form3 != "" && obj.state[0] == 0) {
                        this.form5 = obj.form3[0];
                        this.showform3();
                        if (this.form5.glassheightmm < 380 || this.form5.glasslengthmm < 390 || this.form5.glassheightmm > 1810 || this.form5.glasslengthmm > 2760) {
                            if (this.disabled1 == false) {
                                this.disabled1 = true;
                                this.$message.error(this.$t('The glass size is not within the range'));
                            }
                        } else {
                            this.disabled1 = false;
                        }
                    } else {
                        if (this.form5.glassheightmm < 380 || this.form5.glasslengthmm < 390 || this.form5.glassheightmm > 1810 || this.form5.glasslengthmm > 2760) {
                            if (this.disabled1 == false) {
                                this.disabled1 = true;
                                // this.$message.error(this.$t('The glass size is not within the range'));
                            }
                        } else {
                            this.disabled1 = false;
                        }
                    }
                    //if (obj.dbconnected == "false") {
                    this.text = this.$t('DataBase Connection failed');
                    // }
                    SelectCageInfo(this.cage).then(res => {
                        this.cageinfo = res.data.cageinfo;
                    });
                    if (this.dialogFormVisible3 == true) {
                        SelectCageInfo(this.cage).then(res => {
                            this.cageinfo = res.data.cageinfo;
                        });
                    }
                    SelectGlass(this.orderid).then(res => {
                        this.GlassInfo = res.data.glass;
                    });
@@ -956,6 +984,15 @@
                    if (res.data.form != null) {
                        this.form5 = res.data.form;
                        this.$message.success(this.$t('query was successful'));
                        if (this.form5.glassheightmm < 380 || this.form5.glasslengthmm < 390 || this.form5.glassheightmm > 1810 || this.form5.glasslengthmm > 2760) {
                            if (this.disabled1 == false) {
                                this.disabled1 = true;
                                this.$message.error(this.$t('The glass size is not within the range'));
                            }
                        } else {
                            alert(1);
                            this.disabled1 = false;
                        }
                    } else {
                        this.$message.error(this.$t('There is no such glass'));
                    }
@@ -993,13 +1030,13 @@
            SelectAluminumFrameInfoById(this.framebarcode).then(res => {
                this.AluminumFrame = res.data.listAluminumFrame;
                this.AluminumFrame.forEach(item => {
                    if(item.storageCage!=null&&item.out_slice==null){
                    if (item.storageCage != null && item.out_slice == null) {
                        item.isCheck = true;
                    }else{
                    } else {
                        item.isCheck = false;
                    }
                    item.Flip=res.data.flip;
                    item.FrameNo=this.framebarcode;
                    item.Flip = res.data.flip;
                    item.FrameNo = this.framebarcode;
                });
            });
            this.dialogFormVisible7 = true;
@@ -1053,7 +1090,6 @@
            this.cage = cage;
            SelectCageInfo(cage).then(res => {
                this.cageinfo = res.data.cageinfo;
                console.log(this.cageinfo)
                this.dialogFormVisible3 = true;
            });
        },
@@ -1263,35 +1299,42 @@
                }
            });
        },
        CheckBoxchange(glassid,isChecked){
            this.AluminumFrame.forEach(item=>{item.barcode=glassid;item.isCheck=isChecked})
            console.log(this.AluminumFrame);
        CheckBoxchange(glassid, isChecked) {
            this.AluminumFrame.forEach(item => { item.barcode = glassid; item.isCheck = isChecked })
        },
        addoutslice(){
        addoutslice() {
            // var AluminumFrames1=this.AluminumFrame.map(item=>{return item.barcode});
            // var AluminumFrames2=this.AluminumFrame.map(item=>{return item.isCheck});
            // var AluminumFrames3=this.AluminumFrame.map(item=>{return item.Flip});
            var dats_=new Array();
            var dats_ = new Array();
            this.AluminumFrame.forEach(item => {
                var dats2_=new Array();
                dats2_[0]=item.barcode;
                dats2_[1]=item.isCheck;
                dats2_[2]=item.Flip;
                dats2_[3]=item.FrameNo;
                dats2_[4]=item.glasslengthmm;
                dats2_[5]=item.glassheightmm;
                dats_[dats_.length]=dats2_;
                var dats2_ = new Array();
                dats2_[0] = item.barcode;
                dats2_[1] = item.isCheck;
                dats2_[2] = item.Flip;
                dats2_[3] = item.FrameNo;
                dats2_[4] = item.glasslengthmm;
                dats2_[5] = item.glassheightmm;
                dats_[dats_.length] = dats2_;
            });
            console.log(dats_);
            //var AluminumFrames=this.AluminumFrame.map((item)=>({barcode,isCheck,Flip}) );
            // console.log(AluminumFrames1);
            // console.log(AluminumFrames2);
            // console.log(AluminumFrames3);
            AddOutSliceS(dats_).then(res=>{
            AddOutSliceS(dats_).then(res => {
                if (res.data.message == 200) {
                    this.$message.success(this.$t('Operation successful'));
                }
            });
        }, getTopMove(row, index) {
            this.OutSlice.splice(index, 1)
            this.OutSlice.unshift(row)
        },
        //上移
        getUpMove(row, index) {
            let arr = this.OutSlice;
            arr.splice(index - 1, 1, ...arr.splice(index, 1, arr[index - 1]));
        },
        //下移
        getDownMove(row, index) {
            let arr = this.OutSlice;
            arr.splice(index, 1, ...arr.splice(index + 1, 1, arr[index]));
        }
    }
}
springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java
@@ -40,23 +40,9 @@
      spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
      jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
      // String str = "Hello";
      // char[] charArray = new char[str.length()];
      // for (int i = 0; i < str.length(); i++) {
      // charArray[i] = str.charAt(i);
      // }
      // System.out.println(charArray);
      // spianService.selectout("1145");
      // spianService.selectAll("11");
      // spianService.selectAll2();
      // 增加队列表数据
      // spianMapper.insertqueue("1",1,1500);
      // 根据玻璃id获取订单号,单独数据源
      // try {
      // north_glass_buffer1 glass = jdbcConnections.selectGlass(112);
      // // System.out.println(glass.getOrderId());
      // } catch (SQLException e) {
      // // TODO Auto-generated catch block
@@ -66,110 +52,82 @@
      // 判断进片请求
      List<Short> datas1List = S7control.getinstance().ReadWord("DB106.24", 1);// 获取prc进片请求数据
      List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8", 1);// 获取进片车状态
      List<Short> datas1ListState2 = S7control.getinstance().ReadWord("DB105.12", 1);// 获取进片车任务是否启动
      List<Short> datas1ListState2 = S7control.getinstance().ReadWord("DB105.16", 1);// 获取进片车任务是否启动
      if (datas1List != null && datas1ListState != null) {
        // 获取prc进片请求数据
        boolean exist = datas1List.contains((short) 1);
        // 获取进片车状态
        boolean exist1 = datas1ListState.contains((short) 0);
        // 判断进片车任务是否启动
        boolean exist2 = datas1ListState2.contains((short) 1);
        String glassid = "";
        StringBuilder strId = new StringBuilder();
        StringBuilder writedstrId = new StringBuilder();
        if (!inglassbegin & !exist1)// 当进片车不空闲时
        {
          inglassbegin = true;
        }
        if (inglassbegin & exist1)// 当进片车空闲时
        {
          inglassbegin = false;
          spianMapper.Updatetask(1, 0);// 立即结束数据库表中的上片任务
          spianMapper.UpdataAddCageState(1, 2);
        }
        // 进片请求为1时
        if (exist == true) {
          // 当进片车空闲时
          if (exist1 == true) {
            // 获取已下发的进片id 与plc请求的id作比较
            byte[] writedglassidbytes = S7control.getinstance().ReadByte("DB105.16", 14);
            String teststr1=new String(writedglassidbytes);
            if (writedglassidbytes != null) { //
              // 获取玻璃id
              for (byte iditem : writedglassidbytes) {
                writedstrId.append(iditem);
              }
            }
            // 获取进片id
            byte[] datas1ListID = S7control.getinstance().ReadByte("DB106.26", 14);
            String teststr=new String(datas1ListID);
            if (teststr != null) {
              // 获取玻璃id
              if (teststr1.equals(teststr)) // 已经下发的id与plc请求的id不一样时,认为不是重复的任务,才执行下发任务指令
              {
                north_glass_buffer1 glass1 = spianMapper.selectGlass(teststr.toString());
                int questate = spianMapper.Selectqueuestate();
                if (questate == 0) {
                  spianMapper.insertqueue(teststr, 1,glass1.getglasslengthmm());
                  //spianService.selectAll(teststr);
                } else {
                  //spianService.selectAll(teststr);
                }
                S7control.getinstance().WriteByte("DB105.16", datas1ListID);// 派发进片id
              }
              // spianService.selectAll(Short.parseShort(strId.toString()));
            }
          }
          // System.out.println(exist);
        }
        // 下发任务后将任务启动改为0
        if (exist1 == false) { // 进片车忙碌时
          if (exist2 == true) { // 任务已启动时
            S7control.getinstance().WriteWord("DB105.12", (short) 0);// 进片任务启动改为0
          }
        }
      boolean B01backs =spianService.listbool("DB106.60");// b01汇报
      boolean B02backs = spianService.listbool("DB106.62");// b02汇报
      StringBuilder B01glassid=spianService.queGlassid("DB106.DBB26");//BO1的玻璃id
      StringBuilder B02glassid=spianService.queGlassid("DB106.DBB26");//B02的玻璃id
      //当进片小车完成任务时
      if(B01backs==true){
        //当B01小车汇报完成时更改玻璃状态为1
        spianMapper.UpdateCageOver(B01glassid.toString(),1);//更改笼子表进片状态
        spianMapper.Updatetask(1,0);//更改进片任务状态为1
        spianMapper.overqueue(B01glassid.toString(),0);//更改上片任务表的状态为0
        S7control.getinstance().WriteWord("DB105.48", (short) 1);//应答B01小车收到
        S7control.getinstance().WriteWord("DB105.16", (short) 0);//进片任务启动改为0
      }else{
        S7control.getinstance().WriteWord("DB105.48", (short) 0);//恢复B01小车应答
      }
      //当出片小车完成任务时
      if(B02backs==true){
        //当B02小车汇报完成时更改玻璃状态为0
        spianMapper.UpdateCageOver(B02glassid.toString(),0);//更改笼子表出片状态
        spianMapper.UpdatetaskOut(B02glassid.toString()); // 完成上一次出片或者调度任务
        S7control.getinstance().WriteWord("DB105.50", (short) 1);//应答B02小车收到
      }else{
        S7control.getinstance().WriteWord("DB105.50", (short) 0);//恢复B02小车应答
      }
      // 获取DO1数据
      StringBuilder queueid1 = spianService.queGlassid("DB106.DBB26");
      // 获取DO2数据
      StringBuilder queueid2 = spianService.queGlassid("DB103.DBB46");
      int questate = spianMapper.Selectqueuestate();
      //queueid1.toString().isEmpty()
      StringBuilder queueid2 = spianService.queGlassid("DB103.DBB78");
      System.out.println("D01"+queueid1);
      System.out.println("D02"+queueid2);
      int questate = spianMapper.Selectqueuestate();//判断扫码位是否有玻璃已确认
      // queueid1.toString().isEmpty()
      north_glass_buffer1 glass1 = spianMapper.selectGlass(queueid1.toString());//D01的玻璃信息
      north_glass_buffer1 glass2 = spianMapper.selectGlass(queueid2.toString());//D02玻璃信息
      double quewitdh=0;
      double quewitdh2=0;
      //当扫码位玻璃id为空时 宽度为0
      if(glass1==null){
         quewitdh=0;
         queueid1=new StringBuilder("");
      }else{
        quewitdh=glass1.getglasslengthmm();
      }
      if(glass2==null){
         quewitdh2=0;
         queueid2=new StringBuilder("");
      }else{
        quewitdh2=glass2.getglasslengthmm();
      }
      if (queueid1!=null&& questate == 0) {
        // 写入D01的数据到上片队列表
        north_glass_buffer1 glass1 = spianMapper.selectGlass(queueid1.toString());
        spianMapper.insertqueue(queueid1.toString(), 1, glass1.getglasslengthmm());
        spianMapper.insertqueue(queueid1.toString(), 1, quewitdh);
      }
      if (queueid2.toString().isEmpty()) {
      if (queueid2!=null) {
        // 写入D02的数据到上片队列表
        north_glass_buffer1 glass2 = spianMapper.selectGlass(queueid2.toString());
        spianMapper.insertqueue(queueid2.toString(), 2, glass2.getglasslengthmm());
        spianMapper.insertqueue(queueid2.toString(), 2, quewitdh2);
        spianMapper.overqueue2(queueid2.toString(),0,1);//更改上片任务表的状态为0
      }
       // 出片任务////////////////////////////////
      List<Short> outlist = S7control.getinstance().ReadWord("DB106.20", 1); // 出片车状态
      List<Short> outlist1 = S7control.getinstance().ReadWord("DB105.14", 1); // 出片任务是否启动
      //StringBuilder writedstrIdOut = new StringBuilder();
      List<Short> outlist1 = S7control.getinstance().ReadWord("DB105.18", 1); // 出片任务是否启动
      // StringBuilder writedstrIdOut = new StringBuilder();
      // 获取已下发的出片id
      byte[] writedglassidbytesOut = S7control.getinstance().ReadByte("DB105.30", 14);
      String writedstrIdOut=new String(writedglassidbytesOut);
      String writedstrIdOut = new String(writedglassidbytesOut);
      // 出片任务////////////////////////////////
      boolean outstate = false;// 出片车空闲判断
      boolean outstate1 = false;// 出片车任务是否启动
      if (outlist != null && outlist1 != null) {
@@ -185,41 +143,42 @@
        }
        if (outglassbegin & outstate)// 当任务开始且出片车空闲时
        {
          outglassbegin = false;
          spianMapper.UpdatetaskOut(); // 完成上一次出片或者调度任务
          spianMapper.UpdataAddCageState(0, 3);// 将出片中的格子状态改成0
          outglassbegin = false;
        }
        if (outstate == true & glass.getbarcode() != null) { // 当出片车空闲且有出片任务待完成时
          // 判断有两个出片或调拨任务时并且出片id和未完成的出片任务id不一样时执行出片
          if (glass.getId() == 2 & !writedstrIdOut.toString().equals(glass.getbarcode().toString())) {
          if (!writedstrIdOut.toString().equals(glass.getbarcode().toString())) {
            spianService.selectout2(glass.getbarcode().toString());
            outstate=false;
          }
        }
        // 判断当前是否有未执行的任务
        int outnum = spianMapper.SelectOutSliceshu();
        if (outnum == 0) {
        //当没有任务执行并且出片车空闲时
        if (outnum == 0&&outstate == true ) {
          // 判断铝框出片队列表是否有待出片的玻璃
          String outglassid = spianMapper.SelectOutSlice();
          if (outglassid != null) {
            spianService.selectout2(outglassid);
            outstate=false;
          }
        }
        if (outstate == false) {// 下发任务后将任务启动改为0//出片车空闲判断
        if (outstate == true) {// 下发任务后将任务启动改为0//出片车空闲判断
          if (outstate1 == true) {
            S7control.getinstance().WriteWord("DB105.14", (short) 0);// 出片任务启动改为0
            S7control.getinstance().WriteWord("DB105.18", (short) 0);// 出片任务启动改为0
          }
        }
      }
      if (outstate == true) { // 出片车状态空闲时
        Integer state = spianMapper.Selectoutstate();
        String orderid = spianMapper.SelectOrderout();
      // if (outstate == true) { // 出片车状态空闲时
      //   Integer state = spianMapper.Selectoutstate();
      //   String orderid = spianMapper.SelectOrderout();
        if (orderid != null && state == 0) {
          spianService.selectout(orderid);
        }
      }
      //   if (orderid != null && state == 0) {
      //     spianService.selectout(orderid);
      //   }
      // }
      // 查询数据库
      // 推送到前端
springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
@@ -2,8 +2,13 @@
import cn.hutool.json.JSONObject;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.example.springboot.entity.Out_slice;
import com.example.springboot.entity.StorageCage;
import com.example.springboot.entity.alarmmg;
import com.example.springboot.entity.north_glass_buffer1;
@@ -13,9 +18,11 @@
public class Plchome extends Thread {
    @Autowired
    private HomeMapper homeMapper;
    private SpianMapper spianMapper;
    private JdbcConnections dbserve;
    private JdbcConnections jdbcConnections;
    @Override
    public void run() {
@@ -30,6 +37,7 @@
            // 注入mapper
            homeMapper = WebSocketServer.applicationContext.getBean(HomeMapper.class);
            spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
            jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
            // 笼子使用情况
            List<StorageCage> tableData = homeMapper.selectAll();
            jsonObject.append("tableData", tableData);
@@ -46,36 +54,54 @@
            List<StorageCage> tasklist1 = homeMapper.selectinout(3);
            List<StorageCage> tasklist2 = homeMapper.selectinout(2);
            for (StorageCage storageCage : tasklist1) {
                storageCage.setnorth_glass_buffer1s(homeMapper.SelectBoxNo(storageCage.getGlassId()));
                // storageCage.setnorth_glass_buffer1s(homeMapper.SelectBoxNo(storageCage.getGlassId()));
                try {
                    storageCage.setnorth_glass_buffer1s(jdbcConnections.SelectGlassByGlassIdOrderIdFrameId("", "", ""));
                } catch (SQLException e) {
                    e.printStackTrace();
                }
                try {
                    storageCage.setnorth_glass_buffer1s(
                            jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(storageCage.getGlassId(), "", ""));
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            for (StorageCage storageCage : tasklist2) {
                storageCage.setnorth_glass_buffer1s(homeMapper.SelectBoxNo(storageCage.getGlassId()));
              }
                // storageCage.setnorth_glass_buffer1s(homeMapper.SelectBoxNo(storageCage.getGlassId()));
                try {
                    storageCage.setnorth_glass_buffer1s(
                            jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(storageCage.getGlassId(), "", ""));
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            jsonObject.append("tasklist1", tasklist1);
            jsonObject.append("tasklist2", tasklist2);
            // 查询报警信息
            List<alarmmg> alarmmg = homeMapper.SelectAlarmmgInfo();
            jsonObject.append("alarmmg", alarmmg);
            // 读去Plc进片车与出片车位置W
            List<String> addressList = new ArrayList<String>();
            addressList.add("DB106.12");
            addressList.add("DB106.0");
            List<Short> paramlist = S7control.getinstance().ReadWord(addressList);
            if (paramlist != null) {
            jsonObject.append("params", paramlist);
            }
            // 获取进片车状态
            List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8",
            1);// 获取进片车状态
            boolean exist1 = datas1ListState.contains((short) 0);
            jsonObject.append("zhuangtai", exist1);
            //获取进片玻璃信息
            List<Short> inglassInfo = S7control.getinstance().ReadWord("DB106.24", 1);
            if (inglassInfo != null) {
            if (inglassInfo.size() > 0)
            jsonObject.append("loadglassheight", inglassInfo.get(0) * 70);
            }
            //伍 获取进是否有待确认的玻璃id
            // List<String> addressList = new ArrayList<String>();
            // addressList.add("DB106.12");
            // addressList.add("DB106.0");
            // List<Short> paramlist = S7control.getinstance().ReadWord(addressList);
            // if (paramlist != null) {
            // jsonObject.append("params", paramlist);
            // }
            // // 获取进片车状态
            // List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8",
            // 1);// 获取进片车状态
            // boolean exist1 = datas1ListState.contains((short) 0);
            // jsonObject.append("zhuangtai", exist1);
            // //获取进片玻璃信息
            // List<Short> inglassInfo = S7control.getinstance().ReadWord("DB106.24", 1);
            // if (inglassInfo != null) {
            // if (inglassInfo.size() > 0)
            // jsonObject.append("loadglassheight", inglassInfo.get(0) * 70);
            // }
            // 伍 获取进是否有待确认的玻璃id
            String queid = spianMapper.Selectqueueid();
            int state = spianMapper.Selectqueuestate();
            jsonObject.append("queid", queid);
@@ -83,16 +109,37 @@
            // 获取扫码位与上片位玻璃信息
            String queueglassid2 = homeMapper.GetQueueInfo(2);
            String queueglassid1 = homeMapper.GetQueueInfo(1);
            north_glass_buffer1 form2 = homeMapper.SelectGlassByGlassID(queueglassid2);
            north_glass_buffer1 form3 = homeMapper.SelectGlassByGlassID(queueglassid1);
            jsonObject.append("form2", form2);
            jsonObject.append("form3", form3);
            // List<Short> paramlists = new ArrayList<Short>();
            // short para1 = 11111;
            // short para2 = 32000;
            // paramlists.add(para1);
            // paramlists.add(para2);
            // System.out.println(paramlists);
            // north_glass_buffer1 form2 = homeMapper.SelectGlassByGlassID(queueglassid2);
            // north_glass_buffer1 form3 = homeMapper.SelectGlassByGlassID(queueglassid1);
            north_glass_buffer1 form2;
            if(queueglassid2.length()!=0){
                try {
                    form2 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(queueglassid2, "", "");
                    jsonObject.append("form2", form2);
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            north_glass_buffer1 form3;
            if(queueglassid1.length()!=0){
                try {
                    form3 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(queueglassid1, "", "");
                    jsonObject.append("form3", form3);
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            // 获取出片队列信息
            List<Out_slice> listoutslice = homeMapper.SelectProductionqueue();
            for (Out_slice out_slice : listoutslice) {
                out_slice.setnorth_glass_buffer1s(homeMapper.SelectBoxNo(out_slice.getGlassId()));
                out_slice.setstorageCage(homeMapper.SelectStorageGlassById(out_slice.getGlassId()));
            }
            jsonObject.append("listoutslice", listoutslice);
            dbserve = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
            boolean dbconnected = false;
springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
@@ -29,7 +29,7 @@
    //
    System.out.println("启动完成");
    new PlcHold().start();
      // new PlcHold().start();
//  new Plcaction().start();
//
springboot-vue3/src/main/java/com/example/springboot/controller/HomeController.java
@@ -1,5 +1,6 @@
package com.example.springboot.controller;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -9,6 +10,7 @@
import com.example.springboot.mapper.HomeMapper;
import com.example.springboot.mapper.SpianMapper;
import com.example.springboot.service.HomeService;
import com.example.springboot.service.JdbcConnections;
import com.example.springboot.service.SpianService;
import com.example.springboot.common.Result;
import com.example.springboot.component.S7control;
@@ -17,7 +19,6 @@
import com.example.springboot.entity.alarmmg;
import com.example.springboot.entity.north_glass_buffer1;
import com.example.springboot.entity.Out_slice;
import org.springframework.web.bind.annotation.*;
@@ -36,6 +37,9 @@
  @Autowired
  SpianMapper spianMapper;
  @Autowired
  private JdbcConnections jdbcConnections;
  // 查询理片笼使用情况
  @GetMapping("/load")
  public Result selectAll() {
@@ -62,11 +66,14 @@
  // 查询进/出片任务
  @GetMapping("/loadinout")
  public Result selectinout(Integer types) {
  public Result selectinout(Integer types) throws SQLException{
    List<StorageCage> storageCageinout = homeMapper.selectinout(types);
    for (StorageCage storageCage : storageCageinout) {
      storageCage.setnorth_glass_buffer1s(homeMapper.SelectBoxNo(storageCage.getGlassId()));
      storageCage.setnorth_glass_buffer1s(jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(storageCage.getGlassId(), "", ""));
      // storageCage.setnorth_glass_buffer1s(homeMapper.SelectBoxNo(storageCage.getGlassId()));
    }
    Map<String, Object> map = new HashMap<>();
    map.put("list", storageCageinout);
    return Result.success(map);
@@ -137,10 +144,12 @@
  // 查询理片笼详情
  @GetMapping("/SelectCageInfo")
  public Result SelectCageInfo(short cage) {
  public Result SelectCageInfo(short cage) throws SQLException {
    List<StorageCage> cageinfo = homeMapper.SelectCageInfo(cage);
    for (StorageCage storageCage : cageinfo) {
      storageCage.setnorth_glass_buffer1s(homeMapper.SelectBoxNo(storageCage.getGlassId()));
      // storageCage.setnorth_glass_buffer1s(homeMapper.SelectBoxNo(storageCage.getGlassId()));
      storageCage.setnorth_glass_buffer1s(jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(storageCage.getGlassId(), "", ""));
    }
    Map<String, Object> map = new HashMap<>();
    map.put("cageinfo", cageinfo);
@@ -198,10 +207,16 @@
  // 根据玻璃id查询玻璃信息
  @GetMapping("/SelectGlassByGlassID")
  public Result SelectGlassByGlassID(String glassid) {
    north_glass_buffer1 north_glass_buffer1s = homeMapper.SelectGlassByGlassID(glassid);
  public Result SelectGlassByGlassID(String glassid) throws SQLException {
    // north_glass_buffer1 north_glass_buffer1s = homeMapper.SelectGlassByGlassID(glassid);
    north_glass_buffer1 north_glass_buffer1s=jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(glassid, "", "");
    Map<String, Object> map = new HashMap<>();
    if(glassid!=""){
    map.put("form", north_glass_buffer1s);
    }
    return Result.success(map);
  }
@@ -230,9 +245,9 @@
  // 查询玻璃信息
  @PostMapping("/SelectGlass")
  public Result SelectGlass(String orderid) {
  public Result SelectGlass(String orderid) throws SQLException {
    Map<String, Object> map = new HashMap<>();
    List<north_glass_buffer1> glass = homeMapper.SelectGlass(orderid);
    List<north_glass_buffer1> glass = jdbcConnections.SelectGlassByGlassIdOrderIdFrameIds("", orderid, "");
    map.put("glass", glass);
    return Result.success(map);
  }
@@ -282,8 +297,10 @@
  // 根据铝框id获取对应玻璃信息
  @PostMapping("/SelectAluminumFrameInfoById")
  public Result SelectAluminumFrameInfoById(String FrameBarcode) {
    List<north_glass_buffer1> listAluminumFrame = homeMapper.SelectAluminumFrameInfoById(FrameBarcode);
  public Result SelectAluminumFrameInfoById(String FrameBarcode) throws SQLException {
    // List<north_glass_buffer1> listAluminumFrame = homeMapper.SelectAluminumFrameInfoById(FrameBarcode);
    List<north_glass_buffer1> listAluminumFrame = jdbcConnections.SelectGlassByGlassIdOrderIdFrameIds("","",FrameBarcode);
    String flip=homeMapper.SelectFlipByFrameBarcode(FrameBarcode);
    for (north_glass_buffer1 north_glass_buffer1 : listAluminumFrame) {
      north_glass_buffer1.setstorageCage(homeMapper.SelectStorageGlassById(north_glass_buffer1.getbarcode()));
@@ -299,47 +316,12 @@
  // 查询出片队列数据
  @PostMapping("/SelectProductionqueue")
  public Result SelectProductionqueue() {
  public Result SelectProductionqueue() throws SQLException {
    List<Out_slice> listoutslice = homeMapper.SelectProductionqueue();
    for (Out_slice out_slice : listoutslice) {
      out_slice.setnorth_glass_buffer1s(homeMapper.SelectBoxNo(out_slice.getGlassId()));
      out_slice.setnorth_glass_buffer1s(jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(out_slice.getGlassId(), "", ""));
      out_slice.setstorageCage(homeMapper.SelectStorageGlassById(out_slice.getGlassId()));
    }
    //HashMap<String,List<Out_slice>> map=new HashMap<String,List<Out_slice>>();
    // HashMap map=new HashMap<>();
    // for (Out_slice out_slice : listoutslice) {
    //   String key_=out_slice.getState()+"-";
    //   if (map.get(key_)==null) {
    //     List<Out_slice> lists=new ArrayList<Out_slice>();
    //     lists.add(out_slice);
    //     map.put(key_, lists);
    //   }else{
    //     List<Out_slice> lists=(List<Out_slice>)map.get(key_);
    //     lists.add(out_slice);
    //     map.put(key_,lists);
    //   }
    // }
    // System.out.println(map);
    // List<Out_slice> listskey=(List<Out_slice>)map.get("1-");
    // List<Out_slice> list=new ArrayList<Out_slice>();
    // for (Out_slice out_slice : listskey) {
    //   if (list.isEmpty()) {
    //     list.add(out_slice);
    //   }else{
    //     for (int i=0;i<list.size();i++) {
    //       Out_slice out_slice2=list.get(i);
    //       if(out_slice.getID()>out_slice2.getID()){
    //         continue;
    //       }else{
    //         list.add(i,out_slice2);
    //       }
    //     }
    //   }
    // }
    //Collections.sort(listoutslice,new MultiFieldComparator());
    Map<String, Object> maps = new HashMap<>();
    maps.put("listoutslice", listoutslice);
    return Result.success(maps);
springboot-vue3/src/main/java/com/example/springboot/entity/north_glass_buffer1.java
@@ -9,7 +9,7 @@
    private double glasslength;//玻璃宽
    private double glassheight;//玻璃高
    private double glasslengthmm;//玻璃宽mm
    private double glassheightmm;//玻璃高mm
    private double glassheightmm;
    private String glassoutside;//
    private String glassinside;//
@@ -101,8 +101,8 @@
        this.glasslengthmm = glasslengthmm;
    }
    public Double glassheightmm() {
        return glassheightmm;
    public Double getglassheightmm() {
        return glasslengthmm;
    }
    public void setglassheightmm(Double glassheightmm) {
        this.glassheightmm = glassheightmm;
springboot-vue3/src/main/java/com/example/springboot/mapper/SpianMapper.java
@@ -15,7 +15,7 @@
public interface SpianMapper {
    //判断相邻笼子是否有空格  
    @Select("select COUNT(if(a.state1=0,cell,null))as cell,ROUND(id/2)as id from (select *,max(state)as state1 from storage_cage a  GROUP BY cage,cell)as a where (a.cage=#{cage1}-1 or a.cage=#{cage1}+1)and if(a.cage<6,a.cage>0 and a.cage<6,a.cage>5) GROUP BY cage ORDER BY cell desc LIMIT 1")
    @Select("select COUNT(if(a.state1=0,cell,null))as cell,ROUND(id/2)as id from (select *,max(state)as state1 from storage_cage a  GROUP BY cage,cell)as a where (a.cage=#{cage1}-1 or a.cage=#{cage1}+1)and if(a.cage<6,a.cage>0 and a.cage<6,a.cage>5) and disabled=0 GROUP BY cage ORDER BY cell desc LIMIT 1")
     int selectCage(int  cage1);
     
     //@Select("(select*from storage_cage as a  where a.state=0 and cage%2=0 ORDER BY id LIMIT 1)union (select a.* from storage_cage a inner join  (select cage,if(shu2=1,shu3,shu5) as gezi from ( select  cage, count(case when state1=1 and state2=0 then cell else null end)as shu1,  count(case when state1=0 then cell else null end) as shu2, min(case when state1=1 and state2=0 then cell else null end) as shu3, min(case when state1=0 then cell else null end) as shu4, min(case when state1=0 or state2=0 then cell else null end) as shu5 from  (select *,max(state) as state1,min(state) as state2 from storage_cage group by cage,cell) as a where  cage%2!=0  GROUP BY cage HAVING shu2>1 or (shu2=1 and shu1>0)  ) as sss limit 1)as b on a.cage=b.cage and a.cell=b.gezi and a.state=0 order by tier limit 1) ORDER BY id LIMIT 1;")
@@ -26,29 +26,27 @@
     @Select("select state from storage_cage where  cage=#{cage} and cell=#{cell} and tier=1;")
     int selectcell(int cage,int cell);
     //判断该笼子是否有合适宽度空格
     @Select("select cage,cell,tier,id,ROUND(id/2)as prcId,width from storage_cage where cage=#{cage1} and cell=#{cell} and state=0 and width>=#{width} ORDER BY cell asc,tier asc LIMIT 1")
     @Select("select cage,cell,tier,id,ROUND(id/2)as prcId,width from storage_cage where cage=#{cage1} and cell=#{cell} and state=0 and disabled=0 and width>=#{width} ORDER BY cell asc,tier asc LIMIT 1")
     StorageCage selectCage1(int  cage1,int cell,double width);
     //判断笼子内玻璃数
     @Select("select COUNT(tier)as tier from storage_cage where  cage=#{cage} and cell=#{cell} and state=1;")
     int selectsum(int cage,int cell);
     //完成进片中的玻璃状态
     @Update("update storage_cage set state=#{state} where glass_id=#{glassid};")
     void UpdateCageOver(String glassid,int state);
    //@Update("update longzi set glass_id = #{glass_id}, width = #{width}, state = #{state} where cell = #{cell}")
    @Update("update longzi set glass_id =123, width =1600, state =1 where cell =24")
     void  update();
     //获取玻璃信息
     @Select("select ordernumber as ordernumber,glasslength_mm as glasslengthmm,barcode from north_glass_buffer1 where barcode=#{glassid}")
     north_glass_buffer1 selectGlass(String glassid);
    
    @Insert("insert into storage_task(task_type,task_state,shelf_rack,load_rack)values(#{storage_task},#{task_state},#{shelf_rack},#{load_rack})")
     void insert(StorageTask storageTask);
    //出片任务查询
    @Select("select COUNT(order_id)order_id,cage,cell,glasswidth,tier,ROUND(id/2)as prcId,glass_id from storage_cage a where a.order_id=#{orderId} GROUP BY cage,cell ORDER BY cage desc,order_id desc,cell desc,glasswidth desc limit 1")
    @Select("select COUNT(order_id)order_id,cage,cell,glasswidth,tier,ROUND(id/2)as prcId,glass_id from storage_cage a where a.order_id=#{orderId} and disabled=0 and state=1 GROUP BY cage,cell ORDER BY cage desc,order_id desc,cell desc,glasswidth desc limit 1")
     StorageCage selectOut(String  orderId);
    // @Select("select cage,cell,tier,glasswidth,ROUND(id/2)as prcId,id,glass_id from storage_cage as a where a.order_id=#{orderId} and state=1 order by cage desc,tier desc,cell desc LIMIT 1")
    //  StorageCage selectOut(String  orderId);
    //按玻璃ID出片任务查询
    @Select("select cage,cell,tier,glasswidth,ROUND(id/2)as prcId,id from storage_cage as a where a.glass_id=#{glassid} and state=1 order by cage desc,tier desc,cell desc LIMIT 1")
    @Select("select cage,cell,tier,glasswidth,ROUND(id/2)as prcId,id from storage_cage as a where a.glass_id=#{glassid} and state=1 and disabled=0 order by cage desc,tier desc,cell desc LIMIT 1")
     StorageCage selectOut2(String  glassid);
    //判断出片为1时,是否可直接出片
@@ -91,8 +89,8 @@
    @Update("update storage_task set task_state=#{state} where task_type=#{type} and task_state=0;")
    void Updatetask(int state,int type);
    //修改任务表
    @Update("update storage_task set task_state=1 where (task_type=1 or task_type=2) and task_state=0;")
    void UpdatetaskOut();
    @Update("update storage_task set task_state=1 where (task_type=1 or task_type=2) and task_state=0 and glass_id=#{glassid};")
    void UpdatetaskOut(String glassid);
    //查询按订单出片
    @Select("select order_id state from order_out where state=0")
    String  SelectOrderout();
@@ -108,13 +106,18 @@
    //根据笼子格子层数获取玻璃id
     @Select("select glass_id from storage_cage where cage=#{cage} and cell=#{cell} and tier=2;")
     String SelectGlassid(int cage,int cell);
     //根据笼子格子层数获取玻璃id
     //判断有几块玻璃还在出片中
     @Select("SELECT COUNT(*) FROM `storage_cage` where state=3;")
     Integer Selectoutstate();
     //添加任务序列
     //获取进片队列id
     @Insert("update queue set glassid=#{glassid},width=#{width} where type=#{type};")
     void insertqueue(String glassid,int type,double width);
     //完成进片队列任务
     @Update("update queue set state=#{state} where glassid=#{glassid};")
     void overqueue(String glassid,int state);
     //更换任务队列
     @Update("update queue set state=#{state} where glassid=#{glassid} and type=#{type};")
     void overqueue2(String glassid,int state,int type);
     //获取任务序列
     @Select("select glassid,orderid,width,type from queue where state=#{state}")
     StorageCage SelectQueue(int state);
@@ -139,7 +142,7 @@
     //获取进片队列id
     @Select("select glassid from queue where type=1")
     String Selectqueueid();
     //获取进片队列是否有待出库
     //获取进片队列是否有待入库
     @Select("select state from queue where type=1")
     int Selectqueuestate();
     //判断铝框出片表是否有玻璃需要出
springboot-vue3/src/main/java/com/example/springboot/service/JdbcConnections.java
@@ -5,6 +5,8 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Component;
@@ -38,6 +40,72 @@
         conn.close();
         return glass;
    }
    public  north_glass_buffer1 SelectGlassByGlassIdOrderIdFrameId(String glassid,String orderid,String frameid) throws SQLException {
        conn = getConn();
        north_glass_buffer1 north_glass_buffer1s=new north_glass_buffer1();
        String sql = "select * from north_glass_buffer1 where barcode=? or ordernumber=? or FrameBarcode=?";
         ps = conn.prepareStatement(sql);
         ps.setString(1, glassid);
         ps.setString(2, orderid);
         ps.setString(3, frameid);
         rs= ps.executeQuery();
         while (rs.next()) {
            north_glass_buffer1s.setId(rs.getInt("Id"));
            north_glass_buffer1s.setordernumber(rs.getString("ordernumber"));
            north_glass_buffer1s.setlistnumber(rs.getString("listnumber"));
            north_glass_buffer1s.setboxnumber(rs.getString("boxnumber"));
            north_glass_buffer1s.setbarcode(rs.getString("barcode"));
            north_glass_buffer1s.setglasslength(rs.getDouble("glasslength"));
            north_glass_buffer1s.setglassheight(rs.getDouble("glassheight"));
            north_glass_buffer1s.setglasslengthmm(rs.getDouble("glasslength_mm"));
            north_glass_buffer1s.setglassheightmm(rs.getDouble("glassheight_mm"));
            north_glass_buffer1s.setitemtype(rs.getString("itemtype"));
            north_glass_buffer1s.setslotnumber(rs.getString("slotnumber"));
            north_glass_buffer1s.setdatemodified(rs.getString("datemodified"));
            north_glass_buffer1s.setdatecreated(rs.getString("datecreated"));
            north_glass_buffer1s.setFrameBarcode(rs.getString("FrameBarcode"));
         }
        //  conn.close();
         return north_glass_buffer1s;
    }
    public  List<north_glass_buffer1> SelectGlassByGlassIdOrderIdFrameIds(String glassid,String orderid,String frameid) throws SQLException {
        conn = getConn();
        // north_glass_buffer1 glass=new north_glass_buffer1();
        List<north_glass_buffer1> glass=new ArrayList<north_glass_buffer1>();
        String sql = "select * from north_glass_buffer1 where barcode=? or ordernumber=? or FrameBarcode=?";
         ps = conn.prepareStatement(sql);
         ps.setString(1, glassid);
         ps.setString(2, orderid);
         ps.setString(3, frameid);
         rs= ps.executeQuery();
         while (rs.next()) {
            north_glass_buffer1 north_glass_buffer1s=new north_glass_buffer1();
            north_glass_buffer1s.setId(rs.getInt("Id"));
            north_glass_buffer1s.setordernumber(rs.getString("ordernumber"));
            north_glass_buffer1s.setlistnumber(rs.getString("listnumber"));
            north_glass_buffer1s.setboxnumber(rs.getString("boxnumber"));
            north_glass_buffer1s.setbarcode(rs.getString("barcode"));
            north_glass_buffer1s.setglasslength(rs.getDouble("glasslength"));
            north_glass_buffer1s.setglassheight(rs.getDouble("glassheight"));
            north_glass_buffer1s.setglasslengthmm(rs.getDouble("glasslength_mm"));
            north_glass_buffer1s.setglassheightmm(rs.getDouble("glassheight_mm"));
            north_glass_buffer1s.setitemtype(rs.getString("itemtype"));
            north_glass_buffer1s.setslotnumber(rs.getString("slotnumber"));
            north_glass_buffer1s.setdatemodified(rs.getString("datemodified"));
            north_glass_buffer1s.setdatecreated(rs.getString("datecreated"));
            north_glass_buffer1s.setFrameBarcode(rs.getString("FrameBarcode"));
            glass.add(north_glass_buffer1s);
         }
        //  conn.close();
         return glass;
    }
    /**
     * 1. 加载驱动
     * 2. 获取连接    conn
springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java
@@ -22,8 +22,6 @@
    private SpianMapper spianMapper;
    // @GetMapping("/all")
    // 进片任务,传订单id
    // 按订单优先进片
    public Short selectAll(String glassid) {
        int cage1;
@@ -96,6 +94,7 @@
                    spianMapper.UpdataAddCage1(widths, cage1, cells);// 减少格子宽度
                    spianMapper.Inserttask(0, 0, 1000, ids, glassid.toString());// 新增任务
                    S7control.getinstance().WriteWord(adddresslist, datas);
                }else{
                 // 数据库修改笼子表新增一条玻璃
                spianMapper.UpdataAddCage(orderids.toString(), glassid, widths, cage1, cells, ids, 2);
@@ -105,7 +104,7 @@
                // S7control.getinstance().WriteByte("DB105.16",glassid);
                }
                outmesid(glassid,"DB105.20");
                return (200);
            }
@@ -157,10 +156,12 @@
                    ids = cages1.getId();// 数据库ID
                    cells = cages1.getCell();// 格子号
                    prcid = cages1.getPrcId();// 传给prc的目标地id
                    String glassid="";
                    // 数据库修改笼子表新增一条玻璃
                    for (int i = 2; i > 0; i--) {
                        north_glass_buffer1 qglass = spianMapper.SelectQueueGlass(i);
                        width = qglass.getglasslengthmm();// 格子剩余宽度
                        glassid=qglass.getbarcode();
                        spianMapper.UpdataAddqueCage(qglass.getordernumber(), qglass.getbarcode(), width, cage1, cells, i,
                                1);
                        spianMapper.UpdataAddCage1(width, cage1, cells);// 减少格子宽度
@@ -172,7 +173,7 @@
                    datas.add((short) 0);
                    datas.add((short) 1);
                    S7control.getinstance().WriteWord(adddresslist, datas);
                    outmesid(glassid,"DB105.20");
                    return (200);
                }
@@ -220,6 +221,7 @@
                        spianMapper.UpdataAddCage(orderid, glassid, widths, cage1, cells, ids, 2);
                        spianMapper.UpdataAddCage1(widths, cage1, cells);// 减少格子宽度
                        spianMapper.Inserttask(0, 0, 1000, ids, glassid.toString());// 新增任务
                        outmesid(glassid,"DB105.20");
                        // S7control.getinstance().WriteWord(adddresslist, datas);
                        break;
                        // S7control.getinstance().WriteByte("DB105.16",glassid);
@@ -241,10 +243,10 @@
        // spianMapper.UpdatetaskOut(); //完成上一次出片或者调度任务,改到plchold里,出片或调度任务完成立即改变结束任务;
        // 定义PRC数据传送数组
        List<String> adddresslist = new ArrayList<>();
        adddresslist.add("DB105.6");// 出片车起始位置
        adddresslist.add("DB105.8");// 出片车目标位置
        adddresslist.add("DB105.10");// 出片笼玻璃数
        adddresslist.add("DB105.14");// 出片车启动 1为启动
        adddresslist.add("DB105.10");// 出片车起始位置
        adddresslist.add("DB105.12");// 出片车目标位置
        adddresslist.add("DB105.14");// 出片笼玻璃数
        adddresslist.add("DB105.18");// 出片车启动 1为启动
        List<Short> datas = new ArrayList<>();
        // 获取优先出片的位置
        StorageCage cageout = spianMapper.selectOut(orderid);
@@ -291,7 +293,7 @@
                spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 3);// 清除格子玻璃信息
                spianMapper.Inserttask(1, 0, cageout.getId(), 1000, orderid);// 新增任务
                S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务
                outmesid(glassid);// 派发出片ID
                outmesid(glassid,"DB105.34");// 派发出片ID
                if (pd != null) {
                    cage = pd.getCage();
                    cell = pd.getCage();
@@ -352,7 +354,7 @@
                        // 传输mes数据,坐标,数据
                        S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务
                        System.out.println(datas);
                        outmesid(glassids);// 派发调拨玻璃ID
                        outmesid(glassids,"DB105.34");// 派发调拨玻璃ID
                        return Result.success(cagecell); // 结束
                    } else {// 笼子号大于5时
@@ -379,7 +381,7 @@
                        // 传输mes数据,坐标,数据
                        S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务
                        outmesid(glassids);// 派发调拨玻璃ID
                        outmesid(glassids,"DB105.34");// 派发调拨玻璃ID
                        return Result.success(cagecell); // 结束
                    }
@@ -392,7 +394,6 @@
    
    public Short selectout2(String glassid) {
        // spianMapper.UpdatetaskOut(); //完成上一次出片或者调度任务,改到plchold里,出片或调度任务完成立即改变结束任务;
        // 定义PRC数据传送数组
        List<String> adddresslist = new ArrayList<>();
        char[] a=glassid.toCharArray();
@@ -436,7 +437,7 @@
                spianMapper.UpdateDBCage2(cage, cell);// 清除内片数据
            }
            S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务
            outmesid(glassid);// 派发出片ID
            outmesid(glassid,"DB105.34");// 派发出片ID
            return (200);// 结束
        } else {
@@ -449,7 +450,7 @@
                datas.add((short) 1000);
                datas.add((short) 1);
                datas.add((short) 1);
                outmesid(glassid);// 派发出片ID
                outmesid(glassid,"DB105.34");// 派发出片ID
                spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid);// 新增任务
                spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度
                spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 3);// 清除格子玻璃信息
@@ -486,7 +487,7 @@
                    // 传输mes数据,坐标,数据
                    S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务
                    outmesid(glassids);// 派发调拨玻璃ID
                    outmesid(glassids,"DB105.34");// 派发调拨玻璃ID
                    return (200); // 结束
                } else {// 笼子号大于5时
@@ -514,7 +515,7 @@
                    // 传输mes数据,坐标,数据
                    S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务
                    outmesid(glassids);// 派发调拨玻璃ID
                    outmesid(glassids,"DB105.34");// 派发调拨玻璃ID
                    return (200);// 结束
                }
@@ -522,8 +523,8 @@
        }
    }
    //派发调拨任务玻璃id
    public void outmesid(String glassid) {
    //派发任务玻璃id
    public void outmesid(String glassid,String address) {
        //System.out.println("outmesid:" + glassid);
        List<Byte> glassidlist = new ArrayList();
        char ds[]=glassid.toCharArray();
@@ -532,7 +533,7 @@
        }
        byte[] bytes = Bytes.toArray(glassidlist);
        System.out.println("outmesidbytes:" + bytes.length);
        S7control.getinstance().WriteByte("DB105.34", bytes);// 派发出片id
        S7control.getinstance().WriteByte(address, bytes);// 派发出片id
    }
    //获取地址内的玻璃id转字符串
    public StringBuilder queGlassid(String address) {
@@ -556,4 +557,10 @@
        String s = new String(bytes, StandardCharsets.UTF_8);
        return s.toCharArray();
    }
    //判断集合里是否为1
    public  boolean listbool(String address) {
       List<Short> list = S7control.getinstance().ReadWord(address, 1);//返回为ture时为1
       boolean listbool = list.contains((short) 1);
        return listbool;
    }
}