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