package com.usky.fire.controller.web;


import com.usky.common.log.annotation.Log;
import com.usky.common.log.enums.BusinessType;
import com.usky.fire.domain.DemReformReview;
import com.usky.fire.service.vo.DemFireReformVO;
import com.usky.fire.service.vo.DemReformReviewMaterialVO;
import com.usky.fire.service.vo.MobileScheduleVO;
import com.usky.fire.service.vo.UpdateReformReviewVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.usky.fire.service.DemFireReformService;
import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;

import java.util.Map;
import java.util.List;
/**
 * <p>
 * 消防整改数据表 前端控制器
 * </p>
 *
 * @author ZYJ
 * @since 2023-02-24
 */
@RestController
@RequestMapping("/demFireReform")
public class DemFireReformController {

    @Autowired
    private DemFireReformService demFireReformService;

    /**
     * 重点单位信息-消防整改审核-列表查询
     *
     * @param companyName 单位名称
     * @param reformId   整改单编号
     * @param companyType  单位类型（1：重点单位、2：一般单位、3：九小场所、9：其他单位）
     * @param pageNum   当前页
     * @param pageSize   每页条数
     * @return
     */
    @GetMapping("fireReformList")
    public ApiResult<CommonPage<DemFireReformVO>> fireReformList(@RequestParam(value = "companyName",required = false) String companyName,
                                                                 @RequestParam(value = "reformId",required = false) String reformId,
                                                                 @RequestParam(value = "companyType",required = false) Integer companyType,
                                                                 @RequestParam(value = "pageNum",required = false,defaultValue = "1") Integer pageNum,
                                                                 @RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize){
        return ApiResult.success(demFireReformService.fireReformList(companyName, reformId, companyType, pageNum, pageSize));
    }

    /**
     * 移动端-消防整改-待办事项列表查询
     *
     * @param companyId  单位编号
     * @param reformId   整改单编号
     * @param reformStatus 整改状态（1 已接收、2 整改中、3 整改完成、4 审核不通过、5 审核通过）
     * @param pageNum   当前页
     * @param pageSize   每页条数
     * @return
     */
    @GetMapping("mobileScheduleList")
    public ApiResult<CommonPage<MobileScheduleVO>> mobileScheduleList(@RequestParam(value = "companyId", required = false) String companyId,
                                                                      @RequestParam(value = "reformId", required = false) String reformId,
                                                                      @RequestParam(value = "reformStatus", required = false) Integer reformStatus,
                                                                      @RequestParam(value = "pageNum",required = false,defaultValue = "1") Integer pageNum,
                                                                      @RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize){
        return ApiResult.success(demFireReformService.mobileScheduleList(companyId, reformId, reformStatus, pageNum, pageSize));
    }


    /**
     * 重点单位信息-消防整改审核-审核/查看资料
     *
     * @param reformId  整改单编号
     * @return
     */
    @GetMapping("reformReview")
    public ApiResult<List<Map<String,Object>>> reformView(@RequestParam(value = "reformId") String reformId){
        return ApiResult.success(demFireReformService.reformReview(reformId));
    }

    /**
     * 重点单位信息-消防整改审核-通过/不通过
     *
     * @param updateReformReviewVO
     * @return
     */
    @Log(title = "重点单位信息-消防整改审核-通过/不通过", businessType = BusinessType.UPDATE)
    @PutMapping("updateReformReview")
    public ApiResult<Void> updateReformReview(@RequestBody UpdateReformReviewVO updateReformReviewVO){
        demFireReformService.updateReformReview(updateReformReviewVO);

        return ApiResult.success();
    }

    /**
     * 移动端-消防整改-去整改
     *
     * @param reformId 整改单编号
     * @return
     */
    @Log(title="移动端-消防整改-去整改", businessType = BusinessType.UPDATE)
    @PutMapping("updateMobileReformStatus")
    public ApiResult<Void> updateMobileReformStatus(@RequestParam(value="reformId") String reformId){
        demFireReformService.updateMobileReformStatus(reformId);
        return ApiResult.success();
    }

    /**
     * 移动端-消防整改-待办事项上传整改资料
     *
     * @param
     * @return
     */
    @PostMapping("addReformMaterial")
    public ApiResult<Void> addReformMaterial(@RequestBody DemReformReviewMaterialVO demReformReviewMaterialVO){
        demFireReformService.addReformMaterial(demReformReviewMaterialVO);
        return ApiResult.success();
    }
}

