From cbf12607ca1179d98f76d9b3a475d6224e85d59a Mon Sep 17 00:00:00 2001
From: wangfei <3597712270@qq.com>
Date: 星期四, 30 十月 2025 09:03:49 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10105/r/YiWuProject
---
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java | 257 ++++++++++++++++++++++++++++++---------------------
1 files changed, 151 insertions(+), 106 deletions(-)
diff --git a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java
index 14d0ff2..3b1bf13 100644
--- a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java
+++ b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java
@@ -7,13 +7,17 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mes.common.config.Const;
+import com.mes.common.config.ConstSysConfig;
import com.mes.glassinfo.entity.GlassInfo;
import com.mes.glassinfo.service.GlassInfoService;
import com.mes.hollow.controller.HollowBigStorageCageController;
import com.mes.hollow.entity.HollowBigStorageCageDetails;
import com.mes.hollow.entity.HollowFormulaDetails;
import com.mes.hollow.entity.HollowGlassOutRelationInfo;
-import com.mes.hollow.entity.dto.*;
+import com.mes.hollow.entity.dto.LisecHollowDetails;
+import com.mes.hollow.entity.dto.LisecHollowFrameDetails;
+import com.mes.hollow.entity.dto.LisecHollowGlassAndFrameDetails;
+import com.mes.hollow.entity.dto.LisecHollowGlassDetails;
import com.mes.hollow.entity.request.HollowHistoryTaskRequest;
import com.mes.hollow.entity.request.HollowTaskRequest;
import com.mes.hollow.mapper.HollowGlassOutRelationInfoMapper;
@@ -24,6 +28,10 @@
import com.mes.hollowqueue.entity.HollowGlassQueueInfo;
import com.mes.hollowqueue.service.HollowGlassQueueInfoService;
import com.mes.largenscreen.entity.PieChartVO;
+import com.mes.order.entity.HollowOrderDTO;
+import com.mes.order.entity.OrderDetailsDTO;
+import com.mes.order.service.OrdersService;
+import com.mes.sysconfig.service.SysConfigService;
import com.mes.tools.DateUtil;
import com.mes.utils.Blank;
import com.mes.utils.RedisUtil;
@@ -33,8 +41,9 @@
import freemarker.template.Version;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.*;
@@ -62,24 +71,30 @@
HollowFormulaDetailsService hollowFormulaDetailsService;
@Resource
HollowGlassRelationInfoService hollowGlassRelationInfoService;
+ @Resource
+ SysConfigService sysConfigService;
+ @Resource
+ OrdersService ordersService;
@Resource
RedisUtil redisUtil;
- @Value("${mes.glassGap}")
- private Integer glassGap;
-
- @Value("${mes.carWidth}")
- private Integer carWidth;
+// @Value("${mes.glassGap}")
+// private Integer glassGap;
+//
+// @Value("${mes.carWidth}")
+// private Integer carWidth;
private static final int ID_RATIO = 10;
@Override
+// @Transactional
public HollowGlassOutRelationInfo receiveTask(HollowTaskRequest request) {
return childrenTask(request, 0);
}
@Override
+// @Transactional
public HollowGlassOutRelationInfo forceOutGlass(HollowTaskRequest request) {
return childrenTask(request, 1);
}
@@ -88,6 +103,12 @@
public Boolean dispatchHollowSwitch(Boolean flag) {
redisUtil.setCacheObject("dispatchHollowSwitch", flag);
return redisUtil.getCacheObject("dispatchHollowSwitch");
+ }
+
+ @Override
+ public Boolean priorityHollowSwitch(Boolean flag) {
+ redisUtil.setCacheObject("priorityHollowSwitch", flag);
+ return redisUtil.getCacheObject("priorityHollowSwitch");
}
@Override
@@ -103,44 +124,44 @@
}
@Override
- public List<HollowGlassQueueInfo> appointHollowTaskDetails(String flowCardId, int cell) {
+ public Map<String, List<HollowGlassQueueInfo>> appointHollowTaskDetails(int cell) {
//鎸夌収娴佺▼鍗″強璺嚎锛屾煡鎵惧搴旂殑浠诲姟淇℃伅
- HollowGlassOutRelationInfo hollowGlassOutRelationInfo = this.getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
+ List<HollowGlassOutRelationInfo> hollowGlassOutRelationInfos = this.list(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
.in(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_NEW, Const.HOLLOW_FLOW_CARD_START, Const.HOLLOW_FLOW_CARD_PAUSE)
- .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId)
- .eq(HollowGlassOutRelationInfo::getCell, cell).last("limit 1"));
- if (null == hollowGlassOutRelationInfo) {
- return new ArrayList<HollowGlassQueueInfo>();
+ .eq(HollowGlassOutRelationInfo::getCell, cell));
+ if (CollectionUtil.isEmpty(hollowGlassOutRelationInfos)) {
+ return null;
}
+ List<Long> ids = hollowGlassOutRelationInfos.stream()
+ .map(HollowGlassOutRelationInfo::getId) // 鎻愬彇姣忎釜鍏冪礌鐨刬d
+ .collect(Collectors.toList());
//鎸夌収浠诲姟id鏌ヨ瀵瑰垪琛ㄤ腑鐨勯槦鍒椾俊鎭�
- return hollowGlassQueueInfoService.list(new LambdaQueryWrapper<HollowGlassQueueInfo>()
- .eq(HollowGlassQueueInfo::getRelationId, hollowGlassOutRelationInfo.getId()));
+ List<HollowGlassQueueInfo> hollowGlassQueueInfos = hollowGlassQueueInfoService.list(new LambdaQueryWrapper<HollowGlassQueueInfo>()
+ .in(HollowGlassQueueInfo::getRelationId, ids)
+ .orderByAsc(HollowGlassQueueInfo::getId));
+ Map<String, List<HollowGlassQueueInfo>> groupedByFlowCardId = hollowGlassQueueInfos.stream()
+ .collect(Collectors.groupingBy(
+ HollowGlassQueueInfo::getFlowCardId,
+ LinkedHashMap::new,
+ Collectors.toList()
+ ));
+ return groupedByFlowCardId;
}
@Override
- public Boolean startTask(String flowCardId, int cell) {
- log.info("鏌ョ湅璇ユ祦绋嬪崱鏄惁鐢辨鍦ㄦ墽琛岀殑浠诲姟锛屾祦绋嬪崱锛歿}", flowCardId);
- int taskCount = this.count(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
- .in(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_NEW, Const.HOLLOW_FLOW_CARD_START, Const.HOLLOW_FLOW_CARD_PAUSE)
- .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId));
- if (taskCount == 0 || taskCount > 1) {
- log.info("璇ユ祦绋嬪崱涓嶅瓨鍦ㄤ换鍔℃垨鑰呮湁姝e湪鎵ц涓紝鏃犳硶鍐嶆鎵ц");
- return Boolean.FALSE;
- }
+ public Boolean startTask(int cell) {
//鏇存柊浠诲姟鐘舵�佷负寮�濮�
return this.update(new LambdaUpdateWrapper<HollowGlassOutRelationInfo>()
.set(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
- .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId)
.ne(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_SUCCESS)
.eq(HollowGlassOutRelationInfo::getCell, cell));
}
@Override
- public Boolean pauseTask(String flowCardId, int cell) {
+ public Boolean pauseTask(int cell) {
// 鏇存柊浠诲姟鐘舵�佷负鏆傚仠
return this.update(new LambdaUpdateWrapper<HollowGlassOutRelationInfo>()
.set(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_PAUSE)
- .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId)
.ne(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_SUCCESS)
.eq(HollowGlassOutRelationInfo::getCell, cell));
}
@@ -182,15 +203,17 @@
if (CollectionUtil.isEmpty(outRelationList) || outRelationList.size() != 1) {
return "鏈潯绾夸笉瀛樺湪璇ユ祦绋嬩换鍔℃垨鑰呭悓娴佺▼鍗′换鍔℃暟澶т簬1";
}
+ log.info("鏉庤禌鍏嬫祦绋嬪崱锛歿}", flowCardId);
HollowGlassOutRelationInfo relationInfo = outRelationList.get(0);
if (relationInfo.getTotalLayer() < 2) {
return "浠诲姟鎬诲眰鏁板皬浜�2锛屼笉鐢熸垚鏉庤禌鍏嬫枃浠�";
}
//鑾峰彇璁㈠崟鐩稿叧淇℃伅
- OrderDTO order = baseMapper.queryOrderByFlowCardId(flowCardId);
+ HollowOrderDTO order = ordersService.queryOrderByFlowCardId(flowCardId);
if (null == order) {
return "鐢熸垚澶辫触锛岀浉鍏宠鍗曚俊鎭笉瀛樺湪";
}
+ log.info("鏉庤禌鍏嬬浉鍏宠鍗曚俊鎭瘂}", order);
//鑾峰彇閰嶆柟鐩稿叧淇℃伅
HollowFormulaDetails formulaDetails = hollowFormulaDetailsService.getById(relationInfo.getFormulaId());
if (null == formulaDetails) {
@@ -201,6 +224,8 @@
if (layerCount != relationInfo.getTotalLayer() && isForce == 0) {
return "鐢熸垚澶辫触锛岃娴佺▼鍗″唴灞傛暟涓庤繘绗煎叧绯昏〃鍐呭眰鏁版暟閲忎笉鐩稿悓";
}
+
+ log.info("鏉庤禌鍏嬫�诲眰鏁皗}", layerCount);
//璁剧疆鏂囦欢鐨勪富浣撳唴瀹�
LisecHollowDetails details = new LisecHollowDetails();
String randomNumber = "" + (int) (Math.random() * 100000 + 100000);
@@ -290,6 +315,7 @@
// 鍒涘缓Calculator瀹炰緥
Blank blank = new Blank();
+ log.info("鏉庤禌鍏嬪熀纭�鏁版嵁宸茬敓鎴愶細{}", details);
// 鍒涘缓鏁版嵁妯″瀷
Map<String, Object> root = new HashMap<>();
root.put("blank", blank);
@@ -309,6 +335,8 @@
writer.write(out.toString());
} catch (TemplateException | IOException e) {
e.printStackTrace();
+
+ log.info("鏉庤禌鍏嬬敓鎴愬紓甯革細{}", e.getMessage());
}
return "success";
}
@@ -330,90 +358,107 @@
return this.page(page, wrapper);
}
+ @Override
+ @Cacheable(value = "orderDetails", key = "#flowCardId")
+ public OrderDetailsDTO queryProductNameByFlowCardId(String flowCardId) {
+ log.info("鏌ヨ鏁版嵁搴撲竴娆★細{}", flowCardId);
+ return ordersService.queryProductNameByFlowCardId(flowCardId);
+ }
private HollowGlassOutRelationInfo childrenTask(HollowTaskRequest request, int isForce) {
- GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getFlowCardId, request.getFlowCardId()).last("limit 1"));
- HollowGlassOutRelationInfo info = new HollowGlassOutRelationInfo();
- if (null == glassInfo) {
- log.info("璇ユ祦绋嬪崱淇℃伅绯荤粺鏈壘鍒�");
- return info;
- }
- List<HollowGlassOutRelationInfo> outRelationInfos = this.list(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
- .eq(HollowGlassOutRelationInfo::getFlowCardId, request.getFlowCardId())
- .in(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_NEW, Const.HOLLOW_FLOW_CARD_START, Const.HOLLOW_FLOW_CARD_PAUSE));
- if (CollectionUtil.isNotEmpty(outRelationInfos)) {
- log.info("褰撳墠娴佺▼鍗℃湁鏈畬鎴愮殑浠诲姟");
- return null;
- }
- //淇濆瓨浠诲姟鍏崇郴涓昏〃
- info.setFlowCardId(request.getFlowCardId());
- info.setCell(request.getCell());
- info.setIsForce(isForce);
- info.setTotalLayer(glassInfo.getTotalLayer());
- info.setState(Const.HOLLOW_FLOW_CARD_NEW);
- info.setTotalPairQuantity(request.getTotalPairQuantity());
- info.setFormulaId(request.getFormulaId());
- this.save(info);
- // 鏌ヨ鍑洪渶瑕佸嚭鐜荤拑鐨勯槦鍒�
- List<HollowBigStorageCageDetails> hollowBigStorageCageDetailsList = hollowBigStorageCageDetailsService
- .queryOutGlassList(request.getFlowCardId(), request.getCell());
- int isPairCount = glassInfo.getTotalLayer() * request.getTotalPairQuantity();
- List<HollowGlassQueueInfo> hollowQueues = new ArrayList<>();
- if (930 == request.getCell()) {
- Map<Integer, List<HollowBigStorageCageDetails>> listMap = hollowBigStorageCageDetailsList.stream()
- .collect(Collectors.groupingBy(HollowBigStorageCageDetails::getHollowSequence));
- Map<Integer, List<HollowBigStorageCageDetails>> sortListMap = new TreeMap<>();
- sortListMap.putAll(listMap);
- for (Map.Entry<Integer, List<HollowBigStorageCageDetails>> entry : sortListMap.entrySet()) {
- //鍒涘缓闃熷垪鎺ユ敹涓嶆弧瓒虫垚瀵规儏鍐典笅锛氫竴瀵圭幓鐠冨垎鍑犳涓婅溅鐨勬搴忛棶棰�
- List<HollowGlassQueueInfo> tempList = new ArrayList<>();
- //鍏堝皢鐜荤拑鎸夌収姝e父椤哄簭鎺掑垪锛岃绠椾竴杞︽渶澶氭斁鍑犲潡锛岀畻濂藉潡鏁颁箣鍚庡皢涓�杞︾殑鐜荤拑鎸夌収鍊掑簭瀛樺偍
- List<HollowBigStorageCageDetails> reverse = CollectionUtil.reverse(entry.getValue());
- int remainWidth = carWidth;
- for (HollowBigStorageCageDetails item : reverse) {
- remainWidth = remainWidth - (int) Math.max(item.getWidth(), item.getHeight());
- if (remainWidth < 0) {
- hollowQueues.addAll(CollectionUtil.reverse(tempList));
- tempList = new ArrayList<>();
- remainWidth = carWidth - (int) Math.max(item.getWidth(), item.getHeight());
- }
- HollowGlassQueueInfo queueInfo = HollowBDetailToQueue(item, info.getId(), request.getCell());
- tempList.add(queueInfo);
- remainWidth = remainWidth - glassGap;
- }
- hollowQueues.addAll(CollectionUtil.reverse(tempList));
- HollowBigStorageCageDetails cageDetails = entry.getValue().get(0);
- if (cageDetails.getIsPair() == 1) {
- isPairCount = isPairCount - cageDetails.getTotalLayer();
- if (isPairCount == 0) {
- break;
- }
- }
- }
-
- } else {
- loop:
- for (HollowBigStorageCageDetails item : hollowBigStorageCageDetailsList) {
- HollowGlassQueueInfo queueInfo = HollowBDetailToQueue(item, info.getId(), request.getCell());
- hollowQueues.add(queueInfo);
- if (item.getIsPair() == 1) {
- isPairCount = isPairCount - 1;
- if (isPairCount == 0) {
- break loop;
- }
- }
- }
- }
- hollowGlassQueueInfoService.saveBatch(hollowQueues);
try {
- if (request.getCell() == 930) {
- generateHollowLisecFile(request.getFlowCardId(), 930, isForce, 0);
+
+ GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getFlowCardId, request.getFlowCardId()).last("limit 1"));
+ HollowGlassOutRelationInfo info = new HollowGlassOutRelationInfo();
+ if (null == glassInfo) {
+ log.info("璇ユ祦绋嬪崱淇℃伅绯荤粺鏈壘鍒�");
+ return info;
}
+ log.error("鍒涘缓浠诲姟鏃惰幏鍙栫幓鐠冧俊鎭細{}", info);
+ List<HollowGlassOutRelationInfo> outRelationInfos = this.list(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
+ .eq(HollowGlassOutRelationInfo::getFlowCardId, request.getFlowCardId())
+ .in(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_NEW, Const.HOLLOW_FLOW_CARD_START, Const.HOLLOW_FLOW_CARD_PAUSE));
+ if (CollectionUtil.isNotEmpty(outRelationInfos)) {
+ log.info("褰撳墠娴佺▼鍗℃湁鏈畬鎴愮殑浠诲姟");
+ return null;
+ }
+ //淇濆瓨浠诲姟鍏崇郴涓昏〃
+ info.setFlowCardId(request.getFlowCardId());
+ info.setCell(request.getCell());
+ info.setIsForce(isForce);
+ info.setTotalLayer(glassInfo.getTotalLayer());
+ info.setState(Const.HOLLOW_FLOW_CARD_NEW);
+ info.setTotalPairQuantity(request.getTotalPairQuantity());
+ info.setFormulaId(request.getFormulaId());
+ this.save(info);
+ // 鏌ヨ鍑洪渶瑕佸嚭鐜荤拑鐨勯槦鍒�
+ List<HollowBigStorageCageDetails> hollowBigStorageCageDetailsList = hollowBigStorageCageDetailsService
+ .queryOutGlassList(request.getFlowCardId(), request.getCell());
+ int isPairCount = glassInfo.getTotalLayer() * request.getTotalPairQuantity();
+ List<HollowGlassQueueInfo> hollowQueues = new ArrayList<>();
+ Integer carWidth = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_CAR_WIDTH);
+ Integer glassGap = hollowGlassRelationInfoService.getGlassGapByThickness(hollowBigStorageCageDetailsList.get(0).getThickness());
+ if (930 == request.getCell()) {
+ Map<Integer, List<HollowBigStorageCageDetails>> listMap = hollowBigStorageCageDetailsList.stream()
+ .collect(Collectors.groupingBy(HollowBigStorageCageDetails::getHollowSequence));
+ Map<Integer, List<HollowBigStorageCageDetails>> sortListMap = new TreeMap<>();
+ sortListMap.putAll(listMap);
+ for (Map.Entry<Integer, List<HollowBigStorageCageDetails>> entry : sortListMap.entrySet()) {
+ //鍒涘缓闃熷垪鎺ユ敹涓嶆弧瓒虫垚瀵规儏鍐典笅锛氫竴瀵圭幓鐠冨垎鍑犳涓婅溅鐨勬搴忛棶棰�
+ List<HollowGlassQueueInfo> tempList = new ArrayList<>();
+ //鍏堝皢鐜荤拑鎸夌収姝e父椤哄簭鎺掑垪锛岃绠椾竴杞︽渶澶氭斁鍑犲潡锛岀畻濂藉潡鏁颁箣鍚庡皢涓�杞︾殑鐜荤拑鎸夌収鍊掑簭瀛樺偍
+ List<HollowBigStorageCageDetails> reverse = CollectionUtil.reverse(entry.getValue());
+ int remainWidth = carWidth;
+ for (HollowBigStorageCageDetails item : reverse) {
+ remainWidth = remainWidth - (int) Math.max(item.getWidth(), item.getHeight());
+ if (remainWidth < 0) {
+ hollowQueues.addAll(CollectionUtil.reverse(tempList));
+ tempList = new ArrayList<>();
+ remainWidth = carWidth - (int) Math.max(item.getWidth(), item.getHeight());
+ }
+ HollowGlassQueueInfo queueInfo = HollowBDetailToQueue(item, info.getId(), request.getCell());
+ tempList.add(queueInfo);
+ remainWidth = remainWidth - glassGap;
+ }
+ hollowQueues.addAll(CollectionUtil.reverse(tempList));
+ HollowBigStorageCageDetails cageDetails = entry.getValue().get(0);
+ if (cageDetails.getIsPair() == 1) {
+ isPairCount = isPairCount - cageDetails.getTotalLayer();
+ if (isPairCount == 0) {
+ break;
+ }
+ }
+ }
+
+ } else {
+ loop:
+ for (HollowBigStorageCageDetails item : hollowBigStorageCageDetailsList) {
+ HollowGlassQueueInfo queueInfo = HollowBDetailToQueue(item, info.getId(), request.getCell());
+ hollowQueues.add(queueInfo);
+ if (item.getIsPair() == 1) {
+ isPairCount = isPairCount - 1;
+ if (isPairCount == 0) {
+ break loop;
+ }
+ }
+ }
+ }
+ hollowGlassQueueInfoService.saveBatch(hollowQueues);
+ try {
+ log.info("鏉庤禌鍏嬬敓鎴愭枃浠讹細{}", request);
+ if (request.getCell() == 930) {
+ generateHollowLisecFile(request.getFlowCardId(), 930, isForce, 0);
+ }
+ } catch (Exception e) {
+ log.info("鐢熸垚鏉庤禌鍏嬫枃浠舵椂鍙戠敓寮傚父锛屾祦绋嬪崱鍙蜂负{}", request.getFlowCardId());
+ }
+ return info;
+
} catch (Exception e) {
- log.info("鐢熸垚鏉庤禌鍏嬫枃浠舵椂鍙戠敓寮傚父锛屾祦绋嬪崱鍙蜂负{}", request.getFlowCardId());
+ log.error("鍒涘缓浠诲姟鏃跺彂鐢熷紓甯革細{}", e.getMessage());
+ throw new RuntimeException(e);
}
- return info;
}
private HollowGlassQueueInfo HollowBDetailToQueue(HollowBigStorageCageDetails details, Long taskId, int targetCell) {
@@ -428,7 +473,7 @@
}
@Override
- public List<PieChartVO> queryPieChart(){
+ public List<PieChartVO> queryPieChart() {
return baseMapper.queryPieChart();
}
}
--
Gitblit v1.8.0