From 8223485b2f6c909de81924e107b1e268aa04bd41 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期日, 30 六月 2024 22:59:26 +0800
Subject: [PATCH] 1、大理片笼进片逻辑调整:a、将扫描id后进生成任务信息,不执行卧转立进片命令;                      b、进片车空闲扫描,如果存在卧转立有满片的直接启动, 2、下片任务新增任务向plc发送任务信息 3、对外提供手工生成人工下片任务

---
 hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/JsonFile/PlcCacheVerticalGlass.json                  |    2 
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/controller/DownGlassTaskController.java    |   16 +
 hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/common/S7object.java                              |    9 
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/entity/DownGlassTask.java                  |    4 
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownCacheGlassTask.java                              |    5 
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/resources/JsonFile/PlcdownGlass.json                                  |  502 +++++++++++------------------------------
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/DownGlassInfoService.java          |   10 
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java                          |   44 ++-
 hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/PlcStorageCageTask.java                       |   84 ++++--
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/impl/DownGlassInfoServiceImpl.java |   36 ++
 10 files changed, 293 insertions(+), 419 deletions(-)

diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/common/S7object.java b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/common/S7object.java
index 304846e..4f5e96b 100644
--- a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/common/S7object.java
+++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/common/S7object.java
@@ -14,7 +14,7 @@
 public class S7object extends Thread {
     public S7control plccontrol; // PLC閫氳绫诲疄渚�
     private EPlcType plcType = EPlcType.S1200; // 瑗块棬瀛怭LC绫诲瀷
-    private String ip = "192.168.10.1"; // plc ip鍦板潃
+    private String ip = "192.168.20.100"; // plc ip鍦板潃
     private int port = 102; // plc 绔彛鍙�
 
 
@@ -25,7 +25,7 @@
         if (plccontrol == null) {
             plccontrol = new S7control(plcType, ip, port, 0, 0);
 
-            String PlcLoadGlass=S7object.class.getResource("/JsonFile/PlcCacheVerticalGlass.json").getPath();
+            String PlcLoadGlass = S7object.class.getResource("/JsonFile/PlcCacheVerticalGlass.json").getPath();
             //log.info(PLCAutoMes.class.getResource("").getPath());
             PlcMesObject = InitUtil.initword(PlcLoadGlass);
         }
@@ -54,8 +54,9 @@
             }
 
             byte[] getplcvlues = plccontrol.readByte(PlcMesObject.getPlcAddressBegin(), PlcMesObject.getPlcAddressLength());
-            PlcMesObject.setPlcParameterList(getplcvlues);
-
+            if (getplcvlues != null) {
+                PlcMesObject.setPlcParameterList(getplcvlues);
+            }
         }
     }
 }
diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/PlcStorageCageTask.java b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/PlcStorageCageTask.java
index 7042a34..28c7f1f 100644
--- a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/PlcStorageCageTask.java
+++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/PlcStorageCageTask.java
@@ -78,11 +78,11 @@
     @Value("${mes.galssGap}")
     private Integer galssGap;
 
-    @Scheduled(fixedDelay = 5000)
+    //    @Scheduled(fixedDelay = 5000)
     public void plcToHomeEdgScan() {
         PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject;
-        String d01Id = plcParameterObject.getPlcParameter("D01ID1").getValue();
-        String d02Id = plcParameterObject.getPlcParameter("D02ID1").getValue();
+        String d01Id = plcParameterObject.getPlcParameter("D01ID").getValue();
+        String d02Id = plcParameterObject.getPlcParameter("D02ID").getValue();
         String d03State = plcParameterObject.getPlcParameter("D03State").getValue();
         String d05State = plcParameterObject.getPlcParameter("D05State").getValue();
         String mesD03Address = plcParameterObject.getPlcParameter("MESToD03").getAddress();
@@ -98,27 +98,28 @@
             log.info("涓ゆ潯绾垮崸杞珛鍧囧湪鎵ц浠诲姟锛岀粨鏉熸湰娆℃壂鎻忚繘鍗ц浆绔嬩换鍔�");
             return;
         }
-        Boolean flag01 = Boolean.FALSE;
-        Boolean flag04 = Boolean.FALSE;
+//        Boolean flag01 = Boolean.FALSE;
+//        Boolean flag04 = Boolean.FALSE;
         //鎸夌収绾胯矾鍙婄幓鐠僫d鑾峰彇鐩搁偦涓ゅ潡鐜荤拑 鍗ц浆绔嬩笂鐨勭幓鐠�
