cheng
2024-01-16 7279b6314b350cc0c865d82dbaa4d0624e4f7b3f
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.data.center.controller;
 
import com.product.common.enums.IEnum;
import com.product.core.controller.support.AbstractBaseController;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import com.product.data.center.config.ErrorCode;
import com.product.data.center.service.ProductionRealTimeInfoService;
import com.product.module.sys.version.ApiVersion;
import com.product.util.BaseUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
/**
 * @Author cheng
 * @Date 2022/11/14 17:57
 * @Desc 生产实时信息 report
 */
@RestController
@RequestMapping("/api/report/production-real-time")
public class ProductionRealTimeInfoController extends AbstractBaseController {
 
    @Resource
    ProductionRealTimeInfoService productionRealTimeInfoService;
 
    @PostMapping("/excel/{version}")
    @ApiVersion(1)
    public String getReportExcel(HttpServletRequest request, HttpServletResponse response) {
        try {
            productionRealTimeInfoService.getReportExcel(request, response);
            return OK();
        } catch (Exception e) {
            e.printStackTrace();
            return error(ErrorCode.EXPORT_EXCEL_FAIL.getValue(), getErrorMessage(ErrorCode.EXPORT_EXCEL_FAIL, e));
        }
    }
 
    /**
     * 制造指令单
     *
     * @param request
     * @return
     */
    @PostMapping("/manufacture-command-sheet/{version}")
    @ApiVersion(1)
    public String getManufacturingCommandSheet(HttpServletRequest request) {
        FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
        try {
            return OK_List(productionRealTimeInfoService.getManufacturingCommandSheet(fse));
        } catch (Exception e) {
            e.printStackTrace();
            return error(ErrorCode.REPORT_SELECT_FAIL.getValue(), getErrorMessage(ErrorCode.REPORT_SELECT_FAIL, e));
        }
    }
 
    @PostMapping("/process-list/{version}")
    @ApiVersion(1)
    public String getProcessList() {
        try {
            return OK_List(productionRealTimeInfoService.getProcessList());
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(ErrorCode.PROCESS_LIST_GET_FAIL.getValue(), getErrorMessage(ErrorCode.PROCESS_LIST_GET_FAIL, e));
        }
    }
 
    @PostMapping("/process/{version}")
    @ApiVersion(1)
    public String getProcessReport(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            return OK_List(productionRealTimeInfoService.getProcessSheet(fse));
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(ErrorCode.PROCESS_REPORT_GET_FAIL.getValue(), getErrorMessage(ErrorCode.PROCESS_REPORT_GET_FAIL, e));
        }
    }
 
    @PostMapping("/product/{version}")
    @ApiVersion(1)
    public String getProductReport(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            return OK_List(productionRealTimeInfoService.getProductSheet(fse));
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(ErrorCode.PRODUCT_REPORT_GET_FAIL.getValue(), getErrorMessage(ErrorCode.PRODUCT_REPORT_GET_FAIL, e));
        }
    }
 
    public String getErrorMessage(IEnum iEnum, Throwable throwable) {
        String message = iEnum.getText();
        if (throwable.getMessage() != null) {
            message += "," + throwable.getMessage();
        }
        return message;
    }
}