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;
|
}
|
}
|