-        if (StringUtils.isBlank(d01Id) && !REQUEST_WORD.equals(d03State)) {
-            flag01 = judgeGlassTypeStatus(d01Id, Const.A09_OUT_TARGET_POSITION, mesD03Address);
+        if (StringUtils.isNotBlank(d01Id) && !REQUEST_WORD.equals(d03State)) {
+            judgeGlassTypeStatus(d01Id, Const.A09_OUT_TARGET_POSITION, mesD03Address);
         }
-        if (StringUtils.isBlank(d02Id) && !REQUEST_WORD.equals(d05State)) {
-            flag04 = judgeGlassTypeStatus(d02Id, Const.A10_OUT_TARGET_POSITION, mesD05Address);
+        if (StringUtils.isNotBlank(d02Id) && !REQUEST_WORD.equals(d05State)) {
+            judgeGlassTypeStatus(d02Id, Const.A10_OUT_TARGET_POSITION, mesD05Address);
         }
-        if (flag01 && flag04) {
-            //姣旇緝鏈�鏃╀竴鐗囦换鍔$殑鐗堝浘id鍙婄増搴� 姹傚嚭鍗ц浆绔嬬殑绾胯矾
-            Integer startLine = getStartLine();
-            //璁$畻鐩爣鏍煎瓙锛屽彂閫佸惎鍔ㄤ换鍔�
-            computeTargetByLine(startLine);
-        } else if (flag01 || flag04) {
-            Integer startLine = flag01.equals(Boolean.TRUE) ? Const.A09_OUT_TARGET_POSITION : Const.A10_OUT_TARGET_POSITION;
-            //璁$畻鐩爣鏍煎瓙锛屽彂閫佸惎鍔ㄤ换鍔�
-            computeTargetByLine(startLine);
-        } else {
-            log.info("涓ゆ潯绾挎湭鏀跺埌杩涚墖浠诲姟锛岀粨鏉熸湰娆℃壂鎻忚繘鍗ц浆绔嬩换鍔�");
-        }
+        log.info("缁撴潫鎵爜浠诲姟");
+//        if (flag01 && flag04) {
+//            //姣旇緝鏈�鏃╀竴鐗囦换鍔$殑鐗堝浘id鍙婄増搴� 姹傚嚭鍗ц浆绔嬬殑绾胯矾
+//            Integer startLine = getStartLine();
+//            //璁$畻鐩爣鏍煎瓙锛屽彂閫佸惎鍔ㄤ换鍔�
+//            computeTargetByLine(startLine);
+//        } else if (flag01 || flag04) {
+//            Integer startLine = flag01.equals(Boolean.TRUE) ? Const.A09_OUT_TARGET_POSITION : Const.A10_OUT_TARGET_POSITION;
+//            //璁$畻鐩爣鏍煎瓙锛屽彂閫佸惎鍔ㄤ换鍔�
+//            computeTargetByLine(startLine);
+//        } else {
+//            log.info("涓ゆ潯绾挎湭鏀跺埌杩涚墖浠诲姟锛岀粨鏉熸湰娆℃壂鎻忚繘鍗ц浆绔嬩换鍔�");
+//        }
     }
 
     @Scheduled(fixedDelay = 5000)
@@ -129,10 +130,24 @@
             log.info("杩涚墖澶ц溅闈炵┖闂�");
             return;
         }
-        String d01Id = plcParameterObject.getPlcParameter("D01ID1").getValue();
-        String d02Id = plcParameterObject.getPlcParameter("D02ID1").getValue();
+        List<BigStorageCageFeedTask> feedTaskList = bigStorageCageFeedTaskService.list(new LambdaQueryWrapper<BigStorageCageFeedTask>()
+                .eq(BigStorageCageFeedTask::getTaskType, Const.BIG_STORAGE_IN_RUN)
+                .eq(BigStorageCageFeedTask::getTaskState, Const.BIG_STORAGE_IN_UP));
+        if (CollectionUtils.isNotEmpty(feedTaskList)) {
+            if (feedTaskList.size() == 1) {
+                computeTargetByLine(feedTaskList.get(0).getLine());
+                return;
+            } else {
+                //姣旇緝鏈�鏃╀竴鐗囦换鍔$殑鐗堝浘id鍙婄増搴� 姹傚嚭鍗ц浆绔嬬殑绾胯矾
+                Integer startLine = getStartLine();
+//            //璁$畻鐩爣鏍煎瓙锛屽彂閫佸惎鍔ㄤ换鍔�
+                computeTargetByLine(startLine);
+                return;
+            }
+        }
+        String d01Id = plcParameterObject.getPlcParameter("D01ID").getValue();
+        String d02Id = plcParameterObject.getPlcParameter("D02ID").getValue();
         log.info("1銆佽幏鍙杁01Id鎵弿ID涓猴細{};鑾峰彇d02Id鎵弿ID涓猴細{};", d01Id, d02Id);
