| | |
| | | package com.example.springboot.service; |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | 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{ |
| | | // 数据库修改笼子表新增一条玻璃 |
| | |
| | | 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); |
| | | } |
| | |
| | | return (400); |
| | | |
| | | } |
| | | |
| | | |
| | | public Short selectout2(String glassid) { |
| | | // 定义PRC数据传送数组 |
| | |
| | | spianMapper.UpdateDBCage1(cage, cell);// 将内片数据更新到外片里 |
| | | spianMapper.UpdateDBCage2(cage, cell);// 清除内片数据 |
| | | } |
| | | |
| | | System.out.println("出片任务|" + datas); |
| | | S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务 |
| | | outmesid(glassid,"DB105.34");// 派发出片ID |
| | | |
| | |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度 |
| | | spianMapper.UpdataGlassCageState(glassid,3);//更改笼子表的玻璃状态 |
| | | spianMapper.OverOutSlice(glassid,2);//完成出片队列任务 |
| | | System.out.println("出片任务|" + datas); |
| | | outmesid(glassid,"DB105.34");// 派发出片ID |
| | | S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务 |
| | | |
| | |
| | | spianMapper.UpdateDBCage(ids, cage, cell,2);// 将原格子数据更新到新格子里 |
| | | spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 减少新格子宽度 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度 |
| | | spianMapper.UpdataGlassCageState(glassids,3);//更改笼子表的玻璃状态 |
| | | //spianMapper.UpdataGlassCageState(glassids, 3);// 更改笼子表的玻璃状态 |
| | | spianMapper.Inserttask(2, 0, cageout.getId(), ids, glassid,2);// 新增调度任务 |
| | | //spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid);// 新增出片任务 |
| | | // 传输mes数据,坐标,数据 |
| | | System.out.println("出片任务|" + datas); |
| | | S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务 |
| | | |
| | | outmesid(glassids,"DB105.34");// 派发调拨玻璃ID |
| | |
| | | spianMapper.UpdateDBCage(ids, cage, cell,2);// 将原格子数据更新到新格子里 |
| | | spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 减少新格子宽度 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度 |
| | | spianMapper.UpdataGlassCageState(glassids,3);//更改笼子表的玻璃状态 |
| | | //spianMapper.UpdataGlassCageState(glassids, 3);// 更改笼子表的玻璃状态 |
| | | // 传输mes数据,坐标,数据 |
| | | System.out.println("出片任务|" + datas); |
| | | S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务 |
| | | |
| | | outmesid(glassids,"DB105.34");// 派发调拨玻璃ID |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | //派发任务玻璃id |
| | | public void outmesid(String glassid,String address) { |
| | | //System.out.println("outmesid:" + glassid); |
| | |
| | | System.out.println("outmesidbytes:" + bytes.length); |
| | | S7control.getinstance().WriteByte(address, bytes);// 派发出片id |
| | | } |
| | | |
| | | //获取地址内的玻璃id转字符串 |
| | | public StringBuilder queGlassid(String address,int count) { |
| | | StringBuilder writedstrIdOut = new StringBuilder(); |
| | |
| | | } |
| | | return writedstrIdOut; |
| | | } |
| | | |
| | | //char数组转化成bit数组 |
| | | public static byte[] toBytes(char[] chars) { |
| | | String s = new String(chars); |
| | | return s.getBytes(StandardCharsets.UTF_8); |
| | | } |
| | | |
| | | //bit数组转化成char数组 |
| | | public static char[] toChars(byte[] bytes) { |
| | | 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; |
| | | } |
| | | |
| | | //根据玻璃id完成在进行中的任务 |
| | | public void overtask(String glassid){ |
| | | spianMapper.UpdateCageOver(glassid, 0);// 更改笼子表出片状态 |
| | | spianMapper.UpdatetaskOut(glassid); // 完成上一次出片或者进片任务 |
| | | spianMapper.OverOutSlice(glassid, 2);// 完成出片队列任务 |
| | | spianMapper.UpdataGlassCage(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); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |