wu
2024-02-01 18dfd899e47fd2c0876251389941891388a2ebb6
优化出片逻辑,更换DB区读取方式
5个文件已修改
1个文件已添加
500 ■■■■ 已修改文件
springboot-vue3/src/main/java/com/example/springboot/component/PLCAutoMes.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java 136 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/mapper/SpianMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/service/SpianServiceNew.java 314 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springboot-vue3/src/main/java/com/example/springboot/component/PLCAutoMes.java
@@ -28,23 +28,20 @@
    private static String PlcRead = PLCAutoMes.class.getResource("/JsonFile/PlcRead.json").getPath();
    private static String Plcframe = PLCAutoMes.class.getResource("/JsonFile/Plcframe.json").getPath();
    private static String PlcParameter = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcParameter.json").getPath();
    private static String PlcSign = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcSign.json").getPath();
    private static String PlcState = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcState.json").getPath();
    private static String PlcState = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcState.json").getPath();
    private static String PlcAlarm = PLCAutoMes.class.getResource("/JsonFile/PlcAlarm.json").getPath();
    private static String PlcTest = PLCAutoMes.class.getResource("/JsonFile/PlcTest.json").getPath();
    // 调用initword方法
    public static PlcParameterObject plcParameterObject = initUtil.initword(PlcParameter);
    public static PlcBitObject plcPlcTest = initUtil.initbit(PlcTest);
    public static PlcBitObject  plcBitObject= initUtil.initbit(PlcSign);
    public static PlcParameterObject  plcStateObject = initUtil.initword(PlcState);
    public static PlcBitObject plcPlcAlarm = initUtil.initbit(PlcAlarm);
    public static PlcParameterObject PlcMesObject = initUtil.initword(PlcMes);
    public static PlcParameterObject PlcReadObject = initUtil.initword(PlcRead);
    public static PlcParameterObject PlcframeObject = initUtil.initword(Plcframe);
    public static PlcParameterObject plcParameterObject = initUtil.initword(PlcParameter);
    public static PlcParameterObject plcStateObject = initUtil.initword(PlcSign);
    public static PlcBitObject plcBitObject = initUtil.initbit(PlcState);
    public static PlcBitObject plcPlcAlarm= initUtil.initbit(PlcAlarm);
    public static PlcBitObject plcPlcTest = initUtil.initbit(PlcTest);
    // 私有构造函数
    public PLCAutoMes() throws IOException {
springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java
@@ -5,6 +5,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import com.example.springboot.service.JdbcConnections;
import com.example.springboot.service.SpianService;
import com.example.springboot.service.SpianServiceNew;
import com.example.springboot.entity.north_glass_buffer1;
import com.example.springboot.mapper.AlarmMapper;
import com.example.springboot.mapper.SpianMapper;
@@ -17,6 +18,7 @@
  private JdbcConnections jdbcConnections;
  private SpianMapper spianMapper;
  private SpianService spianService;
  private SpianServiceNew spianServiceNew;
  int aaa;
  @Override
@@ -34,6 +36,7 @@
      // if (S7control.getinstance().CheckConnected() == false) {
      spianService = WebSocketServer.applicationContext.getBean(SpianService.class);
      spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
      spianServiceNew = WebSocketServer.applicationContext.getBean(SpianServiceNew.class);
      jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
      // 根据玻璃id获取订单号,单独数据源
      // try {
@@ -45,6 +48,8 @@
      // }
      // 出片任务////////////////////////////////
      spianServiceNew.selectout2("X21942613103GV");
      List<Short> outlist = S7control.getinstance().ReadWord("DB106.20", 1); // 出片车状态
      List<Short> outlist1 = S7control.getinstance().ReadWord("DB105.18", 1); // 出片任务是否启动
springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java
@@ -37,49 +37,31 @@
      spianService = WebSocketServer.applicationContext.getBean(SpianService.class);
      spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
      jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
      // 根据玻璃id获取订单号,单独数据源
      // try {
      // north_glass_buffer1 glass = jdbcConnections.selectGlass(112);
      // // System.out.println(glass.getOrderId());
      // } catch (SQLException e) {
      // // TODO Auto-generated catch block
      // e.printStackTrace();
      // }
      //读取DB105区文件
      PlcParameterObject plcParameterObjects=PLCAutoMes.PlcMesObject;
      PlcParameterObject plcmes=PLCAutoMes.PlcMesObject;
      //读106
      PlcParameterObject plcParameterObjects2=PLCAutoMes.PlcReadObject;
      // List<String> addresses105 = new ArrayList<>();
      // addresses105.add("OutRequest");// 出片请求字
      // List<String> addresses106 = new ArrayList<>();
      // addresses106.add("OutActivate");// 出片启动
      PlcParameterObject plcread=PLCAutoMes.PlcReadObject;
      //读103
      PlcParameterObject plcstate=PLCAutoMes.plcStateObject;
      String OutRequest=plcread.getPlcParameter("OutRequest").getValue();//出片请求
      String OutActivate=plcmes.getPlcParameter("OutActivate").getValue();//出片启动
      
      String OutActivate=plcParameterObjects2.getPlcParameter("OutActivate").getValue();
      S7control.getinstance().WriteWord( plcmes.getPlcParameter("1231").getAddress(plcmes.getPlcParameter("1231").getAddressIndex()), (short) 0);
      // 出片任务
      boolean Plcout = spianService.listbool("DB106.64");
      boolean Plcout2 = spianService.listbool("DB105.18");
      
      if (Plcout == false&&Plcout2==true) {
        S7control.getinstance().WriteWord("DB105.18", (short) 0);// 出片任务启动改为0
        System.out.println("关闭出片启动" + LocalDateTime.now());// 出片任务发送字改为0
      if (OutActivate.equals("1") == false&&OutRequest.equals("1")==true) {
        S7control.getinstance().WriteWord("DB105.18", (short) 0);// 出片任务启动改为0
      }
      boolean Plcadd = spianService.listbool("DB106.24"); // 进片请求字
      boolean Plcadd2 = spianService.listbool("DB105.16"); // 进片启动
      if (Plcadd == false&&Plcadd2==true) {
      String FeedRequest=plcread.getPlcParameter("FeedRequest").getValue();// 进片请求字
      String AddActivate=plcmes.getPlcParameter("AddActivate").getValue();// 进片启动
      if (FeedRequest.equals("1") == false&&AddActivate.equals("1")==true) {
        S7control.getinstance().WriteWord("DB105.16", (short) 0);//进片任务启动改为0
        System.out.println("关闭进片启动" + LocalDateTime.now());// 进片任务发送字改为0
      }
      // StringBuilder writedstrIdOut = new StringBuilder();
      // 获取已下发的出片id
      byte[] writedglassidbytesOut = S7control.getinstance().ReadByte("DB105.30", 14);
      String writedstrIdOut = new String(writedglassidbytesOut);
      }
   
      if (Plcout == true) {
      if (OutActivate.equals("1") == true) {
        // 判断当前是否有未执行的任务
        int outnum = spianMapper.SelectOutSliceshu();//是否有正在出片的任务
        int cageoutsum = spianMapper.Selectcageout(3);//笼子内是否还有在出片的玻璃
@@ -104,89 +86,81 @@
     
      }
      ///////////// 进片任务
      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.16", 1);// 获取进片车任务是否启动
      ///////////// 进片任务
      boolean B01backs = spianService.listbool("DB106.60");// b01汇报
      boolean B02backs = spianService.listbool("DB106.62");// b02汇报
      StringBuilder B01glassid = spianService.queGlassid("DB103.184", 14);// BO1的玻璃id
      StringBuilder B02glassid = spianService.queGlassid("DB103.212", 14);// B02的玻璃id
      String B01backs = plcread.getPlcParameter("B01CompleteTheReport").getValue();// b01汇报
      String B02backs = plcread.getPlcParameter("B02CompleteTheReport").getValue();// b02汇报
      String B01glassid = plcstate.getPlcParameter("B01ID1").getValue();// BO1的玻璃id
      String B02glassid = plcstate.getPlcParameter("B02ID1").getValue();// B02的玻璃id
      // 当进片小车完成任务时
      if (B01backs == true) {
      if (B01backs.equals("1") == true) {
        // 判断是否汇报正确的id
        int HB = spianMapper.SelectHB(B01glassid.toString());
        if (HB > 0) {
          // 当B01小车汇报完成时更改玻璃状态 为1
          S7control.getinstance().WriteWord("DB105.48", (short) 1);// 恢复B01小车应答改为1
          boolean yingda = spianService.listbool("DB105.48");// b01汇报
          if (yingda == true) {
          // 恢复B01小车应答改为1
          S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(plcmes.getPlcParameter("B01report").getAddressIndex()), (short) 1);
          String yingda =plcmes.getPlcParameter("B01report").getValue();// b01汇报
          if (yingda.equals("1")) {
            spianService.overtask(B01glassid.toString());// 完成任务
          }
          System.out.println("汇报时B01|第" + aaa + "次" + B01glassid + "应答" + yingda);
          aaa += 1;
          }
        }
      }else{
        S7control.getinstance().WriteWord("DB105.48", (short) 0);// 恢复B01小车应答改为1
        // 恢复B01小车应答改为0
        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(plcmes.getPlcParameter("B01report").getAddressIndex()), (short) 0);
      }
      // 当出片小车完成任务时
      if (B02backs == true) {
      if (B02backs.equals("1") == true) {
        // 判断是否汇报正确的id
        int HB = spianMapper.SelectHB(B02glassid.toString());
        System.out.println("汇报时B02|" + B02glassid);
        int HB = spianMapper.SelectHB(B02glassid);
        if (HB > 0) {
          // 当B02小车汇报完成时更改玻璃状态为0
          S7control.getinstance().WriteWord("DB105.50", (short) 1);// 恢复B02小车应答改为1
          System.out.println("汇报时B02ID|" + B02glassid);
          boolean yingda = spianService.listbool("DB105.50");// b02汇报
          if (yingda == true) {
            spianService.overtask(B02glassid.toString());// 完成任务
          }
          System.out.println("汇报时B02|第" + aaa + "次" + B02glassid + "应答" + yingda);
          // 恢复B02小车应答改为1
          S7control.getinstance().WriteWord(plcmes.getPlcParameter("B02report").getAddress(plcmes.getPlcParameter("B02report").getAddressIndex()), (short) 1);
          String yingda =plcmes.getPlcParameter("B01report").getValue();// b02应答
          if (yingda.equals("1") == true) {
            spianService.overtask(B02glassid);// 完成任务
          }
        }
      }else{
         S7control.getinstance().WriteWord("DB105.50", (short) 0);// 恢复B02小车应答改为0
        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B02report").getAddress(plcmes.getPlcParameter("B02report").getAddressIndex()), (short) 0);
      }
      // 获取DO1数据
      StringBuilder queueid1 = spianService.queGlassid("DB106.26", 14);// 获取请求的id跟DO1同时清
      String Do1ID=plcread.getPlcParameter("FeedID").getValue();// 获取请求的id跟DO1同时清
      // 获取DO2数据
      StringBuilder queueid2 = spianService.queGlassid("DB103.58", 14);
      String Do2ID=plcread.getPlcParameter("FeedID").getValue();// 获取请求的id跟DO1同时清
      int questate = spianMapper.Selectquecount(queueid1.toString());// 判断扫码位是否有玻璃已确认
      int questate = spianMapper.Selectquecount(Do1ID.toString());// 判断扫码位是否有玻璃已确认
      // queueid1.toString().isEmpty()
      north_glass_buffer1 glass1 = spianMapper.selectGlass(queueid1.toString());// D01的玻璃信息
      north_glass_buffer1 glass2 = spianMapper.selectGlass(queueid2.toString());// D02玻璃信息
      north_glass_buffer1 glass1 = spianMapper.selectGlass(Do1ID);// D01的玻璃信息
      north_glass_buffer1 glass2 = spianMapper.selectGlass(Do2ID);// D02玻璃信息
      // 当扫码位玻璃id为空时 宽度为0
      if (queueid1 != null && questate == 0) {
      if (Do1ID != null && questate == 0) {
        // 写入D01的数据到上片队列表
        if (glass1 == null) { // 当没有值时传空
          spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 1);
        } else {
          spianMapper.Updatequeue(queueid1.toString(), glass1.getordernumber(), glass1.getlistnumber(),
              glass1.getboxnumber(), 0, glass1.getglasslengthmm().toString(), glass1.getglassheightmm().toString(),
              glass1.getglasslength().toString(), glass1.getglassheight().toString(), 1);
          spianMapper.Updatequeue(Do1ID.toString(), glass1.getordernumber(), glass1.getlistnumber(),
          glass1.getboxnumber(), 0, glass1.getglasslengthmm().toString(), glass1.getglassheightmm().toString(),
          glass1.getglasslength().toString(), glass1.getglassheight().toString(), 1);
        }
      }
      if (queueid2 != null) {
      if (Do2ID != null) {
        // 写入D02的数据到上片队列表
        if (glass2 == null) {
          spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 2);
        } else {
          spianMapper.Updatequeue(queueid2.toString(), glass2.getordernumber(), glass2.getlistnumber(),
              glass2.getboxnumber(), 0, glass2.getglasslengthmm().toString(), glass2.getglassheightmm().toString(),
              glass2.getglasslength().toString(), glass2.getglassheight().toString(), 2);
          spianMapper.overqueue2(queueid2.toString(), 0, 1);// 更改扫码位任务表的状态为0
          spianMapper.Updatequeue(Do2ID.toString(), glass2.getordernumber(), glass2.getlistnumber(),
          glass2.getboxnumber(), 0, glass2.getglasslengthmm().toString(), glass2.getglassheightmm().toString(),
          glass2.getglasslength().toString(), glass2.getglassheight().toString(), 2);
          spianMapper.overqueue2(Do2ID.toString(), 0, 1);// 更改扫码位任务表的状态为0
          S7control.getinstance().WriteWord("DB105.16", (short) 0);// 关闭任务启动
        }
springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
@@ -19,25 +19,25 @@
         new PlcHold().start();
        new Plchome().start();
         new PlcLayout().start();
         new Plcalarm().start();
        // new Plchome().start();
        //  new PlcLayout().start();
        //  new Plcalarm().start();
         new Plcsign().start();
        //  new Plcsign().start();
         new Plcstate().start();
         new PlcPositioning1().start();
        //  new Plcstate().start();
        //  new PlcPositioning1().start();
         new PlcParameter2().start();
         new PLCAutomaticParameterSetting().start();
        //  new PlcParameter2().start();
        //  new PLCAutomaticParameterSetting().start();
         new PlcManualonePosition().start();
         new PlcManualonePosition2().start();
         new PlcServoManualone().start();
         new PLCManualJog().start();
         new Plclog().start();
        //  new PlcManualonePosition().start();
        //  new PlcManualonePosition2().start();
        //  new PlcServoManualone().start();
        //  new PLCManualJog().start();
        //  new Plclog().start();
         new PlcInteractionState().start();
        //  new PlcInteractionState().start();
        //new PlcParameter1Review().start();
        //new PLCAutomaticParameterSettingReview2().start();
springboot-vue3/src/main/java/com/example/springboot/mapper/SpianMapper.java
@@ -98,7 +98,7 @@
    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=#{tier})as b set a.glass_id=b.glass_id,a.order_id=b.order_id,a.state=1,a.glasswidth=b.glasswidth,a.glassheight=b.glassheight,a.glasswidthmm=b.glasswidthmm,a.glassheightmm=b.glassheightmm,a.listid=b.listid,a.boxid=b.boxid,a.FrameBarcode=b.FrameBarcode where a.id=#{id1}")
    @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=2,a.glasswidth=b.glasswidth,a.glassheight=b.glassheight,a.glasswidthmm=b.glasswidthmm,a.glassheightmm=b.glassheightmm,a.listid=b.listid,a.boxid=b.boxid,a.FrameBarcode=b.FrameBarcode 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},
springboot-vue3/src/main/java/com/example/springboot/service/SpianServiceNew.java
New file
@@ -0,0 +1,314 @@
package com.example.springboot.service;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.springboot.component.PLCAutoMes;
import com.example.springboot.component.S7control;
import com.example.springboot.entity.StorageCage;
import com.example.springboot.entity.north_glass_buffer1;
import com.example.springboot.entity.device.PlcParameterObject;
import com.example.springboot.mapper.SpianMapper;
import com.google.common.primitives.Bytes;
@Service
public class SpianServiceNew {
    @Autowired
    private SpianMapper spianMapper;
          //读取DB105区文件
      PlcParameterObject plcmes=PLCAutoMes.PlcMesObject;
      //读106
      PlcParameterObject plcread=PLCAutoMes.PlcReadObject;
    // @GetMapping("/all")
    public Short selectAll(String glassid) {
        int cage1 = 0;
        int cells;
        int ids;
        int prcid;
        int tiers;
        int prctier;
        double width;
        double minwidth = 0;
        north_glass_buffer1 glasslist = spianMapper.selectGlass(glassid); // 获取玻璃参数
        // 如果没有此id时
        if (glasslist == null) {
            return (300);
        }
        double widths = glasslist.getglasslengthmm();
        String orderids = glasslist.getordernumber();
        String FrameBarcode = glasslist.getFrameBarcode();
        // 获取铝框相关度最高的笼子排序
        List<StorageCage> storageCage = spianMapper.selectAllFbarcode(FrameBarcode, widths, 400);
        // 判断铝框指定空格是否需要间隔空间
        if (storageCage.size() == 0) {
            storageCage = spianMapper.selectAll(orderids, FrameBarcode);
        }
        if (storageCage == null) {
            return (400);
        }
        for (StorageCage storageCage2 : storageCage) {
            // 保存订单优先顺序笼子号
            cage1 = storageCage2.getCage();
            // 判断该笼子号相邻最大的空格数
            int cages = spianMapper.selectCage(cage1);
            // 如果相邻笼子没有空格,或者有正在执行的出片任务时返回400
            if (cages == 0) {
                return (400);
            }
            StorageCage cages1;
            // 判断是否是第二片需要加间隔物
            prctier = spianMapper.selectsum(cage1, storageCage2.getCell());// 传给prc的格子内玻璃数
            if (prctier > 0) {
                cages1 = spianMapper.selectCage1(cage1, storageCage2.getCell(), widths + 400);
            } else {
                cages1 = spianMapper.selectCage1(cage1, storageCage2.getCell(), widths);
            }
            // 判断选中笼子是否有合适宽度空格
            // 有合适空格时进片
            if (cages1 != null && cages >= 1 && storageCage2.getDisabled() == 0) {
                ids = cages1.getId();// 数据库ID
                tiers = cages1.getTier();// 内外片
                cells = cages1.getCell();// 格子号
                prcid = cages1.getPrcId();// 传给prc的目标地id
                width = cages1.getWidth();// 格子剩余宽度
                widths = glasslist.getglasslengthmm();
                // 执行进片
                // 获取该格子内是否有玻璃
                int cellint = spianMapper.selectcell(cage1, cells);
                if (cellint == 1) {
                    // 将外片玻璃的数据更新到内片
                    spianMapper.UpdateDBCage(ids, cage1, cells, 1);
                    // 将新入的玻璃存入外片
                    spianMapper.UpdataAddCage2(orderids, glassid, glasslist, cage1, cells, ids - 1, 2);
                    spianMapper.UpdataAddCage1(widths, cage1, cells);// 减少格子宽度
                } else {
                    // 数据库修改笼子表新增一条玻璃
                    spianMapper.UpdataAddCage2(orderids, glassid, glasslist, cage1, cells, ids, 2);
                    spianMapper.UpdataAddCage1(widths, cage1, cells);// 减少格子宽度
                }
                // 进片车起始位置
                S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddStart").getAddress(plcmes.getPlcParameter("AddStart").getAddressIndex()), (short) 1000);
                // 进片车目标位置
                S7control.getinstance().WriteWord(plcmes.getPlcParameter("Addgoal").getAddress(plcmes.getPlcParameter("Addgoal").getAddressIndex()), (short) prcid);
                // 进片玻璃宽
                S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddLength").getAddress(plcmes.getPlcParameter("AddLength").getAddressIndex()), (short) widths);
                // 进片笼内已有玻璃数
                S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddCount").getAddress(plcmes.getPlcParameter("AddCount").getAddressIndex()), (short) prctier);
                // 进片车启动 1为启动
                S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddActivate").getAddress(plcmes.getPlcParameter("AddActivate").getAddressIndex()), (short) 1);
                String activate =plcmes.getPlcParameter("AddActivate").getValue();// 判断启动是否写入
                int activate2 = 0;
                if (activate.equals("1")) {
                    activate2 = 1;
                }else{
                    while (activate.equals("1")) {
                        // 出片任务发送字改为1
                        S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddActivate").getAddress(plcmes.getPlcParameter("AddActivate").getAddressIndex()), (short) 1);
                        activate =plcmes.getPlcParameter("AddActivate").getValue();// 判断启动是否写入
                    }
                }
                outmesid(glassid, "FeedID");//派发id
                spianMapper.Inserttask(0, 0, 1000, ids, glassid.toString(), prctier,activate2);// 新增任务
                return (200);
            }
        }
        return (400);
    }
    public Short selectout2(String glassid) {
        char[] a = glassid.toCharArray();
        List<Short> datas = new ArrayList<>();
        // 获取优先出片的位置
        StorageCage cageout = spianMapper.selectOut2(glassid);
        if (cageout == null) {
            return (300);
        }
        int cage = cageout.getCage(); // 储存出片位置,笼子格子几号玻璃
        int cell = cageout.getCell();// 出片格号
        int tier = cageout.getTier();// 出片内外片
        int prcid = cageout.getPrcId();// prcid
        int prcid2;
        int ids;
        int cages;
        int cells;
        double glasswidth = cageout.getGlassWidth();
        int state = spianMapper.selectGlassState(cage, cell);// 获取格子数量
        // 判断玻璃内外片
        if (tier == 2) {
            // 判断玻璃可直接出片时
            spianMapper.OverOutSlice(glassid.toString(), 1, 0);// 更新出片队列任务状态为进行中
            spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度
            spianMapper.UpdataGlassCageState(glassid.toString(), 3);// 更改笼子表的玻璃状态
            spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid, state, 3);// 新增任务
        } else {
            // 获取格子的玻璃数量
            // 判断内片是否需要调拨
            if (state == 1) {
                spianMapper.OverOutSlice(glassid.toString(), 1, 0);// 更新出片队列任务状态为进行中
                spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度
                spianMapper.UpdataGlassCageState(glassid, 3);// 更改笼子表的玻璃状态
                spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid, 1,3);// 新增任务
            } else {
                // 玻璃需要调拨时,判断属于哪个半区的笼子
                if (cage < 6) {
                    StorageCage cagecell = spianMapper.selectGlassCage(cage, glasswidth, 0, 6, cell);
                    if (cagecell == null) {
                        return (300);
                    }
                    // 获取调拨位置进行调拨
                    prcid2 = cagecell.getPrcId();// 调拨目标位PRCID
                    ids = cagecell.getId();// 调拨目标位ID
                    cages = cagecell.getCage();// 调拨目标位笼子
                    cells = cagecell.getCell();// 调拨目标位格子
                    // 更换玻璃的笼子
                    String glassids = spianMapper.SelectGlassid(cage, cell); // 获取被调拨的玻璃id
                    spianMapper.UpdataGlassCageState(glassids, 3);// 更改笼子表的玻璃状态
                    spianMapper.UpdateDBCage(ids, cage, cell, 2);// 将原格子数据更新到新格子里
                    spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 减少新格子宽度
                    spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度
                    spianMapper.Inserttask(2, 0, cageout.getId(), ids, glassids, 2, 3);// 新增调度任务
                } else {// 笼子号大于5时
                    StorageCage cagecell = spianMapper.selectGlassCage(cage, glasswidth, 5, 11, cell);
                    if (cagecell == null) {
                        return (300);
                    }
                    // 获取调拨位置进行调拨
                    prcid2 = cagecell.getPrcId();// 调拨目标位prcID
                    ids = cagecell.getId();// 调拨目标位ID
                    cages = cagecell.getCage();// 调拨目标位笼子
                    cells = cagecell.getCell();// 调拨目标位格子
                    String glassids = spianMapper.SelectGlassid(cage, cell); // 获取被调拨的玻璃id
                    spianMapper.UpdataGlassCageState(glassids, 3);// 更改笼子表的玻璃状态
                    spianMapper.Inserttask(2, 0, cageout.getId() + 1, ids, glassids, 2, 3);// 新增调度任务
                    spianMapper.UpdateDBCage(ids, cage, cell, 2);// 将原格子数据更新到新格子里
                    spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 减少新格子宽度
                    spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 增加原格子宽度
                }
                //发送plc任务
                 S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddStart").getAddress(plcmes.getPlcParameter("AddStart").getAddressIndex()), (short) prcid);
                 S7control.getinstance().WriteWord(plcmes.getPlcParameter("Addgoal").getAddress(plcmes.getPlcParameter("Addgoal").getAddressIndex()), (short) prcid2);
                 S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddCount").getAddress(plcmes.getPlcParameter("AddCount").getAddressIndex()), (short) state);
                 S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddActivate").getAddress(plcmes.getPlcParameter("AddActivate").getAddressIndex()), (short) 1);
                 String activate =plcmes.getPlcParameter("AddActivate").getValue();// 判断启动是否写入
                 int activate2 = 0;
                 if (activate.equals("1")) {
                     activate2 = 1;
                 }else{
                     while (activate.equals("1")) {
                         // 出片任务发送字改为1
                         S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddActivate").getAddress(plcmes.getPlcParameter("AddActivate").getAddressIndex()), (short) 1);
                         activate =plcmes.getPlcParameter("AddActivate").getValue();// 判断启动是否写入
                     }
                 }
                outmesid(glassid, "ReleaseID");//派发id
                //发送完倒片结束
                return (200); // 结束
            }
        }
         // 出片车起始位置
         S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddStart").getAddress(plcmes.getPlcParameter("OutStart").getAddressIndex()), (short) prcid);
         // 出片车目标位置
         S7control.getinstance().WriteWord(plcmes.getPlcParameter("Addgoal").getAddress(plcmes.getPlcParameter("Outgoal").getAddressIndex()), (short) 1000);
         // 出片笼内已有玻璃数
         S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddCount").getAddress(plcmes.getPlcParameter("OutCount").getAddressIndex()), (short) state);
         // 出片车启动 1为启动
         S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddActivate").getAddress(plcmes.getPlcParameter("OutActivate").getAddressIndex()), (short) 1);
         String activate =plcmes.getPlcParameter("AddActivate").getValue();// 判断启动是否写入
         int activate2 = 0;
         if (activate.equals("1")) {
             activate2 = 1;
         }else{
             while (activate.equals("1")) {
                 // 出片任务发送字改为1
                 S7control.getinstance().WriteWord(plcmes.getPlcParameter("AddActivate").getAddress(plcmes.getPlcParameter("AddActivate").getAddressIndex()), (short) 1);
                 activate =plcmes.getPlcParameter("AddActivate").getValue();// 判断启动是否写入
             }
         }
         outmesid(glassid, "ReleaseID");//派发id
        //直接出片结束
        return(200);// 结束
    }
    // 派发任务玻璃id
    public void outmesid(String glassid, String address) {
        // System.out.println("outmesid:" + glassid);
        List<Byte> glassidlist = new ArrayList();
        char ds[] = glassid.toCharArray();
        for (char iditem : ds) {
            glassidlist.add((byte) iditem);
        }
        byte[] bytes = Bytes.toArray(glassidlist);
        System.out.println("outmesidbytes:" + bytes.length);
        S7control.getinstance().WriteByte(plcmes.getPlcParameter(address).getAddress(plcmes.getPlcParameter(address).getAddressIndex()),bytes);
        //S7control.getinstance().WriteByte(address, bytes);// 派发出片id
    }
    // 获取地址内的玻璃id转字符串
    public StringBuilder queGlassid(String address, int count) {
        StringBuilder writedstrIdOut = new StringBuilder();
        byte[] writedglassidbytesOut = S7control.getinstance().ReadByte(address, count);
        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();
    }
    // 判断集合里是否为1
    public boolean listbool(String address) {
        List<Short> list = S7control.getinstance().ReadWord(address, 1);// 返回为ture时为1
        boolean listbool = list.contains((short) 1);
        return listbool;
    }
    // 根据玻璃id完成在进行中的任务
    public void overtask(String glassid) {
        spianMapper.UpdatetaskOut(glassid.toString());// 完成上一次 出片或者进片任务
        spianMapper.OverOutSlice(glassid.toString(), 2, 1);// 完成出片队列任务
        spianMapper.UpdataGlassCage(glassid.toString(), 0);// 清除出片格子玻璃信息
        spianMapper.UpdateCageOver(glassid.toString(), 0);// 更改笼子表出片状态
        spianMapper.UpdateCageadd(glassid.toString(), 1);// 更改笼子表进片状态
        spianMapper.UpdateAddQueue(glassid.toString());// 把进片的玻璃更新到出片队列中
    }
}