From e208aa1ef8e861dba168e8d83ab3066fc9f1e02d Mon Sep 17 00:00:00 2001 From: 严智鑫 <test> Date: 星期二, 16 四月 2024 13:30:45 +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/DownGlassCacheLogic.java | 247 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 247 insertions(+), 0 deletions(-) diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/DownGlassCacheLogic.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/DownGlassCacheLogic.java new file mode 100644 index 0000000..8a505fa --- /dev/null +++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/DownGlassCacheLogic.java @@ -0,0 +1,247 @@ +package com.mes.downstorage.service; + +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.DownStorageCageDetails; +import com.mes.downstorage.mapper.DownStorageCageDetailsMapper; +import com.mes.downworkstation.mapper.DownWorkstationMapper; +import com.mes.tools.WebSocketServer; +import com.mes.glassinfo.entity.GlassInfo; +import com.mes.glassinfo.service.GlassInfoService; +import lombok.Data; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Data +@Service +public class DownGlassCacheLogic { + @Autowired + private DownStorageCageDetailsMapper selectInfo; + private GlassInfoService GlassInfoService; + private DownStorageCageDetailsService downStorageCageDetailsService; + private DownGlassTaskService downGlassTaskService; + + /** + * @param Number + * //璇嗗埆閫昏緫 涓嶄氦浜� + */ + + public void identify(String Number){ + //鏌ヨ浠诲姟 + PlcParameterObject plcmes= PLCAutoMes.PlcMesObject; + S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); + String s=S7control.getinstance().ReadWord("DB14.26", 1).get(0)+""; + boolean isexist=isExist(Number); + if (isexist) { + //瀛樺湪閫昏緫 1.娣诲姞淇℃伅 2.鍥炲PLC瀛樺湪 + //S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); + }else { + //涓嶅瓨鍦ㄩ�昏緫 1.鍥炲PLC涓嶅瓨鍦� + //S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 2); + } + } + //涓嬬墖鍓嶇悊鐗� + public static final String RESULT_IN = "1"; + public static final String RESULT_OUT = "2"; + public static final String RESULT_IN_OUT = "3"; + + public void process() { + String result = S7control.getinstance().ReadWord("DB14.0", 1).get(0) + ""; + String number = S7control.getinstance().ReadWord("DB14.2", 1).get(0) + ""; + + // 杩涚墖璇锋眰 + if (RESULT_IN.equals(result)) { + processInto(number); + } + // 鍑虹墖璇锋眰 + else if (RESULT_OUT.equals(result)) { + processOut(); + } + // 杩涘嚭鐗囪姹� + else if (RESULT_IN_OUT.equals(result)) { + // 鍏堝嚭鍚庤繘 + if (!processOut()) { + processInto(number); + } + } + } + + + /** + * @param Number + * @return + * //涓嬬墖鍓嶇悊鐗� 杩� + */ + + public boolean processInto(String Number){ + GlassInfoService = WebSocketServer.applicationContext.getBean(GlassInfoService.class); + //鎸塱d鏌ヨ鐜荤拑淇℃伅琛ㄩ噷鐨勭幓鐠� + GlassInfo GlassInfo=GlassInfoService.selectGlassId(Number); + PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; + //瀛樺湪姝ょ幓鐠冪紪鍙� + if(GlassInfo!=null){ + //鍚岄挗鍖栫増鍥惧唴鐨勬爡鏍煎彿 + List<DownStorageCageDetails> list=selectInfo.SelectIsExistIntoCache(GlassInfo.getTemperingLayoutId(),GlassInfo.getTemperingFeedSequence(),GlassInfo.getWidth()); + //绌烘爡鏍煎彿 + if (list.size()==0) { + list=selectInfo.SelectCacheLeisure(); + } + //灏忎簬姝ょ幓鐠冮挗鍖栫増鍥惧簭鍙风殑鏍呮牸鍙� + if(list.size()==0){ + list=selectInfo.SelectIsExistIntoCache(GlassInfo.getTemperingLayoutId(),GlassInfo.getWidth()); + } + 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()); + + S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); + return true; + } + + }else{ + // ID缂栧彿涓嶅瓨鍦� 涓嶅鐞�/鍥炲PLC 杩涜鎶ヨ鎻愮ず + } + //杩斿洖缁撴灉 + return false; + } + //鐞嗙墖 鍑� + public boolean processOut() { + // 鏌ヨ浠诲姟 + String G06 = S7control.getinstance().ReadWord("DB14.56", 1).get(0) + ""; + String G11 = S7control.getinstance().ReadWord("DB14.58", 1).get(0) + ""; + String G13 = S7control.getinstance().ReadWord("DB14.58", 1).get(0) + ""; + PlcParameterObject plcmes = PLCAutoMes.PlcMesObject; + List<DownStorageCageDetails> list = selectInfo.SelectCacheOut(1, 5); + List<DownStorageCageDetails> list2 = selectInfo.SelectCacheOut(6, 10); + List<DownStorageCageDetails> list3 = selectInfo.SelectCacheOut(1, 10); + + // 鎸夌収椤哄簭绗﹀悎鍓嶇鍑虹墖 + if (!list.isEmpty()) { + DownStorageCageDetails item = list.get(0); + if (G06.equals("0") && G11.equals("1")) { + // 鍑哄埌 G06 + selectInfo.insertCacheTask(item.getGlassId() + "", "0", "06", "2", item.getWidth(), item.getHeight(), item.getFilmsid(), item.getThickness(), item.getFlowCardId()); + 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); + if (G06.equals("1") && G11.equals("0")) { + // 鍑哄埌 G11 + selectInfo.insertCacheTask(item2.getGlassId() + "", "0", "11", "2", item2.getWidth(), item2.getHeight(), item2.getFilmsid(), item2.getThickness(), item2.getFlowCardId()); + S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "2"); + S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); + return true; + } + // 瓒呭嚭灏哄浼樺厛浜哄伐鍑虹墖 浜哄伐澶勭悊 + } else if (!list3.isEmpty()) { + DownStorageCageDetails item3 = list3.get(0); + if (item3.getHeight() >= 3440 && item3.getWidth() >= 1440) { + + String endcell = "06"; + String SendEndcell = "1"; + + selectInfo.insertCacheTask(item3.getGlassId() + "", "0", endcell, "2", item3.getWidth(), item3.getHeight(), item3.getFilmsid(), item3.getThickness(), item3.getFlowCardId()); + S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), SendEndcell); + S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); + return true; + } + } + + // 杩斿洖缁撴灉 + return false; + } + +//鏌ヨ鏄惁缁戝畾鏋跺瓙 +// public boolean selectFlowCardId(String FlowCardId){ +// +// } + + /** + * @param Number + * //纾ㄨ竟 涓嶄氦浜� 鐞嗙墖鍜岀(杈规満鑷繁浜や簰 + */ + + public void processMb(String Number){ + //鎸塱d鏌ヨ鐜荤拑淇℃伅琛ㄩ噷鐨勭幓鐠� + GlassInfo GlassInfo=GlassInfoService.selectGlassId(Number); + PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; + if(GlassInfo!=null){ + //鍙戦�佷换鍔� ID 闀� 瀹� 鍘� 鍊掕 宸ヨ壓鍔熻兘绛� + S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.22").getAddress(),"N10000"); + S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.24").getAddress(), "1000"); + S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.26").getAddress(),"800"); + S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(),"60"); + S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.30").getAddress(), "2"); + S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); + } + //杩斿洖缁撴灉 + } + + + /** + * @param Number + * @return + * 鏌ヨ娑堟伅闃熷垪閲屾鐜荤拑ID鐨勬暟鎹� + */ + public boolean selectMessageId(String Number){ + //鏌ヨ鏄惁瀛樺湪 + + GlassInfo GlassInfo=GlassInfoService.selectGlassId(Number); + if(GlassInfo==null){ + //杩斿洖 涓嶅瓨鍦� + return false; + + } + //杩斿洖 瀛樺湪 + return true; + } + + /** + * @param Number + * @return + * 鍒犻櫎娑堟伅闃熷垪閲屾鐜荤拑ID鐨勬暟鎹� + */ + + public boolean deleteMessageId(String Number){ + //鏌ヨ鏄惁瀛樺湪 + GlassInfo GlassInfo=GlassInfoService.selectGlassId(Number); + if(GlassInfo==null){ + //杩斿洖 涓嶅瓨鍦� + return false; + } + //杩斿洖 瀛樺湪 + return true; + } + + + + /** + * @param Number + * @return + * //鏄惁瀛樺湪姝ょ紪鍙风幓鐠� + */ + public boolean isExist(String Number){ + //鏌ヨ鏄惁瀛樺湪 + GlassInfo GlassInfo=GlassInfoService.selectGlassId(Number); + if(GlassInfo==null){ + //杩斿洖 涓嶅瓨鍦� + return false; + } + //杩斿洖 瀛樺湪 + return true; + } + +} + -- Gitblit v1.8.0