From 9b8d63e96ab1930c4eeff26f0764af800284120c Mon Sep 17 00:00:00 2001
From: wangfei <3597712270@qq.com>
Date: 星期二, 09 七月 2024 14:23:38 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/HangZhouMes
---
hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java | 229 +++++++++++++++++++++++++++++++++-----------------------
1 files changed, 135 insertions(+), 94 deletions(-)
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 e3afe50..6e63d8e 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
@@ -4,6 +4,7 @@
import cn.smallbun.screw.core.util.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.mes.common.S7object;
import com.mes.common.config.Const;
import com.mes.device.PlcParameterObject;
@@ -20,11 +21,13 @@
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;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
@@ -70,21 +73,30 @@
@Value("${mes.maxHeight}")
private Integer maxHeight;
+ @Value("${mes.minWidth}")
+ private Integer minWidth;
- // @Scheduled(fixedDelay = 1000)
+ @Value("${mes.minHeight}")
+ private Integer minHeight;
+
+
+ @Scheduled(fixedDelay = 3000)
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 requestWord = plcParameterObject.getPlcParameter("requestWord").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)) {
@@ -92,7 +104,7 @@
return;
}
log.info("2銆佽幏鍙栧埌鐨勮姹傚瓧涓�0锛屽皢纭瀛楁敼涓�0");
- S7object.getinstance().plccontrol.writeWord(confirmationWrodAddress, (short) 0);
+ S7object.getinstance().plccontrol.writeWord(confirmationWrodAddress, 0);
return;
}
if (!"0".equals(confirmationWrodValue)) {
@@ -101,26 +113,23 @@
}
if ("1".equals(requestWord)) {
log.info("2銆佽繘鐗囪姹傦紝涓旂‘璁ゅ瓧涓�0锛屾墽琛岃繘鐗囦换鍔�");
- inTo(glassIdeValue, requestWord, confirmationWrodAddress, currentSlot);
+ inTo(glassIdeValue, requestWord, currentSlot);
} else if ("2".equals(requestWord)) {
//09绌洪棽 锛�1 10绌洪棽 锛�2 閮界┖闂诧細3 鍏朵粬0
- log.info("2銆佸嚭鐗囪姹傦紝涓旂‘璁ゅ瓧涓�0锛屾墽琛岃繘鐗囦换鍔�");
-// outTo(Integer.parseInt(out08Glassstate),
-// Integer.parseInt(out10Glassstate), confirmationWrodAddress, "", 0);
+ log.info("2銆佸嚭鐗囪姹傦紝涓旂‘璁ゅ瓧涓�0锛屾墽琛屽嚭鐗囦换鍔�");
+ outTo(out06Glassstate, out08Glassstate, out11Glassstate, out13Glassstate, glassIdeValue, currentSlot);
} else if ("3".equals(requestWord)) {
log.info("2銆佽繘鐗囧拰鍑虹墖閮界┖闂诧紝鎵ц鍑虹墖浠诲姟");
//鍔犵瀛愰噷闈㈡槸鍚︽湁鐜荤拑锛屾湁鍏堝嚭锛屾棤鐜荤拑鍏堣繘
- boolean outFlase = false;
-// outTo(Integer.parseInt(out08Glassstate),
-// Integer.parseInt(out10Glassstate), confirmationWrodAddress, glassIdeValue, Integer.parseInt(currentSlot));
+ boolean outFlase = outTo(out06Glassstate, out08Glassstate, out11Glassstate, out13Glassstate, glassIdeValue, currentSlot);
log.info("鍑虹墖浠诲姟鏄惁瀹屾垚锛歿},澶辫触涓旂幓鐠僫d:{}涓嶄负绌哄垯鎵ц杩涚墖浠诲姟", outFlase, glassIdeValue);
if (!outFlase && StringUtils.isNotBlank(glassIdeValue)) {
- inTo(glassIdeValue, requestWord, confirmationWrodAddress, currentSlot);
+ inTo(glassIdeValue, requestWord, currentSlot);
}
}
}
- public void inTo(String glassId, String requestWord, String confirmationWrodAddress, String currentSlot) {
+ public void inTo(String glassId, String requestWord, String currentSlot) {
log.info("1銆佹寜鐓х幓鐠僫d:{}鑾峰彇鐜荤拑灏忕墖淇℃伅,褰撳墠鏍煎瓙涓�:{}", glassId, currentSlot);
//娣诲姞杩涚墖浠诲姟 鏌ユ壘绌烘牸
DownStorageCage nearestEmpty = downStorageCageService.selectCacheEmpty(Integer.parseInt(currentSlot), Boolean.FALSE);
@@ -134,8 +143,8 @@
}
Boolean checkFlag = Boolean.FALSE;
//鐜荤拑灏哄鏄惁璧颁汉宸ヤ笅鐗�
- if (glassInfo.getWidth() > maxWidth || glassInfo.getHeight() > maxHeight) {
- log.info("璇ョ幓鐠冨昂瀵歌蛋浜哄伐涓嬬墖,鐩存帴杩涚墖");
+ if (glassInfo.getWidth() > maxWidth || glassInfo.getHeight() > maxHeight || glassInfo.getWidth() < minWidth || glassInfo.getHeight() < minHeight) {
+ log.info("璇ョ幓鐠冨昂瀵镐笉绗﹀悎瑕佹眰锛岄渶瑕佽蛋浜哄伐涓嬬墖鐩存帴杩涚墖");
} else {
log.info("璇ョ幓鐠冨昂瀵搁潪浜哄伐涓嬬墖");
//鑾峰彇璇ョ幓鐠冪殑娴佺▼鍗℃槸鍚﹀凡缁戝畾鏋跺瓙
@@ -151,7 +160,7 @@
if (!checkFlag && !isBind) {
log.info("璇ョ幓鐠冪殑娴佺▼鍗℃湭缁戝畾鏋跺瓙锛岃幏鍙栨槸鍚︽湁绌烘灦瀛�");
List<DownWorkstation> list = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>()
- .isNull(DownWorkstation::getFlowCardId));
+ .isNull(DownWorkstation::getFlowCardId).orderByDesc(DownWorkstation::getWorkstationId));
if (CollectionUtils.isNotEmpty(list)) {
log.info("鏈夌┖鏋跺瓙,灏嗘祦绋嬪崱涓庢灦瀛愬ソ缁戝畾锛屾墽琛岃繘鐗囦换鍔� 缁撴潫");
//缁戝畾娴佺▼鍗�
@@ -166,7 +175,7 @@
log.info("鏃犵┖鏋跺瓙,鑾峰彇宸茬粦瀹氭灦瀛愮殑娴佺▼鍗′俊鎭�,鏌ョ湅鐜荤拑淇℃伅鏄惁鍙瀵硅皟");
List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Boolean.FALSE);
log.info("鑾峰彇鏋跺瓙涓婂凡缁戝畾娴佺▼鍗¤惤鏋剁殑鏁伴噺鍙婃湭钀芥灦鐨勭幓鐠冩暟鎹細{}", downGlassInfoDTOList);
- if (CollectionUtils.isNotEmpty(downGlassInfoDTOList)) {
+ if (CollectionUtils.isEmpty(downGlassInfoDTOList)) {
log.info("宸茬粦瀹氭祦绋嬪崱鍧囨棤鏈惤鏋剁幓鐠冿紝璇峰強鏃跺鐞嗘灦瀛愪笂鐨勭幓鐠冿紝娓呴櫎娴佺▼鍗�,鎵ц杩涚墖浠诲姟");
} else {
//鏇挎崲鐜荤拑淇℃伅
@@ -174,8 +183,8 @@
for (DownGlassInfoDTO e : downGlassInfoDTOList) {
List<GlassInfo> glassInfoList = e.getGlassInfoList();
for (GlassInfo item : glassInfoList) {
- if (item.getWidth().equals(glassInfo.getWidth()) && item.getHeight().equals(glassInfo.getHeight())
- && item.getThickness().equals(glassInfo.getThickness()) && item.getFilmsid().equals(glassInfo.getFilmsid())) {
+ if (item.getWidth() == glassInfo.getWidth() && item.getHeight() == glassInfo.getHeight()
+ && item.getThickness() == glassInfo.getThickness() && item.getFilmsid().equals(glassInfo.getFilmsid())) {
//鐜荤拑鏄惁涓哄灞�
checkFlag = multilayerCheck(item, Boolean.FALSE);
if (checkFlag) {
@@ -208,12 +217,9 @@
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) {
+ public Boolean outTo(String glassStatus06, String out08Glassstate, String glassStatus11, String glassStatus13, String glassId, String currentSlot) {
if ("2".equals(glassStatus06) && "2".equals(glassStatus11) && "2".equals(glassStatus13)) {
log.info("G06銆丟11銆丟13鍒嗗埆涓簕},{}銆亄}闈炶嚜鍔ㄧ姸鎬侊紝鏃犳硶鍑虹墖", glassStatus06, glassStatus11, glassStatus13);
return Boolean.FALSE;
@@ -221,12 +227,14 @@
List<DownStorageCageDetails> tempList = downStorageCageDetailsService.list(new LambdaQueryWrapper<DownStorageCageDetails>()
.eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN));
- //todo:鑾峰彇寰呰繘鐗囩幓鐠�
+ //鑾峰彇寰呰繘鐗囩幓鐠�
DownStorageCageDetails cageDetails = new DownStorageCageDetails();
if (StringUtils.isNotBlank(glassId)) {
GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId));
BeanUtils.copyProperties(glassInfo, cageDetails);
- cageDetails.setSlot(0);
+ //鑾峰彇褰撳墠绗煎瓙绌烘牸淇℃伅
+ DownStorageCage empty = downStorageCageService.selectCacheEmpty(Integer.parseInt(currentSlot), Boolean.TRUE);
+ cageDetails.setSlot(empty.getSlot());
tempList.add(cageDetails);
}
@@ -235,20 +243,69 @@
log.info("绗煎唴娌℃湁鐜荤拑,鏃犳硶鎵ц鍑虹墖");
return Boolean.FALSE;
}
+ Boolean flag08 = "1".equals(out08Glassstate) ? Boolean.TRUE : Boolean.FALSE;
+ if (!generateTaskByShelf(glassStatus06, glassStatus11, flag08, glassStatus13, tempList, cageDetails, glassId)) {
+ return generateTaskByShelf(glassStatus06, glassStatus11, !flag08, glassStatus13, tempList, cageDetails, glassId);
+ }
+ return Boolean.TRUE;
+ }
+
+ private Boolean multilayerCheck(GlassInfo glassInfo, boolean isBind) {
+ //鏌ヨ璇ユ祦绋嬪崱鏄惁涓哄灞�
+ if (glassInfo.getTotalLayer() > 1) {
+ log.info("鎸夌収娴佺▼鍗¤幏鍙栧綋鍓嶆祦绋嬪崱鍚勫眰宸茶惤鏋舵暟閲�");
+ DownGlassInfoDTO downGlassInfoDTO = downGlassInfoService.queryDownGlassMaxLayer(glassInfo.getFlowCardId());
+ if (null == downGlassInfoDTO) {
+ if (isBind) {
+ return Boolean.TRUE;
+ } else {
+ log.info("鏋跺瓙宸茬粡鍗犳弧锛屽灞傜幓鐠冩棤娉曟壘鍒板搴旂殑鏍煎瓙锛岄渶鎵ц鏇挎崲鐜荤拑鐨勬搷浣�");
+ return Boolean.FALSE;
+ }
+
+ }
+ if (downGlassInfoDTO.getLayer().equals(glassInfo.getLayer())) {
+ log.info("褰撳墠鐜荤拑鐨勬祦绋嬪湪鏋跺瓙涓婅惤鏋舵渶澶� 鐩存帴杩涚墖");
+ return Boolean.TRUE;
+ }
+ Integer sequence = downGlassInfoService.queryMaxSequence(glassInfo.getFlowCardId(), glassInfo.getLayer());
+ log.info("鑾峰彇褰撳墠鐜荤拑闇�瑕佹斁鐨勬搴忥細绗煎唴鍚屾祦绋� 鍚屽眰鏁扮殑閫氳揪娆″簭+1:{}", sequence);
+ DownGlassInfo downGlassInfo = downGlassInfoService.getOne(new LambdaQueryWrapper<DownGlassInfo>()
+ .eq(DownGlassInfo::getFlowCardId, downGlassInfoDTO.getFlowCardId())
+ .eq(DownGlassInfo::getLayer, downGlassInfoDTO.getLayer()).eq(DownGlassInfo::getSequence, sequence));
+ log.info("鎷垮綋鍓嶇増搴忚幏鍙栫幓鐠冧俊鎭瘂}锛屾寜鐓ф搴忓垽鏂綋鍓嶇幓鐠冩槸鍚﹀昂瀵稿搴旂殑涓婏紙涓庢暟閲忔渶澶氱殑娆″簭姣旇緝锛夈��", downGlassInfo);
+ if (null != downGlassInfoDTO && downGlassInfo.getWidth() == glassInfo.getWidth() && downGlassInfo.getHeight() == glassInfo.getHeight()) {
+ log.info("鐩稿悓娆″簭鐜荤拑瀵瑰簲涓婏紝鍙墽琛岃繘鐗囦换鍔�");
+ return Boolean.TRUE;
+ } else {
+ log.info("鍚屾搴忕幓鐠冨搴斾笉涓婏紝闇�鎵ц鏇挎崲鐜荤拑鐨勬搷浣�");
+ return Boolean.FALSE;
+ }
+ } else {
+ log.info("闈炲灞傜幓鐠冿紝鐩存帴杩涚墖");
+ return Boolean.TRUE;
+ }
+ }
+
+ private Boolean generateTaskByShelf(String glassStatus06, String glassStatus11, Boolean flag08, String glassStatus13, List<DownStorageCageDetails> tempList, DownStorageCageDetails cageDetails, String glassId) {
//鑾峰彇2涓満姊拌噦鑼冨洿鍐呯殑鏋跺瓙缁戝畾鐨勬祦绋嬪崱淇℃伅
List<Integer> workList = new ArrayList();
- if (!"2".equals(glassStatus06)) {
- workList.addAll(Const.G06_WORK_STATION);
- }
- if (!"2".equals(glassStatus11)) {
- workList.addAll(Const.G11_WORK_STATION);
+
+ if (flag08) {
+ if (!"2".equals(glassStatus11)) {
+ workList.addAll(Const.G11_WORK_STATION);
+ }
+ } else {
+ if (!"2".equals(glassStatus06)) {
+ workList.addAll(Const.G06_WORK_STATION);
+ }
}
List<DownStorageCageDetails> list = new ArrayList();
Boolean isEmptyShelf = Boolean.FALSE;
//瀵圭鍐呯幓鐠冭繘琛岃繃婊わ紝浠呭嚭绗﹀悎閫昏緫鐨勭幓鐠�
if (CollectionUtils.isNotEmpty(workList)) {
List<DownWorkstation> downWorkstationList = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>()
- .eq(DownWorkstation::getEnableState, 0).in(DownWorkstation::getWorkstationId, workList));
+ .eq(DownWorkstation::getEnableState, Const.SLOT_ON).in(DownWorkstation::getWorkstationId, workList));
log.info("鏋跺瓙琚鐢紝鏃犳硶鍑虹墖钀芥灦");
if (CollectionUtils.isEmpty(downWorkstationList)) {
log.info("绗煎瓙琚鐢紝鏃犳硶璧版満姊拌噦涓嬬墖");
@@ -272,8 +329,10 @@
}
}
} else {
- //鐩存帴璧颁汉宸ヤ笅鐗�
- list = tempList.stream().filter(item -> item.getWidth() > maxWidth || item.getHeight() > maxHeight).collect(Collectors.toList());
+ if (flag08 && !"2".equals(glassStatus13)) {
+ //鐩存帴璧颁汉宸ヤ笅鐗�
+ list = tempList.stream().filter(item -> item.getWidth() > maxWidth || item.getHeight() > maxHeight).collect(Collectors.toList());
+ }
}
if (CollectionUtils.isEmpty(list)) {
log.info("绗煎唴鐜荤拑鏃犳硶鎵ц鍑虹墖");
@@ -284,9 +343,11 @@
for (DownStorageCageDetails item : list) {
if (item.getWidth() > maxWidth || item.getHeight() > maxHeight) {
- log.info("鐜荤拑瀹藉害鎴栭珮搴﹁秴鍑洪槇鍊硷紝鎵ц浜哄伐涓嬬墖");
- tempGlassId = item.getGlassId();
- break;
+ if (flag08 && !"2".equals(glassStatus13)) {
+ log.info("鐜荤拑瀹藉害鎴栭珮搴﹁秴鍑洪槇鍊硷紝鎵ц浜哄伐涓嬬墖");
+ tempGlassId = item.getGlassId();
+ break;
+ }
}
}
loop:
@@ -295,10 +356,8 @@
List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Boolean.TRUE);
List<String> downGlassFlowList = downGlassInfoDTOList.stream().map(item -> item.getFlowCardId() + ":" + item.getLayer()).collect(Collectors.toList());
if (CollectionUtils.isEmpty(downGlassFlowList)) {
- //鏋跺瓙閮芥湭缁戝畾娴佺▼鍗★紝鍑虹鍐呭瓙鏁伴噺鏈�澶氬昂瀵告渶澶х殑鐜荤拑
- DownStorageCageDetails downStorageCageDetails = downStorageCageDetailsService.getGlassInfoMaxCount();
- //缁戝畾娴佺▼鍗★紝鏇存柊鐜荤拑鐘舵�侊紝鐢熸垚鍑虹墖浠诲姟锛�
- tempGlassId = downStorageCageDetails.getGlassId();
+ //鏋跺瓙閮芥湭缁戝畾娴佺▼鍗★紝鍑虹鍐呭瓙鏁伴噺鏈�澶氬昂瀵告渶澶х殑鐜荤拑id,鏃� 鍒欒繑鍥炴壂鎻忔壂鍒扮殑鐜荤拑id杩涜鍑虹墖
+ tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId);
isBind = Boolean.TRUE;
break loop;
}
@@ -309,9 +368,8 @@
// List<DownWorkstation> emptyShelfList = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>()
// .isNull(DownWorkstation::getFlowCardId));
if (isEmptyShelf) {
- DownStorageCageDetails downStorageCageDetails = downStorageCageDetailsService.getGlassInfoMaxCount();
- //缁戝畾娴佺▼鍗★紝鏇存柊鐜荤拑鐘舵�侊紝鐢熸垚鍑虹墖浠诲姟
- tempGlassId = downStorageCageDetails.getGlassId();
+ //鏋跺瓙閮芥湭缁戝畾娴佺▼鍗★紝鍑虹鍐呭瓙鏁伴噺鏈�澶氬昂瀵告渶澶х殑鐜荤拑id,鏃� 鍒欒繑鍥炴壂鎻忔壂鍒扮殑鐜荤拑id杩涜鍑虹墖
+ tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId);
isBind = Boolean.TRUE;
break loop;
}
@@ -347,7 +405,7 @@
DownGlassInfo downGlassInfo = downGlassInfoService.getOne(new LambdaQueryWrapper<DownGlassInfo>()
.eq(DownGlassInfo::getFlowCardId, downGlassInfoDTO.getFlowCardId())
.eq(DownGlassInfo::getLayer, downGlassInfoDTO.getLayer()).eq(DownGlassInfo::getSequence, sequence));
- if (null != downGlassInfoDTO && downGlassInfo.getWidth().equals(item.getWidth()) && downGlassInfo.getHeight().equals(item.getHeight())) {
+ if (null != downGlassInfoDTO && downGlassInfo.getWidth() == item.getWidth() && downGlassInfo.getHeight() == item.getHeight()) {
log.info("鐩稿悓娆″簭鐜荤拑瀵瑰簲涓婏紝鍙墽琛岃繘鐗囦换鍔�");
//鏇存柊鐜荤拑鐘舵�侊紝鐢熸垚鍑虹墖浠诲姟
tempGlassId = item.getGlassId();
@@ -382,44 +440,7 @@
}
}
- private Boolean multilayerCheck(GlassInfo glassInfo, boolean isBind) {
- //鏌ヨ璇ユ祦绋嬪崱鏄惁涓哄灞�
- if (glassInfo.getTotalLayer() > 1) {
- log.info("鎸夌収娴佺▼鍗¤幏鍙栧綋鍓嶆祦绋嬪崱鍚勫眰宸茶惤鏋舵暟閲�");
- DownGlassInfoDTO downGlassInfoDTO = downGlassInfoService.queryDownGlassMaxLayer(glassInfo.getFlowCardId());
- if (null == downGlassInfoDTO) {
- if (isBind) {
- return Boolean.TRUE;
- } else {
- log.info("鏋跺瓙宸茬粡鍗犳弧锛屽灞傜幓鐠冩棤娉曟壘鍒板搴旂殑鏍煎瓙锛岄渶鎵ц鏇挎崲鐜荤拑鐨勬搷浣�");
- return Boolean.FALSE;
- }
-
- }
- if (downGlassInfoDTO.getLayer().equals(glassInfo.getLayer())) {
- log.info("褰撳墠鐜荤拑鐨勬祦绋嬪湪鏋跺瓙涓婅惤鏋舵渶澶� 鐩存帴杩涚墖");
- return Boolean.TRUE;
- }
- Integer sequence = downGlassInfoService.queryMaxSequence(glassInfo.getFlowCardId(), glassInfo.getLayer());
- log.info("鑾峰彇褰撳墠鐜荤拑闇�瑕佹斁鐨勬搴忥細绗煎唴鍚屾祦绋� 鍚屽眰鏁扮殑閫氳揪娆″簭+1:{}", sequence);
- DownGlassInfo downGlassInfo = downGlassInfoService.getOne(new LambdaQueryWrapper<DownGlassInfo>()
- .eq(DownGlassInfo::getFlowCardId, downGlassInfoDTO.getFlowCardId())
- .eq(DownGlassInfo::getLayer, downGlassInfoDTO.getLayer()).eq(DownGlassInfo::getSequence, sequence));
- log.info("鎷垮綋鍓嶇増搴忚幏鍙栫幓鐠冧俊鎭瘂}锛屾寜鐓ф搴忓垽鏂綋鍓嶇幓鐠冩槸鍚﹀昂瀵稿搴旂殑涓婏紙涓庢暟閲忔渶澶氱殑娆″簭姣旇緝锛夈��", downGlassInfo);
- if (null != downGlassInfoDTO && downGlassInfo.getWidth().equals(glassInfo.getWidth()) && downGlassInfo.getHeight().equals(glassInfo.getHeight())) {
- log.info("鐩稿悓娆″簭鐜荤拑瀵瑰簲涓婏紝鍙墽琛岃繘鐗囦换鍔�");
- return Boolean.TRUE;
- } else {
- log.info("鍚屾搴忕幓鐠冨搴斾笉涓婏紝闇�鎵ц鏇挎崲鐜荤拑鐨勬搷浣�");
- return Boolean.FALSE;
- }
- } else {
- log.info("闈炲灞傜幓鐠冿紝鐩存帴杩涚墖");
- return Boolean.TRUE;
- }
- }
-
- 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())) {
@@ -458,6 +479,9 @@
log.info("鏇存柊璇︽儏琛ㄥ唴鐨勭姸鎬佸け璐�");
return Boolean.FALSE;
}
+ //鏇存柊钀芥灦鐜荤拑鏁伴噺
+ downWorkstationService.update(new UpdateWrapper<DownWorkstation>().eq("flow_card_id", downStorageCageDetails.getFlowCardId())
+ .eq("layer", downStorageCageDetails.getLayer()).setSql("racks_number = racks_number +1"));
//鐢熸垚浠诲姟淇℃伅
DownGlassInfo downGlassInfo = new DownGlassInfo();
BeanUtils.copyProperties(downStorageCageDetails, downGlassInfo);
@@ -468,18 +492,35 @@
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);
downGlassTask.setGlassId(glassInfo.getGlassId());
downGlassTask.setEndCell(endCell);
- downGlassTask.setTaskType(taskType + "");
- downGlassTask.setWidth(glassInfo.getWidth().intValue());
- downGlassTask.setHeight(glassInfo.getHeight().intValue());
+ downGlassTask.setTaskType(taskType);
+ downGlassTask.setWidth((int) glassInfo.getWidth());
+ downGlassTask.setHeight((int) glassInfo.getHeight());
downGlassTask.setFlowCardId(glassInfo.getFlowCardId());
+ downGlassTask.setLayer(glassInfo.getLayer());
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(), width);
+ s7control.writeWord(plcMesObject.getPlcParameter("Glass_height").getAddress(), height);
+ s7control.writeWord(plcMesObject.getPlcParameter("Glass_thickness").getAddress(), thickness);
+ s7control.writeWord(plcMesObject.getPlcParameter("Start_cell").getAddress(), startCell);
+ s7control.writeWord(plcMesObject.getPlcParameter("End_cell").getAddress(), endCell);
+ s7control.writeWord(plcMesObject.getPlcParameter("task_type").getAddress(), taskType);
+ s7control.writeWord(plcMesObject.getPlcParameter("confirmationWord").getAddress(), 1);
+ return Boolean.TRUE;
}
}
--
Gitblit v1.8.0