From 33308e16bbb153d9aac76fd703ec0f38ea7e344a Mon Sep 17 00:00:00 2001
From: wangfei <3597712270@qq.com>
Date: 星期三, 09 十月 2024 15:47:59 +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 | 223 +++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 197 insertions(+), 26 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 d6369fa..e96ddf0 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
@@ -3,10 +3,13 @@
import cn.hutool.core.lang.Assert;
import cn.smallbun.screw.core.util.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.damage.entity.Damage;
+import com.mes.damage.service.DamageService;
import com.mes.device.PlcParameterObject;
import com.mes.downglassinfo.entity.DownGlassInfo;
import com.mes.downglassinfo.entity.DownGlassTask;
@@ -27,6 +30,7 @@
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -54,9 +58,8 @@
DownWorkstationService downWorkstationService;
@Autowired
DownGlassInfoService downGlassInfoService;
-
- @Value("${mes.threshold}")
- private Integer threshold;
+ @Autowired
+ DamageService damageService;
@Value("${mes.throughWidth}")
private Integer throughWidth;
@@ -94,7 +97,6 @@
log.info("1銆佽幏鍙栧埌鐨勮姹傚瓧涓猴細{}锛岃幏鍙栧埌鐨勬壂鎻廔D涓猴細{}锛岃幏鍙栧埌鐨勭‘璁ゅ瓧涓猴細{}锛岃幏鍙栧埌鐨勫嚭鐗囩姸鎬佸垎鍒负锛歡06:{}銆乬08:{}銆乬11:{}銆乬13:{},褰撳墠鏍煎瓙鍙蜂负锛歿}",
requestWord, glassIdeValue, confirmationWrodValue, out06Glassstate, out08Glassstate, out11Glassstate, out13Glassstate, currentSlot);
-
if ("0".equals(requestWord)) {
if ("0".equals(confirmationWrodValue)) {
log.info("2銆佽幏鍙栧埌鐨勮姹傚瓧涓�0锛屼笖纭瀛椾负0锛屼笉鎵ц浠诲姟");
@@ -126,6 +128,87 @@
}
}
+ @Scheduled(fixedDelay = 300)
+ public void plcShelfFull() {
+ List<DownWorkstation> list = downGlassInfoService.queryWorkStationIsFull();
+ S7control s7control = S7object.getinstance().plccontrol;
+ PlcParameterObject plcMesObject = S7object.getinstance().PlcMesObject;
+ if (CollectionUtils.isNotEmpty(list)) {
+ s7control.writeWord(plcMesObject.getPlcParameter("alarm_signal").getAddress(), 1);
+ } else {
+ s7control.writeWord(plcMesObject.getPlcParameter("alarm_signal").getAddress(), 0);
+ }
+ }
+
+ @Scheduled(fixedDelay = 1000)
+ public void dealDamageTask() {
+ Date startDate = new Date();
+ log.info("涓嬬墖鐮存崯鐜荤拑娓呴櫎浠诲姟寮�濮嬫墽琛屾椂闂达細{}", startDate);
+ List<DownGlassTask> downGlassTaskList = downGlassTaskService.list(new LambdaQueryWrapper<DownGlassTask>()
+ .in(DownGlassTask::getTaskType, Const.GLASS_CACHE_TYPE_OUT_ALL).in(DownGlassTask::getTaskStatus, Const.GLASS_STATE_DAMAGE_TAKE));
+ if (CollectionUtils.isNotEmpty(downGlassTaskList)) {
+ //鑾峰彇鐮存崯/鎷胯蛋鐜荤拑id
+ List<String> glassList = downGlassTaskList.stream().map(DownGlassTask::getGlassId).collect(Collectors.toList());
+ //灏嗕换鍔¤〃涓殑鏁版嵁鍒犻櫎
+ downGlassTaskService.remove(new LambdaQueryWrapper<DownGlassTask>().in(DownGlassTask::getTaskType, Const.GLASS_CACHE_TYPE_OUT_ALL).in(DownGlassTask::getGlassId, glassList));
+ //娓呴櫎涓嬬墖鐜荤拑淇℃伅琛ㄦ暟鎹�
+ downGlassInfoService.remove(new LambdaQueryWrapper<DownGlassInfo>().in(DownGlassInfo::getGlassId, glassList));
+ //涓嬬墖鏁伴噺-1
+ for (DownGlassTask downGlassTask : downGlassTaskList
+ ) {
+ if (Const.GLASS_CACHE_TYPE_OUT_ALL.equals(downGlassTask.getTaskType())) {
+ downWorkstationService.update(
+ new LambdaUpdateWrapper<DownWorkstation>()
+ .setSql("racks_number = racks_number-1")
+ .eq(DownWorkstation::getWorkstationId, downGlassTask.getEndCell())
+ );
+
+ }
+ }
+ List<Damage> damageList = downGlassTaskList.stream().map(e -> {
+ Damage damage = new Damage();
+ damage.setGlassId(e.getGlassId());
+ damage.setLine(Const.TEMPERING_OUT_TARGET_POSITION);
+ damage.setWorkingProcedure("涓嬬墖");
+ damage.setRemark("涓嬬墖");
+ damage.setStatus(0);
+ damage.setType(e.getTaskStatus());
+ return damage;
+ }).collect(Collectors.toList());
+ damageService.batchInsertDamage(damageList);
+ }
+ Date endDate = new Date();
+ log.info("鏈浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms", endDate, endDate.getTime() - startDate.getTime());
+ }
+
+ /**
+ * 鏇存柊宸茬粦瀹氬伐浣嶆祦绋嬪崱鐨勭牬鎹�/鎷胯蛋鐨勬暟閲忎俊鎭�
+ */
+ @Scheduled(fixedDelay = 1000)
+ public void updateWorkStationOtherCount() {
+ Date startDate = new Date();
+ log.info("涓嬬墖鐮存洿鏂版崯鐜荤拑鏁伴噺浠诲姟寮�濮嬫墽琛屾椂闂达細{}", startDate);
+ //鑾峰彇宸茬粦瀹氭祦绋嬪崱鐨勫伐浣嶄俊鎭�
+ List<DownWorkstation> downWorkstationList = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>()
+ .isNotNull(DownWorkstation::getFlowCardId)
+ .ne(DownWorkstation::getFlowCardId, "")
+ .orderByDesc(DownWorkstation::getWorkstationId));
+ for (DownWorkstation downWorkstation : downWorkstationList) {
+ //鏇存柊宸ヤ綅鍏朵粬鐜荤拑淇℃伅鐨勬暟閲�
+ QueryWrapper<Damage> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("process_id", downWorkstation.getFlowCardId());
+ queryWrapper.gt("type", 3);
+ if (downWorkstation.getLayer() != 0) {
+ queryWrapper.eq("technology_number", downWorkstation.getLayer());
+ }
+ int otherNumber = damageService.count(queryWrapper);
+ downWorkstationService.update(new LambdaUpdateWrapper<DownWorkstation>().set(DownWorkstation::getOtherNumber, otherNumber)
+ .eq(DownWorkstation::getWorkstationId, downWorkstation.getWorkstationId()));
+ }
+ Date endDate = new Date();
+ log.info("涓嬬墖鐮存洿鏂版崯鐜荤拑鏁伴噺浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms", endDate, endDate.getTime() - startDate.getTime());
+ }
+
public void inTo(String glassId, String requestWord, String currentSlot) {
log.info("1銆佹寜鐓х幓鐠僫d:{}鑾峰彇鐜荤拑灏忕墖淇℃伅,褰撳墠鏍煎瓙涓�:{}", glassId, currentSlot);
//娣诲姞杩涚墖浠诲姟 鏌ユ壘绌烘牸
@@ -147,9 +230,16 @@
} else {
log.info("璇ョ幓鐠冨昂瀵搁潪浜哄伐涓嬬墖");
//鑾峰彇璇ョ幓鐠冪殑娴佺▼鍗℃槸鍚﹀凡缁戝畾鏋跺瓙
- DownWorkstation one = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>()
- .eq(DownWorkstation::getLayer, glassInfo.getLayer())
- .eq(DownWorkstation::getFlowCardId, glassInfo.getFlowCardId()));
+ DownWorkstation one;
+ if (glassInfo.getCombine() != 0) {
+ one = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>()
+ .eq(DownWorkstation::getFlowCardId, glassInfo.getFlowCardId()));
+ } else {
+ 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) {
@@ -160,17 +250,22 @@
if (!checkFlag && !isBind) {
log.info("璇ョ幓鐠冪殑娴佺▼鍗℃湭缁戝畾鏋跺瓙锛岃幏鍙栨槸鍚︽湁绌烘灦瀛�");
List<DownWorkstation> list = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>()
- .isNull(DownWorkstation::getFlowCardId).orderByDesc(DownWorkstation::getWorkstationId));
+ .and(on -> on.isNull(DownWorkstation::getFlowCardId).or().eq(DownWorkstation::getFlowCardId, "")).orderByDesc(DownWorkstation::getWorkstationId));
if (CollectionUtils.isNotEmpty(list)) {
log.info("鏈夌┖鏋跺瓙,灏嗘祦绋嬪崱涓庢灦瀛愬ソ缁戝畾锛屾墽琛岃繘鐗囦换鍔� 缁撴潫");
//缁戝畾娴佺▼鍗�
- downWorkstationService.updateFlowCardIdAndCount(glassInfo.getFlowCardId(), list.get(0).getWorkstationId(), glassInfo.getLayer());
+ if (glassInfo.getCombine() == 0) {
+ downWorkstationService.updateFlowCardIdAndCount(glassInfo.getFlowCardId(), list.get(0).getWorkstationId(), glassInfo.getLayer());
+ } else {
+ downWorkstationService.updateFlowCardIdAndCount(glassInfo.getFlowCardId(), list.get(0).getWorkstationId(), 0);
+ }
+// downWorkstationService.updateFlowCardIdAndCount(glassInfo.getFlowCardId(), list.get(0).getId(), glassInfo.getLayer());
checkFlag = Boolean.TRUE;
}
}
if (!checkFlag) {
log.info("鏃犵┖鏋跺瓙,鑾峰彇宸茬粦瀹氭灦瀛愮殑娴佺▼鍗′俊鎭�,鏌ョ湅鐜荤拑淇℃伅鏄惁鍙瀵硅皟");
- List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Boolean.FALSE);
+ List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Const.WORK_STATION_ALL, Boolean.FALSE);
log.info("鑾峰彇鏋跺瓙涓婂凡缁戝畾娴佺▼鍗¤惤鏋剁殑鏁伴噺鍙婃湭钀芥灦鐨勭幓鐠冩暟鎹細{}", downGlassInfoDTOList);
if (CollectionUtils.isEmpty(downGlassInfoDTOList)) {
log.info("宸茬粦瀹氭祦绋嬪崱鍧囨棤鏈惤鏋剁幓鐠冿紝璇峰強鏃跺鐞嗘灦瀛愪笂鐨勭幓鐠冿紝娓呴櫎娴佺▼鍗�,鎵ц杩涚墖浠诲姟");
@@ -213,11 +308,18 @@
//灏嗕换鍔℃彃鍏ョ悊鐗囩璇︽儏琛�
DownStorageCageDetails downStorageCageDetails = new DownStorageCageDetails();
BeanUtils.copyProperties(glassInfo, downStorageCageDetails);
+ //褰撻渶瑕佸悎骞惰惤鏋舵椂涓嶇粦瀹氬眰鍙�
+ if (glassInfo.getCombine() != 0) {
+ downStorageCageDetails.setLayer(0);
+ }
downStorageCageDetails.setState(Const.GLASS_STATE_IN);
downStorageCageDetails.setSlot(nearestEmpty.getSlot());
+ downStorageCageDetails.setDeviceId(nearestEmpty.getDeviceId());
downStorageCageDetailsService.save(downStorageCageDetails);
// 鐢熸垚杩涚墖浠诲姟
initDownGlassTask(glassInfo, 0, nearestEmpty.getSlot(), Const.GLASS_CACHE_TYPE_IN);
+ //鍒犻櫎鐞嗙墖绗艰〃鎷胯蛋/鐮存崯鏁版嵁鏁版嵁
+ damageService.deleteByGlassId(glassInfo.getGlassId());
}
public Boolean outTo(String glassStatus06, String out08Glassstate, String glassStatus11, String
@@ -234,9 +336,14 @@
if (StringUtils.isNotBlank(glassId)) {
GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId));
BeanUtils.copyProperties(glassInfo, cageDetails);
+ //褰撻渶瑕佸悎骞惰惤鏋舵椂涓嶇粦瀹氬眰鍙�
+ if (glassInfo.getCombine() != 0) {
+ cageDetails.setLayer(0);
+ }
//鑾峰彇褰撳墠绗煎瓙绌烘牸淇℃伅
DownStorageCage empty = downStorageCageService.selectCacheEmpty(Integer.parseInt(currentSlot), Boolean.TRUE);
cageDetails.setSlot(empty.getSlot());
+ cageDetails.setDeviceId(empty.getDeviceId());
tempList.add(cageDetails);
}
log.info("鍑虹墖2锛氱鍐呯幓鐠冪殑鏁版嵁(鍖呮嫭寰呰繘鐗�)鏈夛細{}", tempList);
@@ -249,6 +356,7 @@
//2銆�08鍙扮┖闂诧紝鍏堣蛋鎵斿伐涓嬬墖鎴�2鍙锋満姊拌噦锛屾棤鐜荤拑鍑虹墖 鍦ㄨ蛋1鍙锋満姊拌噦
//鏈烘鑷傝绂佺敤鐨勬儏鍐典笅涓嶈兘缁х画鍚戠鐢ㄧ殑鏈烘鑷傛斁鐜荤拑
Boolean flag08 = "1".equals(out08Glassstate) ? Boolean.TRUE : Boolean.FALSE;
+ flag08 = true;
if (!flag08) {
generateTaskByShelf(glassStatus06, glassStatus11, flag08, glassStatus13, tempList, cageDetails, glassId);
} else {
@@ -301,14 +409,25 @@
List<Integer> workList = new ArrayList();
if (flag08) {
if (!"2".equals(glassStatus11)) {
- workList.addAll(Const.G11_WORK_STATION);
+ List<Integer> wroklistOne = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>()
+ .eq(DownWorkstation::getEnableState, Const.SLOT_ON).in(DownWorkstation::getWorkstationId, Const.G11_WORK_STATION))
+ .stream()
+ .map(DownWorkstation::getWorkstationId)
+ .collect(Collectors.toList());
+ workList.addAll(wroklistOne);
}
} else {
if (!"2".equals(glassStatus06)) {
- workList.addAll(Const.G06_WORK_STATION);
+ List<Integer> wroklistTwo = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>()
+ .eq(DownWorkstation::getEnableState, Const.SLOT_ON).in(DownWorkstation::getWorkstationId, Const.G06_WORK_STATION))
+ .stream()
+ .map(DownWorkstation::getWorkstationId)
+ .collect(Collectors.toList());
+ workList.addAll(wroklistTwo);
}
}
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:鏃�
@@ -330,17 +449,25 @@
} else {
//鑾峰彇鍙惤鏋剁殑鐨勬灦瀛愪俊鎭紙鍖呮嫭绌烘灦瀛愶級
//浠呰幏鍙栫┖鏋跺瓙淇℃伅
- List<DownWorkstation> workstationsIsNotBind = downWorkstationList.stream().filter(item -> null == (item.getFlowCardId())).collect(Collectors.toList());
+ 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 -> null != (item.getFlowCardId())).collect(Collectors.groupingBy(item -> item.getFlowCardId() + ":" + item.getLayer()));
+ .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());
+ if (CollectionUtils.isEmpty(list) && 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 {
- 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)));
@@ -349,7 +476,7 @@
list = tempList;
} else {
//绗煎唴瀛樺湪鏃犳硶鍑虹墖鐨勭幓鐠冧俊鎭紝杩囨护鏃犳硶鍑虹墖鐨勭幓鐠冧俊鎭紝浠呰幏鍙栧彲鍑虹墖鐨勭幓鐠冧俊鎭� 鏃犳硶鍑虹墖鐨勭幓鐠冧负锛氭湭缁戝畾鏋跺瓙銆佺粦瀹氭灦瀛愯绂佺敤銆侀潪鏈満姊拌噦瀵瑰簲鐨勬灦瀛�
- Map<String, List<DownWorkstation>> listOffMap = downWorkstationOffList.stream().filter(item -> null != (item.getFlowCardId())).collect(Collectors.groupingBy(item -> item.getFlowCardId() + ":" + item.getLayer()));
+ 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
@@ -370,6 +497,8 @@
log.info("绗煎唴鐜荤拑鏃犳硶鎵ц鍑虹墖");
return Boolean.FALSE;
}
+ //鑾峰彇鍏蜂綋鍑洪偅涓�鐗囩幓鐠�
+ //tao:浜哄伐--> 鎵�鏈夋灦瀛愰兘鏈粦瀹氭椂杩涜缁戝畾 --->鏈夋湭缁戝畾鏋跺瓙鏃惰繘琛岀粦瀹� --->缁戝畾杩囨祦绋嬪崱鐨勭幓鐠�-->鐜荤拑娴佺▼鍗″灞�--->鐜荤拑娴佺▼鍗″崟灞�
String tempGlassId = null;
Boolean isNeedBind = Boolean.FALSE;
@@ -387,16 +516,17 @@
loop:
if (StringUtils.isBlank(tempGlassId)) {
//鑾峰彇姝e湪钀芥灦鐨勭粦瀹氭祦绋嬪崱鐨勪俊鎭�(娴佺▼鍗°�佸眰鏁般�佽惤鏋舵暟閲�)
- List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Boolean.TRUE);
+ //钀芥灦鐜荤拑鏁颁负0锛屽嵆浣跨粦瀹氫簡娴佺▼鍗★紝涔熸棤娉曟壘鍒板搴旂殑鏋跺瓙淇℃伅锛屽彧鑳介噸鏂扮粦瀹�
+ List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationFlowCard(workList);
List<String> downGlassFlowList = downGlassInfoDTOList.stream().map(item -> item.getFlowCardId() + ":" + item.getLayer()).collect(Collectors.toList());
if (CollectionUtils.isEmpty(downGlassFlowList)) {
//鏋跺瓙閮芥湭缁戝畾娴佺▼鍗★紝鍑虹鍐呭瓙鏁伴噺鏈�澶氬昂瀵告渶澶х殑鐜荤拑id,鏃� 鍒欒繑鍥炴壂鎻忔壂鍒扮殑鐜荤拑id杩涜鍑虹墖
tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId, offWorkStationList);
-
isNeedBind = Boolean.TRUE;
break loop;
}
//灏嗙瀛愬唴鐨勭幓鐠冭繘琛岃繃婊わ紝浠呰幏鍙栨棤娉曡惤鏋剁殑娴佺▼鍗$幓鐠�
+ //tao:褰撴湁绌烘灦鏃朵紭鍏堝绗煎唴鍙嚭鐗囦笖鏈粦鏋跺瓙鐨勭幓鐠冭繘鍑虹粦鏋跺苟鍑虹墖
List<DownStorageCageDetails> noDownLoadList = list.stream().filter(item -> !downGlassFlowList.contains(item.getFlowCardId() + ":" + item.getLayer()))
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(noDownLoadList)) {
@@ -417,7 +547,7 @@
return Boolean.FALSE;
}
//灏嗙鍐呯幓鐠冪殑娴佺▼鍗�+灞傚彿 鍜岃惤鏋剁殑娴佺▼鍗� 鍘婚噸锛屽緱鍑哄睍绀烘棤娉曡惤鏋剁殑鐜荤拑锛屽垽鏂幓鐠冩暟鏄惁瓒呰繃闃堝��
- //绗煎唴鐜荤拑鏄惁鍙惤鏋�:绗煎唴鏄惁鏈夐渶瑕佷腑绌虹殑
+ //绗煎唴鐜荤拑鏄惁鍙惤鏋�:绗煎唴鏄惁鏈夐渶瑕佷腑绌�
List<DownStorageCageDetails> multiLayerList = list.stream().filter(item -> item.getTotalLayer() >= 2).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(multiLayerList)) {
for (DownStorageCageDetails item : multiLayerList) {
@@ -434,7 +564,7 @@
break loop;
}
Integer sequence = downGlassInfoService.queryMaxSequence(item.getFlowCardId(), item.getLayer());
- log.info("鑾峰彇褰撳墠鐜荤拑闇�瑕佹斁鐨勬搴忥細绗煎唴鍚屾祦绋� 鍚屽眰鏁扮殑閫氳揪娆″簭+1:{}", sequence);
+ 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));
@@ -456,6 +586,7 @@
if (CollectionUtils.isNotEmpty(downStorageCageDetails)) {
tempGlassId = downStorageCageDetails.get(0).getGlassId();
break;
+
}
}
}
@@ -498,22 +629,34 @@
if (isNeedBind) {
//鑾峰彇绌烘灦瀛愪俊鎭紝灏嗙┖鏋跺瓙淇℃伅缁戝畾娴佺▼鍗�
DownWorkstation emptyDownWorkstation = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>()
- .isNull(DownWorkstation::getFlowCardId).in(DownWorkstation::getWorkstationId, workList).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("鑾峰彇鍒扮┖鏋跺瓙淇℃伅锛岀粦瀹氭祦绋嬪崱");
downWorkstationService.updateFlowCardIdAndCount(downStorageCageDetails.getFlowCardId(), emptyDownWorkstation.getWorkstationId(), downStorageCageDetails.getLayer());
+// downWorkstationService.updateFlowCardIdAndCount(downStorageCageDetails.getFlowCardId(), emptyDownWorkstation.getId(), downStorageCageDetails.getLayer());
endCell = emptyDownWorkstation.getWorkstationId();
} else {
+ //todo:澧炲姞铏氭嫙宸ヤ綅,缁戝畾娴佺▼鍗�
+// downWorkstationService.insertDownWorkstation();
+// endCell = Const.G13_WORK_STATION;
+// downWorkstationService.updateFlowCardIdAndCount(downStorageCageDetails.getFlowCardId(), emptyDownWorkstation.getId(), downStorageCageDetails.getLayer());
log.info("娌℃湁绌烘灦瀛愪俊鎭紝鏃犳硶缁戝畾娴佺▼鍗�");
return Boolean.FALSE;
}
} else {
- DownWorkstation workstation = downWorkstationService.getOne(new LambdaUpdateWrapper<DownWorkstation>()
- .eq(DownWorkstation::getFlowCardId, downStorageCageDetails.getFlowCardId()).eq(DownWorkstation::getLayer, downStorageCageDetails.getLayer()));
- endCell = workstation.getWorkstationId();
+ double firstLength = Math.max(downStorageCageDetails.getWidth(), downStorageCageDetails.getHeight());
+ double secondLength = Math.min(downStorageCageDetails.getWidth(), downStorageCageDetails.getHeight());
+ if (firstLength > maxWidth || secondLength > maxHeight) {
+ endCell = Const.G13_WORK_STATION;
+ } else {
+ DownWorkstation workstation;
+ workstation = downWorkstationService.getOne(new LambdaUpdateWrapper<DownWorkstation>()
+ .eq(DownWorkstation::getFlowCardId, downStorageCageDetails.getFlowCardId()).eq(DownWorkstation::getLayer, downStorageCageDetails.getLayer()));
+ endCell = workstation.getWorkstationId();
+ }
}
//鏇存柊钀芥灦鐜荤拑鏁伴噺
- if (endCell == 7) {
+ if (endCell == Const.G13_WORK_STATION) {
downWorkstationService.update(new UpdateWrapper<DownWorkstation>().eq("flow_card_id", downStorageCageDetails.getFlowCardId())
.eq("layer", downStorageCageDetails.getLayer()).setSql("other_number = other_number +1"));
} else {
@@ -525,11 +668,31 @@
DownGlassInfo downGlassInfo = new DownGlassInfo();
BeanUtils.copyProperties(downStorageCageDetails, downGlassInfo);
//钀芥灦鐗囧簭
- downGlassInfo.setSequence(downGlassInfoService.queryMaxSequence(downGlassInfo.getFlowCardId(), downGlassInfo.getLayer()));
+ LambdaQueryWrapper<DownGlassInfo> wrapper = new LambdaQueryWrapper<DownGlassInfo>();
+ wrapper.eq(DownGlassInfo::getFlowCardId, downGlassInfo.getFlowCardId())
+ .orderByDesc(DownGlassInfo::getSequence)
+ .last("limit 1");
+ if (downStorageCageDetails.getLayer() != 0) {
+ wrapper.eq(DownGlassInfo::getLayer, downGlassInfo.getLayer());
+ }
+// downGlassInfo.setSequence(downGlassInfoService.queryMaxSequence(downGlassInfo.getFlowCardId(), downGlassInfo.getLayer()));
+ int k = 0;
+ DownGlassInfo downGlassInfo1 = downGlassInfoService.getOne(wrapper);
+ if (downGlassInfo1 != null) {
+ k = 1;
+ } else {
+ k = 1;
+ }
+ downGlassInfo.setSequence(k);
+ downGlassInfo.setWorkStationId(endCell);
+ downGlassInfo.setGmtCreate(new Date());
downGlassInfoService.save(downGlassInfo);
//鐢熸垚浠诲姟淇℃伅
GlassInfo glassInfo = new GlassInfo();
+ downStorageCageDetails.setLayer(0);
BeanUtils.copyProperties(downStorageCageDetails, glassInfo);
+ //鍒犻櫎鐞嗙墖绗艰〃鎷胯蛋/鐮存崯鏁版嵁鏁版嵁
+ damageService.deleteByGlassId(glassInfo.getGlassId());
return initDownGlassTask(glassInfo, downStorageCageDetails.getSlot(), endCell, taskType);
}
@@ -547,6 +710,14 @@
downGlassTask.setTaskStatus(0);
downGlassTask.setCreateTime(new Date());
downGlassTaskService.save(downGlassTask);
+ //娣诲姞鎶ュ伐鏁版嵁
+ Damage damage = new Damage();
+ damage.setGlassId(glassInfo.getGlassId());
+ damage.setWorkingProcedure("閽㈠寲");
+ damage.setLine(4001);
+ damage.setType(1);
+ damage.setRemark("閽㈠寲鍚庡崸寮忕悊鐗�");
+ damageService.insertDamage(damage);
//鍚憄lc鍙戦�佸懡浠�
return sendMessageToPlc((int) glassInfo.getWidth(), (int) glassInfo.getHeight(), (int) glassInfo.getThickness(),
startCell, endCell, taskType);
--
Gitblit v1.8.0