shicf
2024-08-23 2fef20fe45a1fc901b51243bcc60682524447990
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
package com.product.device.controller;
 
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import com.product.device.config.DeviceCode;
import com.product.module.sys.version.ApiVersion;
import com.product.util.BaseUtil;
import com.product.util.support.AbstractBaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
 
import com.product.device.service.DeviceMainenanceService;
 
import javax.servlet.http.HttpServletRequest;
 
/**
 * 设备保养
 */
@RestController
@RequestMapping("/api/device/maintenance")
public class DeviceMaintenanceController extends AbstractBaseController {
    @Autowired
    DeviceMainenanceService deviceMainenanceService;
 
 
    @PostMapping("/{version}")
    @ApiVersion(1)
    public String getMaintainByCurrentYear(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            return OK_List(deviceMainenanceService.getMaintainByCurrentYear(fse));
        } catch (BaseException e) {
            return error(e);
        } catch (Exception e) {
            return error(DeviceCode.COMMON_DATA_ERROR, e);
        }
    }
 
    @PostMapping("/month/{version}")
    @ApiVersion(1)
    public String getMaintainMonth(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            return OK_List(deviceMainenanceService.getMaintainMonth(fse));
        } catch (BaseException e) {
            return error(e);
        } catch (Exception e) {
            return error(DeviceCode.COMMON_DATA_ERROR, e);
        }
    }
 
    /**
     * 复核维保记录
     *
     * @param request
     * @return
     */
    @PostMapping("/review/{version}")
    @ApiVersion(1)
    public String reviewRecord(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            if (!deviceMainenanceService.maintenanceReview(fse)) {
                //更新失败
                return error(DeviceCode.DEVICE_MAINTENANCE_REVIEW_FAIL);
            }
            return OK();
        } catch (BaseException e) {
            return error(e);
        } catch (Exception e) {
            return error(DeviceCode.COMMON_DATA_ERROR, e);
        }
    }
 
    /**
     * 维保单位年度维保统计
     * @param request
     * @return
     */
    @PostMapping("/year-maintenance/{version}")
    @ApiVersion(1)
    public String yearMaintenance(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            return OK_List(deviceMainenanceService.yearMaintenance(fse));
        } catch (BaseException e) {
            return error(e);
        } catch (Exception e) {
            return error(DeviceCode.DEVICE_MAINTENANCE_YEAR_FAIL, e);
        }
    }
 
    /**
     * 维保单位年度维保任务完成情况
     * @param request
     * @return
     */
    @PostMapping("/year-maintenance-finish/{version}")
    @ApiVersion(1)
    public String yearMaintenanceFinish(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            return OK_List(deviceMainenanceService.yearMaintenanceFinish(fse));
        } catch (BaseException e) {
            return error(e);
        } catch (Exception e) {
            return error(DeviceCode.DEVICE_MAINTENANCE_YEAR_FINISH_FAIL, e);
        }
    }
}