-        ;
         //涓ゆ潯绾块兘鏈夎繘鍗ц浆绔嬩换鍔★紝鐩存帴缁撴潫
         if (StringUtils.isNotBlank(d01Id) && StringUtils.isNotBlank(d02Id)) {
             log.info("涓ゆ潯绾块兘瀛樺湪杩涚墖浠诲姟锛岀粨鏉熶换鍔�");
@@ -168,7 +183,7 @@
         computeTargetByLine(outLine);
     }
 
-    @Scheduled(fixedDelay = 5000)
+    //    @Scheduled(fixedDelay = 5000)
     public void plcToHomeEdgOutTask() {
 
         List<BigStorageCageOutTask> outingList = bigStorageCageOutTaskService.list(new LambdaQueryWrapper<BigStorageCageOutTask>().eq(BigStorageCageOutTask::getTaskState, Const.BIG_STORAGE_OUT_NEW));
@@ -253,17 +268,19 @@
             remainWidth = sitToUpRemainWidth.getWidth();
             glassCount = sitToUpRemainWidth.getGlassCount();
         }
+
+        Boolean flag = Boolean.TRUE;
         //2銆佽幏鍙栧崸杞珛
         Integer widthFirst = edgGlassTaskInfoList.get(0).getWidth();
         if (edgGlassTaskInfoList.size() == 1) {
             if (remainWidth >= widthFirst) {
                 if (glassCount <= 5) {
                     addFeedTask(glassId, line, Const.BIG_STORAGE_IN_WAIT, widthFirst);
-                    return Boolean.FALSE;
                 } else {
                     addFeedTask(glassId, line, Const.BIG_STORAGE_IN_RUN, widthFirst);
-                    return Boolean.TRUE;
                 }
+            } else {
+                flag = Boolean.FALSE;
             }
         } else {
             Integer widthSecond = edgGlassTaskInfoList.get(1).getWidth();
@@ -271,20 +288,22 @@
                 if (remainWidth - widthFirst - galssGap >= widthSecond) {
                     if (glassCount <= carMaxSize - 1) {
                         addFeedTask(glassId, line, Const.BIG_STORAGE_IN_WAIT, widthFirst);
-                        return Boolean.FALSE;
                     } else {
                         addFeedTask(glassId, line, Const.BIG_STORAGE_IN_RUN, widthFirst);
-                        return Boolean.TRUE;
                     }
                 } else {
                     addFeedTask(glassId, line, Const.BIG_STORAGE_IN_RUN, widthFirst);
                 }
+            } else {
+                flag = Boolean.FALSE;
             }
         }
         //鍚憄lc鍙戦�佽繘鐗囩‘璁�
-        S7object.getinstance().plccontrol.writeWord(mesAddress, (short) 1);
+        if (flag) {
+            S7object.getinstance().plccontrol.writeWord(mesAddress, (short) 1);
+        }
         //璁板綍鏃犳硶鏀句笅鐜荤拑锛屽悗缁垽鏂惎鍔�
