wangfei
2025-04-15 cd7f3fa89aed4e7a4b87c0ee4164cd606103b318
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
package com.mes.hollow.service.impl;
 
import cn.hutool.core.collection.CollectionUtil;
import cn.smallbun.screw.core.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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.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.request.HollowHistoryTaskRequest;
import com.mes.hollow.entity.request.HollowTaskRequest;
import com.mes.hollow.mapper.HollowGlassOutRelationInfoMapper;
import com.mes.hollow.service.HollowBigStorageCageDetailsService;
import com.mes.hollow.service.HollowFormulaDetailsService;
import com.mes.hollow.service.HollowGlassOutRelationInfoService;
import com.mes.hollow.service.HollowGlassRelationInfoService;
import com.mes.hollowqueue.entity.HollowGlassQueueInfo;
import com.mes.hollowqueue.service.HollowGlassQueueInfoService;
import com.mes.largenscreen.entity.PieChartVO;
import com.mes.tools.DateUtil;
import com.mes.utils.Blank;
import com.mes.utils.RedisUtil;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.Version;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * (HollowGlassOutRelationInfo)表服务实现类
 *
 * @author makejava
 * @since 2024-11-30 13:57:29
 */
@Service
@Slf4j
public class HollowGlassOutRelationInfoServiceImpl extends ServiceImpl<HollowGlassOutRelationInfoMapper, HollowGlassOutRelationInfo> implements HollowGlassOutRelationInfoService {
 
    @Resource
    GlassInfoService glassInfoService;
    @Resource
    HollowBigStorageCageDetailsService hollowBigStorageCageDetailsService;
    @Resource
    HollowGlassQueueInfoService hollowGlassQueueInfoService;
    @Resource
    HollowFormulaDetailsService hollowFormulaDetailsService;
    @Resource
    HollowGlassRelationInfoService hollowGlassRelationInfoService;
 
    @Resource
    RedisUtil redisUtil;
 
    @Value("${mes.glassGap}")
    private Integer glassGap;
 
    @Value("${mes.carWidth}")
    private Integer carWidth;
 
    private static final int ID_RATIO = 10;
 
    @Override
    public HollowGlassOutRelationInfo receiveTask(HollowTaskRequest request) {
        return childrenTask(request, 0);
    }
 
    @Override
    public HollowGlassOutRelationInfo forceOutGlass(HollowTaskRequest request) {
        return childrenTask(request, 1);
    }
 
