From 164cb74e2c471321caf9c4870de846cf08ca5f6c Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期一, 23 十二月 2024 15:36:08 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/HangZhouMes
---
hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/impl/BigStorageCageDetailsServiceImpl.java | 102 ++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 93 insertions(+), 9 deletions(-)
diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/impl/BigStorageCageDetailsServiceImpl.java b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/impl/BigStorageCageDetailsServiceImpl.java
index f223c3c..bccf36a 100644
--- a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/impl/BigStorageCageDetailsServiceImpl.java
+++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/impl/BigStorageCageDetailsServiceImpl.java
@@ -2,11 +2,12 @@
import cn.hutool.core.lang.Assert;
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.toolkit.CollectionUtils;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.mes.base.entity.BigStorageCageBaseInfo;
import com.mes.bigstorage.entity.BigStorageCage;
import com.mes.bigstorage.entity.BigStorageCageDetails;
import com.mes.bigstorage.entity.BigStorageDTO;
@@ -20,8 +21,8 @@
import com.mes.bigstoragetask.entity.UpdateBigStorageCageDTO;
import com.mes.bigstoragetask.mapper.BigStorageCageFeedTaskMapper;
import com.mes.bigstoragetask.mapper.BigStorageCageOutTaskMapper;
+import com.mes.bigstoragetask.service.BigStorageCageOutTaskService;
import com.mes.common.config.Const;
-import com.mes.common.utils.RedisUtil;
import com.mes.damage.entity.Damage;
import com.mes.damage.service.DamageService;
import com.mes.glassinfo.entity.GlassInfo;
@@ -31,6 +32,7 @@
import com.mes.temperingglass.entity.TemperingGlassInfo;
import com.mes.temperingglass.mapper.TemperingGlassInfoMapper;
import com.mes.temperingglass.service.TemperingGlassInfoService;
+import com.mes.utils.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
@@ -76,6 +78,10 @@
private DamageService damageService;
@Resource
private RedisUtil redisUtil;
+ @Resource
+ private BigStorageCageOutTaskService bigStorageCageOutTaskService;
+ @Resource
+ private BigStorageCageDetailsService bigStorageCageDetailsService;
@Value("${mes.minCount}")
private int minCount;
@@ -266,6 +272,13 @@
@Override
public BigStorageDTO queryTargetSlotByTempering(GlassInfo glassInfo) {
+ List<GlassInfo> glassInfoList = glassInfoService.list(
+ new LambdaQueryWrapper<GlassInfo>()
+ .eq(GlassInfo::getEngineerId, glassInfo.getEngineerId())
+ .eq(GlassInfo::getTemperingLayoutId, glassInfo.getTemperingLayoutId())
+ .eq(GlassInfo::getTargetSlot, glassInfo.getTargetSlot())
+ );
+ List<String> glassIds = glassInfoList.stream().map(GlassInfo::getGlassId).collect(Collectors.toList());
BigStorageDTO bigStorageDTO = null;
MPJLambdaWrapper<BigStorageCage> wrapper = new MPJLambdaWrapper<>(BigStorageCage.class)
.selectAll(BigStorageCage.class)
@@ -275,13 +288,14 @@
.eq(BigStorageCageDetails::getEngineerId, glassInfo.getEngineerId())
.eq(BigStorageCageDetails::getTemperingLayoutId, glassInfo.getTemperingLayoutId())
.gt(BigStorageCage::getRemainWidth, Math.max(glassInfo.getWidth(), glassInfo.getHeight()))
+ .in(BigStorageCageDetails::getGlassId, glassIds)
.last("limit 1");
if (glassInfo.getTemperingLayoutId() == 0) {
wrapper.eq(BigStorageCageDetails::getFlowCardId, glassInfo.getFlowCardId())
.eq(BigStorageCageDetails::getLayer, glassInfo.getLayer());
// wrapper.eq(BigStorageCageDetails::getWidth, glassInfo.getWidth()).eq(BigStorageCageDetails::getHeight, glassInfo.getHeight());
} else {
- wrapper.eq(BigStorageCageDetails::getTemperingFeedSequence, glassInfo.getTemperingFeedSequence() + 1);
+ wrapper.eq(BigStorageCageDetails::getTemperingFeedSequence, glassInfo.getTemperingFeedSequence() - 1);
}
BigStorageCage bigStorageCage = bigStorageCageService.selectJoinOne(BigStorageCage.class, wrapper);
if (null != bigStorageCage) {
@@ -325,15 +339,30 @@
.groupBy(BigStorageCageDetails::getEngineerId)
.between(BigStorageCageDetails::getDeviceId, 6, 8)
);
- if (glassInfo.getThickness() == 8) {
- deviceUsedList.removeIf(device -> device < 6);
- } else {
- if (engineerCount1.size() > engineerCount2.size()) {
+ BigStorageCageDetails bigStorageCageDetails = baseMapper.selectOne(
+ new LambdaQueryWrapper<BigStorageCageDetails>()
+ .eq(BigStorageCageDetails::getEngineerId, glassInfo.getEngineerId())
+ .orderByAsc(BigStorageCageDetails::getSlot)
+ .last("limit 1")
+ );
+ if (bigStorageCageDetails == null) {
+ if (glassInfo.getThickness() == 8) {
deviceUsedList.removeIf(device -> device < 6);
} else {
+ if (engineerCount1.size() > engineerCount2.size()) {
+ deviceUsedList.removeIf(device -> device < 6);
+ } else {
+ deviceUsedList.removeIf(device -> device > 5);
+ }
+ }
+ } else {
+ if (bigStorageCageDetails.getDeviceId() >= 1 && bigStorageCageDetails.getDeviceId() <= 5) {
deviceUsedList.removeIf(device -> device > 5);
+ } else {
+ deviceUsedList.removeIf(device -> device < 6);
}
}
+
if (CollectionUtils.isEmpty(deviceUsedList)) {
deviceUsedList = deviceUseds;
}
@@ -396,7 +425,6 @@
temperingGlassInfoLambdaQueryWrapper
.eq(TemperingGlassInfo::getState, Const.TEMPERING_NEW);
List<TemperingGlassInfo> temperingGlassInfoList = temperingGlassInfoMapper.selectList(temperingGlassInfoLambdaQueryWrapper);
-
if (temperingGlassInfoList.size() == 0) {
List<TemperingGlassInfo> temperingGlassInfos = glassInfoService.selectJoinList(TemperingGlassInfo.class, JoinWrappers.lambda(GlassInfo.class)
.selectAll(GlassInfo.class)
@@ -410,7 +438,7 @@
if (CollectionUtils.isNotEmpty(temperingGlassInfos)) {
if ("0".equals(temperingFeedSequence)) {
if (CollectionUtils.isNotEmpty(temperingGlassInfos)) {
- plcStorageCageTask.computeOutMoreGlassInfo(temperingGlassInfos, Boolean.FALSE, "");
+ plcStorageCageTask.computeOutMoreGlassInfo(temperingGlassInfos, Boolean.FALSE, 1);
}
} else {
temperingGlassInfoService.saveBatch(temperingGlassInfos);
@@ -443,4 +471,60 @@
public void appointEngineerId(String engineerId) {
redisUtil.setCacheObject("temperingengineerId", engineerId);
}
+
+ @Override
+ public long scheduleTime() {
+ //鎵ц鍐呴儴璋冨害浠诲姟
+ List<TemperingLayoutDTO> temperingOccupySlotList = bigStorageCageDetailsService.queryTemperingOccupySlot();
+ List<BigStorageCageOutTask> bigStorageCageOutTasks = new ArrayList<>();
+ if (CollectionUtils.isNotEmpty(temperingOccupySlotList)) {
+ for (TemperingLayoutDTO temperingOccupySlot : temperingOccupySlotList) {
+ List<GlassInfo> glassInfos = glassInfoService.list(
+ new LambdaQueryWrapper<GlassInfo>()
+ .eq(GlassInfo::getEngineerId, temperingOccupySlot.getEngineerId())
+ .eq(GlassInfo::getTemperingLayoutId, temperingOccupySlot.getTemperingLayoutId())
+ .notInSql(GlassInfo::getGlassId, "select glass_id from damage where type=8 and engineer_id='"
+ + temperingOccupySlot.getEngineerId() + "' and tempering_layout_id = '" + temperingOccupySlot.getTemperingLayoutId() + "'")
+ .orderBy(Boolean.TRUE, sequenceOrder, GlassInfo::getTemperingFeedSequence)
+ );
+ Map<Integer, List<GlassInfo>> listMap = glassInfos.stream().collect(Collectors.groupingBy(item -> item.getTargetSlot()));
+ for (Map.Entry<Integer, List<GlassInfo>> entry : listMap.entrySet()) {
+ List<GlassInfo> valueList = entry.getValue();
+ List<String> glassIds = valueList.stream().map(GlassInfo::getGlassId).collect(Collectors.toList());
+ List<BigStorageCageDetails> bigStorageCageDetailsList = bigStorageCageDetailsService.list(
+ new LambdaQueryWrapper<BigStorageCageDetails>()
+ .in(BigStorageCageDetails::getGlassId, glassIds)
+ .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN)
+ .orderBy(Boolean.TRUE, sequenceOrder, BigStorageCageDetails::getTemperingFeedSequence)
+ );
+ //褰撲竴鏍肩幓鐠冮兘鍒伴綈鏃�
+ if (bigStorageCageDetailsList.size() == valueList.size()) {
+ long distinctSlotCount = bigStorageCageDetailsList.stream()
+ .map(BigStorageCageDetails::getSlot)
+ .distinct()
+ .count();
+ //褰撶幓鐠冧笉鍦ㄥ悓涓�鏍兼椂
+ if (distinctSlotCount > 1) {
+ BigStorageCageDetails maxSequenceDetail = bigStorageCageDetailsList.stream()
+ .max(Comparator.comparingInt(BigStorageCageDetails::getTemperingFeedSequence))
+ .orElse(null); // 濡傛灉娌℃湁鍏冪礌锛岃繑鍥� null
+ int maxSlot = maxSequenceDetail.getSlot();
+ int serialNumber = 1;
+ for (BigStorageCageDetails bigStorageCageDetails : bigStorageCageDetailsList
+ ) {
+ if (bigStorageCageDetails.getSlot() != maxSlot) {
+ bigStorageCageOutTasks.add(new BigStorageCageOutTask(bigStorageCageDetails.getGlassId(), bigStorageCageDetails.getSlot(), maxSlot,
+ bigStorageCageDetails.getWidth() * 10, bigStorageCageDetails.getHeight() * 10, 1, serialNumber++, Const.BIG_STORAGE_OUT_NEW, new Date()));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ long startSlotCount = bigStorageCageOutTasks.stream().map(BigStorageCageOutTask::getStartSlot).distinct().count();
+ long endSlotCount = bigStorageCageOutTasks.stream().map(BigStorageCageOutTask::getEndSlot).distinct().count();
+ long time = (startSlotCount * 10 + endSlotCount * 20) / 60;
+ return time;
+ }
}
--
Gitblit v1.8.0