wangfei
2025-05-13 0b41a5c59028a61bff22f60e74cb1d6d53a40e61
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
package com.mes.bigstorage.controller;
 
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.mes.bigstorage.entity.BigStorageCageDetails;
import com.mes.bigstorage.entity.dto.GlassInfoLackDTO;
import com.mes.bigstorage.entity.dto.TemperingGlassCountDTO;
import com.mes.bigstorage.entity.vo.BigStorageQueryVO;
import com.mes.bigstorage.service.BigStorageCageDetailsService;
import com.mes.bigstorage.service.BigStorageCageService;
import com.mes.common.config.Const;
import com.mes.utils.RedisUtil;
import com.mes.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
 
/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhoush
 * @since 2024-03-27
 */
@Api(tags = "理片笼详情")
@RestController
@RequestMapping("/bigStorageCageDetails")
public class BigStorageCageDetailsController {
 
    @Autowired
    private BigStorageCageDetailsService bigStorageCageDetailsService;
    @Autowired
    private BigStorageCageService bigStorageCageService;
    @Resource
    private RedisUtil redisUtil;
 
 
    @ApiOperation("玻璃详情查询")
    @PostMapping("/selectBigStorageCageDetails")
    public Result selectBigStorageCageDetails(@RequestBody Map map) {
        List<BigStorageCageDetails> bigStorageCageDetails = bigStorageCageDetailsService.selectBigStorageCageDetails(map.get("glassId").toString());
        if (bigStorageCageDetails.size() > 0) {
            return Result.build(200, "查询成功", bigStorageCageDetails);
        } else {
            return Result.build(200, "查询失败,无此玻璃id", bigStorageCageDetails);
        }
    }
 
    @ApiOperation("理片笼详情添加")
    @PostMapping("/insertBigStorageCageDetails")
    public Result insertBigStorageCageDetails(@RequestBody BigStorageCageDetails bigStorageCageDetails) {
        bigStorageCageDetailsService.insertBigStorageCageDetails(bigStorageCageDetails);
        return Result.build(200, "添加成功", bigStorageCageService.querybigStorageCageDetail());
    }
 
    @ApiOperation("理片笼详情删除")
    @PostMapping("/deleteBigStorageCageDetails")
    public Result deleteBigStorageCageDetails(@RequestBody BigStorageCageDetails bigStorageCageDetails) {
        bigStorageCageDetailsService.deleteBigStorageCageDetails(bigStorageCageDetails);
        return Result.build(200, "删除成功", bigStorageCageService.querybigStorageCageDetail());
    }
 
    @ApiOperation("理片笼笼内玻璃破损0/拿走1")
    @PostMapping("/damageBigStorageCageDetails")
    public Result damageBigStorageCageDetails(@RequestBody BigStorageCageDetails bigStorageCageDetails, int status) {
        bigStorageCageDetailsService.damageBigStorageCageDetails(bigStorageCageDetails.getGlassId(), status);
        return Result.build(200, "破损/拿走成功", 1);
    }
 
    @ApiOperation("理片笼任务完成")
    @PostMapping("/finishBigStorageCageDetails")
    public Result finishBigStorageCageDetails(@RequestBody BigStorageCageDetails bigStorageCageDetails) {
        bigStorageCageDetailsService.finishBigStorageCageDetails(bigStorageCageDetails);
        return Result.build(200, "任务完成成功", 1);
    }
 
    @ApiOperation("理片笼任务出片")
    @PostMapping("/outBigStorageCageDetails")
    public Result outBigStorageCageDetails(@RequestBody BigStorageCageDetails bigStorageCageDetails) {
        bigStorageCageDetailsService.outBigStorageCageDetails(bigStorageCageDetails);
        return Result.build(200, "出片添加成功", 1);
    }
 
    @ApiOperation("指定钢化")
    @PostMapping("/TemperingGlass")
    public Result temperingGlass(@RequestBody BigStorageCageDetails bigStorageCageDetails) {
        boolean result = bigStorageCageDetailsService
                .temperingGlass(bigStorageCageDetails.getTemperingLayoutId().toString(), bigStorageCageDetails.getEngineerId(), bigStorageCageDetails.getTemperingFeedSequence().toString());
        if (result == true) {
            return Result.build(200, "指定钢化成功", 1);
        } else {
            return Result.build(200, "已存在钢化任务,请等待钢化完成再指定钢化", 1);
        }
    }
 
