package cn.cecep.talroad.controller.callback;

import cn.cecep.talroad.common.core.web.controller.BasesController;
import cn.cecep.talroad.common.core.web.domain.AjaxResults;
import cn.cecep.talroad.domain.AmProblemFiProcess;
import cn.cecep.talroad.service.IAmProblemFiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
//import org.junit.jupiter.api.Disabled;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Api(tags = "预警报警信息回调")
@RestController
@RequestMapping("/callback/amProblemFi")
public class AmProblemFiCallbackController extends BasesController {
    @Autowired
    private IAmProblemFiService amProblemFiService;


    @ApiOperation(value = "审核结果回调--new")
    @PostMapping(value = "/rectify/required")
    public AjaxResults rectifyRequired(@RequestBody @Validated AmProblemFiProcess param) {
//        amProblemFiService.rectifyRequired(param);
        logger.info("审核结果回调--new---远程来客::"+param);
        //因为先河审核结果跟咱们系统相反，故进行转换
        param.setAuditResult( param.getAuditResult().replace("1", "temp").
                replace("2", "1").replace("temp", "2"));
        amProblemFiService.auditResult(param);
        return AjaxResults.success();
    }

    @ApiOperation(value = "审核结果回调")
    @PostMapping(value = "/audit/result")
//    @Disabled
    public AjaxResults auditResult(@RequestBody @Validated AmProblemFiProcess param) {
        amProblemFiService.auditResult(param);
        return AjaxResults.success();
    }
}
