From 1845e4a29c1231ebdc2971f99b0c57c6a608a843 Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期四, 09 五月 2024 13:20:56 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/HangZhouMes

---
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/impl/DownStorageCageServiceImpl.java |  292 ++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 193 insertions(+), 99 deletions(-)

diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/impl/DownStorageCageServiceImpl.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/impl/DownStorageCageServiceImpl.java
index 05c3b11..d1a6673 100644
--- a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/impl/DownStorageCageServiceImpl.java
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/impl/DownStorageCageServiceImpl.java
@@ -1,22 +1,27 @@
 package com.mes.downstorage.service.impl;
 
-import com.github.yulichang.query.MPJQueryWrapper;
+import com.github.yulichang.toolkit.JoinWrappers;
+import com.mes.common.PLCAutoMes;
+import com.mes.common.S7control;
+import com.mes.device.PlcParameterObject;
+import com.mes.downglassinfo.entity.DownGlassTask;
+import com.mes.downglassinfo.service.DownGlassTaskService;
 import com.mes.downstorage.entity.DownStorageCage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.mes.downstorage.entity.DownStorageCageDetails;
-import com.mes.downstorage.mapper.DownStorageCageDetailsMapper;
 import com.mes.downstorage.mapper.DownStorageCageMapper;
+import com.mes.downstorage.service.DownStorageCageDetailsService;
 import com.mes.downstorage.service.DownStorageCageService;
