| | |
| | | package com.example.springboot.service; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | import com.example.springboot.mapper.SpianMapper; |
| | | import com.google.common.primitives.Bytes; |
| | | |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | |
| | | @Service |
| | | public class SpianService { |
| | | @Autowired |
| | |
| | | // @GetMapping("/all") |
| | | public Short selectAll(String glassid) { |
| | | |
| | | int cage1=0; |
| | | int cage1 = 0; |
| | | int cells; |
| | | int ids; |
| | | int prcid; |
| | |
| | | double minwidth = 0; |
| | | |
| | | north_glass_buffer1 glasslist = spianMapper.selectGlass(glassid); // 获取玻璃参数 |
| | | //如果没有此id时 |
| | | // 如果没有此id时 |
| | | if (glasslist == null) { |
| | | return (300); |
| | | } |
| | | |
| | | |
| | | double widths = glasslist.getglasslengthmm(); |
| | | String orderids = glasslist.getordernumber(); |
| | | String FrameBarcode = glasslist.getFrameBarcode(); |
| | |
| | | List<Short> datas = new ArrayList<>(); |
| | | |
| | | // String orderid="A001"; |
| | | // 获取订单相关度最高的笼子排序 |
| | | List<StorageCage> storageCage = spianMapper.selectAllFbarcode(FrameBarcode,widths,400); |
| | | //判断铝框指定空格是否需要间隔空间 |
| | | |
| | | |
| | | // 获取铝框相关度最高的笼子排序 |
| | | List<StorageCage> storageCage = spianMapper.selectAllFbarcode(FrameBarcode, widths, 400); |
| | | // 判断铝框指定空格是否需要间隔空间 |
| | | |
| | | if (storageCage.size() == 0) { |
| | | storageCage = spianMapper.selectAll(orderids, FrameBarcode); |
| | | } |
| | |
| | | // 将外片玻璃的数据更新到内片 |
| | | spianMapper.UpdateDBCage(ids, cage1, cells, 1); |
| | | // 将新入的玻璃存入外片 |
| | | // spianMapper.UpdataAddCage(orderids, glassid, widths, cage1, cells, ids-1, 2); |
| | | |
| | | spianMapper.UpdataAddCage2(orderids, glassid, glasslist, cage1, cells, ids - 1, 2); |
| | | spianMapper.UpdataAddCage1(widths, cage1, cells);// 减少格子宽度 |
| | | spianMapper.Inserttask(0, 0, 1000, ids, glassid.toString(), prctier);// 新增任务 |
| | | S7control.getinstance().WriteWord(adddresslist, datas); |
| | | |
| | | System.out.println("进片任务|" + datas); |
| | | |
| | | } else { |
| | | // 数据库修改笼子表新增一条玻璃 |
| | | // spianMapper.UpdataAddCage(orderids, glassid, widths, cage1, cells, ids, 2); |
| | | |
| | | spianMapper.UpdataAddCage2(orderids, glassid, glasslist, cage1, cells, ids, 2); |
| | | spianMapper.UpdataAddCage1(widths, cage1, cells);// 减少格子宽度 |
| | | spianMapper.Inserttask(0, 0, 1000, ids, glassid.toString(), prctier);// 新增任务 |
| | | S7control.getinstance().WriteWord(adddresslist, datas); |
| | | System.out.println("进片任务|" + datas); |
| | | |
| | | // S7control.getinstance().WriteByte("DB105.16",glassid); |
| | | |
| | | } |
| | | outmesid(glassid, "DB105.20"); |
| | | return (200); |
| | |
| | | spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid, state);// 新增任务 |
| | | // int state = spianMapper.selectGlassState(cage, cell);//获取格子数量 |
| | | // if (state == 2) { |
| | | // spianMapper.UpdateDBCage1(cage, cell);// 将内片数据更新到外片里 |
| | | // spianMapper.UpdateDBCage2(cage, cell);// 清除内片数据 |
| | | // spianMapper.UpdateDBCage1(cage, cell);// 将内片数据更新到外片里 |
| | | // spianMapper.UpdateDBCage2(cage, cell);// 清除内片数据 |
| | | // } |
| | | System.out.println("出片任务|" + datas); |
| | | S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务 |
| | | S7control.getinstance().WriteWord("DB105.18", (short) 1);// 出片任务发送字改为1 |
| | | outmesid(glassid, "DB105.34");// 派发出片ID |
| | | |
| | | return (200);// 结束 |
| | |
| | | System.out.println("出片任务|" + datas); |
| | | outmesid(glassid, "DB105.34");// 派发出片ID |
| | | S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务 |
| | | S7control.getinstance().WriteWord("DB105.18", (short) 1);// 出片任务发送字改为1 |
| | | |
| | | return (200);// 结束 |
| | | |
| | |
| | | // 传输mes数据,坐标,数据 |
| | | System.out.println("出片任务|" + datas); |
| | | S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务 |
| | | |
| | | S7control.getinstance().WriteWord("DB105.18", (short) 1);// 出片任务发送字改为1 |
| | | outmesid(glassids, "DB105.34");// 派发调拨玻璃ID |
| | | return (200); // 结束 |
| | | |
| | |
| | | // 传输mes数据,坐标,数据 |
| | | System.out.println("出片任务|" + datas); |
| | | S7control.getinstance().WriteWord(adddresslist, datas);// 派发出片车任务 |
| | | |
| | | S7control.getinstance().WriteWord("DB105.18", (short) 1);// 出片任务发送字改为1 |
| | | outmesid(glassids, "DB105.34");// 派发调拨玻璃ID |
| | | return (200);// 结束 |
| | | |
| | |
| | | byte[] bytes = Bytes.toArray(glassidlist); |
| | | System.out.println("outmesidbytes:" + bytes.length); |
| | | S7control.getinstance().WriteByte(address, bytes);// 派发出片id |
| | | |
| | | } |
| | | |
| | | // 获取地址内的玻璃id转字符串 |
| | |
| | | // } |
| | | |
| | | } |
| | | |
| | | |
| | | } |