-        return Boolean.TRUE;
+        return flag;
     }
 
     /**
@@ -332,7 +351,7 @@
         //2銆佸幓绗煎瓙鍐呮煡鎵炬槸鍚﹀彲浠ョ户缁瓨鏀剧殑绗煎瓙
         List<String> glassIds = taskList.stream().map(BigStorageCageFeedTask::getGlassId).collect(Collectors.toList());
         List<GlassInfo> glassInfos = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>().in(GlassInfo::getGlassId, glassIds));
-        return computeIsTemperingTargetByLine(glassInfos, taskList, line) && computeIsTemperingTargetByLine(glassInfos, taskList, line);
+        return computeIsTemperingTargetByLine(glassInfos, taskList, line);
     }
 
     /**
@@ -368,7 +387,6 @@
             cageDetails.setState(Const.GLASS_STATE_IN);
             bigStorageCageDetailsService.save(cageDetails);
         }
-        //todo:鎸夌収杩涚墖淇℃伅鍚戞墦杞﹀彂閫佽繘杞︽暟鎹�
         sendTaskListToPLC(taskList, line);
         return Boolean.TRUE;
     }
diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/JsonFile/PlcCacheVerticalGlass.json b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/JsonFile/PlcCacheVerticalGlass.json
index 1b4d72d..e19b6ac 100644
--- a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/JsonFile/PlcCacheVerticalGlass.json
+++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/JsonFile/PlcCacheVerticalGlass.json
@@ -1,6 +1,6 @@
 {
 	"plcAddressBegin": "DB14.0",
-	"plcAddressLenght": "894",
+	"plcAddressLenght": "938",
 	"dataType": "word",
 	"parameteInfor": [{
 			"codeId": "D01ID",
diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/controller/DownGlassTaskController.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/controller/DownGlassTaskController.java
index 4daca39..97130df 100644
--- a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/controller/DownGlassTaskController.java
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/controller/DownGlassTaskController.java
@@ -1,9 +1,12 @@
 package com.mes.downglassinfo.controller;
 
 
-import io.swagger.annotations.Api;
+import com.mes.downglassinfo.service.DownGlassInfoService;
+import com.mes.utils.Result;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -20,5 +23,14 @@
 @RequestMapping("/downGlassTask")
 public class DownGlassTaskController {
 
+    @Autowired
+    DownGlassInfoService downGlassInfoService;
+
+    @PostMapping("/generateOutGlassTask")
+    @ApiOperation(value = "鐢熸垚鍑虹墖浠诲姟", notes = "鐢熸垚鍑虹墖浠诲姟")
+    public Result<Boolean> generateOutGlassTask(@RequestBody String glassId) {
+        return Result.success(downGlassInfoService.generateOutGlassTask(glassId));
+    }
+
 }
 
diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/entity/DownGlassTask.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/entity/DownGlassTask.java
index 1f275f1..d14ded1 100644
--- a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/entity/DownGlassTask.java
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/entity/DownGlassTask.java
@@ -73,6 +73,10 @@
      * 娴佺▼鍗″彿
      */
     private String flowCardId;
+    /**
+     * 灞傚彿
+     */
+    private int layer;
 
     /**
      * 浠诲姟鐘舵�� 0 鏈紑濮�  1姝e湪杩涜   2瀹屾垚
diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/DownGlassInfoService.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/DownGlassInfoService.java
index 8475169..0830e6b 100644
--- a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/DownGlassInfoService.java
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/DownGlassInfoService.java
@@ -13,7 +13,7 @@
      * @param flowCardId
      * @return // 鏍规嵁娴佺▼鍗″彿鏌ヨ鏈�澶у簭鍙�
      */
-    Integer getMaxSequenceByFlowCardId(String flowCardId);
+    Integer getMaxSequenceByFlowCardId(String flowCardId, int layer);
 
     /**
      * @param downGlassInfo 鎻掑叆涓嬬墖淇℃伅
@@ -32,4 +32,12 @@
      * @return
      */
     List<DownGlassInfoDTO> queryWorkStationIsIn(Boolean isDownload);
+
+    /**
+     * 鐢熸垚鍑虹墖浠诲姟
+     *
+     * @param glassId
+     * @return
+     */
+    boolean generateOutGlassTask(String glassId);
 }
diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/impl/DownGlassInfoServiceImpl.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/impl/DownGlassInfoServiceImpl.java
index 4cfb8bd..64317a2 100644
--- a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/impl/DownGlassInfoServiceImpl.java
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/impl/DownGlassInfoServiceImpl.java
@@ -1,12 +1,20 @@
 package com.mes.downglassinfo.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.mes.common.config.Const;
 import com.mes.downglassinfo.entity.DownGlassInfo;
 import com.mes.downglassinfo.mapper.DownGlassInfoMapper;
 import com.mes.downglassinfo.service.DownGlassInfoService;
+import com.mes.downstorage.entity.DownStorageCageDetails;
+import com.mes.downstorage.service.DownStorageCageDetailsService;
 import com.mes.downworkstation.entity.dto.DownGlassInfoDTO;
