zss
6 天以前 51ec98113c6d49d0f7eec4e3c030e55e337e97db
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
package com.yuanchu.mom.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.annotation.CustomClazzName;
import com.yuanchu.mom.annotation.ValueAuth;
import com.yuanchu.mom.dto.FePowerStableAddDto;
import com.yuanchu.mom.dto.FePowerStableDto;
import com.yuanchu.mom.pojo.FeMeasuredQuantity;
import com.yuanchu.mom.pojo.FePowerStable;
import com.yuanchu.mom.service.FeMeasuredQuantityService;
import com.yuanchu.mom.service.FePowerStableService;
import com.yuanchu.mom.vo.Result;
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 javax.servlet.http.HttpServletResponse;
 
/**
 * <p>
 * 设施和环境条件-设施和环境条件要求-电源稳定性 前端控制器
 * </p>
 *
 * @author
 * @since 2024-11-07 04:16:52
 */
@Api(tags = "设施和环境条件-设施和环境条件要求-电源稳定性")
@RestController
@RequestMapping("/fePowerStable")
public class FePowerStableController {
 
    @Autowired
    private FeMeasuredQuantityService feMeasuredQuantityService;
 
    @Autowired
    private FePowerStableService fePowerStableService;
 
    @PostMapping("addLaboratoryFacilityPowerStable")
    @ApiOperation("电源稳定性新增/修改")
    public Result<?> addLaboratoryFacilityPowerStable(@RequestBody FePowerStableAddDto fePowerStableAddDto) {
        FePowerStable fePowerStable = new FePowerStable();
        BeanUtils.copyProperties(fePowerStableAddDto, fePowerStable);
        fePowerStableService.saveOrUpdate(fePowerStable);
        fePowerStableAddDto.getFeMeasuredQuantityList().forEach(i -> i.setPowerStableId(fePowerStable.getPowerStableId()));
        feMeasuredQuantityService.saveOrUpdateBatch(fePowerStableAddDto.getFeMeasuredQuantityList());
        return Result.success();
    }
 
    @DeleteMapping("deleteLaboratoryFacilityPowerStable")
    @ApiOperation("电源稳定性删除")
    public Result<FePowerStable> deleteLaboratoryFacilityPowerStable(@RequestParam("powerStableId") Integer powerStableId) {
        fePowerStableService.removeById(powerStableId);
        feMeasuredQuantityService.remove(Wrappers.<FeMeasuredQuantity>lambdaQuery()
                .eq(FeMeasuredQuantity::getPowerStableId, powerStableId));
        return Result.success();
    }
 
    @GetMapping("getLaboratoryFacilityPowerStablePage")
    @ApiOperation("电源稳定性查询")
    public Result<IPage<FePowerStableDto>> getLaboratoryFacilityPowerStablePage(
            Page page) {
        IPage<FePowerStableDto> page1 = fePowerStableService.getLaboratoryFacilityPowerStablePage(page);
        return Result.success(page1);
    }
 
    @ValueAuth
    @ApiOperation("选择设备后查询最新设备编号,校准日期")
    @GetMapping("getCalibrationDate")
    public Result<?> getCalibrationDate(@RequestParam("deviceId") Integer deviceId) {
        return Result.success(fePowerStableService.getCalibrationDate(deviceId));
    }
 
    @DeleteMapping("deleteFeMeasuredQuantity")
    @ApiOperation("电源稳定性-测定量 删除")
    public Result<?> deleteFeMeasuredQuantity(@RequestParam("measuredQuantityId") Integer measuredQuantityId) {
        return Result.success(feMeasuredQuantityService.removeById(measuredQuantityId));
    }
 
    @GetMapping("getFeMeasuredQuantityService")
    @ApiOperation("电源稳定性-测定量 根据电源稳定性查询")
    public Result<?> getFeMeasuredQuantityService(@RequestParam("powerStableId") Integer powerStableId) {
        return Result.success(feMeasuredQuantityService.list(Wrappers.<FeMeasuredQuantity>lambdaQuery()
                .eq(FeMeasuredQuantity::getPowerStableId, powerStableId)));
    }
 
    /**
     * 导出电源稳定性
     * @return
     */
    @ValueAuth
    @ApiOperation(value = "导出电源稳定性")
    @GetMapping("/exportFePowerStable")
    public void exportFePowerStable(Integer powerStableId, HttpServletResponse response){
        fePowerStableService.exportFePowerStable(powerStableId, response);
    }
}