From 918c870a2bc093f22b6e80e7ed447aba0b161f4a Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期四, 08 八月 2024 14:28:57 +0800
Subject: [PATCH] 修改打印数据格式,下面界面实现打印功能

---
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/impl/DownGlassInfoServiceImpl.java |  113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 110 insertions(+), 3 deletions(-)

diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/impl/DownGlassInfoServiceImpl.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/impl/DownGlassInfoServiceImpl.java
index 89770f5..909c76a 100644
--- a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/impl/DownGlassInfoServiceImpl.java
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/impl/DownGlassInfoServiceImpl.java
@@ -1,26 +1,56 @@
 package com.mes.downglassinfo.service.impl;
 
+import cn.hutool.json.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 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.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.mes.common.config.Const;
+import com.mes.common.utils.RedisUtil;
 import com.mes.downglassinfo.entity.DownGlassInfo;
+import com.mes.downglassinfo.entity.request.DownGlassInfoRequest;
 import com.mes.downglassinfo.mapper.DownGlassInfoMapper;
 import com.mes.downglassinfo.service.DownGlassInfoService;
+import com.mes.downstorage.entity.DownStorageCageDetails;
+import com.mes.downstorage.service.DownStorageCageDetailsService;
 import com.mes.downworkstation.entity.dto.DownGlassInfoDTO;
+import com.mes.glassinfo.entity.GlassInfo;
+import com.mes.job.DownLoadCacheGlassTask;
+import com.mes.pp.service.FlowCardService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class DownGlassInfoServiceImpl extends ServiceImpl<DownGlassInfoMapper, DownGlassInfo> implements DownGlassInfoService {
+
+    @Autowired
+    DownLoadCacheGlassTask downLoadCacheGlassTask;
+
+    @Autowired
+    DownStorageCageDetailsService downStorageCageDetailsService;
+
+    @Autowired
+    RedisUtil redisUtil;
+
+    @Autowired
+    FlowCardService flowCardService;
 
     /**
      * 鏍规嵁娴佺▼鍗″彿鏌ヨ鏈�澶у簭鍙�
      */
     @Override
-    public Integer getMaxSequenceByFlowCardId(String flowCardId) {
+    public Integer getMaxSequenceByFlowCardId(String flowCardId, int layer) {
         LambdaQueryWrapper<DownGlassInfo> lambdaQueryWrapper = Wrappers.lambdaQuery();
         lambdaQueryWrapper.eq(DownGlassInfo::getFlowCardId, flowCardId)
+                .eq(DownGlassInfo::getLayer, layer)
                 .select(DownGlassInfo::getSequence)
                 .orderByDesc(DownGlassInfo::getSequence)
                 .last("LIMIT 1");
@@ -45,7 +75,84 @@
     }
 
     @Override
-    public List<DownGlassInfoDTO> queryWorkStationNotIn() {
-        return baseMapper.queryWorkStationNotIn();
+    public List<DownGlassInfoDTO> queryWorkStationIsIn(Boolean isDownload) {
+        return baseMapper.queryWorkStationIsIn(isDownload);
     }
+
+    @Override
+    public boolean generateOutGlassTask(String glassId) {
+        //鏇存柊鍗у紡鐞嗙墖绗煎唴鐜荤拑鐘舵��
+        downStorageCageDetailsService.update(new LambdaUpdateWrapper<DownStorageCageDetails>()
+                .set(DownStorageCageDetails::getState, Const.GLASS_STATE_OUT).eq(DownStorageCageDetails::getGlassId, glassId));
+        DownStorageCageDetails details = downStorageCageDetailsService.getOne(new LambdaQueryWrapper<DownStorageCageDetails>()
+                .eq(DownStorageCageDetails::getGlassId, glassId));
+        //鐢熸垚涓嬬墖淇℃伅
+        DownGlassInfo downGlassInfo = new DownGlassInfo();
+        BeanUtils.copyProperties(details, downGlassInfo);
+        //鑾峰彇褰撳墠娴佺▼鍗℃渶澶х墖搴�
+        downGlassInfo.setSequence(this.getMaxSequenceByFlowCardId(details.getFlowCardId(), details.getLayer()) + 1);
+        this.save(downGlassInfo);
+        //鐢熸垚浠诲姟淇℃伅 骞跺悜plc鍙戦�佸嚭鐗囦换鍔�
+        GlassInfo glassInfo = new GlassInfo();
+        BeanUtils.copyProperties(details, glassInfo);
+        return downLoadCacheGlassTask.initDownGlassTask(glassInfo, details.getSlot(), Const.G13_WORK_STATION, 2);
+    }
+
+    @Override
+    public String setDownGlassInfoRequest(DownGlassInfoRequest request) {
+        if (request == null) {
+            redisUtil.deleteObject("downGlassRequest");
+        } else {
+            redisUtil.setCacheObject("downGlassRequest", request);
+        }
+        return "success";
+    }
+
+    @Override
+    public List<Map<String, List<Map<String, Object>>>> downGlassPrint(DownGlassInfo downGlassInfo){
+        QueryWrapper<DownGlassInfo> queryWrapper = Wrappers.query();
+        queryWrapper.eq("flow_card_id", "NG24080012A001")
+                .eq("layer", 1)
+                .select("flow_card_id", "layer", "width", "height", "filmsid", "thickness","glass_type","COUNT(*) AS quantity")
+                .groupBy("flow_card_id", "layer", "width", "height", "filmsid", "thickness");
+        List<Map<String, Object>> resultList = baseMapper.selectMaps(queryWrapper);
+
+
+        List<Map<String, Object>> projectInfo=flowCardService.selectProject(downGlassInfo.getFlowCardId(),downGlassInfo.getLayer());
+        List<Map<String, Object>> flowCardInfo=flowCardService.selectFlowCard(downGlassInfo.getFlowCardId(),downGlassInfo.getLayer());
+
+        for (Map<String, Object> row : flowCardInfo) {
+            int order_number = (int) row.get("order_number");
+            int technology_number = (int) row.get("technology_number");
+
+            for (Map<String, Object> row1 : resultList) {
+                int glass_type = (int) row1.get("glass_type");
+                int layer = (int) row1.get("layer");
+                Long quantity=(Long) row1.get("quantity");
+
+                if(order_number==glass_type&&technology_number==layer){
+                    row.put("quantity1",quantity);
+                }
+            }
+        }
+        List<Map<String, List<Map<String, Object>>>> listMap=new ArrayList<>();
+        Map<String, List<Map<String, Object>>> result = new HashMap<>();
+        result.put("detail", projectInfo);
+        result.put("detailList", flowCardInfo);
+        for (Map<String, Object> row : projectInfo) {
+            String order_number = (String) row.get("process");
+            String[] processes=order_number.split("->");
+            List<Map<String, Object>> processList = new ArrayList<>();
+            for (int i = 0; i < processes.length; i++) {
+                Map<String, Object> processMap = new JSONObject();
+                processMap.put("process", processes[i]);
+                processMap.put("id", i);
+                processList.add(processMap);
+            }
+            result.put("processList", processList);
+        }
+        listMap.add(result);
+        return listMap;
+    }
+
 }

--
Gitblit v1.8.0