From 2e20e85173b764e43a6e4022072bc8fb0cc61330 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期一, 30 十二月 2024 19:45:35 +0800
Subject: [PATCH] 1、李赛克生成trf文件模板初始化

---
 hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java |  128 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 110 insertions(+), 18 deletions(-)

diff --git a/hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java b/hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java
index f695563..17e9a24 100644
--- a/hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java
+++ b/hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassOutRelationInfoServiceImpl.java
@@ -1,12 +1,15 @@
 package com.mes.hollow.service.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.mes.common.config.Const;
 import com.mes.glassinfo.entity.GlassInfo;
 import com.mes.glassinfo.service.GlassInfoService;
 import com.mes.hollow.entity.HollowBigStorageCageDetails;
 import com.mes.hollow.entity.HollowGlassOutRelationInfo;
+import com.mes.hollow.entity.request.HollowTaskRequest;
 import com.mes.hollow.mapper.HollowGlassOutRelationInfoMapper;
 import com.mes.hollow.service.HollowBigStorageCageDetailsService;
 import com.mes.hollow.service.HollowGlassOutRelationInfoService;
@@ -19,6 +22,7 @@
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -43,54 +47,142 @@
     RedisUtil redisUtil;
 
     @Override
-    public HollowGlassOutRelationInfo receiveTask(String flowCardId, int cell, int totalPairQuantity) {
-        return childrenTask(flowCardId,cell,totalPairQuantity,0);
+    public HollowGlassOutRelationInfo receiveTask(HollowTaskRequest request) {
+        return childrenTask(request, 0);
     }
 
     @Override
-    public HollowGlassOutRelationInfo forceOutGlass(String flowCardId, int cell, int totalPairQuantity) {
-        return childrenTask(flowCardId,cell,totalPairQuantity,1);
+    public HollowGlassOutRelationInfo forceOutGlass(HollowTaskRequest request) {
+        return childrenTask(request, 1);
     }
 
     @Override
     public Boolean dispatchHollowSwitch(Boolean flag) {
         redisUtil.setCacheObject("dispatchHollowSwitch", flag);
-        return  redisUtil.getCacheObject("dispatchHollowSwitch");
+        return redisUtil.getCacheObject("dispatchHollowSwitch");
+    }
+
+    @Override
+    public List<String> hollowTaskList(int cell) {
+        //鏌ヨ浠诲姟琛ㄤ腑鏈潯绾挎墍鏈夋湭瀹屾垚鐨勪换鍔′俊鎭�
+        List<HollowGlassOutRelationInfo> list = 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::getCell, cell));
+        if (CollectionUtil.isNotEmpty(list)) {
+            return list.stream().map(HollowGlassOutRelationInfo::getFlowCardId).collect(Collectors.toList());
+        }
+        return new ArrayList<String>();
+    }
+
+    @Override
+    public List<HollowGlassQueueInfo> appointHollowTaskDetails(String flowCardId, int cell) {
+        //鎸夌収娴佺▼鍗″強璺嚎锛屾煡鎵惧搴旂殑浠诲姟淇℃伅
+        HollowGlassOutRelationInfo hollowGlassOutRelationInfo = this.getOne(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>();
+        }
+        //鎸夌収浠诲姟id鏌ヨ瀵瑰垪琛ㄤ腑鐨勯槦鍒椾俊鎭�
+        return hollowGlassQueueInfoService.list(new LambdaQueryWrapper<HollowGlassQueueInfo>()
+                .eq(HollowGlassQueueInfo::getRelationId, hollowGlassOutRelationInfo.getId()));
+    }
+
+    @Override
+    public Boolean startTask(String flowCardId, int cell) {
+        //鏇存柊浠诲姟鐘舵�佷负寮�濮�
+        return this.update(new LambdaUpdateWrapper<HollowGlassOutRelationInfo>()
+                .set(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
+                .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId)
+                .eq(HollowGlassOutRelationInfo::getCell, cell));
+    }
+
+    @Override
+    public Boolean pauseTask(String flowCardId, int cell) {
+//        鏇存柊浠诲姟鐘舵�佷负鏆傚仠
+        return this.update(new LambdaUpdateWrapper<HollowGlassOutRelationInfo>()
+                .set(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_PAUSE)
+                .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId)
+                .eq(HollowGlassOutRelationInfo::getCell, cell));
+    }
+
+    @Override
+    public Boolean finishTask(String flowCardId, int cell) {
+        //娓呯┖闃熷垪琛ㄤ腑鏈畬鎴愮殑鐜荤拑淇℃伅
+        hollowGlassQueueInfoService.remove(new LambdaQueryWrapper<HollowGlassQueueInfo>()
+                .in(HollowGlassQueueInfo::getState, Const.TEMPERING_NEW)
+                .eq(HollowGlassQueueInfo::getFlowCardId, flowCardId)
+                .eq(HollowGlassQueueInfo::getCell, cell));
+        //鏇存柊浠诲姟鐘舵�佹湭宸插畬鎴�
+        return this.update(new LambdaUpdateWrapper<HollowGlassOutRelationInfo>()
+                .set(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_SUCCESS)
+                .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId)
+                .eq(HollowGlassOutRelationInfo::getCell, cell));
+    }
+
+    @Override
+    public Boolean deleteHollowTaskDetails(String flowCardId, int cell) {
+        //鎸夌収娴佺▼鍗″強璺嚎锛屾煡鎵惧搴旂殑浠诲姟淇℃伅
+        this.remove(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));
+        hollowGlassQueueInfoService.remove(new LambdaQueryWrapper<HollowGlassQueueInfo>()
+                .in(HollowGlassQueueInfo::getState, Const.TEMPERING_NEW)
+                .eq(HollowGlassQueueInfo::getFlowCardId, flowCardId)
+                .eq(HollowGlassQueueInfo::getCell, cell));
+        return Boolean.TRUE;
     }
 
 
