xuhy
2025-04-25 b2690b02f12d529ec7bb45e059c6d2eef59b7f2c
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
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.framework.web.service.TokenService;
import com.ruoyi.system.dto.TExperimentResultReportDTO;
import com.ruoyi.system.model.TExperimentResultReport;
import com.ruoyi.system.model.TExperimentScheme;
import com.ruoyi.system.model.TInspectionReport;
import com.ruoyi.system.model.TResultWorkEvaluate;
import com.ruoyi.system.query.TExperimentResultReportQuery;
import com.ruoyi.system.service.*;
import com.ruoyi.system.vo.TExperimentResultReportVO;
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.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * <p>
 * 实验结果汇报 前端控制器
 * </p>
 *
 * @author xiaochen
 * @since 2025-04-08
 */
@Api(tags = "实验结果汇报")
@RestController
@RequestMapping("")
public class TExperimentResultReportController {
 
    private final TExperimentResultReportService experimentResultReportService;
    private final TokenService tokenService;
    private final ISysUserService sysUserService;
    private final TResultWorkEvaluateService resultWorkEvaluateService;
    private final TExperimentSchemeService experimentSchemeService;
    private final TInspectionReportService inspectionReportService;
    @Autowired
    public TExperimentResultReportController(TExperimentResultReportService experimentResultReportService, TokenService tokenService, ISysUserService sysUserService, TResultWorkEvaluateService resultWorkEvaluateService, TExperimentSchemeService experimentSchemeService, TInspectionReportService inspectionReportService) {
        this.experimentResultReportService = experimentResultReportService;
        this.tokenService = tokenService;
        this.sysUserService = sysUserService;
        this.resultWorkEvaluateService = resultWorkEvaluateService;
        this.experimentSchemeService = experimentSchemeService;
        this.inspectionReportService = inspectionReportService;
    }
 
    /**
     * 获取实验结果汇报管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:experimentResultReport:list')")
    @ApiOperation(value = "获取实验结果汇报分页列表")
    @PostMapping(value = "/api/t-experiment-result-report/pageList")
    public R<PageInfo<TExperimentResultReportVO>> pageList(@RequestBody String param) {
        TExperimentResultReportQuery query = JSON.parseObject(param, TExperimentResultReportQuery.class);
        return R.ok(experimentResultReportService.pageList(query));
    }
 
    /**
     * 添加实验结果汇报管理
     */
    @PreAuthorize("@ss.hasPermi('system:experimentResultReport:add')")
    @Log(title = "实验结果汇报信息-新增实验结果汇报", businessType = BusinessType.INSERT)
    @ApiOperation(value = "添加实验结果汇报",response = TExperimentResultReportDTO.class)
    @PostMapping(value = "/api/t-experiment-result-report/add")
    public R<Boolean> add(@RequestBody String param) {
        TExperimentResultReportDTO dto = JSON.parseObject(param,TExperimentResultReportDTO.class);
        experimentResultReportService.save(dto);
        // 添加实验结果工作评价
        List<TResultWorkEvaluate> resultWorkEvaluates = dto.getResultWorkEvaluates();
        for (TResultWorkEvaluate resultWorkEvaluate : resultWorkEvaluates) {
            resultWorkEvaluate.setResultReportId(dto.getId());
        }
        resultWorkEvaluateService.saveBatch(resultWorkEvaluates);
        return R.ok();
    }
 
    /**
     * 修改实验结果汇报
     */
    @PreAuthorize("@ss.hasPermi('system:experimentResultReport:edit')")
    @Log(title = "实验结果汇报信息-修改实验结果汇报", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改实验结果汇报")
    @PostMapping(value = "/api/t-experiment-result-report/update")
    public R<Boolean> update(@RequestBody String param) {
        TExperimentResultReportDTO dto = JSON.parseObject(param,TExperimentResultReportDTO.class);
        experimentResultReportService.updateById(dto);
        // 修改实验结果工作评价
        List<TResultWorkEvaluate> resultWorkEvaluates = dto.getResultWorkEvaluates();
        resultWorkEvaluateService.updateBatchById(resultWorkEvaluates);
        return R.ok();
    }
 
    /**
     * 修改实验结果汇报
     */
    @PreAuthorize("@ss.hasPermi('system:experimentResultReport:edit')")
    @Log(title = "实验结果汇报信息-评定工艺工程师实验", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "评定工艺工程师实验")
    @PostMapping(value = "/api/t-experiment-result-report/evaluateProcess")
    public R<Boolean> evaluateProcess(@RequestBody String param) {
        TResultWorkEvaluate resultWorkEvaluate = JSON.parseObject(param,TResultWorkEvaluate.class);
        resultWorkEvaluateService.save(resultWorkEvaluate);
        return R.ok();
    }
 
    /**
     * 查看实验结果汇报详情
     */
    @PreAuthorize("@ss.hasPermi('system:experimentResultReport:detail')")
    @ApiOperation(value = "查看实验结果汇报详情")
    @GetMapping(value = "/open/t-experiment-result-report/getDetailById")
    public R<TExperimentResultReportVO> getDetailById(@RequestParam String id) {
        TExperimentResultReport experimentResultReport = experimentResultReportService.getById(id);
        TExperimentResultReportVO experimentResultReportVO = new TExperimentResultReportVO();
        BeanUtils.copyProperties(experimentResultReport, experimentResultReportVO);
        // 获取评分列表
        List<TResultWorkEvaluate> resultWorkEvaluates = resultWorkEvaluateService.list(Wrappers.lambdaQuery(TResultWorkEvaluate.class)
                .eq(TResultWorkEvaluate::getResultReportId, id));
        experimentResultReportVO.setResultWorkEvaluates(resultWorkEvaluates);
        // 查询实验结果列表
        List<TExperimentScheme> experimentSchemes = experimentSchemeService.list(Wrappers.lambdaQuery(TExperimentScheme.class)
                .eq(TExperimentScheme::getDispatchId, experimentResultReport.getDispatchId()));
        experimentResultReportVO.setExperimentSchemes(experimentSchemes);
        // 查询检验报告列表
        List<TInspectionReport> inspectionReports = inspectionReportService.list(Wrappers.lambdaQuery(TInspectionReport.class)
                .eq(TInspectionReport::getDispatchId, experimentResultReport.getDispatchId()));
        experimentResultReportVO.setInspectionReports(inspectionReports);
        return R.ok(experimentResultReportVO);
    }
 
    /**
     * 删除实验结果汇报
     */
    @PreAuthorize("@ss.hasPermi('system:experimentResultReport:delete')")
    @Log(title = "实验结果汇报信息-删除实验结果汇报", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除实验结果汇报")
    @DeleteMapping(value = "/open/t-experiment-result-report/deleteById")
    public R<Boolean> deleteById(@RequestParam String id) {
        return R.ok(experimentResultReportService.removeById(id));
    }
 
    /**
     * 批量删除实验结果汇报
     */
    @PreAuthorize("@ss.hasPermi('system:experimentResultReport:delete')")
    @Log(title = "实验结果汇报信息-删除实验结果汇报", businessType = BusinessType.DELETE)
    @ApiOperation(value = "批量删除实验结果汇报")
    @DeleteMapping(value = "/open/t-experiment-result-report/deleteByIds")
    public R<Boolean> deleteByIds(@RequestBody List<String> ids) {
        return R.ok(experimentResultReportService.removeByIds(ids));
    }
 
}