+import com.mes.glassinfo.entity.GlassInfo;
+import com.mes.glassinfo.service.GlassInfoService;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
-import java.util.Collections;
-import java.util.Comparator;
+
 /**
  * <p>
  *  鏈嶅姟瀹炵幇绫�
@@ -30,117 +35,206 @@
 public class DownStorageCageServiceImpl extends ServiceImpl<DownStorageCageMapper, DownStorageCage> implements DownStorageCageService {
     @Autowired
     private DownStorageCageMapper downStorageCageMapper;
-    @Override
-    public List<Map> gettask(){
-        downStorageCageMapper.selectList(null);
-//        downStorageCageMapper.selectJoin();
-        return null;
-    };
+
+    @Autowired
+    private GlassInfoService glassInfoService;
+
+    @Autowired
+    private DownGlassTaskService downGlassTaskService;
+    @Autowired
+    private DownStorageCageDetailsService downStorageCageDetailsService;
 
 
 
-    @Override
-    public List<Map> getCacheLeisure() {
-        log.info(" 鏌ヨ绗煎瓙鍐呯┖闂�");
-        List<Map> map = downStorageCageMapper.selectJoinList(
-                Map.class, new MPJQueryWrapper<DownStorageCageDetails>()
-                        .select("escd.*")
-                        .leftJoin("down_storage_cage_details escd on t.slot = escd.slot")
-                        .isNull("escd.slot")
-                        .orderByAsc("escd.slot")
-        );
-        return map;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    public DownGlassTask createDownGlassTask(GlassInfo glassInfo, String startCell, String endCell,String taskType ) {
+        DownGlassTask downGlassTask = new DownGlassTask();
+
+        BeanUtils.copyProperties(glassInfo,downGlassTask);
+
+        downGlassTask.setStartCell(startCell);
+       downGlassTask.setTaskType(taskType);
+      downGlassTask.setEndCell(endCell);
+        return downGlassTask;
     }
 
-//    @Override
-//    public List<Map> getCacheOut(int start, int end) {
-//        log.info(" 鏍规嵁浼犲叆鐨勫伐浣嶆煡璇㈢鍚堟寜鐓ч『搴忓拰澶у皬鍑虹墖鐨勫皬鐗�");
-//        List<Map> map = downStorageCageMapper.selectJoinList(
-//                Map.class, new MPJQueryWrapper<DownStorageCageDetails>()
-//                        .select("escd.*")
-//                        .leftJoin("down_storage_cage_details escd on t.slot = escd.slot")
-//                        .leftJoin("down_workstation dw on escd.flow_card_id = dw.flow_card_id")
-//                        .isNotNull("escd.slot")
-//                        .between("dw.workstation_id", start, end)
-//                        .orderByAsc("escd.tempering_layout_id, escd.tempering_feed_sequence")
-//        );
-//        return map;
-//    }
 
+    public DownGlassTask createDownGlassTask(DownStorageCageDetails glassInfo, String startCell, String endCell,String taskType ) {
+        DownGlassTask downGlassTask = new DownGlassTask();
 
-
+        BeanUtils.copyProperties(glassInfo,downGlassTask);
+        downGlassTask.setStartCell(startCell);
+        downGlassTask.setTaskType(taskType);
+        downGlassTask.setEndCell(endCell);
+        return downGlassTask;
+    }
 
 
     @Override
-    public List<Map> getCacheOut(int start, int end) {
-        log.info("鏍规嵁浼犲叆鐨勫伐浣嶆煡璇㈢鍚堟寜鐓ч『搴忓拰澶у皬鍑虹墖鐨勫皬鐗�");
-        List<Map> map = downStorageCageMapper.selectJoinList(
-                Map.class, new MPJQueryWrapper<DownStorageCageDetails>()
-                        .select("escd.*")
-                        .leftJoin("down_storage_cage_details escd on t.slot = escd.slot")
-                        .leftJoin("down_workstation dw on escd.flow_card_id = dw.flow_card_id")
-                        .isNotNull("escd.slot")
-                        .between("dw.workstation_id", start, end)
-                        .orderByAsc("escd.tempering_layout_id, escd.tempering_feed_sequence")
-        );
+    public boolean processInto(String Number) {
 
-        // 瀵硅幏鍙栫殑鏁版嵁鍒楄〃鎸夌収瀹藉害杩涜鎺掑簭
-        Collections.sort(map, new Comparator<Map>() {
-            @Override
-            public int compare(Map o1, Map o2) {
-                // 鑾峰彇瀹藉害骞舵瘮杈�
-                double width1 = (double) o1.get("width");
-                double width2 = (double) o2.get("width");
-                return Double.compare(width2, width1);
+        //鎸塱d鏌ヨ鐜荤拑淇℃伅琛ㄩ噷鐨勭幓鐠�
+        GlassInfo GlassInfo = glassInfoService.selectGlassId(Number);
+     PlcParameterObject plcmes = PLCAutoMes.PlcMesObject;
+        //瀛樺湪姝ょ幓鐠冪紪鍙�
+        if (GlassInfo != null) {
+            //鍚屾壘鍒板悓娴佺▼鍗¢檮杩戠┖鏍�
+            List<DownStorageCageDetails> list = selectCacheEmpty();
+
+
+
+            //            list<Map> list=selectCacheEmpty();
+//            list<Map> = downStorageCageService.selectCacheEmpty();
+            if (list.size() > 0) {
+                //瀛樺湪绌烘牸
+                //1.鐢熸垚浠诲姟锛�  璧峰浣嶇疆0   缁撴潫浣嶇疆this.slot  浠诲姟绫诲瀷 1   锛堣繘鐗囦换鍔★級
+                //2.鍥炲 1杩涚墖
+                DownStorageCageDetails item = list.get(0);
+
+                //selectInfo.insertCacheTask(GlassInfo.getId() + "", "0", item.getSlot() + "", "1", GlassInfo.getWidth(), GlassInfo.getHeight(), GlassInfo.getFilmsid(), GlassInfo.getThickness(), GlassInfo.getFlowcardId());
+
+                DownGlassTask downGlassTask =   createDownGlassTask(GlassInfo,"0",item.getSlot()+"","1");
+
+                downGlassTaskService.insertCacheTask(downGlassTask);
+
+               //S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(), (short) 1);
+
+
+                //瀹屾垚鍚庢彃鍏ュ皬鐗囨暟鎹埌缂撳瓨琛�
+                return true;
             }
-        });
 
-        return map;
+        } else {
+            // ID缂栧彿涓嶅瓨鍦�   涓嶅鐞�/鍥炲PLC  杩涜鎶ヨ鎻愮ず
+        }
+        //杩斿洖缁撴灉
+        return false;
+    }
+
+
+    /**
+     * 鐞嗙墖 鍑�
+     * @return
+     */
+    //
+    @Override
+    public boolean processOut() {
+        // 鏌ヨ浠诲姟
+
+
+        PlcParameterObject plcmes = PLCAutoMes.PlcMesObject;
+
+        List<DownStorageCageDetails> list = downStorageCageDetailsService.CacheOut(1, 5);
+        List<DownStorageCageDetails> list2 = downStorageCageDetailsService.CacheOut(6, 10);
+        List<DownStorageCageDetails> list3 = downStorageCageDetailsService.CacheOut(1, 10);
+        //鑷姩缁戝畾鏋跺瓙
+
+
+
+
+        // 浼樺厛 瓒呭嚭灏哄浼樺厛浜哄伐鍑虹墖 浜哄伐澶勭悊
+
+        if (!list3.isEmpty()) {
+            DownStorageCageDetails item3 = list3.get(0);
+            if (item3.getHeight() >= 1 && item3.getWidth() >= 1) {
+
+                String endcell = "13";
+                String SendEndcell = "1";
+
+
+
+                DownGlassTask downGlassTask =createDownGlassTask(item3,"0",endcell,"2");
+
+                downGlassTaskService.insertCacheTask(downGlassTask);
+           //  S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), SendEndcell);
+               // S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1");
+                return true;
+            }
+        }
+
+
+        //濡傛灉鍚屾椂鍓嶅悗绔兘绌洪棽 浼樺厛鍚庣鍑虹墖骞朵笖浼樺厛婊℃灦
+        else if (!list2.isEmpty()&&!list3.isEmpty()) {
+
+            DownStorageCageDetails item3 = list2.get(0);
+            String endcell = "11";
+            String SendEndcell = "1";
+
+            DownGlassTask downGlassTask =createDownGlassTask(item3,"0",endcell,"2");
+            downGlassTaskService.insertCacheTask(downGlassTask);
+
+            S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), SendEndcell);
+            S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1");
+            return true;
+
+        }
+        // 鎸夌収澶у皬绗﹀悎鍓嶇鍑虹墖
+        else if (!list.isEmpty()) {
+            DownStorageCageDetails item = list.get(0);
+
+            // 鍑哄埌 G06
+
+
+            DownGlassTask downGlassTask =createDownGlassTask(item,"0","06","2");
+            downGlassTaskService.insertCacheTask(downGlassTask);
+            S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "1");
+            S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1");
+            return true;
+
+            // 鎸夌収澶у皬绗﹀悎鍚庣鍑虹墖
+        } else if (!list2.isEmpty()) {
+            DownStorageCageDetails item2 = list2.get(0);
+
+            // 鍑哄埌 G11
+
+            DownGlassTask downGlassTask =createDownGlassTask(item2,"0","11","2");
+            downGlassTaskService.insertCacheTask(downGlassTask);
+
+            S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "2");
+            S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1");
+            return true;
+
+
+        }
+
+
+
+        // 杩斿洖缁撴灉
+        return false;
     }
 
 
     @Override
