yangys
2024-04-04 ed4a5236bab800094be4a8378f5098eebe3de6ac
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
package com.qianwen.smartman.modules.mdc.controller;
 
import java.util.List;
import java.util.stream.Collectors;
 
import javax.validation.Valid;
 
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.qianwen.core.log.exception.ServiceException;
import com.qianwen.core.mp.support.Condition;
import com.qianwen.core.mp.support.Query;
import com.qianwen.core.scanner.modular.stereotype.ApiResource;
import com.qianwen.core.tool.api.R;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.common.cache.RegionCache;
import com.qianwen.smartman.common.utils.Lambda;
import com.qianwen.smartman.modules.cps.service.IWorkstationService;
import com.qianwen.smartman.modules.cps.vo.WorkstationVO;
import com.qianwen.smartman.modules.mdc.dto.WorkstationEndAndStartImmediateFeedBackDTO;
import com.qianwen.smartman.modules.mdc.dto.WorkstationEndImmediateFeedBackDTO;
import com.qianwen.smartman.modules.mdc.dto.WorkstationFeedBackQueryDTO;
import com.qianwen.smartman.modules.mdc.dto.WorkstationImmediateFeedBackDTO;
import com.qianwen.smartman.modules.mdc.dto.WorkstationNoImmediateFeedBackDTO;
import com.qianwen.smartman.modules.mdc.entity.WorkstationFeedback;
import com.qianwen.smartman.modules.mdc.entity.WorkstationFeedbackDetail;
import com.qianwen.smartman.modules.mdc.enums.FeedbackDetailStatus;
import com.qianwen.smartman.modules.mdc.enums.FeedbackStatus;
import com.qianwen.smartman.modules.mdc.service.IWorkstationFeedbackDetailService;
import com.qianwen.smartman.modules.mdc.service.IWorkstationFeedbackService;
import com.qianwen.smartman.modules.mdc.vo.WorkstationFeedBackDetailVO;
import com.qianwen.smartman.modules.mdc.vo.WorkstationFeedBackVO;
import com.qianwen.smartman.modules.mdc.vo.WorkstationFeedbackInfoVO;
import com.qianwen.smartman.modules.mdc.wrapper.WorkstationFeedBackDetailWrapper;
import com.qianwen.smartman.modules.mdc.wrapper.WorkstationFeedbackWrapper;
 
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.lang.Assert;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
 
@Api(value = "工位反馈", tags = {"工位反馈"})
@ApiResource({"blade-cps/workstation-wcs-feedback"})
@RestController
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/mdc/controller/WorkstationFeedbackController.class */
public class WorkstationFeedbackController {
    private final IWorkstationFeedbackService wcsFeedbackService;
    private final IWorkstationService workstationService;
    private final IWorkstationFeedbackDetailService detailService;
 
    public WorkstationFeedbackController(final IWorkstationFeedbackService wcsFeedbackService, final IWorkstationService workstationService, final IWorkstationFeedbackDetailService detailService) {
        this.wcsFeedbackService = wcsFeedbackService;
        this.workstationService = workstationService;
        this.detailService = detailService;
    }
 
    @ApiOperationSupport(order = -2)
    @GetMapping({"/get/{id}"})
    @ApiOperation("H5:根据ID获取反馈详情")
    public R<WorkstationFeedBackVO> getById(@PathVariable Long id) {
        WorkstationFeedback feedback = this.wcsFeedbackService.cachedById(id);
        return R.data(WorkstationFeedbackWrapper.build().entityVO(feedback));
    }
 
    @ApiOperationSupport(order = -1)
    @GetMapping({"/latest"})
    @ApiOperation("根据工位ID获取最新反馈信息")
    public R<WorkstationFeedBackVO> latestByWorkstationId(@RequestParam Long workstationId) {
        WorkstationFeedback feedback = this.wcsFeedbackService.getImmediateFeedback(workstationId);
        if (feedback == null) {
            WorkstationFeedbackDetail detail = this.detailService.latestFeedbackByWorkstationId(workstationId);
            if (detail == null) {
                return R.data( null);
            }
            return R.data(WorkstationFeedbackWrapper.entityVO(detail));
        }
        return R.data(WorkstationFeedbackWrapper.build().entityVO(feedback));
    }
 
