zhangyong
2024-11-26 dcc799551b532fa29d64f5f2cb614f5b80b233f6
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
package com.mes.temperingglass.service.impl;
 
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mes.temperingglass.entity.TemperingGlassInfo;
import com.mes.temperingglass.mapper.TemperingGlassInfoMapper;
import com.mes.temperingglass.service.TemperingGlassInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.yulichang.base.MPJBaseServiceImpl;
 
import java.util.List;
 
/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zhoush
 * @since 2024-04-07
 */
@Service
@DS("salve_hangzhoumes")
public class TemperingGlassInfoServiceImpl extends MPJBaseServiceImpl<TemperingGlassInfoMapper, TemperingGlassInfo> implements TemperingGlassInfoService {
    @Autowired
    TemperingGlassInfoMapper temperingMapper;
 
    @Override
    public List<TemperingGlassInfo> selectWaitingGlass() {
        //获取等待进炉中的玻璃信息
        QueryWrapper<TemperingGlassInfo> wrapper = new QueryWrapper<>();
        wrapper.select("Top 1 *").in("state",1,0);
        TemperingGlassInfo glass=temperingMapper.selectOne(wrapper);
        if(glass!=null) {
            QueryWrapper<TemperingGlassInfo> glassinfo = new QueryWrapper<>();
            glassinfo.eq("engineer_id", glass.getEngineerId())
                    .eq("tempering_layout_id", glass.getTemperingLayoutId());
            //return temperingMapper.selectList(glassinfo);
            return temperingMapper.selectByEngineerIdAndLayoutId(glass.getEngineerId(),glass.getTemperingLayoutId());
        }else {
            return null;
        }
    }
 
    @Override
    public List<TemperingGlassInfo> selectIntoGlass(TemperingGlassInfo temperingGlassInfo) {
        //获取进炉中的玻璃信息
//        QueryWrapper<TemperingGlassInfo> wrapper = new QueryWrapper<>();
//        wrapper.eq("tempering_layout_id", temperingGlassInfo.getTemperingLayoutId())
//                .eq("engineer_id", temperingGlassInfo.getEngineerId())
//                .orderByAsc("tempering_layout_id","tempering_feed_sequence");
//        return temperingMapper.selectList(wrapper);
        return temperingMapper.selectByEngineerIdAndLayoutId(temperingGlassInfo.getEngineerId(),temperingGlassInfo.getTemperingLayoutId());
 
    }
 
    @Override
    public List<TemperingGlassInfo> selectOutGlass() {
        //获取出炉中的玻璃信息
        QueryWrapper<TemperingGlassInfo> wrap = new QueryWrapper<>();
        wrap.select("Top 1 *").eq("state",3);
        TemperingGlassInfo glass=temperingMapper.selectOne(wrap);
        //根据工程号和版图获取数据
        if(glass != null) {
            return temperingMapper.selectByEngineerIdAndLayoutId(glass.getEngineerId(),glass.getTemperingLayoutId());
        }
        return  null;
    }
 
    @Override
    public List<TemperingGlassInfo> selectOverGlass() {
        //获取过旋转台最大的钢化版图id
        QueryWrapper<TemperingGlassInfo> wapper = new QueryWrapper<>();
        wapper.select("Top 1 *").eq("state", 4)
                .orderByDesc("tempering_layout_id,engineer_id");
        //根据最大的版图id显示钢化后的版图信息
        TemperingGlassInfo glassinfo= temperingMapper.selectOne(wapper);
        if (glassinfo == null) {
            return null;  // 直接返回null,表示没有找到符合条件的记录
        }
        return temperingMapper.selectByEngineerIdAndLayoutId(glassinfo.getEngineerId(),glassinfo.getTemperingLayoutId());
 
    }
 
    @Override
    public List<TemperingGlassInfo> selectLayoutId() {
        QueryWrapper<TemperingGlassInfo> wrapper = new QueryWrapper<>();
        wrapper.select("tempering_layout_id,engineer_id,max(id) as id")
                .eq("state",2)
                .groupBy("tempering_layout_id,engineer_id")
                .orderByAsc("id");
        return temperingMapper.selectList(wrapper);
    }
 
    @Override
    public List<TemperingGlassInfo> selectTaskType() {
        QueryWrapper<TemperingGlassInfo> wrapper = new QueryWrapper<>();
        wrapper.select("state")
                .groupBy("state");
        return temperingMapper.selectList(wrapper);
    }
 
    @Override
    public Integer updateTemperingState(TemperingGlassInfo temperingGlassInfo) {
        if (temperingMapper.updateTemperingGlassInfo(temperingGlassInfo) > 0) {
            return 200;
        }else {
            return 100;
        }
    }
 
    @Override
    public List<TemperingGlassInfo> selectGlassInfoById(Integer id)
    {
        List<TemperingGlassInfo> result=null;
        QueryWrapper<TemperingGlassInfo> wrapper = new QueryWrapper<>();
        wrapper.select("Top 1 *").in("state",1,0).eq("temperingLayoutId",id);
        TemperingGlassInfo glass=temperingMapper.selectOne(wrapper);
        if(glass!=null) {
            QueryWrapper<TemperingGlassInfo> glassinfo = new QueryWrapper<>();
            glassinfo.eq("engineer_id", glass.getEngineerId())
                    .eq("tempering_layout_id", id);
            //return temperingMapper.selectList(glassinfo);
            result= temperingMapper.selectByEngineerIdAndLayoutId(glass.getEngineerId(),glass.getTemperingLayoutId());
        }
        return result;
    }
}