| | |
| | | |
| | | public static void main(String[] args) { |
| | | |
| | | // SpringApplication.run(AuthorityApplication.class, args); |
| | | // 111 |
| | | //System.out.println("null"); |
| | | |
| | | SpringApplication springApplication = new SpringApplication(AuthorityApplication.class); |
| | | ConfigurableApplicationContext configurableApplicationContext = springApplication.run(args); |
| | | WebSocketServer.setApplicationContext(configurableApplicationContext); |
| | |
| | | // // TODO Auto-generated catch block |
| | | // e.printStackTrace(); |
| | | // } |
| | | spianService.selectAll((short)257); |
| | | // spianService.selectAll((short)257); |
| | | //判断进片请求 |
| | | List<Short> datas1List = S7control.getinstance().ReadWord("DB106.24", 1); |
| | | List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8", 1); |
| | |
| | | // 获取进片车状态 |
| | | boolean exist1 = datas1ListState.contains((short) 0); |
| | | String glassid=""; |
| | | StringBuilder strId=new StringBuilder(); |
| | | |
| | | // 进片请求为1时 |
| | | if (exist == true) { |
| | | // 当进片车空闲时 |
| | | if (exist1 == true) { |
| | | // 获取进片id |
| | | List<Short> datas1ListID = S7control.getinstance().ReadWord("DB106.26", 1); |
| | | byte[] datas1ListID = S7control.getinstance().ReadByte("DB106.26", 4); |
| | | if (datas1ListID != null) { |
| | | // 获取玻璃id |
| | | for (Short list1 : datas1ListID) { |
| | | glassid=glassid.concat(list1.toString()); |
| | | for (byte list1 : datas1ListID) { |
| | | strId.append(list1); |
| | | |
| | | } |
| | | spianService.selectAll(Short.parseShort(glassid)); |
| | | spianService.selectAll(strId.toString()); |
| | | //spianService.selectAll(Short.parseShort(strId.toString())); |
| | | S7control.getinstance().WriteByte("DB105.16",datas1ListID); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | import javax.print.DocFlavor.STRING; |
| | | |
| | | @Mapper |
| | | |
| | | public interface SpianMapper { |
| | |
| | | void update(); |
| | | //获取玻璃信息 |
| | | @Select("select orderid,width from glass where glassid=#{glassid}") |
| | | Glass selectGlass(Short glassid); |
| | | Glass 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 cage,cell,tier,glasswidth,ROUND(id/2)as prcId,id from storage_cage as a where a.order_id=#{orderId} 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,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") |
| | |
| | | |
| | | //修改笼子信息(进片) |
| | | @Update("update storage_cage set state=#{state},glass_id=#{glassid},order_id=#{orderid},glasswidth=#{width} where id=#{id};") |
| | | void UpdataAddCage(Short orderid,Short glassid,double width,int cage,int cell,int id,int state); |
| | | void UpdataAddCage(Short orderid,String glassid,double width,int cage,int cell,int id,int state); |
| | | //修改同笼子格子宽度 |
| | | @Update("update storage_cage set width=width-#{width} where cage=#{cage} and cell=#{cell};") |
| | | void UpdataAddCage1(double width,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(); |
| | | //根据笼子格子层数获取玻璃id |
| | | @Select("select glass_id from storage_cage where cage=#{cage} and cell=#{cell} and tier=2;") |
| | | String SelectGlassid(int cage,int cell); |
| | | } |
| | |
| | | package com.example.springboot.service; |
| | | |
| | | import java.lang.reflect.Array; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | import com.example.springboot.entity.Glass; |
| | | import com.example.springboot.entity.StorageCage; |
| | | import com.example.springboot.mapper.SpianMapper; |
| | | import com.google.common.primitives.Bytes; |
| | | |
| | | @Service |
| | | public class SpianService { |
| | |
| | | int cell = cageout.getCell();// 出片格号 |
| | | int tier = cageout.getTier();// 出片内外片 |
| | | int prcid = cageout.getPrcId();// prcid |
| | | String glassid=cageout.getGlassId(); |
| | | int prcid2; |
| | | int ids; |
| | | int cages; |
| | |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 0);//清除格子玻璃信息 |
| | | spianMapper.Inserttask(1, 0,cageout.getId(),1000,orderid);//新增任务 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | outmesid(glassid);//派发出片ID |
| | | return Result.success(datas);//结束 |
| | | } else { |
| | | // 获取格子的玻璃数量 |
| | |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度 |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 0);//清除格子玻璃信息 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | outmesid(glassid);//派发出片ID |
| | | //spianMapper.Updatetask(1, 1);//完成任务 |
| | | return Result.success(datas);//结束 |
| | | |
| | |
| | | prcid2 = cagecell.getPrcId();// 调拨目标位PRCID |
| | | ids = cagecell.getId();// 调拨目标位ID |
| | | cages=cagecell.getCage();//调拨目标位笼子 |
| | | cells=cagecell.getCell();//调拨目标位格子 |
| | | |
| | | |
| | | |
| | | cells=cagecell.getCell();//调拨目标位格子 |
| | | |
| | | // 填入调拨数据 |
| | | datas.add((short) prcid);// 调拨外片起始位置 |
| | |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 0);// 清除被调拨格子数据 |
| | | spianMapper.Inserttask(2, 0,cageout.getId(),ids,orderid);//新增调度任务 |
| | | // 传输mes数据,坐标,数据 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | String glassids=spianMapper.SelectGlassid(cage, cell); //获取被调拨的玻璃id |
| | | outmesid(glassids);//派发调拨玻璃ID |
| | | return Result.success(cagecell); //结束 |
| | | |
| | | } else {// 笼子号大于5时 |
| | |
| | | spianMapper.UpdataOutCage1(glasswidth, cage, cell);//增加原格子宽度 |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 0);// 清除被调拨格子数据 |
| | | // 传输mes数据,坐标,数据 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | String glassids=spianMapper.SelectGlassid(cage, cell); //获取被调拨的玻璃id |
| | | outmesid(glassids);//派发调拨玻璃ID |
| | | return Result.success(cagecell); //结束 |
| | | |
| | | } |
| | |
| | | // @GetMapping("/all") |
| | | // 进片任务,传订单id |
| | | // 按订单优先进片 |
| | | public Short selectAll(Short glassid) { |
| | | public Short selectAll(String glassid) { |
| | | |
| | | int cage1; |
| | | int cells; |
| | |
| | | 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); |
| | | |
| | | } |
| | |
| | | spianMapper.UpdateDBCage2(cage, cell);// 清除内片数据 |
| | | } |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | |
| | | |
| | | 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, 0);//清除格子玻璃信息 |
| | | outmesid(glassid);//派发出片ID |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | //spianMapper.Updatetask(1, 1);//完成任务 |
| | | |
| | | |
| | | return (200);//结束 |
| | | |
| | | } else { |
| | |
| | | spianMapper.Inserttask(2, 0,cageout.getId(),ids,glassid);//新增调度任务 |
| | | spianMapper.Inserttask(1, 0,cageout.getId(),1000,glassid);//新增出片任务 |
| | | // 传输mes数据,坐标,数据 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | String glassids=spianMapper.SelectGlassid(cage, cell); //获取被调拨的玻璃id |
| | | outmesid(glassids);//派发调拨玻璃ID |
| | | return (200); //结束 |
| | | |
| | | } else {// 笼子号大于5时 |
| | |
| | | spianMapper.UpdateDBCage(ids, cage, cell);// 将原格子数据更新到新格子里 |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 0);// 清除被调拨格子数据 |
| | | // 传输mes数据,坐标,数据 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | S7control.getinstance().WriteWord(adddresslist, datas);//派发出片车任务 |
| | | String glassids=spianMapper.SelectGlassid(cage, cell); //获取被调拨的玻璃id |
| | | outmesid(glassids);//派发调拨玻璃ID |
| | | return (200);//结束 |
| | | |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | public void outmesid(String glassid) { |
| | | List<Byte> glassidlist=new ArrayList(); |
| | | for (char iditem : glassid.toCharArray()) { |
| | | glassidlist.add(Byte.valueOf(String.valueOf(iditem))); |
| | | } |
| | | byte[] bytes= Bytes.toArray(glassidlist); |
| | | S7control.getinstance().WriteByte("DB105.30", bytes);//派发出片id |
| | | } |
| | | |
| | | /*** 修改用户* @throws SQLException */ |
| | | // public static int updateUser(Glass user) throws SQLException {conn = |
| | | // getConn(); |