    @PostMapping({"/page"})
    @ApiOperationSupport
    @ApiOperation("工位反馈分页列表查询")
    public R<IPage<WorkstationFeedBackDetailVO>> page(Query query, @RequestBody WorkstationFeedBackQueryDTO queryDTO) {
        IPage<WorkstationFeedbackDetail> page = this.detailService.page(Condition.getPage(query), 
                
                Lambda.eq(WorkstationFeedbackDetail::getStatus, Integer.valueOf(FeedbackDetailStatus.EFFECTED.getValue()))
                .eq(WorkstationFeedbackDetail::getCancel, Boolean.FALSE)
                .in(Func.isNotEmpty(queryDTO.getWorkstationGroupId()), WorkstationFeedbackDetail::getWorkstationId, this.workstationService
                  .getWorkstationByGroupIds(ListUtil.toList(new String[] { queryDTO.getWorkstationGroupId() })).stream().map(WorkstationVO::getId).collect(Collectors.toList()))
                
                .eq(Func.isNotEmpty(queryDTO.getWorkstationId()), WorkstationFeedbackDetail::getWorkstationId, queryDTO.getWorkstationId())
                .ge(Func.isNotEmpty(queryDTO.getStartDate()), WorkstationFeedbackDetail::getStartTime, queryDTO.getStartDate())
                .le(Func.isNotEmpty(queryDTO.getEndDate()), WorkstationFeedbackDetail::getEndTime, queryDTO.getEndDate())
                .in(Func.isNotEmpty(queryDTO.getFeedBackStatus()), WorkstationFeedbackDetail::getWcs, queryDTO.getFeedBackStatus())
                .nested(Func.isNotEmpty(queryDTO.getStartDate()), w -> w.apply(Func.isNotEmpty(queryDTO.getStartDate()), String.format("'%s' between start_time and end_time", new Object[] { queryDTO.getStartDate() }), new Object[0]).or().apply(Func.isNotEmpty(queryDTO.getEndDate()), String.format("'%s' between start_time and end_time", new Object[] { queryDTO.getEndDate() }), new Object[0]).orderByDesc(WorkstationFeedbackDetail::getStartTime)));
        /*
        IPage<WorkstationFeedbackDetail> page = this.detailService.page(Condition.getPage(query), (Wrapper) ((ExtraLambdaQueryWrapper) Lambda.eq((v0) -> {
            return v0.getStatus();
        }, Integer.valueOf(FeedbackDetailStatus.EFFECTED.getValue())).eq((v0) -> {
            return v0.getCancel();
        }, Boolean.FALSE)).in(Func.isNotEmpty(queryDTO.getWorkstationGroupId()), (v0) -> {
            return v0.getWorkstationId();
        }, (Collection) this.workstationService.getWorkstationByGroupIds(ListUtil.toList(new String[]{queryDTO.getWorkstationGroupId()})).stream().map((v0) -> {
            return v0.getId();
        }).collect(Collectors.toList())).eq(Func.isNotEmpty(queryDTO.getWorkstationId()), (v0) -> {
            return v0.getWorkstationId();
        }, queryDTO.getWorkstationId()).ge(Func.isNotEmpty(queryDTO.getStartDate()), (v0) -> {
            return v0.getStartTime();
        }, queryDTO.getStartDate()).le(Func.isNotEmpty(queryDTO.getEndDate()), (v0) -> {
            return v0.getEndTime();
        }, queryDTO.getEndDate()).in(Func.isNotEmpty(queryDTO.getFeedBackStatus()), (v0) -> {
            return v0.getWcs();
        }, queryDTO.getFeedBackStatus()).nested(Func.isNotEmpty(queryDTO.getStartDate()), w -> {
            ((ExtraLambdaQueryWrapper) w.apply(Func.isNotEmpty(queryDTO.getStartDate()), String.format("'%s' between start_time and end_time", queryDTO.getStartDate()), new Object[0]).or()).apply(Func.isNotEmpty(queryDTO.getEndDate()), String.format("'%s' between start_time and end_time", queryDTO.getEndDate()), new Object[0]);
        }).orderByDesc((v0) -> {
            return v0.getStartTime();
        }));*/
        return R.data(WorkstationFeedBackDetailWrapper.build().pageVO(page));
    }
 
