wu
2024-11-14 5780c58879296cfced72012c8831c1d3cf4dafb2
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
package com.example.springboot.service;
 
import java.sql.SQLException;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import com.example.springboot.entity.StorageCage;
import com.example.springboot.entity.north_glass_buffer1;
import com.example.springboot.mapper.HomeMapper;
import java.util.Collections;
 
@Service
public class North_Glass_Buffer1Service {
    @Autowired
    private HomeMapper homeMapper;
 
    @Autowired
    private JdbcConnections jdbcConnections;
 
    class north_glass_buffer1Comparator implements Comparator<north_glass_buffer1> {
        @Override
        public int compare(north_glass_buffer1 n1, north_glass_buffer1 n2) {//对查询到的铝框对应的玻璃数据进行排序,将离出片位置近的,靠近笼子出片侧的玻璃排在前面
            if (n1.getstorageCage() != null) {
                if (n2.getstorageCage() != null) {
                    int cageComparison = n2.getstorageCage().getCage().compareTo(n1.getstorageCage().getCage());//靠出片口近的笼子优先
                    if (cageComparison != 0) {
                        return cageComparison;
                    } else {
                        int cellComparison = n2.getstorageCage().getCell().compareTo(n1.getstorageCage().getCell());//靠出片口近的格子优先
                        if (cellComparison != 0) {
                            return cellComparison;
                        } else {
                            return n2.getstorageCage().getTier().compareTo(n1.getstorageCage().getTier());//靠出片口近的格子外层优先
                        }
                    }
                } else {
                    return -1;
                }
 
            } else {
                return 1;
            }
 
        }
    }
 
    // 获取玻璃是否在笼子,是否在出片队列
    public List<north_glass_buffer1> SelectAluminumFrameInfoById(String FrameBarcode) throws SQLException {
        List<north_glass_buffer1> listAluminumFrame = jdbcConnections
                .SelectGlassByGlassIdOrderIdFrameIdss(FrameBarcode);
        for (north_glass_buffer1 north_glass_buffer1 : listAluminumFrame) {
            north_glass_buffer1.setstorageCage(homeMapper.SelectStorageGlassById(north_glass_buffer1.getbarcode()));
            north_glass_buffer1.setOut_slice(homeMapper.SelectQueueByglassid(north_glass_buffer1.getbarcode()));
        }
        // 对嵌套类进行排序
        Collections.sort(listAluminumFrame, new north_glass_buffer1Comparator());
        return listAluminumFrame;
    }
 
    // 根据铝框id添加玻璃到出片队列
    public void AddOutSliceS(String FrameBarcode) throws SQLException {
        List<north_glass_buffer1> north_glass_buffer1s = SelectAluminumFrameInfoById(FrameBarcode);
        String flip = jdbcConnections.SelectFlipByFrameBarcode(FrameBarcode);
        String position = jdbcConnections.SelectPositionByFrameBarcode(FrameBarcode);
        String framelength=jdbcConnections.SelectFrameLengthByFrameBarcode(FrameBarcode);
        String frameheight=jdbcConnections.SelectFrameHeightByFrameBarcode(FrameBarcode);
        int sequence = homeMapper.SelectMaxSquence();
        for (north_glass_buffer1 north_glass_buffer1 : north_glass_buffer1s) {
            Short state = 0;
            if (north_glass_buffer1.getOut_slice() == null) {
                if (north_glass_buffer1.getstorageCage() == null) {
                    state = 3;
                }
                homeMapper.AddOutSliceS(north_glass_buffer1.getbarcode(), flip, FrameBarcode,
                        north_glass_buffer1.getglasslengthmm().toString(),
                        north_glass_buffer1.getglassheightmm().toString(), sequence, position, state,
                        north_glass_buffer1.getordernumber(), north_glass_buffer1.getlistnumber(),
                        north_glass_buffer1.getboxnumber(), north_glass_buffer1.getglasslength().toString(),
                        north_glass_buffer1.getglassheight().toString(),framelength,frameheight);
                sequence += 1;
            }
        }
    }
 
}