package com.project.zcustom.controller.engineering;


import com.project.zcustom.controller.core.AjaxResult;
import com.project.zcustom.controller.core.BaseController;
import com.project.zcustom.domain.addional.LargeIssue;
import com.project.zcustom.service.unit.ILargeIssueService;
import com.project.zcustom.service.unit.ILargePlanService;
import com.project.zcustom.service.unit.ILargeProjectService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.FileSystemResource;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.ws.mime.MimeMessage;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Date;

@RestController
@RequestMapping("/large/check")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class PlatProjectCheckController extends BaseController {

    private final ILargeProjectService largeProjectService;

    private final ILargeIssueService largeIssueService;

    private final ILargePlanService largePlanService;


    /**
     * 问题数量
     */
    @GetMapping("/getIssueNum/{appOrg}")
    public AjaxResult getIssueNum(@PathVariable String appOrg) {
        return AjaxResult.success("查询成功", largeIssueService.getIssueNum(appOrg));
    }

    /**
     * 已整改问题数量
     */
    @GetMapping("/getOverIssueNum/{appOrg}")
    public AjaxResult getOverIssueNum(@PathVariable String appOrg) {
        return AjaxResult.success("查询成功", largeIssueService.getOverIssueNum(appOrg));
    }

    /**
     * 本周检查项目数量
     */
    @GetMapping("/getProjectNumThisWeek/{appOrg}")
    public AjaxResult getProjectNumThisWeek(@PathVariable String appOrg) {
        return AjaxResult.success("查询成功", largeProjectService.getProjectNumThisWeek(appOrg));
    }

    /**
     * 近一周问题列表
     */
    @GetMapping("/getIssueListLastWeek/{appOrg}")
    public AjaxResult getIssueListLastWeek(@PathVariable String appOrg, @RequestParam(required = false, name = "day") Date day) {
        return AjaxResult.success("查询成功", largeIssueService.getIssueListLastWeek(appOrg, day));
    }

    /**
     * 问题列表
     * */
    @GetMapping("/issueList")
    public AjaxResult issueList(LargeIssue entity) {
        return AjaxResult.success("查询成功", largeIssueService.selectList(entity));
    }

    /**
     * 更改问题状态
     * */
    @PostMapping("changeIssueStatus")
    public AjaxResult changeIssueStatus(@RequestBody LargeIssue entity) {
        return toAjax(largeIssueService.updateById(entity));
    }


    /**
     * 本周检查计划
     * */
    @GetMapping("/planCheckList")
    public AjaxResult planCheckList() {
        return AjaxResult.success("查询成功", largePlanService.planCheckList());
    }

    /**
     * 本周施工计划
     * */
    @GetMapping("/planDoneList")
    public AjaxResult planDoneList() {
        return AjaxResult.success("查询成功", largePlanService.planDoneList());
    }
}
