无关风月
2 天以前 0b4f853f6b05b28e3201386bdda3e8af0bfcfc7f
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
package com.ruoyi.web.controller.api;
 
 
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.enums.QATestItemStatusEnum;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.dto.TQaTestItemDTO;
import com.ruoyi.system.dto.TQaTestItemEvaluateDTO;
import com.ruoyi.system.model.TProjectTeamStaff;
import com.ruoyi.system.model.TQaTestItem;
import com.ruoyi.system.model.TQaTestItemReport;
import com.ruoyi.system.query.TQaTestItemQuery;
import com.ruoyi.system.service.TProjectTeamService;
import com.ruoyi.system.service.TProjectTeamStaffService;
import com.ruoyi.system.service.TQaTestItemReportService;
import com.ruoyi.system.service.TQaTestItemService;
import com.ruoyi.system.vo.TQaTestItemReportVO;
import com.ruoyi.system.vo.TQaTestItemVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * <p>
 * QA检测项 前端控制器
 * </p>
 *
 * @author xiaochen
 * @since 2025-04-08
 */
@Api(tags = "QA检测项管理")
@RestController
@RequestMapping("")
public class TQaTestItemController {
 
    private final TQaTestItemService qaTestItemService;
    private final TQaTestItemReportService qaTestItemReportService;
    private final TokenService tokenService;
    private final TProjectTeamService projectTeamService;
    private final TProjectTeamStaffService projectTeamStaffService;
    @Autowired
    public TQaTestItemController(TQaTestItemService qaTestItemService, TQaTestItemReportService qaTestItemReportService, TokenService tokenService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService) {
        this.qaTestItemService = qaTestItemService;
        this.qaTestItemReportService = qaTestItemReportService;
        this.tokenService = tokenService;
        this.projectTeamService = projectTeamService;
        this.projectTeamStaffService = projectTeamStaffService;
    }
 
    /**
     * 获取QA检测项管理管理列表
     */
    //@PreAuthorize("@ss.hasPermi('system:qaTestItem:list')")
    @ApiOperation(value = "获取QA检测项管理分页列表",  response = TQaTestItemQuery.class)
    @PostMapping(value = "/api/t-qa-test-item/pageList")
    public R<PageInfo<TQaTestItemVO>> pageList(@RequestBody String param) {
        TQaTestItemQuery query = JSON.parseObject(param, TQaTestItemQuery.class);
        Long userId = tokenService.getLoginUser().getUserId();
        Integer roleType = tokenService.getLoginUser().getUser().getRoleType();
        if(roleType != 1){
            // 查询用户所在项目组
            List<TProjectTeamStaff> projectTeamStaffs = projectTeamStaffService.list(Wrappers.lambdaQuery(TProjectTeamStaff.class)
                    .eq(TProjectTeamStaff::getUserId, userId));
            if(projectTeamStaffs.size() > 0){
                // 查询项目组id
                List<String> teamIds = projectTeamStaffs.stream().map(TProjectTeamStaff::getTeamId).distinct().collect(Collectors.toList());
                query.setTeamIds(teamIds);
            }
        }
        return R.ok(qaTestItemService.pageList(query));
    }
 
    /**
     * 获取QA检测项管理评定列表
     */
    //@PreAuthorize("@ss.hasPermi('system:qaTestItem:evaluateList')")
    @ApiOperation(value = "获取QA检测项管理评定列表",  response = TQaTestItemQuery.class)
    @PostMapping(value = "/api/t-qa-test-item/evaluateList")
    public R<PageInfo<TQaTestItemVO>> evaluateList(@RequestBody String param) {
        TQaTestItemQuery query = JSON.parseObject(param, TQaTestItemQuery.class);
        Long userId = tokenService.getLoginUser().getUserId();
        Integer roleType = tokenService.getLoginUser().getUser().getRoleType();
        if(roleType != 1){
            // 查询用户所在项目组
            List<TProjectTeamStaff> projectTeamStaffs = projectTeamStaffService.list(Wrappers.lambdaQuery(TProjectTeamStaff.class)
                    .eq(TProjectTeamStaff::getUserId, userId));
            if(projectTeamStaffs.size() > 0){
                // 查询项目组id
                List<String> teamIds = projectTeamStaffs.stream().map(TProjectTeamStaff::getTeamId).distinct().collect(Collectors.toList());
                query.setTeamIds(teamIds);
            }
        }
        return R.ok(qaTestItemService.evaluateList(query));
    }
 
