package com.rongwei.controller;


import com.bsentity.domain.FsFileDataListDo;
import com.bsentity.dto.RemindDto;
import com.bsentity.vo.CloseProcVo;
import com.bsentity.vo.FsFileFormVo;
import com.rongwei.bscommon.sys.service.FsFileDataListService;
import com.rongwei.rwcommon.base.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * 奥克宁可——文件清单 前端控制器
 * </p>
 *
 * @author trj
 * @since 2023-07-17
 */
@RestController
@RequestMapping("/fsFileDataListDo")
public class FsFileDataListController {

    @Autowired
    private FsFileDataListService fileDataListService;
    private final Logger log = LoggerFactory.getLogger(FsFileDataListController.class.getName());

    /**
     * 定时任务，所有生效文件进行回顾
     *
     * @return
     */
    @PostMapping("/updateReviewByAll")
    public R updateReviewByAll() {
        log.info("进入接口：fsFileDataListDo/updateReviewByAll");

        return fileDataListService.updateReviewByAll();
    }

    /**
     * 预警提醒
     *
     * @param remindDto
     * @return
     */
    @PostMapping("/earlyWarningReminder")
    public void earlyWarningReminder(@RequestBody RemindDto remindDto) {
        log.info("进入接口：fsFileDataListDo/earlyWarningReminder,参数为：{}", remindDto);
        fileDataListService.earlyWarningReminder(remindDto);
    }


    /**
     * 变更流程关闭流程
     */
    @PostMapping("/closeProc")
    public R closeProc(@RequestBody CloseProcVo closeProcVo) {
        log.info("关闭流程 closeProcVo:{}", closeProcVo);
        return fileDataListService.closeProc(closeProcVo);
    }


    /**
     * 初始化数据
     * @param folderPath  文件夹路径
     */
    @PostMapping("/initialization")
    public R initialization(@RequestBody String folderPath){
        log.info("--> 文件初始数据");
        return  fileDataListService.initialization(folderPath);
    }


    /**
     * 奥克宁可定制版 -  文件初始化
     */
    @PostMapping("/aknkInitFolder")
    public void aknkInitFolder(@RequestBody String folderPath , HttpServletResponse response){
        log.info("--> 文件初始数据");
        fileDataListService.aknkInitFolder(folderPath ,response);
    }


    /**
     * 文件列表点击保存，将当前Bean 替换 掉历史记录最大版本中的数据
     */
    @PostMapping("/reSaveFileRecord")
    public R reSaveFileRecord (@RequestBody FsFileFormVo fsFileFormVo){
        return fileDataListService.reSaveFileRecord(fsFileFormVo);
    }
}

