package com.njcn.harmonic.controller.upload;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.LogUtil;
import com.njcn.harmonic.pojo.param.upload.RUploadWorkOrderParam;
import com.njcn.harmonic.pojo.po.upload.RUploadWorkOrderPO;
import com.njcn.harmonic.service.upload.IRUploadWorkOrderService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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;
import com.njcn.web.controller.BaseController;

import java.util.List;


/**
 * <p>
 * 用于存储总部下发的工单信息 前端控制器
 * </p>
 *
 * @author cdf
 * @since 2024-06-18
 */
@RestController
@RequestMapping("/pms-tech-powerquality-start/pqWorkorderDistributeSuperviseController/")
@RequiredArgsConstructor
@Slf4j
public class RUploadWorkOrderController extends BaseController {

    private final IRUploadWorkOrderService irUploadWorkOrderService;

    /**
     * 用于总部调用省级下发工单信息(总部调用)
     * @author cdf
     * @date 2024/6/18
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
    @PostMapping("/insertWorkorderDistributeSupervise")
    @ApiOperation("用于总部调用省级下发工单信息")
    @ApiImplicitParam(name = "param", value = "实体参数", required = true)
    public HttpResult<Object> insertWorkorderDistributeSupervise(@RequestBody RUploadWorkOrderParam param) {
        String methodDescribe = getMethodDescribe("insertWorkorderDistributeSupervise");
        LogUtil.njcnDebug(log, "{}，实体参数：{}", methodDescribe, param);
        boolean result = irUploadWorkOrderService.insertWorkorderDistributeSupervise(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }


    /**
     * 总部下发工单后的闭环操作(总部调用)
     * @author cdf
     * @date 2024/6/18
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.UPDATE)
    @PostMapping("/closeWorkorderDistributeSupervise")
    @ApiOperation("总部下发工单后的闭环操作")
    @ApiImplicitParam(name = "param", value = "实体参数", required = true)
    public HttpResult<Object> closeWorkorderDistributeSupervise(@RequestBody RUploadWorkOrderParam param) {
        String methodDescribe = getMethodDescribe("closeWorkorderDistributeSupervise");
        LogUtil.njcnDebug(log, "{}，实体参数：{}", methodDescribe, param);
        boolean result = irUploadWorkOrderService.closeWorkorderDistributeSupervise(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }



    /**
     * 调用总部反馈接口(总部调用)
     * @author cdf
     * @date 2024/6/18
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/receiveFeedbackInfo")
    @ApiOperation("上送反馈工单处理措施")
    @ApiImplicitParam(name = "ids", value = "工单主键", required = true)
    public HttpResult<Object> receiveFeedbackInfo(@RequestBody List<String> ids) {
        String methodDescribe = getMethodDescribe("receiveFeedbackInfo");
        LogUtil.njcnDebug(log, "{}，实体参数：{}", methodDescribe, ids);
        boolean result = irUploadWorkOrderService.receiveFeedbackInfo(ids);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }


    /**
     * 分页查询
     * @author cdf
     * @date 2024/6/18
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/pageList")
    @ApiOperation("分页查询工单")
    @ApiImplicitParam(name = "rUploadWorkOrderQuery", value = "请求参数", required = true)
    public HttpResult<Page<RUploadWorkOrderPO>> pageList(@RequestBody RUploadWorkOrderParam.RUploadWorkOrderQuery rUploadWorkOrderQuery) {
        String methodDescribe = getMethodDescribe("pageList");
        Page<RUploadWorkOrderPO> result = irUploadWorkOrderService.pageList(rUploadWorkOrderQuery);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }


    /**
     * 填写反馈措施
     * @author cdf
     * @date 2024/6/18
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.UPDATE)
    @PostMapping("/feedBackAdd")
    @ApiOperation("填写反馈措施")
    @ApiImplicitParam(name = "param", value = "实体参数", required = true)
    public HttpResult<Object> feedBackAdd(@RequestBody RUploadWorkOrderParam param) {
        String methodDescribe = getMethodDescribe("feedBackAdd");
        LogUtil.njcnDebug(log, "{}，实体参数：{}", methodDescribe, param);
        boolean result = irUploadWorkOrderService.feedBackAdd(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }


}