    @DeleteMapping
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "批量撤销反馈", notes = "传入的是feedbackId")
    public R<Boolean> cancelWorkstationFeedbacks(@RequestBody List<String> ids) {
        return R.status(this.detailService.cancelWorkstationFeedbacks(ids));
    }
 
    @ApiOperationSupport(order = 2)
    @GetMapping({"/workingstation-feedback-info"})
    @ApiOperation("H5: 分页获取各个工位当前反馈信息")
    public R<IPage<WorkstationFeedbackInfoVO>> feedbackInfo(Query query, @RequestParam @ApiParam("排除持续反馈工位  true: 排除  false: 不排除") boolean excludeImmediate) {
        IPage<WorkstationFeedbackInfoVO> page = this.wcsFeedbackService.workstationPage(query, excludeImmediate);
        return R.data(page);
    }
 
    @PostMapping({"/start-feedback-by-immediate"})
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "H5: 状态即时反馈登记", notes = "工位即时反馈, 进行中的反馈")
    public R<Boolean> startFeedbackByImmediate(@Valid @RequestBody WorkstationImmediateFeedBackDTO immediateFeedBackDTO) {
        return R.status(this.wcsFeedbackService.startFeedbackByImmediate(immediateFeedBackDTO));
    }
 
    @PostMapping({"/start-feedback-by-no-immediate"})
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "H5: 时间段反馈", notes = "时间段反馈")
    public R<Boolean> startFeedbackByNoImmediate(@Validated @RequestBody WorkstationNoImmediateFeedBackDTO noImmediateFeedBackDTO) {
        if (noImmediateFeedBackDTO.getStartTime().compareTo(noImmediateFeedBackDTO.getEndTime()) >= 0) {
            throw new ServiceException("开始时间必须小于结束时间");
        }
        return R.status(this.wcsFeedbackService.startFeedbackByNoImmediate(noImmediateFeedBackDTO));
    }
 
    @PostMapping({"/overwrite-feedback-check"})
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "查询是否有覆盖的反馈", notes = "data true: 会覆盖反馈,提示 false: 不会覆盖反馈,不提示直接提交")
    public R<Boolean> overwriteFeedback(@Validated @RequestBody WorkstationNoImmediateFeedBackDTO noImmediateFeedBackDTO) {
        return R.data(Boolean.valueOf(this.detailService.overwriteFeedbackCheck(noImmediateFeedBackDTO)));
    }
 
    @ApiOperationSupport(order = RegionCache.VILLAGE_LEVEL)
    @PutMapping({"/end-feedback"})
    @ApiOperation(value = "H5: 结束反馈", notes = "结束指定工位进行中的反馈记录")
    public R<Boolean> endFeedback(@Valid @RequestBody WorkstationEndImmediateFeedBackDTO workstationEndImmediateFeedBackDTO) {
        return R.status(this.wcsFeedbackService.endFeedback(workstationEndImmediateFeedBackDTO));
    }
 
    @ApiOperationSupport(order = 6)
    @PutMapping({"/end-and-start-again-feedback"})
    @ApiOperation(value = "H5: 结束再次发起反馈", notes = "结束并再次发起反馈")
    public R<Boolean> endAndStartAgainFeedback(@Valid @RequestBody WorkstationEndAndStartImmediateFeedBackDTO endAgainFeedbackDTO) {
        return R.status(this.wcsFeedbackService.endAndStartAgainFeedback(endAgainFeedbackDTO));
    }
 
    @ApiOperationSupport(order = 7)
    @GetMapping({"/today-feedback"})
    @ApiOperation(value = "H5:今日反馈,历史反馈", notes = "查询工位今日反馈记录")
    public R<List<WorkstationFeedBackDetailVO>> todayFeedback(@RequestParam Long workstationId) {
        return R.data(WorkstationFeedBackDetailWrapper.build().listVO(this.detailService.todayFeedback(workstationId)));
    }
 
    @PostMapping({"/feedback-status"})
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "查询工位状态", notes = "查询是否有未计算的反馈记录, true:有正在计算的记录, false: 没有")
    public R<Boolean> feedbackStatus(@RequestBody List<Long> workstationIds) {
        Assert.notEmpty(workstationIds);
        boolean exist = (this.wcsFeedbackService.count(Lambda.in(WorkstationFeedback::getWorkstationId, workstationIds)
                .nested(w -> w.eq(WorkstationFeedback::getStatus, FeedbackStatus.SYNCING.getValue())
                        .or().eq(WorkstationFeedback::getStatus, FeedbackStatus.WAIT_SYNC.getValue()))) != 0);
        /*
        boolean exist = this.wcsFeedbackService.count((Wrapper) Lambda.in((v0) -> {
            return v0.getWorkstationId();
        }, workstationIds).nested(w -> {
            ExtraLambdaQueryWrapper extraLambdaQueryWrapper = (ExtraLambdaQueryWrapper) ((ExtraLambdaQueryWrapper) ((ExtraLambdaQueryWrapper) w.eq((v0) -> {
                return v0.getStatus();
            }, FeedbackStatus.SYNCING.getValue())).or()).eq((v0) -> {
                return v0.getStatus();
            }, FeedbackStatus.WAIT_SYNC.getValue());
        })) != 0;*/
        return R.data(Boolean.valueOf(exist));
    }
}