+import com.mes.glassinfo.entity.GlassInfo;
+import com.mes.job.DownLoadCacheGlassTask;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -14,13 +22,20 @@
 @Service
 public class DownGlassInfoServiceImpl extends ServiceImpl<DownGlassInfoMapper, DownGlassInfo> implements DownGlassInfoService {
 
+    @Autowired
+    DownLoadCacheGlassTask downLoadCacheGlassTask;
+
+    @Autowired
+    DownStorageCageDetailsService downStorageCageDetailsService;
+
     /**
      * 鏍规嵁娴佺▼鍗″彿鏌ヨ鏈�澶у簭鍙�
      */
     @Override
-    public Integer getMaxSequenceByFlowCardId(String flowCardId) {
+    public Integer getMaxSequenceByFlowCardId(String flowCardId, int layer) {
         LambdaQueryWrapper<DownGlassInfo> lambdaQueryWrapper = Wrappers.lambdaQuery();
         lambdaQueryWrapper.eq(DownGlassInfo::getFlowCardId, flowCardId)
+                .eq(DownGlassInfo::getLayer, flowCardId)
                 .select(DownGlassInfo::getSequence)
                 .orderByDesc(DownGlassInfo::getSequence)
                 .last("LIMIT 1");
@@ -48,4 +63,23 @@
     public List<DownGlassInfoDTO> queryWorkStationIsIn(Boolean isDownload) {
         return baseMapper.queryWorkStationIsIn(isDownload);
     }
+
+    @Override
+    public boolean generateOutGlassTask(String glassId) {
+        //鏇存柊鍗у紡鐞嗙墖绗煎唴鐜荤拑鐘舵��
+        downStorageCageDetailsService.update(new LambdaUpdateWrapper<DownStorageCageDetails>()
+                .set(DownStorageCageDetails::getState, Const.GLASS_STATE_OUT).eq(DownStorageCageDetails::getGlassId, glassId));
+        DownStorageCageDetails details = downStorageCageDetailsService.getOne(new LambdaQueryWrapper<DownStorageCageDetails>()
+                .eq(DownStorageCageDetails::getGlassId, glassId));
+        //鐢熸垚涓嬬墖淇℃伅
+        DownGlassInfo downGlassInfo = new DownGlassInfo();
+        BeanUtils.copyProperties(details, downGlassInfo);
+        //鑾峰彇褰撳墠娴佺▼鍗℃渶澶х墖搴�
+        downGlassInfo.setSequence(this.getMaxSequenceByFlowCardId(details.getFlowCardId(), details.getLayer()) + 1);
+        this.save(downGlassInfo);
+        //鐢熸垚浠诲姟淇℃伅 骞跺悜plc鍙戦�佸嚭鐗囦换鍔�
+        GlassInfo glassInfo = new GlassInfo();
+        BeanUtils.copyProperties(details, glassInfo);
+        return downLoadCacheGlassTask.initDownGlassTask(glassInfo, details.getSlot(), 3001, 2);
+    }
 }
diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownCacheGlassTask.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownCacheGlassTask.java
index 9ce8dcc..da50b29 100644
--- a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownCacheGlassTask.java
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownCacheGlassTask.java
@@ -17,7 +17,6 @@
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import java.util.List;
@@ -52,7 +51,7 @@
     //    @Value("${mes.threshold}")
     private int threshold;
 
-    @Scheduled(fixedDelay = 1000)
+//    @Scheduled(fixedDelay = 1000)
     public void autoBindRack() {
         log.info("鏍规嵁缂撳瓨涓凡缁忚繘鐗囩殑鐜荤拑绉嶆暟閲忔渶澶氱殑娴佺▼鍗″彿鑷姩缁戝畾涓�涓惎鐢ㄧ姸鎬佺殑绌烘灦瀛�");
 
@@ -277,7 +276,7 @@
                     // 鍒涘缓鏂扮殑 DownGlassInfo 瀵硅薄骞惰缃浉鍏冲睘鎬�
                     DownGlassInfo newdownGlassInfo = new DownGlassInfo();
 
-                    Integer maxSequence = downGlassInfoService.getMaxSequenceByFlowCardId(downGlassInfo.getFlowCardId());
+                    Integer maxSequence = downGlassInfoService.getMaxSequenceByFlowCardId(downGlassInfo.getFlowCardId(), downGlassInfo.getLayer());
                     // 鍒濆鍖栭『搴忓瓧娈靛��
                     int sequence = maxSequence != null ? maxSequence + 1 : 1;
                     BeanUtils.copyProperties(downGlassInfo, newdownGlassInfo);
diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java
index e2d0aa2..14c5322 100644
--- a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java
@@ -20,6 +20,7 @@
 import com.mes.downworkstation.service.DownWorkstationService;
 import com.mes.glassinfo.entity.GlassInfo;
 import com.mes.glassinfo.service.GlassInfoService;
+import com.mes.tools.S7control;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.BeanUtils;
@@ -75,16 +76,18 @@
     public void plcHomeEdgTask() {
         PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject;
         String requestWord = plcParameterObject.getPlcParameter("RequestWord").getValue();
-        String glassIdeValue = plcParameterObject.getPlcParameter("G04ID").getValue();
-        String confirmationWrodValue = plcParameterObject.getPlcParameter("MES_confirmation_word").getValue();
+        String glassIdeValue = plcParameterObject.getPlcParameter("requestID").getValue();
         //A08  A09琛ㄧず绾胯矾鐩稿悓  鍙仛绛変环  鏃犳暟鎹浆int寮傚父
-        String out08Glassstate = plcParameterObject.getPlcParameter("A08_glass_status").getValue();
-        String out10Glassstate = plcParameterObject.getPlcParameter("A10_glass_status").getValue();
-        String confirmationWrodAddress = plcParameterObject.getPlcParameter("MES_confirmation_word").getAddress();
-        String currentSlot = plcParameterObject.getPlcParameter("Current_slot").getValue();
+        String out06Glassstate = plcParameterObject.getPlcParameter("glassStatus06").getValue();
+        String out08Glassstate = plcParameterObject.getPlcParameter("glassStatus08").getValue();
+        String out11Glassstate = plcParameterObject.getPlcParameter("glassStatus11").getValue();
+        String out13Glassstate = plcParameterObject.getPlcParameter("glassStatus13").getValue();
+        String confirmationWrodValue = plcParameterObject.getPlcParameter("confirmationWord").getValue();
+        String confirmationWrodAddress = plcParameterObject.getPlcParameter("confirmationWord").getAddress();
+        String currentSlot = plcParameterObject.getPlcParameter("currentCell").getValue();
 
-        log.info("1銆佽幏鍙栧埌鐨勮姹傚瓧涓猴細{}锛岃幏鍙栧埌鐨勬壂鎻廔D涓猴細{}锛岃幏鍙栧埌鐨勭‘璁ゅ瓧涓猴細{}锛岃幏鍙栧埌鐨勫嚭鐗囩姸鎬佸垎鍒负锛欰09:{}銆丄10:{},褰撳墠鏍煎瓙鍙蜂负锛歿}",
-                requestWord, glassIdeValue, confirmationWrodValue, out08Glassstate, out10Glassstate, currentSlot);
+        log.info("1銆佽幏鍙栧埌鐨勮姹傚瓧涓猴細{}锛岃幏鍙栧埌鐨勬壂鎻廔D涓猴細{}锛岃幏鍙栧埌鐨勭‘璁ゅ瓧涓猴細{}锛岃幏鍙栧埌鐨勫嚭鐗囩姸鎬佸垎鍒负锛歡06:{}銆乬08:{}銆乬11:{}銆乬13:{},褰撳墠鏍煎瓙鍙蜂负锛歿}",
+                requestWord, glassIdeValue, confirmationWrodValue, out06Glassstate, out08Glassstate, out11Glassstate, out13Glassstate, currentSlot);
 
         if ("0".equals(requestWord)) {
             if ("0".equals(confirmationWrodValue)) {
@@ -208,9 +211,6 @@
         downStorageCageDetailsService.save(downStorageCageDetails);
 //        鐢熸垚杩涚墖浠诲姟
         initDownGlassTask(glassInfo, 0, nearestEmpty.getSlot(), Const.GLASS_CACHE_TYPE_IN);
-        //log.info("5銆佺敓鎴愯繘鐗囦换鍔′俊鎭瓨鍏ヤ换鍔¤〃鏄惁瀹屾垚锛歿}", taskCache);
-//        S7object.getinstance().plccontrol.writeWord(confirmationWrodAddress, (short) 1);
-//        log.info("6銆佸彂閫佺‘璁ゅ瓧瀹屾垚");
     }
 
     public Boolean outTo(String glassStatus06, String glassStatus11, String glassStatus13, String glassId) {
@@ -419,7 +419,7 @@
         }
     }
 
-    private Boolean generateDownGlassOutTask(String glassId, Integer taskType, Boolean isBind, DownStorageCageDetails cageDetails) {
+    public Boolean generateDownGlassOutTask(String glassId, Integer taskType, Boolean isBind, DownStorageCageDetails cageDetails) {
         //鎸夌幓鐠僫d鑾峰彇鐜荤拑淇℃伅
         DownStorageCageDetails downStorageCageDetails = null;
         if (glassId.equals(cageDetails.getGlassId())) {
@@ -468,7 +468,7 @@
         return initDownGlassTask(glassInfo, downStorageCageDetails.getSlot(), endCell, taskType);
     }
 
-    private Boolean initDownGlassTask(GlassInfo glassInfo, Integer startCell, Integer endCell, Integer taskType) {
+    public Boolean initDownGlassTask(GlassInfo glassInfo, Integer startCell, Integer endCell, Integer taskType) {
         log.info("鐜荤拑{}鐢熸垚杩涚墖浠诲姟", glassInfo.getGlassId());
         DownGlassTask downGlassTask = new DownGlassTask();
         downGlassTask.setStartCell(startCell);
@@ -480,6 +480,22 @@
         downGlassTask.setFlowCardId(glassInfo.getFlowCardId());
         downGlassTask.setTaskStauts(0);
         downGlassTask.setCreateTime(new Date());
-        return downGlassTaskService.save(downGlassTask);
+        downGlassTaskService.save(downGlassTask);
+        //鍚憄lc鍙戦�佸懡浠�
+        return sendMessageToPlc((int) glassInfo.getWidth(), (int) glassInfo.getHeight(), (int) glassInfo.getThickness(),
+                startCell, endCell, taskType);
+    }
+
+    private Boolean sendMessageToPlc(int width, int height, int thickness, int startCell, int endCell, int taskType) {
+        S7control s7control = S7object.getinstance().plccontrol;
+        PlcParameterObject plcMesObject = S7object.getinstance().PlcMesObject;
+        s7control.writeWord(plcMesObject.getPlcParameter("Glass_width").getAddress(), (short) width * 10);
+        s7control.writeWord(plcMesObject.getPlcParameter("Glass_height").getAddress(), (short) height * 10);
+        s7control.writeWord(plcMesObject.getPlcParameter("Glass_thickness").getAddress(), (short) thickness * 10);
+        s7control.writeWord(plcMesObject.getPlcParameter("Start_cell").getAddress(), (short) startCell);
+        s7control.writeWord(plcMesObject.getPlcParameter("End_cell").getAddress(), (short) endCell);
+        s7control.writeWord(plcMesObject.getPlcParameter("task_type").getAddress(), (short) taskType);
+        s7control.writeWord(plcMesObject.getPlcParameter("confirmationWord").getAddress(), (short) 1);
+        return Boolean.TRUE;
     }
 }
diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/resources/JsonFile/PlcdownGlass.json b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/resources/JsonFile/PlcdownGlass.json
index bb10665..06d63e2 100644
--- a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/resources/JsonFile/PlcdownGlass.json
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/resources/JsonFile/PlcdownGlass.json
@@ -1,362 +1,144 @@
 {
-  "plcAddressBegin": "DB100.0",
-  "plcAddressLenght": "230",
-  "dataType": "word",
-  "parameteInfor": [
-    {
-      "codeId": "RequestWord",
-      "addressIndex": "0",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G04ID",
-      "addressIndex": "30",
-      "addressLenght": "30"
-    },
-    {
-      "codeId": "G06RobotTaskRequestWord",
-      "addressIndex": "32",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G06ID",
-      "addressIndex": "62",
-      "addressLenght": "30"
-    },
-    {
-      "codeId": "G11RobotTaskRequestWord",
-      "addressIndex": "64",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G011ID",
-      "addressIndex": "94",
-      "addressLenght": "30"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "96",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "98",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "100",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "102",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "MESSendingWord",
-      "addressIndex": "104",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "InputGrid",
-      "addressIndex": "106",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "OutputGrid",
-      "addressIndex": "108",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "OutputID",
-      "addressIndex": "110",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "FrontOrRearLowerSlice",
-      "addressIndex": "112",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "114",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G06RobotTaskReply",
-      "addressIndex": "116",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G06Rack",
-      "addressIndex": "118",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G11RobotTaskReply",
-      "addressIndex": "120",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G11Rack",
-      "addressIndex": "122",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "124",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "126",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "128",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "130",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "132",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "134",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "136",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "138",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "MESTaskState",
-      "addressIndex": "140",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "142",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "AlarmState",
-      "addressIndex": "144",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "Alarm1",
-      "addressIndex": "146",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "Alarm2",
-      "addressIndex": "148",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "Alarm3",
-      "addressIndex": "150",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "Alarm4",
-      "addressIndex": "152",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "neirong",
-      "addressIndex": "154",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "device",
-      "addressIndex": "156",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "158",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "160",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "InOut1",
-      "addressIndex": "162",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "InOut2",
-      "addressIndex": "164",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "InOut3",
-      "addressIndex": "166",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "InOut4",
-      "addressIndex": "168",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "InOut5",
-      "addressIndex": "170",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "InOut6",
-      "addressIndex": "172",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "InOut7",
-      "addressIndex": "174",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "176",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "178",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "180",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "182",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "spare",
-      "addressIndex": "184",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G04ActionState",
-      "addressIndex": "186",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G05ActionState",
-      "addressIndex": "190",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G06ActionState",
-      "addressIndex": "192",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G07ActionState",
-      "addressIndex": "194",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G08ActionState",
-      "addressIndex": "196",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G09ActionState",
-      "addressIndex": "200",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G10ActionState",
-      "addressIndex": "202",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G11ActionState",
-      "addressIndex": "204",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G12ActionState",
-      "addressIndex": "206",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G13ActionState",
-      "addressIndex": "208",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G04IDS",
-      "addressIndex": "210",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G05IDS",
-      "addressIndex": "212",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G06IDS",
-      "addressIndex": "214",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G07IDS",
-      "addressIndex": "216",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G08IDS",
-      "addressIndex": "218",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G09IDS",
-      "addressIndex": "220",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G10IDS",
-      "addressIndex": "222",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G11IDS",
-      "addressIndex": "224",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G12IDS",
-      "addressIndex": "226",
-      "addressLenght": "2"
-    },
-    {
-      "codeId": "G13ID",
-      "addressIndex": "230",
-      "addressLenght": "2"
-    }
-  ]
+	"plcAddressBegin": "DB100.0",
+	"plcAddressLenght": "100",
+	"dataType": "word",
+	"parameteInfor": [
+
+		{
+			"codeId": "requestWord",
+			"addressIndex": "0",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "requestID",
+			"addressIndex": "2",
+			"addressLenght": "30"
+		},
+		{
+			"codeId": "currentCell",
+			"addressIndex": "32",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "glassStatus08",
+			"addressIndex": "36",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "G06_glass_status",
+			"addressIndex": "40",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "G11_glass_status",
+			"addressIndex": "42",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "G13_glass_status",
+			"addressIndex": "44",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "G04_error_status",
+			"addressIndex": "48",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "G05_error_status",
+			"addressIndex": "50",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "G06_error_status",
+			"addressIndex": "52",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "robot_error_status",
+			"addressIndex": "54",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "G08_error_status",
+			"addressIndex": "56",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "G09_error_status",
+			"addressIndex": "58",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "G10_error_status",
+			"addressIndex": "60",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "G11_error_status",
+			"addressIndex": "62",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "robot_error_status",
+			"addressIndex": "64",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "G13_error_status",
+			"addressIndex": "66",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "confirmationWord",
+			"addressIndex": "72",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "G06_prohibit_film_production",
+			"addressIndex": "74",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "G11_prohibit_film_production",
+			"addressIndex": "76",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "G13_prohibit_film_production",
+			"addressIndex": "78",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "Glass_width",
+			"addressIndex": "82",
+			"addressLenght": "4"
+		},
+		{
+			"codeId": "Glass_height",
+			"addressIndex": "86",
+			"addressLenght": "4"
+		},
+		{
+			"codeId": "Glass_thickness",
+			"addressIndex": "90",
+			"addressLenght": "4"
+		},
+		{
+			"codeId": "Start_cell",
+			"addressIndex": "94",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "End_cell",
+			"addressIndex": "96",
+			"addressLenght": "2"
+		},
+		{
+			"codeId": "task_type",
+			"addressIndex": "98",
+			"addressLenght": "2"
+		}
+
+	]
 }
\ No newline at end of file

--
Gitblit v1.8.0