-    private HollowGlassOutRelationInfo childrenTask(String flowCardId, int cell, int totalPairQuantity,int isForce) {
-        GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getFlowCardId, flowCardId).last("limit 1"));
+    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;
         }
-        info.setFlowCardId(flowCardId);
-        info.setCell(cell);
+        List<HollowGlassOutRelationInfo> outRelationInfos = this.list(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
+                .eq(HollowGlassOutRelationInfo::getCell, request.getCell())
+                .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_START);
-        info.setTotalPairQuantity(totalPairQuantity);
-        List<HollowBigStorageCageDetails> hollowBigStorageCageDetailsList = hollowBigStorageCageDetailsService.queryOutGlassList(flowCardId, cell);
-        int isPairCount = glassInfo.getTotalLayer() * totalPairQuantity;
+        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<>();
         loop:
         for (HollowBigStorageCageDetails queue : hollowBigStorageCageDetailsList) {
             HollowGlassQueueInfo queueInfo = new HollowGlassQueueInfo();
             BeanUtils.copyProperties(queue, queueInfo);
+            queueInfo.setRelationId(info.getId());
             queueInfo.setState(Const.TEMPERING_NEW);
-            queueInfo.setCell(cell);
+            queueInfo.setCell(request.getCell());
+            queueInfo.setCreateTime(new Date());
+            queueInfo.setUpdateTime(new Date());
             hollowQueues.add(queueInfo);
-            if (queue.getIsPair() == 1){
-                isPairCount -=1;
-                if (isPairCount == 0){
+            if (queue.getIsPair() == 1) {
+                isPairCount -= 1;
+                if (isPairCount == 0) {
                     break loop;
                 }
             }
         }
         hollowGlassQueueInfoService.saveBatch(hollowQueues);
-        this.save(info);
         return info;
     }
 }

--
Gitblit v1.8.0