| | |
| | | |
| | | }, |
| | | selectTime () { |
| | | |
| | | //moment需要单独安转依赖,npm install moment |
| | | let sj1 = moment(this.shijian1).format('YYYY-MM-DD%20HH:mm'); |
| | | let sj2 = moment(this.shijian2).format('YYYY-MM-DD%20HH:mm') |
| | |
| | | //console.log("收到数据====" + msg.data);
|
| | | let obj = JSON.parse(msg.data);
|
| | | if (obj.params != null) {
|
| | | this.car1 = 107 + 17.62 * obj.params[0][0];
|
| | | this.car2 = 175 + 17.62 * obj.params[0][1];
|
| | | // this.car1 = 150 + 24.6 * obj.params[0][0];
|
| | | // this.car2 = 242 + 24.6 * obj.params[0][1];
|
| | | this.car1 = 107 + 17.62 * obj.params[0][0]/1000;
|
| | | this.car2 = 175 + 17.62 * obj.params[0][1]/1000;
|
| | | // this.car1 = 150 + 24.6 * obj.params[0][0]/1000;
|
| | | // this.car2 = 242 + 24.6 * obj.params[0][1]/1000;
|
| | | }
|
| | | this.tableData = obj.tableData[0];
|
| | | this.cagelist1 = obj.cagelist1[0];
|
| | |
| | | spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class); |
| | | jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class); |
| | | |
| | | // 根据玻璃id获取订单号 |
| | | try { |
| | | Glass glass = jdbcConnections.selectGlass(112); |
| | | // 根据玻璃id获取订单号,单独数据源 |
| | | // try { |
| | | // Glass glass = jdbcConnections.selectGlass(112); |
| | | |
| | | // System.out.println(glass.getOrderId()); |
| | | } catch (SQLException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | // spianService.selectout("11"); |
| | | |
| | | // 判断进片请求 |
| | | // // System.out.println(glass.getOrderId()); |
| | | // } catch (SQLException e) { |
| | | // // TODO Auto-generated catch block |
| | | // e.printStackTrace(); |
| | | // } |
| | | |
| | | //判断进片请求 |
| | | List<Short> datas1List = S7control.getinstance().ReadWord("DB106.24", 1); |
| | | List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8", 1); |
| | | |
| | | |
| | | |
| | | if (datas1List != null && datas1ListState != null) { |
| | | // 获取prc进片请求数据 |
| | | boolean exist = datas1List.contains((short) 1); |
| | |
| | | boolean exist1 = datas1ListState.contains((short) 0); |
| | | String glassid=""; |
| | | // 进片请求为1时 |
| | | if (exist = true) { |
| | | if (exist == true) { |
| | | // 当进片车空闲时 |
| | | if (exist1 = true) { |
| | | if (exist1 == true) { |
| | | // 获取进片id |
| | | List<Short> datas1ListID = S7control.getinstance().ReadWord("DB106.26", 13); |
| | | if (datas1ListID != null) { |
| | |
| | | } |
| | | |
| | | //spianService.selectAll((short) 111); |
| | | |
| | | |
| | | List<Short> outlist = S7control.getinstance().ReadWord("DB106.20", 1); // 出片车状态 |
| | | //List<Short> outlist2 = S7control.getinstance().ReadWord("DB106.20", 1); // 出片任务完成 |
| | | |
| | | |
| | | if (outlist != null) { |
| | | boolean outstate=false;//出片车空闲判断 |
| | | if (outlist != null) { |
| | | // 判断按订单出片 |
| | | boolean outstate = outlist.contains((short) 0); |
| | | |
| | | if (outstate = true) { // 出片车状态空闲时 |
| | | outstate = outlist.contains((short) 0); |
| | | } |
| | | Glass glass=spianMapper.SelectDBOut();//判断是否有调拨后的出片任务未完成 |
| | | |
| | | if(outstate== true ){ |
| | | if(glass.getId()==2){ |
| | | spianService.selectout2(glass.getGlassId().toString()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | if (outstate == true) { // 出片车状态空闲时 |
| | | String orderid = spianMapper.SelectOrderout(); |
| | | if (orderid != null) { |
| | | spianService.selectout(orderid); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | // 查询数据库 |
| | | // 推送到前端 |
| | |
| | | */ |
| | | public void sendMessage(String message) { |
| | | try { |
| | | log.info("服务端给客户端[{}]发送消息{}", this.session.getId(), message); |
| | | // log.info("服务端给客户端[{}]发送消息{}", this.session.getId(), message); |
| | | this.session.getBasicRemote().sendText(message); |
| | | } catch (Exception e) { |
| | | log.error("服务端发送消息给客户端失败", e); |
| | |
| | | public void sendAllMessage(String message) { |
| | | try { |
| | | for (WebSocketServer webSocketServer : sessionMap.values()) { |
| | | log.info("服务端给客户端[{}]发送消息{}", this.session.getId(), message); |
| | | //log.info("服务端给客户端[{}]发送消息{}", this.session.getId(), message); |
| | | webSocketServer.sendMessage(message); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | public class StorageTask{ |
| | | private Integer id; |
| | | private String taskType; |
| | | private String glassId; |
| | | private String cataskStatege; |
| | | private String shelfRack; |
| | | private String loadrack; |
| | |
| | | public void setTaskType(String taskType) { |
| | | this.taskType = taskType; |
| | | } |
| | | public String getGlassId() { |
| | | return glassId; |
| | | } |
| | | |
| | | public void setGlassId(String glassId) { |
| | | this.glassId = glassId; |
| | | } |
| | | |
| | | public String getCataskStatege() { |
| | | return cataskStatege; |
| | |
| | | int selectGlassState(int cage,int cell); |
| | | |
| | | //判断该调拨的笼子 |
| | | @Select("select cage,cell,max(state)as shu,ROUND(id/2)as prcid,id from storage_cage where width>=#{width} and cage>#{cage1} and cage<#{cage2} GROUP BY cage,cell HAVING shu=0 order by abs(#{cage} - cage) limit 1;") |
| | | @Select("select glass_id,cage,cell,max(state)as shu,ROUND(id/2)as prcid,id from storage_cage where width>=#{width} and cage>#{cage1} and cage<#{cage2} GROUP BY cage,cell HAVING shu=0 order by abs(#{cage} - cage) limit 1;") |
| | | StorageCage selectGlassCage(int cage,double width,int cage1,int cage2); |
| | | |
| | | //删除笼子信息(出片) |
| | | @Update("update storage_cage set state=#{state},glass_id=#{glassid},order_id=#{orderid},glasswidth=0 where cage=#{cage} and cell=#{cell} and tier=#{tier};") |
| | | @Update("update storage_cage as a set state=#{state},glass_id=#{glassid},order_id=#{orderid},glasswidth=0 where cage=#{cage} and cell=#{cell} and tier=#{tier};") |
| | | void UpdataGlassCage(String orderid,String glassid,double width,int cage,int cell,int tier,int state); |
| | | |
| | | //修改笼子信息(进片) |
| | |
| | | // @Insert("insert into user(name, date, address, user_no) values (#{name}, #{date}, #{address}, #{userNo})") |
| | | // void insert (Spian spian); |
| | | //新增任务表 |
| | | @Insert("INSERT INTO `canadames`.`storage_task`(`task_type`, `task_state`, `shelf_rack`, `load_rack`,start_time) VALUES (#{tasktype},#{taskstate},#{shelfrack},#{loadrack},now());") |
| | | void Inserttask(int tasktype,int taskstate,int shelfrack,int loadrack); |
| | | @Insert("INSERT INTO `canadames`.`storage_task`(`task_type`, `task_state`, `shelf_rack`, `load_rack`,start_time,glass_id) VALUES (#{tasktype},#{taskstate},#{shelfrack},#{loadrack},now(),#{glassid});") |
| | | void Inserttask(int tasktype,int taskstate,int shelfrack,int loadrack,String glassid); |
| | | //修改任务表 |
| | | @Update("update storage_task set task_state=#{state} where task_type=#{type} and task_state=0;") |
| | | void Updatetask(int state,int type); |
| | |
| | | //查询按订单出片 |
| | | @Select("select order_id state from order_out where state=0") |
| | | String SelectOrderout(); |
| | | //内外片调换 |
| | | @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.cage=#{cage} and a.cell=#{cell} and a.tier=1") |
| | | void UpdateDBCage1(int cage,int cell); |
| | | //清除内片数据 |
| | | @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(); |
| | | } |
| | |
| | | |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度 |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 0);//清除格子玻璃信息 |
| | | spianMapper.Inserttask(1, 0,cageout.getId(),1000 );//新增任务 |
| | | |
| | | S7control.getinstance().WriteWord("DB106.22", (short)0); //出片任务完成改成0 |
| | | S7control.getinstance().WriteWord("DB106.20", (short)1); //出片车状态改成忙碌 |
| | | spianMapper.Inserttask(1, 0,cageout.getId(),1000,orderid);//新增任务 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | return Result.success(datas);//结束 |
| | | } else { |
| | |
| | | datas.add((short) 1000); |
| | | datas.add((short) 1); |
| | | datas.add((short) 1); |
| | | spianMapper.Inserttask(1, 0,cageout.getId(),1000 );//新增任务 |
| | | spianMapper.Inserttask(1, 0,cageout.getId(),1000,orderid);//新增任务 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度 |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 0);//清除格子玻璃信息 |
| | | S7control.getinstance().WriteWord("DB106.22", (short)0); //出片任务完成改成0 |
| | | S7control.getinstance().WriteWord("DB106.20", (short)1); //出片车状态改成忙碌 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | //spianMapper.Updatetask(1, 1);//完成任务 |
| | | return Result.success(datas);//结束 |
| | |
| | | // 更换玻璃的笼子 |
| | | spianMapper.UpdataAddCage1(glasswidth, cages, cells);//减少新格子宽度 |
| | | spianMapper.UpdateDBCage(ids, cage, cell);// 将原格子数据更新到新格子里 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度 |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 0);// 清除被调拨格子数据 |
| | | spianMapper.Inserttask(2, 0,cageout.getId(),ids );//新增调度任务 |
| | | spianMapper.Inserttask(2, 0,cageout.getId(),ids,orderid);//新增调度任务 |
| | | // 传输mes数据,坐标,数据 |
| | | S7control.getinstance().WriteWord("DB106.22", (short)0); //出片任务完成改成0 |
| | | S7control.getinstance().WriteWord("DB106.20", (short)1); //出片车状态改成忙碌 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | return Result.success(cagecell); //结束 |
| | | |
| | |
| | | datas.add((short) prcid2); |
| | | datas.add((short) 2); |
| | | datas.add((short) 1); |
| | | spianMapper.Inserttask(2, 0,cageout.getId(),ids );//新增调度任务 |
| | | spianMapper.Inserttask(2, 0,cageout.getId(),ids,orderid);//新增调度任务 |
| | | spianMapper.UpdataAddCage1(glasswidth, cages, cells);//减少新格子宽度 |
| | | spianMapper.UpdateDBCage(ids, cage, cell);// 将原格子数据更新到新格子里 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度 |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 0);// 清除被调拨格子数据 |
| | | // 传输mes数据,坐标,数据 |
| | | S7control.getinstance().WriteWord("DB106.22", (short)0); //出片任务完成改成0 |
| | | S7control.getinstance().WriteWord("DB106.20", (short)1); //出片车状态改成忙碌 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | return Result.success(cagecell); //结束 |
| | | |
| | |
| | | int prctier; |
| | | |
| | | spianMapper.Updatetask(1, 0);//完成任务 |
| | | Glass glasslist = spianMapper.selectGlass(glassid); |
| | | Glass glasslist = spianMapper.selectGlass(glassid); |
| | | if(glasslist==null){ |
| | | return (300); |
| | | } |
| | |
| | | if (glasslist == null) { |
| | | return (300); |
| | | } |
| | | spianMapper.Inserttask(0, 0, 1000, ids);//新增任务 |
| | | spianMapper.Inserttask(0, 0, 1000, ids,glassid.toString());//新增任务 |
| | | prctier = spianMapper.selectsum(cage1, cells);// 传给prc的格子内玻璃数 |
| | | // 有合适空格时进片 |
| | | if (cages > 1 && cages1.getTier() != null) { |
| | |
| | | // 数据库修改笼子表新增一条玻璃 |
| | | spianMapper.UpdataAddCage(orderids, glassid, widths, cage1, cells, ids, 1); |
| | | spianMapper.UpdataAddCage1(widths, cage1, cells);//减少格子宽度 |
| | | |
| | | |
| | | S7control.getinstance().WriteWord(adddresslist, datas); |
| | | S7control.getinstance().WriteWord("DB106.10", (short)0); //进片任务完成改成0 |
| | | S7control.getinstance().WriteWord("DB106.8", (short)1); //进片车状态改成忙碌 |
| | | return (200); |
| | | } |
| | | } |
| | |
| | | |
| | | // @GetMapping("/all2") |
| | | public Short selectout2(String glassid) { |
| | | spianMapper.UpdatetaskOut(); //完成上一次出片或者调度任务 |
| | | // 定义PRC数据传送数组 |
| | | List<String> adddresslist = new ArrayList<>(); |
| | | adddresslist.add("DB105.6");// 出片车起始位置 |
| | |
| | | int prcid2; |
| | | int ids; |
| | | int cages; |
| | | int cells; |
| | | int cells; |
| | | double glasswidth = cageout.getGlassWidth(); |
| | | // 判断玻璃内外片 |
| | | if (tier == 2) { |
| | |
| | | |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度 |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 0);//清除格子玻璃信息 |
| | | spianMapper.Inserttask(1, 0,cageout.getId(),1000 );//新增任务 |
| | | |
| | | S7control.getinstance().WriteWord("DB106.22", (short)0); //出片任务完成改成0 |
| | | S7control.getinstance().WriteWord("DB106.20", (short)1); //出片车状态改成忙碌 |
| | | spianMapper.Inserttask(1, 0,cageout.getId(),1000,glassid);//新增任务 |
| | | int state = spianMapper.selectGlassState(cage, cell);//获取格子数量 |
| | | if(state==2){ |
| | | spianMapper.UpdateDBCage1(cage, cell);// 将内片数据更新到外片里 |
| | | spianMapper.UpdateDBCage2(cage, cell);// 清除内片数据 |
| | | } |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | |
| | | |
| | | return (200);//结束 |
| | | } else { |
| | | // 获取格子的玻璃数量 |
| | |
| | | datas.add((short) 1000); |
| | | datas.add((short) 1); |
| | | datas.add((short) 1); |
| | | spianMapper.Inserttask(1, 0,cageout.getId(),1000 );//新增任务 |
| | | spianMapper.Inserttask(1, 0,cageout.getId(),1000 ,glassid);//新增任务 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度 |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 0);//清除格子玻璃信息 |
| | | S7control.getinstance().WriteWord("DB106.22", (short)0); //出片任务完成改成0 |
| | | S7control.getinstance().WriteWord("DB106.20", (short)1); //出片车状态改成忙碌 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | //spianMapper.Updatetask(1, 1);//完成任务 |
| | | return (200);//结束 |
| | |
| | | prcid2 = cagecell.getPrcId();// 调拨目标位PRCID |
| | | ids = cagecell.getId();// 调拨目标位ID |
| | | cages=cagecell.getCage();//调拨目标位笼子 |
| | | cells=cagecell.getCell();//调拨目标位格子 |
| | | |
| | | |
| | | |
| | | cells=cagecell.getCell();//调拨目标位格子 |
| | | |
| | | |
| | | // 填入调拨数据 |
| | |
| | | // 更换玻璃的笼子 |
| | | spianMapper.UpdataAddCage1(glasswidth, cages, cells);//减少新格子宽度 |
| | | spianMapper.UpdateDBCage(ids, cage, cell);// 将原格子数据更新到新格子里 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度 |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 0);// 清除被调拨格子数据 |
| | | spianMapper.Inserttask(2, 0,cageout.getId(),ids );//新增调度任务 |
| | | spianMapper.Inserttask(2, 0,cageout.getId(),ids,glassid);//新增调度任务 |
| | | spianMapper.Inserttask(1, 0,cageout.getId(),1000,glassid);//新增出片任务 |
| | | // 传输mes数据,坐标,数据 |
| | | S7control.getinstance().WriteWord("DB106.22", (short)0); //出片任务完成改成0 |
| | | S7control.getinstance().WriteWord("DB106.20", (short)1); //出片车状态改成忙碌 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | return (200); //结束 |
| | | |
| | |
| | | datas.add((short) prcid2); |
| | | datas.add((short) 2); |
| | | datas.add((short) 1); |
| | | spianMapper.Inserttask(2, 0,cageout.getId(),ids );//新增调度任务 |
| | | spianMapper.Inserttask(2, 0,cageout.getId()+1,ids,glassid);//新增调度任务 |
| | | spianMapper.Inserttask(1, 0,cageout.getId(),1000,glassid);//新增出片任务 |
| | | spianMapper.UpdataAddCage1(glasswidth, cages, cells);//减少新格子宽度 |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度 |
| | | spianMapper.UpdateDBCage(ids, cage, cell);// 将原格子数据更新到新格子里 |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 0);// 清除被调拨格子数据 |
| | | // 传输mes数据,坐标,数据 |
| | | S7control.getinstance().WriteWord("DB106.22", (short)0); //出片任务完成改成0 |
| | | S7control.getinstance().WriteWord("DB106.20", (short)1); //出片车状态改成忙碌 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | return (200);//结束 |
| | | |