    @Override
    public Boolean dispatchHollowSwitch(Boolean flag) {
        redisUtil.setCacheObject("dispatchHollowSwitch", flag);
        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) {
        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("该流程卡不存在任务或者有正在执行中,无法再次执行");
            return Boolean.FALSE;
        }
        //更新任务状态为开始
        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) {
//        更新任务状态为暂停
        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));
    }
 
    @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;
    }
 
    @Override
    public String generateHollowLisecFile(String flowCardId, int cell, int isForce, int isOut) throws IOException {
        List<HollowGlassOutRelationInfo> outRelationList = 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));
        if (CollectionUtil.isEmpty(outRelationList) || outRelationList.size() != 1) {
            return "本条线不存在该流程任务或者同流程卡任务数大于1";
        }
        HollowGlassOutRelationInfo relationInfo = outRelationList.get(0);
        if (relationInfo.getTotalLayer() < 2) {
            return "任务总层数小于2,不生成李赛克文件";
        }
        //获取订单相关信息
        OrderDTO order = baseMapper.queryOrderByFlowCardId(flowCardId);
        if (null == order) {
            return "生成失败,相关订单信息不存在";
        }
        //获取配方相关信息
        HollowFormulaDetails formulaDetails = hollowFormulaDetailsService.getById(relationInfo.getFormulaId());
        if (null == formulaDetails) {
            return "生成失败,相关配方信息不存在";
        }
        //总层数是否与进笼关系表内层数数量相同,层数相同生成继续,不同结束
        int layerCount = hollowGlassRelationInfoService.queryLayerByFlowCardId(flowCardId);
        if (layerCount != relationInfo.getTotalLayer() && isForce == 0) {
            return "生成失败,该流程卡内层数与进笼关系表内层数数量不相同";
        }
        //设置文件的主体内容
        LisecHollowDetails details = new LisecHollowDetails();
        String randomNumber = "" + (int) (Math.random() * 100000 + 100000);
        details.setBcdStart(randomNumber);
        details.setBatchNo(randomNumber);
        details.setOrd(relationInfo.getFlowCardId().substring(4, 9) + (int) (Math.random() * 1000 + 1000));
        details.setCustNum(order.getCustomerId() + "");
        details.setCustNam("");
        details.setProDate((new SimpleDateFormat("dd/MM/yyyy").format(new Date())));
        details.setDelDate(new SimpleDateFormat("dd/MM/yyyy").format(order.getDeliveryDate()));
 
        //设置文件第一层列表数据
        //暂时生成笼内所有的玻璃信息(已配对和未配对的)
        List<HollowBigStorageCageDetails> hollowGlassRelationInfos = hollowBigStorageCageDetailsService.queryPairGlassList(flowCardId, relationInfo.getTotalLayer(), relationInfo.getTotalPairQuantity(), isOut);
        Map<Integer, List<HollowBigStorageCageDetails>> listMap = hollowGlassRelationInfos.stream()
                .collect(Collectors.groupingBy(HollowBigStorageCageDetails::getHollowSequence,
                        Collectors.collectingAndThen(Collectors.toList(),
                                list -> list.stream().sorted(Comparator.comparing(HollowBigStorageCageDetails::getLayer)).collect(Collectors.toList()))));
        Map<Integer, List<HollowBigStorageCageDetails>> sortListMap = new TreeMap<>();
        sortListMap.putAll(listMap);
        //设置间隔板数据共所有配对玻璃使用
        List<LisecHollowGlassAndFrameDetails> glassAndFrameList = new ArrayList<>();
        sortListMap.forEach((e, v) -> {
            LisecHollowGlassAndFrameDetails glassAndFrame = new LisecHollowGlassAndFrameDetails();
            List<LisecHollowGlassDetails> glassList = new ArrayList<>();
            List<LisecHollowFrameDetails> frameList = new ArrayList<>();
            for (int i = 1; i <= v.size(); i++) {
                LisecHollowGlassDetails hollowGlassDetails = new LisecHollowGlassDetails();
                HollowBigStorageCageDetails glassInfo = v.get(i - 1);
                hollowGlassDetails.setRecType("<GL" + i + ">");
                hollowGlassDetails.setThickness((int) (glassInfo.getThickness() * 10) + "");
                hollowGlassDetails.setDescript(formulaDetails.getIntervalFrameWidthOne() + "-" + (int) (glassInfo.getThickness() * 10));
                hollowGlassDetails.setPaneBcd(randomNumber + "" + (e * ID_RATIO + i));
                glassList.add(hollowGlassDetails);
            }
            glassAndFrame.setGlassList(glassList);
 
            glassAndFrame.setItemNum(e + "");
            glassAndFrame.setIdNum(e + "");
            glassAndFrame.setBarcode(randomNumber.substring(randomNumber.length() - 3));
            glassAndFrame.setWidth((int) (v.get(0).getWidth() * 10) + "");
            glassAndFrame.setHeight((int) (v.get(0).getHeight() * 10) + "");
            glassAndFrame.setGlass1(e * ID_RATIO + 1 + "");
            glassAndFrame.setFrame1(formulaDetails.getFrameOne());
            frameList.add(new LisecHollowFrameDetails("<FR1>", formulaDetails.getIntervalFrameTypeOne(), formulaDetails.getIntervalFrameWidthOne(), formulaDetails.getIntervalFrameHeightOne()));
            glassAndFrame.setGasCode1(formulaDetails.getCasOne());
            if (relationInfo.getTotalLayer() == 2) {
                glassAndFrame.setGlass2(e * ID_RATIO + 2 + "");
            } else if (relationInfo.getTotalLayer() == 3) {
                glassAndFrame.setGlass2(e * ID_RATIO + 2 + "");
                glassAndFrame.setFrame2(formulaDetails.getFrameTwo());
                frameList.add(new LisecHollowFrameDetails("<FR2>", formulaDetails.getIntervalFrameTypeTwo(), formulaDetails.getIntervalFrameWidthTwo(), formulaDetails.getIntervalFrameHeightTwo()));
                glassAndFrame.setGasCode2(formulaDetails.getCasTwo());
                glassAndFrame.setGlass3(e * ID_RATIO + 3 + "");
            } else if (relationInfo.getTotalLayer() == 4) {
                glassAndFrame.setGlass2(e * ID_RATIO + 2 + "");
                glassAndFrame.setFrame2(formulaDetails.getFrameTwo());
                frameList.add(new LisecHollowFrameDetails("<FR2>", formulaDetails.getIntervalFrameTypeTwo(), formulaDetails.getIntervalFrameWidthTwo(), formulaDetails.getIntervalFrameHeightTwo()));
                glassAndFrame.setGasCode2(formulaDetails.getCasTwo());
                glassAndFrame.setGlass3(e * ID_RATIO + 3 + "");
                glassAndFrame.setFrame3(formulaDetails.getFrameThree());
                frameList.add(new LisecHollowFrameDetails("<FR3>", formulaDetails.getIntervalFrameTypeThree(), formulaDetails.getIntervalFrameWidthThree(), formulaDetails.getIntervalFrameHeightThree()));
                glassAndFrame.setGasCode3(formulaDetails.getCasThree());
                glassAndFrame.setGlass4(e * ID_RATIO + 4 + "");
            } else {
                glassAndFrame.setGlass2(e * ID_RATIO + 2 + "");
                glassAndFrame.setFrame2(formulaDetails.getFrameTwo());
                frameList.add(new LisecHollowFrameDetails("<FR2>", formulaDetails.getIntervalFrameTypeTwo(), formulaDetails.getIntervalFrameWidthTwo(), formulaDetails.getIntervalFrameHeightTwo()));
                glassAndFrame.setGasCode2(formulaDetails.getCasTwo());
                glassAndFrame.setGlass3(e * ID_RATIO + 3 + "");
                glassAndFrame.setFrame3(formulaDetails.getFrameThree());
                frameList.add(new LisecHollowFrameDetails("<FR3>", formulaDetails.getIntervalFrameTypeThree(), formulaDetails.getIntervalFrameWidthThree(), formulaDetails.getIntervalFrameHeightThree()));
                glassAndFrame.setGasCode3(formulaDetails.getCasThree());
                glassAndFrame.setGlass4(e * ID_RATIO + 4 + "");
                glassAndFrame.setFrame3(formulaDetails.getFrameFour());
                frameList.add(new LisecHollowFrameDetails("<FR4>", formulaDetails.getIntervalFrameTypeFour(), formulaDetails.getIntervalFrameWidthFour(), formulaDetails.getIntervalFrameHeightFour()));
                glassAndFrame.setGasCode4(formulaDetails.getCasFour());
                glassAndFrame.setGlass4(e * ID_RATIO + 5 + "");
            }
            glassAndFrame.setInset(formulaDetails.getSealInsert());
            glassAndFrame.setFrameList(frameList);
            glassAndFrameList.add(glassAndFrame);
        });
        details.setGlassAndFrameList(glassAndFrameList);
        Configuration cfg = new Configuration(new Version("2.3.29"));
        cfg.setClassForTemplateLoading(HollowBigStorageCageController.class, "/templates/");
        // 创建Calculator实例
        Blank blank = new Blank();
 
        // 创建数据模型
        Map<String, Object> root = new HashMap<>();
        root.put("blank", blank);
 
        root.put("details", details);
 
        // 获取模板
        Template temp = cfg.getTemplate("hollowGlass.ftl");
 
 
        // 将生成的文件存入指定路径
        //计算生成李赛克需要的数据给到每个属性
        StringWriter out = new StringWriter();
        File file = new File(System.getProperty("user.dir") + "/lisec", relationInfo.getFlowCardId() + randomNumber.substring(randomNumber.length() - 3) + ".trf");
        try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
            temp.process(root, out);
            writer.write(out.toString());
        } catch (TemplateException | IOException e) {
            e.printStackTrace();
        }
        return "success";
    }
 
    @Override
    public Page<HollowGlassOutRelationInfo> queryHollowHistoryTask(HollowHistoryTaskRequest request) {
        Page<HollowGlassOutRelationInfo> page = new Page<>(request.getPageNo(), request.getPageSize());
        if (null == request.getBeginDate()) {
            request.setBeginDate(DateUtil.getBeginDate());
            request.setEndDate(DateUtil.getEndDate());
        }
        LambdaQueryWrapper<HollowGlassOutRelationInfo> wrapper = new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                .eq(HollowGlassOutRelationInfo::getCell, request.getCell())
                .like(StringUtils.isNotBlank(request.getFlowCardId()), HollowGlassOutRelationInfo::getFlowCardId, request.getFlowCardId())
                .in(CollectionUtil.isNotEmpty(request.getIsForceList()), HollowGlassOutRelationInfo::getIsForce, request.getIsForceList())
                .in(CollectionUtil.isNotEmpty(request.getStateList()), HollowGlassOutRelationInfo::getState, request.getStateList())
                .between(HollowGlassOutRelationInfo::getCreateTime, request.getBeginDate(), request.getEndDate())
                .orderByDesc(HollowGlassOutRelationInfo::getCreateTime);
        return this.page(page, wrapper);
    }
 
 
    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<>();
                //先将玻璃按照正常顺序排列,计算一车最多放几块,算好块数之后将一车的玻璃按照倒序存储
                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);
            }
        } catch (Exception e) {
            log.info("生成李赛克文件时发生异常,流程卡号为{}", request.getFlowCardId());
        }
        return info;
    }
 
    private HollowGlassQueueInfo HollowBDetailToQueue(HollowBigStorageCageDetails details, Long taskId, int targetCell) {
        HollowGlassQueueInfo queueInfo = new HollowGlassQueueInfo();
        BeanUtils.copyProperties(details, queueInfo);
        queueInfo.setRelationId(taskId);
        queueInfo.setState(Const.TEMPERING_NEW);
        queueInfo.setCell(targetCell);
        queueInfo.setCreateTime(new Date());
        queueInfo.setUpdateTime(new Date());
        return queueInfo;
    }
 
    @Override
    public List<PieChartVO> queryPieChart(){
        return baseMapper.queryPieChart();
    }
}