From 5327d8da2fbeda44417a09beba29e897cc7d8951 Mon Sep 17 00:00:00 2001
From: wangfei <3597712270@qq.com>
Date: 星期五, 02 八月 2024 14:08:10 +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 | 465 +++++++++++++++++++++++++++++++++++----------------------
1 files changed, 283 insertions(+), 182 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 cd2a2f3..7e31c30 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,6 +21,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;
@@ -28,10 +30,7 @@
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -71,21 +70,30 @@
@Value("${mes.maxHeight}")
private Integer maxHeight;
+ @Value("${mes.minWidth}")
+ private Integer minWidth;
- @Scheduled(fixedDelay = 1000)
+ @Value("${mes.minHeight}")
+ private Integer minHeight;
+
+
+ @Scheduled(fixedDelay = 300)
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)) {
@@ -93,7 +101,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)) {
@@ -102,26 +110,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);
}
}
}
- private 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);
@@ -129,35 +134,37 @@
log.info("2銆佹煡璇㈠崸寮忕悊鐗囩閲岄潰鐨勭┖鏍�:{}", nearestEmpty);
GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId));
Assert.isFalse(null == glassInfo, "鐜荤拑淇℃伅涓嶅瓨鍦�");
- if ("1".equals(requestWord) && (glassInfo.getWidth() > throughWidth || glassInfo.getHeight() > throughHeight)) {
- log.info("鐜荤拑褰撳墠灏哄瀹斤細{}锛岄珮锛歿}鍙兘鐩撮�氾紝褰撳墠杩涚墖浠诲姟闇�绛夊緟", glassInfo.getWidth(), glassInfo.getHeight());
+ double glassWidth = Math.max(glassInfo.getWidth(), glassInfo.getHeight());
+ double glassHeight = Math.min(glassInfo.getWidth(), glassInfo.getHeight());
+ if ("1".equals(requestWord) && (glassWidth > throughWidth || glassHeight > throughHeight)) {
+ log.info("鐜荤拑褰撳墠灏哄瀹斤細{}锛岄珮锛歿}鍙兘鐩撮�氾紝褰撳墠杩涚墖浠诲姟闇�绛夊緟", glassWidth, glassHeight);
return;
}
Boolean checkFlag = Boolean.FALSE;
//鐜荤拑灏哄鏄惁璧颁汉宸ヤ笅鐗�
- if (glassInfo.getWidth() > maxWidth || glassInfo.getHeight() > maxHeight) {
- log.info("璇ョ幓鐠冨昂瀵歌蛋浜哄伐涓嬬墖,鐩存帴杩涚墖");
+ if (glassWidth > maxWidth || glassHeight > maxHeight || glassWidth < minWidth || glassHeight < minHeight) {
+ log.info("璇ョ幓鐠冨昂瀵镐笉绗﹀悎瑕佹眰锛岄渶瑕佽蛋浜哄伐涓嬬墖鐩存帴杩涚墖");
} else {
log.info("璇ョ幓鐠冨昂瀵搁潪浜哄伐涓嬬墖");
//鑾峰彇璇ョ幓鐠冪殑娴佺▼鍗℃槸鍚﹀凡缁戝畾鏋跺瓙
DownWorkstation one = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>()
.eq(DownWorkstation::getLayer, glassInfo.getLayer())
.eq(DownWorkstation::getFlowCardId, glassInfo.getFlowCardId()));
+ //鏄惁宸茬粡缁戝畾 true锛氬凡缁戝畾 false:鏈粦瀹�
Boolean isBind = Boolean.FALSE;
if (null != one) {
log.info("璇ユ祦绋嬪崱宸茬粦瀹氭灦瀛�");
isBind = Boolean.TRUE;
- checkFlag = multilayerCheck(glassInfo);
+ checkFlag = multilayerCheck(glassInfo, isBind);
}
if (!checkFlag && !isBind) {
log.info("璇ョ幓鐠冪殑娴佺▼鍗℃湭缁戝畾鏋跺瓙锛岃幏鍙栨槸鍚︽湁绌烘灦瀛�");
List<DownWorkstation> list = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>()
- .isNull(DownWorkstation::getFlowCardId));
+ .and(on -> on.isNull(DownWorkstation::getFlowCardId).or().eq(DownWorkstation::getFlowCardId, "")).orderByDesc(DownWorkstation::getWorkstationId));
if (CollectionUtils.isNotEmpty(list)) {
log.info("鏈夌┖鏋跺瓙,灏嗘祦绋嬪崱涓庢灦瀛愬ソ缁戝畾锛屾墽琛岃繘鐗囦换鍔� 缁撴潫");
//缁戝畾娴佺▼鍗�
- downWorkstationService.update(new LambdaUpdateWrapper<DownWorkstation>().set(DownWorkstation::getFlowCardId, glassInfo.getFlowCardId())
- .eq(DownWorkstation::getWorkstationId, list.get(0).getWorkstationId()));
+ downWorkstationService.updateFlowCardIdAndCount(glassInfo.getFlowCardId(), list.get(0).getWorkstationId(), glassInfo.getLayer());
checkFlag = Boolean.TRUE;
}
}
@@ -165,31 +172,38 @@
log.info("鏃犵┖鏋跺瓙,鑾峰彇宸茬粦瀹氭灦瀛愮殑娴佺▼鍗′俊鎭�,鏌ョ湅鐜荤拑淇℃伅鏄惁鍙瀵硅皟");
List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Boolean.FALSE);
log.info("鑾峰彇鏋跺瓙涓婂凡缁戝畾娴佺▼鍗¤惤鏋剁殑鏁伴噺鍙婃湭钀芥灦鐨勭幓鐠冩暟鎹細{}", downGlassInfoDTOList);
- Assert.isTrue(CollectionUtils.isNotEmpty(downGlassInfoDTOList), "宸茬粦瀹氭祦绋嬪崱鍧囨棤鏈惤鏋剁幓鐠冿紝璇峰強鏃跺鐞嗘灦瀛愪笂鐨勭幓鐠冿紝娓呴櫎娴佺▼鍗�");
- //鏇挎崲鐜荤拑淇℃伅
- endLoop:
- 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())) {
- //鐜荤拑鏄惁涓哄灞�
- checkFlag = multilayerCheck(item);
- if (checkFlag) {
- //鐜荤拑鏇挎崲 浠呮浛鎹㈡祦绋嬪崱id鍙婂眰鏁�
- String tempFlowCardId = item.getFlowCardId();
- Integer tempLayer = item.getLayer();
- String flowCardId = glassInfo.getFlowCardId();
- Integer layer = glassInfo.getLayer();
- log.info("鏇挎崲娴佺▼鍗′俊鎭�,褰撳墠鐜荤拑淇℃伅:{}鐨勬祦绋嬪崱鍙穥}鍙婂眰鏁皗},鏇挎崲鍚庣幓鐠冧俊鎭�:{}鐨勬祦绋嬪崱鍙穥}鍙婂眰鏁皗}",
- item, glassInfo, flowCardId, layer, tempFlowCardId, tempLayer);
- glassInfo.setFlowCardId(tempFlowCardId);
- glassInfo.setLayer(tempLayer);
- glassInfoService.updateById(glassInfo);
- item.setFlowCardId(flowCardId);
- item.setLayer(layer);
- glassInfoService.updateById(item);
- break endLoop;
+ if (CollectionUtils.isEmpty(downGlassInfoDTOList)) {
+ log.info("宸茬粦瀹氭祦绋嬪崱鍧囨棤鏈惤鏋剁幓鐠冿紝璇峰強鏃跺鐞嗘灦瀛愪笂鐨勭幓鐠冿紝娓呴櫎娴佺▼鍗�,鎵ц杩涚墖浠诲姟");
+ } else {
+ //鏇挎崲鐜荤拑淇℃伅
+ endLoop:
+ for (DownGlassInfoDTO e : downGlassInfoDTOList) {
+ List<GlassInfo> glassInfoList = e.getGlassInfoList();
+ List<GlassInfo> glassInfoTempList = glassInfoList.stream().filter(item -> item.getWidth() == glassInfo.getWidth() && item.getHeight() == glassInfo.getHeight()
+ && item.getThickness() == glassInfo.getThickness() && item.getFilmsid().equals(glassInfo.getFilmsid())).collect(Collectors.toList());
+ if (CollectionUtils.isNotEmpty(glassInfoTempList)) {
+ for (GlassInfo item : glassInfoTempList) {
+ //鐜荤拑鏄惁涓哄灞傦細1銆佸厛鑾峰彇褰撳墠娴佺▼鍗¤惤鏋舵渶澶氱殑灞傛暟锛屽鏋滀负绌猴紝琛ㄦ槑鏈粦瀹氭祦绋嬪崱锛屾湭钀芥灦锛岀劧鍚庢寜鐓ф槸鍚﹀彲缁戝畾鏋跺瓙鍐冲畾鏄惁鏇挎崲銆傦紙鍙拷鐣ヤ笉璁★紝鏈牎楠屼粎鍦ㄥ墠涓�娆¤皟鐢ㄨ捣浣滅敤锛�
+// 2銆佸垽鏂惤鏋舵渶澶氱殑灞傛暟鏄惁涓哄綋鍓嶆浛鎹㈢幓鐠冪殑灞傛暟锛屾槸 鍒欒蛋鏇挎崲閫昏緫杩斿洖true
+// 3銆佷笉鏄渶澶氱殑灞傛暟锛岃幏鍙栬惤鏋舵渶澶氬眰鏁扮殑鐩稿悓娆″簭鐨勭幓鐠冨昂瀵镐笌褰撳墠鏇挎崲鐜荤拑鐨勫昂瀵告瘮杈冿紝鐩稿悓璧版浛鎹紝鍚﹀垯缁х画寰幆
+// 4銆佸崟灞傜幓鐠冪洿鎺ヨ蛋鏇挎崲
+ checkFlag = multilayerCheck(item, Boolean.FALSE);
+ if (checkFlag) {
+ //鐜荤拑鏇挎崲 浠呮浛鎹㈡祦绋嬪崱id鍙婂眰鏁�
+ String tempFlowCardId = item.getFlowCardId();
+ Integer tempLayer = item.getLayer();
+ String flowCardId = glassInfo.getFlowCardId();
+ Integer layer = glassInfo.getLayer();
+ log.info("鏇挎崲娴佺▼鍗′俊鎭�,褰撳墠鐜荤拑淇℃伅:{}鐨勬祦绋嬪崱鍙穥}鍙婂眰鏁皗},鏇挎崲鍚庣幓鐠冧俊鎭�:{}鐨勬祦绋嬪崱鍙穥}鍙婂眰鏁皗}",
+ item, glassInfo, flowCardId, layer, tempFlowCardId, tempLayer);
+ glassInfo.setFlowCardId(tempFlowCardId);
+ glassInfo.setLayer(tempLayer);
+ glassInfoService.updateById(glassInfo);
+ item.setFlowCardId(flowCardId);
+ item.setLayer(layer);
+ glassInfoService.updateById(item);
+ break endLoop;
+ }
}
}
}
@@ -200,113 +214,199 @@
DownStorageCageDetails downStorageCageDetails = new DownStorageCageDetails();
BeanUtils.copyProperties(glassInfo, downStorageCageDetails);
downStorageCageDetails.setState(Const.GLASS_STATE_IN);
+ downStorageCageDetails.setSlot(nearestEmpty.getSlot());
downStorageCageDetailsService.save(downStorageCageDetails);
-// 鐢熸垚杩涚墖浠诲姟
- initDownGlassTask(glassInfo, nearestEmpty.getSlot(), null, Const.GLASS_CACHE_TYPE_IN);
- //log.info("5銆佺敓鎴愯繘鐗囦换鍔′俊鎭瓨鍏ヤ换鍔¤〃鏄惁瀹屾垚锛歿}", taskCache);
-// S7object.getinstance().plccontrol.writeWord(confirmationWrodAddress, (short) 1);
-// log.info("6銆佸彂閫佺‘璁ゅ瓧瀹屾垚");
+ // 鐢熸垚杩涚墖浠诲姟
+ initDownGlassTask(glassInfo, 0, nearestEmpty.getSlot(), Const.GLASS_CACHE_TYPE_IN);
}
- private 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;
}
List<DownStorageCageDetails> tempList = downStorageCageDetailsService.list(new LambdaQueryWrapper<DownStorageCageDetails>()
.eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN));
- log.info("绗煎唴鐜荤拑鐨勬暟鎹湁锛歿}", tempList);
+ log.info("鍑虹墖1銆佺鍐呯殑鐜荤拑淇℃伅鏈夛細{}", tempList);
+ //鑾峰彇寰呰繘鐗囩幓鐠�
+ DownStorageCageDetails cageDetails = new DownStorageCageDetails();
+ if (StringUtils.isNotBlank(glassId)) {
+ GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId));
+ BeanUtils.copyProperties(glassInfo, cageDetails);
+ //鑾峰彇褰撳墠绗煎瓙绌烘牸淇℃伅
+ DownStorageCage empty = downStorageCageService.selectCacheEmpty(Integer.parseInt(currentSlot), Boolean.TRUE);
+ cageDetails.setSlot(empty.getSlot());
+ tempList.add(cageDetails);
+ }
+ log.info("鍑虹墖2锛氱鍐呯幓鐠冪殑鏁版嵁(鍖呮嫭寰呰繘鐗�)鏈夛細{}", tempList);
if (CollectionUtils.isEmpty(tempList)) {
log.info("绗煎唴娌℃湁鐜荤拑,鏃犳硶鎵ц鍑虹墖");
return Boolean.FALSE;
}
+ //浼樺厛璧�08鐗囧彴鐨勭幓鐠冿細璧颁汉宸ヤ笅鐗囨垨鑰�2鍙锋満姊拌噦
+ //1銆�08鍙板繖纰岋紝浠呰蛋1鍙锋満姊拌噦
+ //2銆�08鍙扮┖闂诧紝鍏堣蛋鎵斿伐涓嬬墖鎴�2鍙锋満姊拌噦锛屾棤鐜荤拑鍑虹墖 鍦ㄨ蛋1鍙锋満姊拌噦
+ //鏈烘鑷傝绂佺敤鐨勬儏鍐典笅涓嶈兘缁х画鍚戠鐢ㄧ殑鏈烘鑷傛斁鐜荤拑
+ Boolean flag08 = "1".equals(out08Glassstate) ? Boolean.TRUE : Boolean.FALSE;
+ if (!flag08) {
+ generateTaskByShelf(glassStatus06, glassStatus11, flag08, glassStatus13, tempList, cageDetails, glassId);
+ } else {
+ 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 (flag08) {
+ if (!"2".equals(glassStatus11)) {
+ workList.addAll(Const.G11_WORK_STATION);
+ }
+ } else {
+ if (!"2".equals(glassStatus06)) {
+ workList.addAll(Const.G06_WORK_STATION);
+ }
}
- if (!"2".equals(glassStatus11)) {
- workList.addAll(Const.G11_WORK_STATION);
- }
+ List<Integer> workStationAll = Arrays.asList(1, 2, 3, 4, 5, 6);
+ List<Integer> offWorkStationList = workStationAll.stream().filter(e -> !workList.contains(e)).collect(Collectors.toList());
List<DownStorageCageDetails> list = new ArrayList();
+ //鏄惁鏈夌┖鏋跺瓙 true锛氭湁 false:鏃�
Boolean isEmptyShelf = Boolean.FALSE;
//瀵圭鍐呯幓鐠冭繘琛岃繃婊わ紝浠呭嚭绗﹀悎閫昏緫鐨勭幓鐠�
if (CollectionUtils.isNotEmpty(workList)) {
List<DownWorkstation> downWorkstationList = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>()
- .eq(DownWorkstation::getEnableState, 0).in(DownWorkstation::getWorkstationId, workList));
- log.info("鏋跺瓙琚鐢紝鏃犳硶鍑虹墖钀芥灦");
+ .eq(DownWorkstation::getEnableState, Const.SLOT_ON).in(DownWorkstation::getWorkstationId, workList));
if (CollectionUtils.isEmpty(downWorkstationList)) {
log.info("绗煎瓙琚鐢紝鏃犳硶璧版満姊拌噦涓嬬墖");
//璧颁汉宸ヤ笅鐗�
- if (!"2".equals(glassStatus13)) {
- list = tempList.stream().filter(item -> item.getWidth() > maxWidth || item.getHeight() > maxHeight).collect(Collectors.toList());
+ if (flag08 && !"2".equals(glassStatus13)) {
+ list = tempList.stream().filter(item -> {
+ double firstLength = Math.max(item.getWidth(), item.getHeight());
+ double secondLength = Math.min(item.getWidth(), item.getHeight());
+ return firstLength > maxWidth || secondLength > maxHeight;
+ }).collect(Collectors.toList());
}
} else {
- List<DownWorkstation> workstationsIsNotBind = downWorkstationList.stream().filter(item -> null == (item.getFlowCardId())).collect(Collectors.toList());
- Map<String, List<DownWorkstation>> listMap = downWorkstationList.stream().collect(Collectors.groupingBy(item -> item.getFlowCardId() + ":" + item.getLayer()));
+ //鑾峰彇鍙惤鏋剁殑鐨勬灦瀛愪俊鎭紙鍖呮嫭绌烘灦瀛愶級
+ //浠呰幏鍙栫┖鏋跺瓙淇℃伅
+ List<DownWorkstation> workstationsIsNotBind = downWorkstationList.stream().filter(item -> StringUtils.isBlank(item.getFlowCardId())).collect(Collectors.toList());
+ //灏嗘灦瀛愮殑娴佺▼鍗″彿鍙婂眰鏁颁綔涓簁ey 涓嶅瓨鍦ㄧ┖鏋跺瓙鐨勬儏鍐�
if (CollectionUtils.isEmpty(workstationsIsNotBind)) {
log.info("涓嶅瓨鍦ㄦ湭缁戝畾娴佺▼鍗℃灦瀛�");
//绛涢�夊嚭瀵瑰簲鏋跺瓙宸茬粦瀹氭祦绋嬪崱鍙笅鐗囩殑鐜荤拑
+ Map<String, List<DownWorkstation>> listMap = downWorkstationList.stream()
+ .filter(item -> StringUtils.isNotBlank(item.getFlowCardId())).collect(Collectors.groupingBy(item -> item.getFlowCardId() + ":" + item.getLayer()));
+ //杩囨护绛涢�夎幏鍙栨灦瀛愪笂瀵瑰簲娴佺▼鍗�+灞傛暟鐨勭瀛愬唴鐨勭幓鐠冧俊鎭�
list = tempList.stream().filter(item -> listMap.containsKey(item.getFlowCardId() + ":" + item.getLayer())).collect(Collectors.toList());
} else {
- log.info("瀛樺湪鏈粦瀹氭祦绋嬪崱鏋跺瓙锛岀洿鎺ヨ幏鍙栫鍐呮墍鏈夌幓鐠�");
+ log.info("瀛樺湪鏈粦瀹氭祦绋嬪崱鏋跺瓙锛岀洿鎺ヨ幏鍙栫鍐呮墍鏈夌幓鐠�,涓旀湭缁戝畾鏋跺瓙鐨勭幓鐠冧俊鎭�");
+ //鑾峰彇绂佺敤鍙婇潪鏈満姊拌噦鐨勬灦瀛愮殑娴佺▼鍙峰強灞傛暟瀵瑰簲鐨勭幓鐠冧俊鎭�
+ List<DownWorkstation> downWorkstationOffList = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>()
+ .and(i -> i.in(DownWorkstation::getWorkstationId, offWorkStationList).or().eq(DownWorkstation::getEnableState, Const.SLOT_OFF)));
+ //鑾峰彇琚鐢ㄧ殑娴佺▼鍗′俊鎭� 涓虹┖锛氬皢杩斿洖绗煎唴鐨勬墍鏈夌幓鐠冧俊鎭�
+ if (CollectionUtils.isEmpty(downWorkstationOffList)) {
+ list = tempList;
+ } else {
+ //绗煎唴瀛樺湪鏃犳硶鍑虹墖鐨勭幓鐠冧俊鎭紝杩囨护鏃犳硶鍑虹墖鐨勭幓鐠冧俊鎭紝浠呰幏鍙栧彲鍑虹墖鐨勭幓鐠冧俊鎭� 鏃犳硶鍑虹墖鐨勭幓鐠冧负锛氭湭缁戝畾鏋跺瓙銆佺粦瀹氭灦瀛愯绂佺敤銆侀潪鏈満姊拌噦瀵瑰簲鐨勬灦瀛�
+ Map<String, List<DownWorkstation>> listOffMap = downWorkstationOffList.stream().filter(item -> StringUtils.isNotBlank(item.getFlowCardId())).collect(Collectors.groupingBy(item -> item.getFlowCardId() + ":" + item.getLayer()));
+ list = tempList.stream().filter(item -> !listOffMap.containsKey(item.getFlowCardId() + ":" + item.getLayer())).collect(Collectors.toList());
+ }
+ //绌烘灦瀛愯〃绀虹疆涓簍rue
isEmptyShelf = Boolean.TRUE;
- //todo:濡傛灉绂佺敤鏋跺瓙宸茬粦瀹氭祦绋嬪崱锛屽洜涓烘椂闂翠笉纭畾锛岀瀛愬唴鐨勭幓鐠冨彲閲嶆柊缁戝畾鏂版灦瀛�
-// list = tempList.stream().filter(item -> !listMap.containsKey(item.getFlowCardId() + ":" + item.getLayer())).collect(Collectors.toList());
- list = tempList;
}
}
} 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 -> {
+ double firstLength = Math.max(item.getWidth(), item.getHeight());
+ double secondLength = Math.min(item.getWidth(), item.getHeight());
+ return firstLength > maxWidth || secondLength > maxHeight;
+ }).collect(Collectors.toList());
+ }
}
if (CollectionUtils.isEmpty(list)) {
log.info("绗煎唴鐜荤拑鏃犳硶鎵ц鍑虹墖");
return Boolean.FALSE;
}
- //瀹氫箟绗煎唴鏃犳硶鍑虹墖鐜荤拑鏁伴噺
- int glassCount = tempList.size() - list.size();
String tempGlassId = null;
- Boolean isBind = Boolean.FALSE;
+ Boolean isNeedBind = Boolean.FALSE;
for (DownStorageCageDetails item : list) {
- if (item.getWidth() > maxWidth || item.getHeight() > maxHeight) {
- log.info("鐜荤拑瀹藉害鎴栭珮搴﹁秴鍑洪槇鍊硷紝鎵ц浜哄伐涓嬬墖");
- tempGlassId = item.getGlassId();
- break;
+ double firstLength = Math.max(item.getWidth(), item.getHeight());
+ double secondLength = Math.min(item.getWidth(), item.getHeight());
+ if (firstLength > maxWidth || secondLength > maxHeight) {
+ if (flag08 && !"2".equals(glassStatus13)) {
+ log.info("鐜荤拑瀹藉害鎴栭珮搴﹁秴鍑洪槇鍊硷紝鎵ц浜哄伐涓嬬墖");
+ tempGlassId = item.getGlassId();
+ break;
+ }
}
}
loop:
- if (tempGlassId == null) {
+ if (StringUtils.isBlank(tempGlassId)) {
//鑾峰彇姝e湪钀芥灦鐨勭粦瀹氭祦绋嬪崱鐨勪俊鎭�(娴佺▼鍗°�佸眰鏁般�佽惤鏋舵暟閲�)
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();
- isBind = Boolean.TRUE;
+ //鏋跺瓙閮芥湭缁戝畾娴佺▼鍗★紝鍑虹鍐呭瓙鏁伴噺鏈�澶氬昂瀵告渶澶х殑鐜荤拑id,鏃� 鍒欒繑鍥炴壂鎻忔壂鍒扮殑鐜荤拑id杩涜鍑虹墖
+ tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId, offWorkStationList);
+
+ isNeedBind = Boolean.TRUE;
break loop;
}
//灏嗙瀛愬唴鐨勭幓鐠冭繘琛岃繃婊わ紝浠呰幏鍙栨棤娉曡惤鏋剁殑娴佺▼鍗$幓鐠�
- List<DownStorageCageDetails> noDownLoadList = list.stream().filter(item -> !downGlassFlowList.contains(item.getFlowCardId() + ":" + item.getLayer())).collect(Collectors.toList());
+ List<DownStorageCageDetails> noDownLoadList = list.stream().filter(item -> !downGlassFlowList.contains(item.getFlowCardId() + ":" + item.getLayer()))
+ .collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(noDownLoadList)) {
//鏄惁鏈夌┖鏋跺瓙
// List<DownWorkstation> emptyShelfList = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>()
// .isNull(DownWorkstation::getFlowCardId));
if (isEmptyShelf) {
- DownStorageCageDetails downStorageCageDetails = downStorageCageDetailsService.getGlassInfoMaxCount();
- //缁戝畾娴佺▼鍗★紝鏇存柊鐜荤拑鐘舵�侊紝鐢熸垚鍑虹墖浠诲姟
- tempGlassId = downStorageCageDetails.getGlassId();
- isBind = Boolean.TRUE;
- break loop;
- }
- glassCount = noDownLoadList.size();
- if (glassCount > threshold) {
- //鏇存柊鐜荤拑鐘舵�侊紝鐢熸垚鍑虹墖浜哄伐涓嬬墖浠诲姟
- tempGlassId = noDownLoadList.get(0).getGlassId();
- isBind = Boolean.FALSE;
+ //鏋跺瓙閮芥湭缁戝畾娴佺▼鍗★紝鍑虹鍐呭瓙鏁伴噺鏈�澶氬昂瀵告渶澶х殑鐜荤拑id,鏃� 鍒欒繑鍥炴壂鎻忔壂鍒扮殑鐜荤拑id杩涜鍑虹墖
+ tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId, offWorkStationList);
+ isNeedBind = Boolean.TRUE;
break loop;
}
}
@@ -323,15 +423,14 @@
for (DownStorageCageDetails item : multiLayerList) {
DownGlassInfoDTO downGlassInfoDTO = downGlassInfoService.queryDownGlassMaxLayer(item.getFlowCardId());
if (null == downGlassInfoDTO) {
-// 钀芥灦鐜荤拑鏌ュ埌鐩稿叧娴佺▼鍗$幓鐠冧俊鎭紝琛ㄦ槑褰撳墠娴佺▼鍗$幓鐠冩湭钀芥灦
- log.info("");
- return Boolean.FALSE;
+// 鍘嗗彶钀芥灦鐜荤拑鎸夌収鐩稿叧娴佺▼鍗″彇鏁版嵁搴撴湭鎵惧埌鏈�澶氱幓鐠冧俊鎭紝琛ㄦ槑褰撳墠娴佺▼鍗′笅鐨勬湁灞傜殑鐜荤拑鍧囨湭钀芥灦锛岀洿鎺ュ彲鍑哄綋鍓嶇幓鐠�
+ tempGlassId = item.getGlassId();
+ log.info("褰撳墠娴佺▼鍗′笉瀛樺湪钀芥灦鐨勭幓鐠冿紝鍙洿鎺ュ嚭鐗囪惤鏋讹紝鐜荤拑id:{}", tempGlassId);
+ break loop;
}
if (downGlassInfoDTO.getLayer().equals(downGlassInfoDTO.getLayer())) {
- log.info("褰撳墠鐜荤拑鐨勬祦绋嬪湪鏋跺瓙涓婅惤鏋舵渶澶�,鐩存帴鍑虹墖");
- //鏇存柊鐜荤拑鐘舵�侊紝鐢熸垚鍑虹墖浠诲姟
- tempGlassId = noDownLoadList.get(0).getGlassId();
- isBind = Boolean.FALSE;
+ tempGlassId = item.getGlassId();
+ log.info("褰撳墠鐜荤拑鐨勬祦绋嬪湪鏋跺瓙涓婅惤鏋舵渶澶�,鐩存帴鍑虹墖锛岀幓鐠僫d:{}", tempGlassId);
break loop;
}
Integer sequence = downGlassInfoService.queryMaxSequence(item.getFlowCardId(), item.getLayer());
@@ -339,96 +438,70 @@
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())) {
- log.info("鐩稿悓娆″簭鐜荤拑瀵瑰簲涓婏紝鍙墽琛岃繘鐗囦换鍔�");
- //鏇存柊鐜荤拑鐘舵�侊紝鐢熸垚鍑虹墖浠诲姟
- tempGlassId = noDownLoadList.get(0).getGlassId();
- isBind = Boolean.FALSE;
+ if (null != downGlassInfoDTO && downGlassInfo.getWidth() == item.getWidth() && downGlassInfo.getHeight() == item.getHeight()) {
+ tempGlassId = item.getGlassId();
+ log.info("鐩稿悓娆″簭鐜荤拑瀵瑰簲涓婏紝鍙墽琛岃繘鐗囦换鍔★紝鐜荤拑id:{}", tempGlassId);
break loop;
- } else {
- log.info("鍚屾搴忕幓鐠冨搴斾笉涓婏紝闇�鎵ц鏇挎崲鐜荤拑鐨勬搷浣�");
- glassCount += 1;
- if (glassCount > threshold) {
- tempGlassId = noDownLoadList.get(0).getGlassId();
- isBind = Boolean.FALSE;
- break loop;
- }
- continue;
}
}
}
Map<String, List<DownStorageCageDetails>> singleLayerMap = list.stream().filter(item -> item.getTotalLayer() == 1)
.collect(Collectors.groupingBy(item -> item.getFlowCardId() + item.getLayer(), Collectors.toList()));
- if (tempGlassId == null) {
+ if (StringUtils.isBlank(tempGlassId)) {
if (CollectionUtils.isNotEmpty(singleLayerMap)) {
//鑾峰彇宸茶惤鏋舵祦绋嬪崱淇℃伅锛屾寜钀芥灦鏁伴噺鎺掑簭
for (DownGlassInfoDTO e : downGlassInfoDTOList) {
List<DownStorageCageDetails> downStorageCageDetails = singleLayerMap.get(e.getFlowCardId() + e.getLayer());
if (CollectionUtils.isNotEmpty(downStorageCageDetails)) {
tempGlassId = downStorageCageDetails.get(0).getGlassId();
- isBind = Boolean.FALSE;
break;
}
}
}
}
}
- if (tempGlassId == null) {
+ if (StringUtils.isBlank(tempGlassId)) {
log.info("娌℃湁鎵惧埌鍙互涓嬬墖鐨勭殑鐜荤拑锛岀粨鏉熶换鍔�");
return Boolean.FALSE;
} else {
//鎸夌収鍑虹墖鐨勭幓鐠僫d鏇存柊绗煎唴鐨勭幓鐠冪姸鎬佷负宸插嚭鐗�
- return generateDownGlassOutTask(tempGlassId, Const.GLASS_CACHE_TYPE_OUT, isBind);
+ return generateDownGlassOutTask(tempGlassId, Const.GLASS_CACHE_TYPE_OUT, isNeedBind, cageDetails, workList);
}
}
- private Boolean multilayerCheck(GlassInfo glassInfo) {
- //鏌ヨ璇ユ祦绋嬪崱鏄惁涓哄灞�
- if (glassInfo.getTotalLayer() > 1) {
- log.info("鎸夌収娴佺▼鍗¤幏鍙栧綋鍓嶆祦绋嬪崱鍚勫眰宸茶惤鏋舵暟閲�");
- DownGlassInfoDTO downGlassInfoDTO = downGlassInfoService.queryDownGlassMaxLayer(glassInfo.getFlowCardId());
- if (null == downGlassInfoDTO) {
- 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) {
+ public Boolean generateDownGlassOutTask(String glassId, Integer taskType, Boolean
+ isNeedBind, DownStorageCageDetails cageDetails, List<Integer> workList) {
//鎸夌幓鐠僫d鑾峰彇鐜荤拑淇℃伅
- DownStorageCageDetails downStorageCageDetails = downStorageCageDetailsService.getOne(new LambdaQueryWrapper<DownStorageCageDetails>()
- .eq(DownStorageCageDetails::getGlassId, glassId));
+ DownStorageCageDetails downStorageCageDetails = null;
+ if (glassId.equals(cageDetails.getGlassId())) {
+ downStorageCageDetails = cageDetails;
+ taskType = 3;
+ //灏嗕笅鐗囩幓鐠冨瓨鍏ョ瀛愯鎯呬俊鎭〃涓�
+ //灏嗕换鍔℃彃鍏ョ悊鐗囩璇︽儏琛�
+ downStorageCageDetails.setState(Const.GLASS_STATE_OUT);
+ downStorageCageDetailsService.save(downStorageCageDetails);
+ } else {
+ downStorageCageDetails = downStorageCageDetailsService.getOne(new LambdaQueryWrapper<DownStorageCageDetails>()
+ .eq(DownStorageCageDetails::getGlassId, glassId).eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN));
+ if (downStorageCageDetailsService.update(new LambdaUpdateWrapper<DownStorageCageDetails>()
+ .set(DownStorageCageDetails::getState, Const.GLASS_STATE_OUT).eq(DownStorageCageDetails::getGlassId, glassId))) {
+ log.info("鏇存柊璇︽儏琛ㄥ唴鐨勭姸鎬佹垚鍔�");
+// return Boolean.TRUE;
+ } else {
+ log.info("鏇存柊璇︽儏琛ㄥ唴鐨勭姸鎬佸け璐�");
+ return Boolean.FALSE;
+ }
+ }
+
Integer endCell = null;
- if (isBind) {
+ if (isNeedBind) {
//鑾峰彇绌烘灦瀛愪俊鎭紝灏嗙┖鏋跺瓙淇℃伅缁戝畾娴佺▼鍗�
DownWorkstation emptyDownWorkstation = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>()
- .isNull(DownWorkstation::getFlowCardId).orderByDesc(DownWorkstation::getWorkstationId).last("limit 1"));
+ .and(on -> on.isNull(DownWorkstation::getFlowCardId).or().eq(DownWorkstation::getFlowCardId, "")).in(DownWorkstation::getWorkstationId, workList).orderByDesc(DownWorkstation::getWorkstationId).last("limit 1"));
if (null != emptyDownWorkstation) {
log.info("鑾峰彇鍒扮┖鏋跺瓙淇℃伅锛岀粦瀹氭祦绋嬪崱");
- emptyDownWorkstation.setFlowCardId(downStorageCageDetails.getFlowCardId());
- emptyDownWorkstation.setLayer(downStorageCageDetails.getLayer());
- downWorkstationService.updateById(emptyDownWorkstation);
+ downWorkstationService.updateFlowCardIdAndCount(downStorageCageDetails.getFlowCardId(), emptyDownWorkstation.getWorkstationId(), downStorageCageDetails.getLayer());
endCell = emptyDownWorkstation.getWorkstationId();
} else {
log.info("娌℃湁绌烘灦瀛愪俊鎭紝鏃犳硶缁戝畾娴佺▼鍗�");
@@ -439,29 +512,57 @@
.eq(DownWorkstation::getFlowCardId, downStorageCageDetails.getFlowCardId()).eq(DownWorkstation::getLayer, downStorageCageDetails.getLayer()));
endCell = workstation.getWorkstationId();
}
- //鏇存柊璇︽儏琛ㄥ唴鐨勭姸鎬�
- if (downStorageCageDetailsService.update(new LambdaUpdateWrapper<DownStorageCageDetails>()
- .set(DownStorageCageDetails::getState, Const.GLASS_STATE_OUT).eq(DownStorageCageDetails::getGlassId, glassId))) {
- log.info("鏇存柊璇︽儏琛ㄥ唴鐨勭姸鎬佹垚鍔�");
+ //鏇存柊钀芥灦鐜荤拑鏁伴噺
+ if (endCell == 7) {
+ downWorkstationService.update(new UpdateWrapper<DownWorkstation>().eq("flow_card_id", downStorageCageDetails.getFlowCardId())
+ .eq("layer", downStorageCageDetails.getLayer()).setSql("other_number = other_number +1"));
} else {
- 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);
+ //钀芥灦鐗囧簭
+ downGlassInfo.setSequence(downGlassInfoService.queryMaxSequence(downGlassInfo.getFlowCardId(), downGlassInfo.getLayer()));
+ downGlassInfoService.save(downGlassInfo);
//鐢熸垚浠诲姟淇℃伅
GlassInfo glassInfo = new GlassInfo();
BeanUtils.copyProperties(downStorageCageDetails, glassInfo);
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();
- BeanUtils.copyProperties(glassInfo, downGlassTask);
downGlassTask.setStartCell(startCell);
+ downGlassTask.setGlassId(glassInfo.getGlassId());
downGlassTask.setEndCell(endCell);
- downGlassTask.setTaskType(taskType + "");
- downGlassTask.setTaskStauts(0);
+ downGlassTask.setTaskType(taskType);
+ downGlassTask.setWidth((int) glassInfo.getWidth());
+ downGlassTask.setHeight((int) glassInfo.getHeight());
+ downGlassTask.setFlowCardId(glassInfo.getFlowCardId());
+ downGlassTask.setLayer(glassInfo.getLayer());
+ downGlassTask.setTaskStatus(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