    /**
     * 添加QA检测项管理管理
     */
    //@PreAuthorize("@ss.hasPermi('system:qaTestItem:add')")
    @Log(title = "QA检测项管理信息-新增QA检测项管理", businessType = BusinessType.INSERT)
    @ApiOperation(value = "添加QA检测项管理",response = TQaTestItemDTO.class)
    @PostMapping(value = "/api/t-qa-test-item/add")
    public R<Boolean> add(@RequestBody String param) {
        TQaTestItemDTO dto = JSON.parseObject(param,TQaTestItemDTO.class);
        qaTestItemService.save(dto);
        return R.ok();
    }
 
    /**
     * 修改QA检测项管理
     */
    //@PreAuthorize("@ss.hasPermi('system:qaTestItem:edit')")
    @Log(title = "QA检测项管理信息-修改QA检测项管理", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改QA检测项管理")
    @PostMapping(value = "/api/t-qa-test-item/update")
    public R<Boolean> update(@RequestBody String param) {
        TQaTestItemDTO dto = JSON.parseObject(param,TQaTestItemDTO.class);
        qaTestItemService.updateById(dto);
        return R.ok();
    }
 
    /**
     * 查看QA检测项管理详情
     */
    //@PreAuthorize("@ss.hasPermi('system:qaTestItem:detail')")
    @ApiOperation(value = "查看QA检测项管理详情")
    @GetMapping(value = "/open/t-qa-test-item/getDetailById")
    public R<TQaTestItemVO> getDetailById(@RequestParam String id) {
        TQaTestItem testItem = qaTestItemService.getById(id);
        TQaTestItemVO testItemVO = new TQaTestItemVO();
        BeanUtils.copyProperties(testItem, testItemVO);
        // 查询QA检测项检测报告
        List<TQaTestItemReportVO> qaTestItemReportVOS= qaTestItemReportService.getList(id);
        testItemVO.setQaTestItemReportList(qaTestItemReportVOS);
        return R.ok(testItemVO);
    }
 
    /**
     * 删除QA检测项管理
     */
    //@PreAuthorize("@ss.hasPermi('system:qaTestItem:delete')")
    @Log(title = "QA检测项管理信息-删除QA检测项管理", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除QA检测项管理")
    @DeleteMapping(value = "/open/t-qa-test-item/deleteById")
    public R<Boolean> deleteById(@RequestParam String id) {
        // 删除QA检测项管理成员
        qaTestItemReportService.remove(Wrappers.lambdaQuery(TQaTestItemReport.class).eq(TQaTestItemReport::getItemId, id));
        return R.ok(qaTestItemService.removeById(id));
    }
 
    /**
     * 批量删除QA检测项管理
     */
    //@PreAuthorize("@ss.hasPermi('system:qaTestItem:delete')")
    @Log(title = "QA检测项管理信息-删除QA检测项管理", businessType = BusinessType.DELETE)
    @ApiOperation(value = "批量删除QA检测项管理")
    @DeleteMapping(value = "/open/t-qa-test-item/deleteByIds")
    public R<Boolean> deleteByIds(@RequestBody List<String> ids) {
        // 删除QA检测项检测报告
        qaTestItemReportService.remove(Wrappers.lambdaQuery(TQaTestItemReport.class).in(TQaTestItemReport::getItemId, ids));
        return R.ok(qaTestItemService.removeByIds(ids));
    }
 
    /**
     * 修改QA检测项管理
     */
    //@PreAuthorize("@ss.hasPermi('system:qaTestItem:commitEvaluate')")
    @Log(title = "QA检测项管理信息-提交评价QA检测项管理状态", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改QA检测项管理状态")
    @PutMapping(value = "/open/t-qa-test-item/commitEvaluate")
    public R<Boolean> commitEvaluate(@RequestParam String id) {
        TQaTestItem testItem = qaTestItemService.getById(id);
        testItem.setStatus(QATestItemStatusEnum.TO_BE_EVALUATED.getCode());
        qaTestItemService.updateById(testItem);
        return R.ok();
    }
 
    /**
     * 评定QA检测项管理
     */
    //@PreAuthorize("@ss.hasPermi('system:qaTestItem:evaluate')")
    @Log(title = "QA检测项管理信息-评定QA检测项管理", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "评定QA检测项管理",response = TQaTestItemEvaluateDTO.class)
    @PostMapping(value = "/api/t-qa-test-item/evaluate")
    public R<Boolean> evaluate(@RequestBody String param) {
        TQaTestItemEvaluateDTO dto = JSON.parseObject(param,TQaTestItemEvaluateDTO.class);
        Long userId = tokenService.getLoginUser().getUserId();
        TQaTestItem testItem = qaTestItemService.getById(dto);
        testItem.setStatus(QATestItemStatusEnum.EVALUATED.getCode());
        testItem.setEvaluatePersonId(userId);
        testItem.setEvaluateTime(LocalDateTime.now());
        testItem.setEvaluateScore(dto.getEvaluateScore());
        qaTestItemService.updateById(testItem);
        return R.ok();
    }
 
}