    @ApiOperation("指定钢化工程")
    @PostMapping("/appointTemperingEngineerId")
    public Result appointTemperingEngineerId(String engineerId) {
        boolean result = bigStorageCageDetailsService.appointTemperingEngineerId(engineerId);
        if (result == true) {
            return Result.build(200, "指定钢化成功", 1);
        } else {
            return Result.build(200, "已存在钢化任务,请等待钢化完成再指定钢化", 1);
        }
    }
 
    @ApiOperation("取消当前钢化")
    @PostMapping("/cancelTemperingTask")
    public Result<Boolean> cancelTemperingTask() {
        boolean result = bigStorageCageDetailsService.cancelTemperingTask();
        if (result == true) {
            return Result.build(200, "取消当前钢化成功", result);
        } else {
            return Result.build(200, "取消当前钢化失败", result);
        }
    }
 
    @ApiOperation("钢化/非钢化查询:0 非钢化  1:钢化")
    @PostMapping("/selectTemperingGlass")
    public Result<List<TemperingGlassCountDTO>> selectTemperingGlass(int isTempering) {
        return Result.build(200, "查询成功", bigStorageCageDetailsService.selectTemperingGlass(isTempering));
    }
 
    @ApiOperation("笼内实际数量查询")
    @PostMapping("/queryRealGlassInfo")
    public Result<List<BigStorageCageDetails>> queryRealGlassInfo(@RequestBody BigStorageQueryVO bigStorageQueryVO) {
        return Result.build(200, "查询成功", bigStorageCageDetailsService.queryRealGlassInfo(bigStorageQueryVO));
    }
 
    @ApiOperation("缺片数量查询")
    @PostMapping("/queryLackGlassInfo")
    public Result<List<GlassInfoLackDTO>> queryLackGlassInfo(@RequestBody BigStorageQueryVO bigStorageQueryVO) {
        return Result.build(200, "查询成功", bigStorageCageDetailsService.queryLackGlassInfo(bigStorageQueryVO));
    }
 
    @ApiOperation("是否调度开关")
    @PostMapping("/dispatchSwitch")
    public Result dispatchSwitch(Boolean flag) {
        bigStorageCageDetailsService.dispatchSwitch(flag);
        return Result.build(200, "修改成功", redisUtil.getCacheObject("dispatchSwitch"));
    }
 
    @ApiOperation("是否钢化开关")
    @PostMapping("/temperingSwitch")
    public Result temperingSwitch(Boolean flag) {
        bigStorageCageDetailsService.temperingSwitch(flag);
        return Result.build(200, "修改成功", redisUtil.getCacheObject("temperingSwitch"));
    }
 
    @ApiOperation("流程卡查询")
    @PostMapping("/selectFlowCardByCache")
    public Result selectFlowCardByCache() {
        List<Map<String, Object>> flowCardIdCount = bigStorageCageDetailsService.listMaps(
                new QueryWrapper<BigStorageCageDetails>()
                        .select("flow_card_id,layer,count(*) as count")
                        .eq("state", Const.GLASS_STATE_IN)
                        .eq("tempering_layout_id", 0)
                        .groupBy("flow_card_id,layer")
        );
        return Result.build(200, "查询成功", flowCardIdCount);
    }
 
    @ApiOperation("指定流程卡")
    @PostMapping("/appointFlowCard")
    public Result appointFlowCard(@RequestBody BigStorageCageDetails bigStorageCageDetails) {
        List<BigStorageCageDetails> bigStorageCageDetailsList = bigStorageCageDetailsService.list(
                new LambdaQueryWrapper<BigStorageCageDetails>()
                        .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_ARTIFICIAL)
        );
        if (bigStorageCageDetailsList.size() == 0) {
            bigStorageCageDetailsService.update(
                    new LambdaUpdateWrapper<BigStorageCageDetails>()
                            .set(BigStorageCageDetails::getState, Const.GLASS_STATE_ARTIFICIAL)
                            .eq(BigStorageCageDetails::getFlowCardId, bigStorageCageDetails.getFlowCardId())
                            .eq(BigStorageCageDetails::getLayer, bigStorageCageDetails.getLayer())
                            .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN)
            );
            return Result.build(200, "指定流程卡成功", 1);
        } else {
            return Result.build(200, "指定流程卡成功", 1);
        }
    }
 
    @ApiOperation("大理片笼报破损")
    @PostMapping("/bigStorageGlassDamageByGlassId")
    public Result<String> bigStorageGlassDamageByGlassId(@RequestBody Map<String, String> map) {
        String glassId = map.get("glassId");
        return Result.build(200, "报破损成功", bigStorageCageDetailsService.bigStorageGlassDamageByGlassId(glassId));
    }
}