-    public List<Map> getCacheInfo() {
-        log.info(" 鏌ヨ绗煎瓙鍐呬俊鎭�");
-        List<Map> map = downStorageCageMapper.selectJoinList(
-                Map.class, new MPJQueryWrapper<DownStorageCageDetails>()
-                        .select("escd.*")
-                        .leftJoin("down_storage_cage_details escd on t.slot = escd.slot")
-                        .orderByAsc("t.slot")
+    public List<DownStorageCageDetails> selectCacheEmpty() {
+        return baseMapper.selectJoinList(DownStorageCageDetails.class,
+                JoinWrappers.lambda(DownStorageCage.class)
+                        .selectAll(DownStorageCage.class)
+                        .select(DownStorageCageDetails::getWidth, DownStorageCageDetails::getHeight, DownStorageCageDetails::getGlassId)
+                        .leftJoin(DownStorageCageDetails.class, on -> on
+                                .eq(DownStorageCageDetails::getDeviceId, DownStorageCage::getDeviceId)
+                                .eq(DownStorageCageDetails::getSlot, DownStorageCage::getSlot))
+                        .isNull(DownStorageCageDetails::getSlot)
         );
-        return map;
     }
-
-    @Override
-    public List<Map> getIsExistIntoCacheByLayoutAndSequence(Integer tempering_layout_id, Integer tempering_feed_sequence, double width) {
-        List<Map> map = downStorageCageMapper.selectJoinList(
-                Map.class, new MPJQueryWrapper<DownStorageCageDetails>()
-                        .select("escd.*")
-                        .leftJoin("down_storage_cage_details escd on t.slot = escd.slot")
-                        .isNotNull("escd.slot")
-                        .eq("escd.tempering_layout_id", tempering_layout_id)
-                        .lt("escd.tempering_feed_sequence", tempering_feed_sequence)
-                        .gt("t.remain_width", width)
-                        .orderByAsc("escd.tempering_feed_sequence")
-        );
-        return map;
-    }
-
-    @Override
-    public List<Map> getIsExistIntoCacheByLayout(Integer tempering_layout_id, double width) {
-        List<Map> map = downStorageCageMapper.selectJoinList(
-                Map.class, new MPJQueryWrapper<DownStorageCageDetails>()
-                        .select("escd.*")
-                        .leftJoin("down_storage_cage_details escd on t.slot = escd.slot")
-                        .isNotNull("escd.slot")
-                        .lt("escd.tempering_layout_id", tempering_layout_id)
-                        .gt("t.remain_width", width)
-                        .orderByDesc("escd.tempering_layout_id, escd.tempering_feed_sequence")
-        );
-        return map;
-    }
-
-
-
 
 }

--
Gitblit v1.8.0