| | |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | |
| | | import com.example.springboot.common.Result; |
| | | import com.example.springboot.component.S7control; |
| | |
| | | public class SpianService { |
| | | @Autowired |
| | | private SpianMapper spianMapper; |
| | | @GetMapping("/all2") |
| | | |
| | | // @GetMapping("/all2") |
| | | public Result selectout(String orderid){ |
| | | //定义PRC数据传送数组 |
| | | List<String> adddresslist=new ArrayList<>(); |
| | |
| | | datas.add((short)1); |
| | | S7control.getinstance().WriteWord(adddresslist, datas); |
| | | return Result.success(datas); |
| | | } |
| | | else{ |
| | | } else { |
| | | //获取格子的玻璃数量 |
| | | int state= spianMapper.selectGlassState(cage,cell); |
| | | //判断内片是否需要调拨 |
| | | if(state==0){ |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 0); |
| | | datas.add((short) prcid); |
| | | datas.add((short) 1000); |
| | | datas.add((short) 1); |
| | | datas.add((short) 1); |
| | | S7control.getinstance().WriteWord(adddresslist, datas); |
| | | return Result.success("状态为0,直接出片"); |
| | | }else{ |
| | | //玻璃需要调拨时,判断属于哪个半区的笼子 |
| | |
| | | |
| | | } |
| | | |
| | | @GetMapping("/all") |
| | | // @GetMapping("/all") |
| | | //进片任务,传订单id |
| | | //按订单优先进片 |
| | | public Result selectAll(Short glassid){ |
| | | //return spianMapper.selectAll(); |
| | | public Short selectAll(Short glassid) { |
| | | |
| | | int cage1; |
| | | int cells; |
| | | int ids; |
| | |
| | | int prctier; |
| | | |
| | | Glass glasslist=spianMapper.selectGlass(glassid); |
| | | if (glasslist == null) { |
| | | return (300); |
| | | } |
| | | double widths=glasslist.getWidth(); |
| | | Short orderids=glasslist.getOrderId(); |
| | | |
| | |
| | | |
| | | //String orderid="A001"; |
| | | //获取订单相关度最高的笼子排序 |
| | | List<StorageCage> storageCage=spianMapper.selectAll(glassid); |
| | | List<StorageCage> storageCage = spianMapper.selectAll(orderids); |
| | | if(storageCage==null){ |
| | | return Result.success(storageCage); |
| | | return (400); |
| | | } |
| | | for (StorageCage storageCage2 : storageCage) { |
| | | //保存订单优先顺序笼子号 |
| | |
| | | int cages=spianMapper.selectCage(cage1); |
| | | //判断选中笼子是否有合适宽度空格 |
| | | StorageCage cages1=spianMapper.selectCage1(cage1,widths); |
| | | if (cages1 != null) { |
| | | ids=cages1.getId();//数据库ID |
| | | tiers=cages1.getTier();//内外片 |
| | | cells=cages1.getCell();//格子号 |
| | |
| | | datas.add((short)prcid); |
| | | datas.add((short)prctier); |
| | | datas.add((short)1); |
| | | S7control.getinstance().WriteWord(adddresslist, datas); |
| | | //数据库修改笼子表新增一条玻璃 |
| | | |
| | | spianMapper.UpdataAddCage(orderids, glassid, widths, cage1, cells, ids, 1); |
| | | return Result.success(cages1); |
| | | S7control.getinstance().WriteWord(adddresslist, datas); |
| | | |
| | | return (200); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | return Result.success("不可进片"); |
| | | return (300); |
| | | |
| | | } |
| | | |
| | | @GetMapping("/all2") |
| | | // @GetMapping("/all2") |
| | | public Result selectout2(String glassid){ |
| | | //定义PRC数据传送数组 |
| | | List<String> adddresslist=new ArrayList<>(); |
| | |
| | | datas.add((short)1); |
| | | S7control.getinstance().WriteWord(adddresslist, datas); |
| | | return Result.success(datas); |
| | | } |
| | | else{ |
| | | } else { |
| | | //获取格子的玻璃数量 |
| | | int state= spianMapper.selectGlassState(cage,cell); |
| | | //判断内片是否需要调拨 |
| | |
| | | |
| | | } |
| | | |
| | | /*** 修改用户* @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(); |
| | | // } |
| | | |
| | | } |