| | |
| | | import com.example.springboot.service.JdbcConnections; |
| | | import com.example.springboot.service.SpianService; |
| | | import com.example.springboot.entity.Glass; |
| | | import com.example.springboot.entity.north_glass_buffer1; |
| | | import com.example.springboot.mapper.AlarmMapper; |
| | | import com.example.springboot.mapper.SpianMapper; |
| | | |
| | |
| | | |
| | | @Override |
| | | public void run() { |
| | | boolean inglassbegin=false; |
| | | boolean outglassbegin=false; |
| | | boolean inglassbegin = false; |
| | | boolean outglassbegin = false; |
| | | while (this != null) { |
| | | try { |
| | | |
| | |
| | | spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class); |
| | | jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class); |
| | | |
| | | spianService.selectout("1145"); |
| | | //spianService.selectAll2(); |
| | | //增加队列表数据 |
| | | //spianMapper.insertqueue("1",1,1500); |
| | | |
| | | 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 { |
| | | |
| | | // Glass glass = jdbcConnections.selectGlass(112); |
| | | // north_glass_buffer1 glass = jdbcConnections.selectGlass(112); |
| | | |
| | | // // System.out.println(glass.getOrderId()); |
| | | // // System.out.println(glass.getOrderId()); |
| | | // } catch (SQLException e) { |
| | | // // TODO Auto-generated catch block |
| | | // e.printStackTrace(); |
| | | // // TODO Auto-generated catch block |
| | | // e.printStackTrace(); |
| | | // } |
| | | |
| | | //判断进片请求 |
| | | |
| | | // 判断进片请求 |
| | | 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);// 获取进片车任务是否启动 |
| | | //测试启动自定义prc值 |
| | | // List<Short> datas1List=new ArrayList<>(); |
| | | // datas1List.add((short)1); |
| | | // List<Short> datas1ListState=new ArrayList<>(); |
| | | // datas1List.add((short)0); |
| | | // List<Short> datas1ListState2=new ArrayList<>(); |
| | | // datas1List.add((short)0); |
| | | |
| | | |
| | | if (datas1List != null && datas1ListState != null) { |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | | 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", 1); |
| | | // 获取已下发的进片id 与plc请求的id作比较 |
| | | byte[] writedglassidbytes = S7control.getinstance().ReadByte("DB105.16", 13); |
| | | if (writedglassidbytes != null) { // |
| | | // 获取玻璃id |
| | | for (byte iditem : writedglassidbytes) { |
| | | for (byte iditem : writedglassidbytes) { |
| | | writedstrId.append(iditem); |
| | | } |
| | | } |
| | | // 获取进片id |
| | | byte[] datas1ListID = S7control.getinstance().ReadByte("DB106.26", 1); |
| | | byte[] datas1ListID = S7control.getinstance().ReadByte("DB106.26", 13); |
| | | if (datas1ListID != null) { |
| | | // 获取玻璃id |
| | | for (byte list1 : datas1ListID) { |
| | | for (byte list1 : datas1ListID) { |
| | | strId.append(list1); |
| | | |
| | | |
| | | } |
| | | if(!writedstrId.toString().equals(strId.toString())) //已经下发的id与plc请求的id不一样时,认为不是重复的任务,才执行下发任务指令 |
| | | if (!writedstrId.toString().equals(strId.toString())) // 已经下发的id与plc请求的id不一样时,认为不是重复的任务,才执行下发任务指令 |
| | | { |
| | | |
| | | int glasslimit=1;//判断是否是多片上片 |
| | | if(glasslimit==1){ |
| | | |
| | | int glasslimit = 1;// 判断是否是多片上片 |
| | | if (glasslimit == 1) { |
| | | spianService.selectAll(strId.toString()); |
| | | }else{ |
| | | } else { |
| | | spianService.selectAll(strId.toString()); |
| | | } |
| | | S7control.getinstance().WriteByte("DB105.16",datas1ListID);//派发进片id |
| | | |
| | | } |
| | | S7control.getinstance().WriteByte("DB105.16", datas1ListID);// 派发进片id |
| | | |
| | | } |
| | | //spianService.selectAll(Short.parseShort(strId.toString())); |
| | | // 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 |
| | | } |
| | | // 下发任务后将任务启动改为0 |
| | | if (exist1 == false) { // 进片车忙碌时 |
| | | if (exist2 == true) { // 任务已启动时 |
| | | S7control.getinstance().WriteWord("DB105.12", (short) 0);// 进片任务启动改为0 |
| | | } |
| | | } |
| | | } |
| | | |
| | | //spianService.selectAll((short) 111); |
| | | |
| | | |
| | | List<Short> outlist = S7control.getinstance().ReadWord("DB106.20", 1); // 出片车状态 |
| | | List<Short> outlist1 = S7control.getinstance().ReadWord("DB105.14", 1); // 出片任务是否启动 |
| | | StringBuilder writedstrIdOut=new StringBuilder(); |
| | | //获取已下发的出片id |
| | | byte[] writedglassidbytesOut = S7control.getinstance().ReadByte("DB105.30", 1); |
| | | if (writedglassidbytesOut != null) { |
| | | // 获取玻璃id |
| | | for (byte iditem : writedglassidbytesOut) { |
| | | writedstrIdOut.append(iditem); |
| | | } |
| | | } |
| | | boolean outstate=false;//出片车空闲判断 |
| | | boolean outstate1=false;//出片车任务是否启动 |
| | | if (outlist != null&&outlist1!=null) { |
| | | // 判断按订单出片 |
| | | outstate = outlist.contains((short) 0);//出片车空闲判断 |
| | | outstate1 = outlist1.contains((short) 1);//出片车任务是否启动 |
| | | |
| | | Glass glass=spianMapper.SelectDBOut();//判断是否有调拨后的出片任务未完成 |
| | | |
| | | if(!outglassbegin&!outstate)//当任务还未开始,且出片车不空闲时,任务状态改为开始 |
| | | { |
| | | outglassbegin=true; |
| | | } |
| | | if(outglassbegin&outstate)//当任务开始且出片车空闲时 |
| | | { |
| | | outglassbegin=false; |
| | | spianMapper.UpdatetaskOut(); //完成上一次出片或者调度任务 |
| | | spianMapper.UpdataAddCageState(0,3); |
| | | } |
| | | |
| | | if(outstate== true &glass.getGlassId()!=null){ //当出片车空闲且有出片任务待完成时 |
| | | if(glass.getId()==2&!writedstrIdOut.toString().equals(glass.getGlassId().toString())){ |
| | | spianService.selectout2(glass.getGlassId().toString()); |
| | | } |
| | | } |
| | | if(outstate==false){//下发任务后将任务启动改为0//出片车空闲判断 |
| | | if(outstate1==true){ |
| | | S7control.getinstance().WriteWord("DB105.14",(short)0);//出片任务启动改为0 |
| | | } |
| | | } |
| | | StringBuilder writedstrIdOut = new StringBuilder(); |
| | | // 获取已下发的出片id |
| | | byte[] writedglassidbytesOut = S7control.getinstance().ReadByte("DB105.30", 13); |
| | | if (writedglassidbytesOut != null) { |
| | | // 获取玻璃id |
| | | for (byte iditem : writedglassidbytesOut) { |
| | | writedstrIdOut.append((char) iditem); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | if (outstate == true) { // 出片车状态空闲时 |
| | | Integer state=spianMapper.Selectoutstate(); |
| | | String orderid = spianMapper.SelectOrderout(); |
| | | |
| | | if (orderid != null &&state==0) { |
| | | spianService.selectout(orderid); |
| | | } |
| | | // 获取BO1数据 |
| | | StringBuilder queueid1 = spianService.queGlassid("DB103.DBB32"); |
| | | // 获取BO2数据 |
| | | StringBuilder queueid2 = spianService.queGlassid("DB103.DBB46"); |
| | | if (queueid1 != null) { |
| | | // 写入B01的数据到上片队列表 |
| | | spianMapper.insertqueue(queueid1.toString(), 1, 0); |
| | | } |
| | | if (queueid2 != null) { |
| | | // 写入B02的数据到上片队列表 |
| | | spianMapper.insertqueue(queueid2.toString(), 2, 0); |
| | | } |
| | | |
| | | // 出片任务//////////////////////////////// |
| | | boolean outstate = false;// 出片车空闲判断 |
| | | boolean outstate1 = false;// 出片车任务是否启动 |
| | | if (outlist != null && outlist1 != null) { |
| | | // 判断按订单出片 |
| | | outstate = outlist.contains((short) 0);// 出片车空闲判断 |
| | | outstate1 = outlist1.contains((short) 1);// 出片车任务是否启动 |
| | | |
| | | north_glass_buffer1 glass = spianMapper.SelectDBOut();// 判断是否有调拨后的出片任务未完成 |
| | | |
| | | if (!outglassbegin & !outstate)// 当任务还未开始,且出片车不空闲时,任务状态改为开始 |
| | | { |
| | | outglassbegin = true; |
| | | } |
| | | if (outglassbegin & outstate)// 当任务开始且出片车空闲时 |
| | | { |
| | | outglassbegin = false; |
| | | spianMapper.UpdatetaskOut(); // 完成上一次出片或者调度任务 |
| | | spianMapper.UpdataAddCageState(0, 3);// 将出片中的格子状态改成0 |
| | | } |
| | | |
| | | |
| | | if (outstate == true & glass.getbarcode() != null) { // 当出片车空闲且有出片任务待完成时 |
| | | // 判断有两个出片或调拨任务时并且出片id和未完成的出片任务id不一样时执行出片 |
| | | if (glass.getId() == 2 & !writedstrIdOut.toString().equals(glass.getbarcode().toString())) { |
| | | spianService.selectout2(glass.getbarcode().toString()); |
| | | } |
| | | } |
| | | // 判断当前是否有未执行的任务 |
| | | int outnum = spianMapper.SelectOutSliceshu(); |
| | | if (outnum == 0) { |
| | | // 判断铝框出片队列表是否有待出片的玻璃 |
| | | String outglassid = spianMapper.SelectOutSlice(); |
| | | if (outglassid != null) { |
| | | spianService.selectout2(outglassid); |
| | | } |
| | | } |
| | | if (outstate == false) {// 下发任务后将任务启动改为0//出片车空闲判断 |
| | | if (outstate1 == true) { |
| | | S7control.getinstance().WriteWord("DB105.14", (short) 0);// 出片任务启动改为0 |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (outstate == true) { // 出片车状态空闲时 |
| | | Integer state = spianMapper.Selectoutstate(); |
| | | String orderid = spianMapper.SelectOrderout(); |
| | | |
| | | if (orderid != null && state == 0) { |
| | | spianService.selectout(orderid); |
| | | } |
| | | } |
| | | |
| | | // 查询数据库 |
| | | // 推送到前端 |
| | |
| | | // |
| | | System.out.println("启动完成"); |
| | | |
| | | // new PlcHold().start(); |
| | | new PlcHold().start(); |
| | | |
| | | new Plcaction().start(); |
| | | |
| | |
| | | private String barcode;//玻璃id |
| | | private double glasslength;//玻璃宽 |
| | | private double glassheight;//玻璃高 |
| | | private double glasslength_mm;//玻璃宽mm |
| | | private double glassheight_mm;//玻璃高mm |
| | | private double glasslengthmm;//玻璃宽mm |
| | | private double glassheightmm;//玻璃高mm |
| | | |
| | | private String glassoutside;// |
| | | private String glassinside;// |
| | | private String glassbetween;// |
| | | private String itemtype;// |
| | | private String slotnumber;// |
| | | private String datemodified;// |
| | | private String datecreated;// |
| | | private String FrameBarcode;// |
| | | |
| | | public Integer id() { |
| | | return id; |
| | |
| | | this.glassheight = glassheight; |
| | | } |
| | | |
| | | public Double getglasslength_mm() { |
| | | return glasslength_mm; |
| | | public Double getglasslengthmm() { |
| | | return glasslengthmm; |
| | | } |
| | | public void setglasslength_mm(Double glasslength_mm) { |
| | | this.glasslength_mm = glasslength_mm; |
| | | public void setglasslengthmm(Double glasslengthmm) { |
| | | this.glasslengthmm = glasslengthmm; |
| | | } |
| | | |
| | | public Double glassheight_mm() { |
| | | return glassheight_mm; |
| | | public Double glassheightmm() { |
| | | return glassheightmm; |
| | | } |
| | | public void setglassheight_mm(Double glassheight_mm) { |
| | | this.glassheight_mm = glassheight_mm; |
| | | public void setglassheightmm(Double glassheightmm) { |
| | | this.glassheightmm = glassheightmm; |
| | | } |
| | | |
| | | public String getitemtype() { |
| | | return itemtype; |
| | | } |
| | | public void setitemtype(String itemtype) { |
| | | this.itemtype = itemtype; |
| | | } |
| | | public String getslotnumber() { |
| | | return slotnumber; |
| | | } |
| | | public void setslotnumber(String slotnumber) { |
| | | this.slotnumber = slotnumber; |
| | | } |
| | | public String getdatemodified() { |
| | | return datemodified; |
| | | } |
| | | public void setdatemodified(String datemodified) { |
| | | this.datemodified = datemodified; |
| | | } |
| | | public String getdatecreated() { |
| | | return datecreated; |
| | | } |
| | | public void setdatecreated(String datecreated) { |
| | | this.datecreated = datecreated; |
| | | } |
| | | public String getFrameBarcode() { |
| | | return FrameBarcode; |
| | | } |
| | | public void setFrameBarcode(String FrameBarcode) { |
| | | this.FrameBarcode = FrameBarcode; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.example.springboot.entity.Glass; |
| | | import com.example.springboot.entity.StorageCage; |
| | | import com.example.springboot.entity.StorageTask; |
| | | |
| | | import com.example.springboot.entity.north_glass_buffer1; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | //获取订单号排序的空订单笼子 |
| | | @Select("select a.cage,COUNT(if(a.order_id=#{orderids},a.order_id,null))as orderid,b.shu,c.shu2,a.cell,min(a.state)as state1 from storage_cage a left join (select COUNT(*)shu,cage from storage_cage where order_id=#{orderids} GROUP BY cage)as b on a.cage=b.cage left join(select cage ,COUNT(glass_id)as shu2 from storage_cage GROUP BY cage)c on a.cage=c.cage where (order_id=#{orderids} or ''='') GROUP BY cage,cell HAVING state1=0 ORDER BY shu desc,shu2,cage asc; ") |
| | | List<StorageCage> selectAll(String orderids); |
| | | |
| | | //获取判断该格子是否需要把外片推入内片位置 |
| | | @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 desc 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 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;") |
| | |
| | | @Update("update longzi set glass_id =123, width =1600, state =1 where cell =24") |
| | | void update(); |
| | | //获取玻璃信息 |
| | | @Select("select orderid,width from glass where glassid=#{glassid}") |
| | | Glass selectGlass(String glassid); |
| | | @Select("select orderid as ordernumber,width as glasslengthmm from glass where glassid=#{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); |
| | |
| | | @Update("update storage_cage set width=width-#{width} where cage=#{cage} and cell=#{cell};") |
| | | void UpdataAddCage1(double width,int cage,int cell); |
| | | //修改同笼子格子宽度 |
| | | |
| | | @Update("update storage_cage set state=#{state} where state=#{oldstate};") |
| | | void UpdataAddCageState(int state,int oldstate); |
| | | //修改同笼子格子宽度(出片) |
| | | @Update("update storage_cage set width=width+#{width} where cage=#{cage} and cell=#{cell};") |
| | | void UpdataOutCage1(double width,int cage,int cell); |
| | | //调拨更换笼子信息 |
| | | @Update("update storage_cage as a,(select*from storage_cage b where b.cage=#{cage} and b.cell=#{cell} and b.tier=2)as b set a.glass_id=b.glass_id,a.order_id=b.order_id,a.state=1,a.glasswidth=b.glasswidth where a.id=#{id1}") |
| | | void UpdateDBCage(int id1,int cage,int cell); |
| | | @Update("update storage_cage as a,(select*from storage_cage b where b.cage=#{cage} and b.cell=#{cell} and b.tier=#{tier})as b set a.glass_id=b.glass_id,a.order_id=b.order_id,a.state=1,a.glasswidth=b.glasswidth where a.id=#{id1}") |
| | | void UpdateDBCage(int id1,int cage,int cell,int tier); |
| | | // @Insert("insert into user(name, date, address, user_no) values (#{name}, #{date}, #{address}, #{userNo})") |
| | | // void insert (Spian spian); |
| | | //新增任务表 |
| | |
| | | @Update("update storage_cage set glass_id='',order_id='',state=0,glasswidth=0 where a.cage=#{cage} and a.cell=#{cell} and a.tier=1;") |
| | | void UpdateDBCage2(int cage,int cell); |
| | | //判断是否有调拨完后出片的任务 |
| | | @Select("select COUNT(*)as id,glass_id from storage_task where (task_type=1 or task_type=2) and task_state=0;") |
| | | Glass SelectDBOut(); |
| | | @Select("select COUNT(*)as id,glass_id as barcode from storage_task where (task_type=1 or task_type=2) and task_state=0;") |
| | | north_glass_buffer1 SelectDBOut(); |
| | | //根据笼子格子层数获取玻璃id |
| | | @Select("select glass_id from storage_cage where cage=#{cage} and cell=#{cell} and tier=2;") |
| | | String SelectGlassid(int cage,int cell); |
| | |
| | | @Select("select cage,cell,tier,id,ROUND(id/2)as prcId,width,max(state)state1 from storage_cage where cage=#{cage1} and cell=#{cell} and state=0 and width>=#{width} HAVING state1=0 ORDER BY cell asc,tier desc LIMIT 1") |
| | | StorageCage selectqueCage1(int cage1,int cell,double width); |
| | | //获取序列表的玻璃 |
| | | @Select("select glassid,orderid,width from queue where state=0 and type=#{type}") |
| | | Glass SelectQueueGlass(int type); |
| | | @Select("select glassid as barcode,orderid as ordernumber,width as glasslengthmm from queue where state=0 and type=#{type}") |
| | | north_glass_buffer1 SelectQueueGlass(int type); |
| | | //多片出库清除一整个空格 |
| | | @Update("update storage_cage set glass_id='',order_id='',glasswidth=0,width=2750,state=0 where cage=#{cage} and cell=#{cell}") |
| | | void UpdatequeOut(int cage,int cell); |
| | |
| | | @Select("select cage,cell,ROUND(id/2)as prcId,width,count(glass_id)shu from storage_cage where order_id=#{orderid} and (cage!=#{cage} or cell!=#{cell}) GROUP BY cage,cell HAVING shu=1 ORDER BY cage desc,cell desc limit 1") |
| | | StorageCage SelectQueout(String orderid,int cage,int cell); |
| | | //获取进片队列id |
| | | @Select("select glassid from queue where type=1 and state=0;") |
| | | @Select("select glassid from queue where type=1") |
| | | String Selectqueueid(); |
| | | //获取进片队列id |
| | | @Select("select state from queue where type=1") |
| | | String Selectqueuestate(); |
| | | } |
| | | //判断铝框出片表是否有玻璃需要出 |
| | | @Select("SELECT * FROM `out_slice` where state=0 or state=0 order by id limit 1;") |
| | | String SelectOutSlice(); |
| | | //判断铝框出片表是否有玻璃正在出片中 |
| | | @Select("SELECT count(*) FROM `out_slice` where state=1 or state=0 order by id limit 1;") |
| | | int SelectOutSliceshu(); |
| | | } |
| | | |
| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.example.springboot.entity.Glass; |
| | | import com.example.springboot.entity.north_glass_buffer1; |
| | | @Component |
| | | public class JdbcConnections { |
| | | /** |
| | |
| | | private static PreparedStatement ps = null; |
| | | private static ResultSet rs = null; |
| | | |
| | | public Glass selectGlass(int glassid) throws SQLException { |
| | | public north_glass_buffer1 selectGlass(int glassid) throws SQLException { |
| | | conn = getConn(); |
| | | Glass glass=new Glass(); |
| | | String sql = "select orderid from glass where glassid=?"; |
| | | north_glass_buffer1 glass=new north_glass_buffer1(); |
| | | String sql = "select ordernumber from north_glass_buffer1 where glassid=?"; |
| | | ps = conn.prepareStatement(sql); |
| | | ps.setInt(1, glassid); |
| | | rs= ps.executeQuery(); |
| | | while (rs.next()) { |
| | | glass.setOrderId(rs.getString("orderid")); |
| | | glass.setordernumber(rs.getString("ordernumber")); |
| | | } |
| | | conn.close(); |
| | | return glass; |
| | |
| | | package com.example.springboot.service; |
| | | |
| | | import java.lang.reflect.Array; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | import com.example.springboot.component.S7control; |
| | | import com.example.springboot.entity.Glass; |
| | | import com.example.springboot.entity.StorageCage; |
| | | import com.example.springboot.entity.north_glass_buffer1; |
| | | import com.example.springboot.mapper.SpianMapper; |
| | | import com.google.common.primitives.Bytes; |
| | | |
| | |
| | | double width; |
| | | double minwidth = 0; |
| | | |
| | | Glass glasslist = spianMapper.selectGlass(glassid); // 获取玻璃参数 |
| | | north_glass_buffer1 glasslist = spianMapper.selectGlass(glassid); // 获取玻璃参数 |
| | | if (glasslist == null) { |
| | | return (300); |
| | | } |
| | | double widths = glasslist.getwidth(); |
| | | String orderids = glasslist.getOrderId(); |
| | | double widths = glasslist.getglasslengthmm(); |
| | | String orderids = glasslist.getordernumber(); |
| | | |
| | | List<String> adddresslist = new ArrayList<>(); |
| | | adddresslist.add("DB105.0");// 进片车起始位置 |
| | |
| | | cells = cages1.getCell();// 格子号 |
| | | prcid = cages1.getPrcId();// 传给prc的目标地id |
| | | width = cages1.getWidth();// 格子剩余宽度 |
| | | widths = glasslist.getwidth(); |
| | | widths = glasslist.getglasslengthmm(); |
| | | |
| | | // 执行进片 |
| | | datas.add((short) 1000); |
| | | datas.add((short) prcid); |
| | | datas.add((short) prctier); |
| | | datas.add((short) 1); |
| | | // 数据库修改笼子表新增一条玻璃 |
| | | datas.add((short) 1); |
| | | //获取该格子内是否有玻璃 |
| | | int cellint=spianMapper.selectcell(cage1,cells); |
| | | if(cellint==1){ |
| | | //将外片玻璃的数据更新到内片 |
| | | spianMapper.UpdateDBCage(ids, cage1, cells,1); |
| | | //将新入的玻璃存入外片 |
| | | spianMapper.UpdataAddCage(orderids.toString(), glassid, widths, cage1, cells, ids-1, 2); |
| | | 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); |
| | | spianMapper.UpdataAddCage1(widths, cage1, cells);// 减少格子宽度 |
| | | spianMapper.Inserttask(0, 0, 1000, ids, glassid.toString());// 新增任务 |
| | | S7control.getinstance().WriteWord(adddresslist, datas); |
| | | |
| | | // S7control.getinstance().WriteByte("DB105.16",glassid); |
| | | } |
| | | |
| | | return (200); |
| | | |
| | | } |
| | |
| | | double widths = queGlass.getWidth(); |
| | | String orderids = queGlass.getOrderId(); |
| | | int num = spianMapper.SelectQueOrder(); |
| | | |
| | | if (num == 1) { |
| | | |
| | | // 获取订单相关度最高的笼子排序 |
| | |
| | | prcid = cages1.getPrcId();// 传给prc的目标地id |
| | | // 数据库修改笼子表新增一条玻璃 |
| | | for (int i = 2; i > 0; i--) { |
| | | Glass qglass = spianMapper.SelectQueueGlass(i); |
| | | width = qglass.getwidth();// 格子剩余宽度 |
| | | spianMapper.UpdataAddqueCage(qglass.getOrderId(), qglass.getGlassId(), width, cage1, cells, i, |
| | | north_glass_buffer1 qglass = spianMapper.SelectQueueGlass(i); |
| | | width = qglass.getglasslengthmm();// 格子剩余宽度 |
| | | spianMapper.UpdataAddqueCage(qglass.getordernumber(), qglass.getbarcode(), width, cage1, cells, i, |
| | | 1); |
| | | spianMapper.UpdataAddCage1(width, cage1, cells);// 减少格子宽度 |
| | | spianMapper.Inserttask(0, 0, 1000, ids, qglass.getGlassId().toString());// 新增任务 |
| | | spianMapper.Inserttask(0, 0, 1000, ids, qglass.getbarcode().toString());// 新增任务 |
| | | } |
| | | // 执行进片 |
| | | datas.add((short) 1000); |
| | |
| | | |
| | | } else { |
| | | for (int i = 2; i > 0; i--) { |
| | | Glass qglass = spianMapper.SelectQueueGlass(i); |
| | | String orderid = qglass.getOrderId().toString(); |
| | | String glassid = qglass.getGlassId(); |
| | | widths = qglass.getwidth(); |
| | | north_glass_buffer1 qglass = spianMapper.SelectQueueGlass(i); |
| | | String orderid = qglass.getordernumber().toString(); |
| | | String glassid = qglass.getbarcode(); |
| | | widths = qglass.getglasslengthmm(); |
| | | List<StorageCage> storageCage = spianMapper.selectAll(orderid); |
| | | if (storageCage == null) { |
| | | return (400); |
| | |
| | | cells = cages1.getCell();// 格子号 |
| | | prcid = cages1.getPrcId();// 传给prc的目标地id |
| | | width = cages1.getWidth();// 格子剩余宽度 |
| | | widths = qglass.getwidth(); |
| | | widths = qglass.getglasslengthmm(); |
| | | |
| | | // 执行进片 |
| | | datas.add((short) 1000); |
| | |
| | | datas.add((short) 1); |
| | | // 更换玻璃的笼子 |
| | | String glassids = spianMapper.SelectGlassid(cage, cell); // 获取被调拨的玻璃id |
| | | spianMapper.UpdateDBCage(ids, cage, cell);// 将原格子数据更新到新格子里 |
| | | spianMapper.UpdateDBCage(ids, cage, cell,2);// 将原格子数据更新到新格子里 |
| | | spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 减少新格子宽度 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度 |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 3);// 清除被调拨格子数据 |
| | |
| | | datas.add((short) 2); |
| | | datas.add((short) 1); |
| | | String glassids = spianMapper.SelectGlassid(cage, cell); // 获取被调拨的玻璃id |
| | | spianMapper.UpdateDBCage(ids, cage, cell);// 将原格子数据更新到新格子里 |
| | | spianMapper.UpdateDBCage(ids, cage, cell,2);// 将原格子数据更新到新格子里 |
| | | spianMapper.Inserttask(2, 0, cageout.getId(), ids, orderid);// 新增调度任务 |
| | | spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 减少新格子宽度 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度 |
| | |
| | | |
| | | } |
| | | |
| | | // @GetMapping("/all2") |
| | | |
| | | public Short selectout2(String glassid) { |
| | | // spianMapper.UpdatetaskOut(); //完成上一次出片或者调度任务,改到plchold里,出片或调度任务完成立即改变结束任务; |
| | | // 定义PRC数据传送数组 |
| | |
| | | spianMapper.UpdateDBCage2(cage, cell);// 清除内片数据 |
| | | } |
| | | S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务 |
| | | //outmesid(glassid);// 派发出片ID |
| | | outmesid(glassid);// 派发出片ID |
| | | |
| | | return (200);// 结束 |
| | | } else { |
| | |
| | | spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid);// 新增任务 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度 |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 3);// 清除格子玻璃信息 |
| | | //outmesid(glassid);// 派发出片ID |
| | | outmesid(glassid);// 派发出片ID |
| | | S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务 |
| | | |
| | | return (200);// 结束 |
| | |
| | | datas.add((short) 1); |
| | | // 更换玻璃的笼子 |
| | | String glassids = spianMapper.SelectGlassid(cage, cell); // 获取被调拨的玻璃id |
| | | spianMapper.UpdateDBCage(ids, cage, cell);// 将原格子数据更新到新格子里 |
| | | spianMapper.UpdateDBCage(ids, cage, cell,2);// 将原格子数据更新到新格子里 |
| | | spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 减少新格子宽度 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度 |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 3);// 清除被调拨格子数据 |
| | |
| | | String glassids = spianMapper.SelectGlassid(cage, cell); // 获取被调拨的玻璃id |
| | | spianMapper.Inserttask(2, 0, cageout.getId() + 1, ids, glassid);// 新增调度任务 |
| | | spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid);// 新增出片任务 |
| | | spianMapper.UpdateDBCage(ids, cage, cell);// 将原格子数据更新到新格子里 |
| | | spianMapper.UpdateDBCage(ids, cage, cell,2);// 将原格子数据更新到新格子里 |
| | | spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 减少新格子宽度 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度 |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 3);// 清除被调拨格子数据 |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | //派发调拨任务玻璃id |
| | | public void outmesid(String glassid) { |
| | | System.out.println("outmesid:" + glassid); |
| | | List<Byte> glassidlist = new ArrayList(); |
| | |
| | | System.out.println("outmesidbytes:" + bytes.length); |
| | | S7control.getinstance().WriteByte("DB105.30", bytes);// 派发出片id |
| | | } |
| | | |
| | | /*** 修改用户* @throws SQLException */ |
| | | // public static int updateUser(Glass user) throws SQLException {conn = |
| | | // getConn(); |
| | | // String sql = "update t_user set name=?,gender=?,age=?,score=?"+ " where |
| | | // id=?";ps = conn.prepareStatement(sql); |
| | | // ps.setString(1, user.getName());ps.setString(2, user.getGender()); |
| | | // ps.setInt(3, user.getAge());ps.setDouble(4, user.getScore());ps.setInt(5, |
| | | // user.getId());return ps.executeUpdate();} |
| | | // /*** 增加用户* @throws SQLException */ |
| | | // public static int insertUser(User user) throws SQLException { |
| | | // conn = getConn(); |
| | | // String sql = "insert into t_user(name,gender,age,score)"+ " values(?,?,?,?)"; |
| | | // ps = conn.prepareStatement(sql);ps.setString(1, |
| | | // user.getName());ps.setString(2, user.getGender()); |
| | | // ps.setInt(3, user.getAge());ps.setDouble(4, user.getScore());return |
| | | // ps.executeUpdate(); |
| | | // } |
| | | |
| | | //获取地址内的玻璃id转字符串 |
| | | public StringBuilder queGlassid(String address) { |
| | | StringBuilder writedstrIdOut = new StringBuilder(); |
| | | byte[] writedglassidbytesOut = S7control.getinstance().ReadByte(address, 13); |
| | | if (writedglassidbytesOut != null) { |
| | | // 获取玻璃id |
| | | for (byte iditem : writedglassidbytesOut) { |
| | | writedstrIdOut.append((char) iditem); |
| | | } |
| | | } |
| | | 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(); |
| | | } |
| | | } |