package com.ruoyi.web.controller.zdsz;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import lombok.RequiredArgsConstructor;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;

import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.zdsz.domain.vo.ZEngineeringCivilVo;
import com.ruoyi.zdsz.domain.bo.ZEngineeringCivilBo;
import com.ruoyi.zdsz.service.IZEngineeringCivilService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 民用工程
 *
 * @author ruoyi
 * @date 2023-12-27
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/zdsz/engineeringCivil")
public class ZEngineeringCivilController extends BaseController {

    private final IZEngineeringCivilService iZEngineeringCivilService;

    /**
     * 查询民用工程列表
     */
    @SaCheckPermission("zdsz:engineeringCivil:list")
    @GetMapping("/list")
    public TableDataInfo<ZEngineeringCivilVo> list(ZEngineeringCivilBo bo, PageQuery pageQuery) {
        return iZEngineeringCivilService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出民用工程列表
     */
    @SaCheckPermission("zdsz:engineeringCivil:export")
    @Log(title = "民用工程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(ZEngineeringCivilBo bo, HttpServletResponse response) {
        List<ZEngineeringCivilVo> list = iZEngineeringCivilService.queryList(bo);
        ExcelUtil.exportExcel(list, "民用工程", ZEngineeringCivilVo.class, response);
    }

    /**
     * 获取民用工程详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("zdsz:engineeringCivil:query")
    @GetMapping("/{id}")
    public R<ZEngineeringCivilVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable String id) {
        return R.ok(iZEngineeringCivilService.queryById(id));
    }
    /**
     * 获取民用工程详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("zdsz:engineeringCivil:query")
    @PostMapping("/query")
    public R<ZEngineeringCivilVo> query(@RequestBody ZEngineeringCivilBo zEngineeringCivilBo) {
        return R.ok(iZEngineeringCivilService.queryByEntityBo(zEngineeringCivilBo));
    }
    /**
     * 获取民用工程节点信息
     *
     * @param id 主键
     */
    @SaCheckPermission("zdsz:engineeringCivil:query")
    @GetMapping("/{id}/{type}")
    public R<ZEngineeringCivilVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable String id, @NotNull(message = "节点类型不能为空") @PathVariable String type) {
        return R.ok(iZEngineeringCivilService.query(id,type));
    }

    /**
     * 新增民用工程
     */
    @SaCheckPermission("zdsz:engineeringCivil:add")
    @Log(title = "民用工程", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody ZEngineeringCivilBo bo) {
        return toAjax(iZEngineeringCivilService.insertByBo(bo));
    }
    /**
     * 新增民用工程
     */
    @SaCheckPermission("zdsz:engineeringCivil:add")
    @Log(title = "民用工程", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping("add")
    public R<Void> addList(@Validated(AddGroup.class) @RequestBody ZEngineeringCivilBo bo) {
        return toAjax(iZEngineeringCivilService.insertByBo(bo));
    }

    /**
     * 修改民用工程
     */
    @SaCheckPermission("zdsz:engineeringCivil:edit")
    @Log(title = "民用工程", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody ZEngineeringCivilBo bo) {
        return toAjax(iZEngineeringCivilService.updateByBo(bo));
    }

    /**
     * 删除民用工程
     *
     * @param ids 主键串
     */
    @SaCheckPermission("zdsz:engineeringCivil:remove")
    @Log(title = "民用工程", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable String[] ids) {
        return toAjax(iZEngineeringCivilService.deleteWithValidByIds(Arrays.asList(ids), true));
    }
   // @SaCheckPermission("zdsz:engineeringCivil:remove")
    @Log(title = "民用工程", businessType = BusinessType.DELETE)
    @PostMapping("/getObtainRoomcCompletionInformationList")
    public R getObtainRoomcCompletionInformationList(@RequestBody ZEngineeringCivilBo zEngineeringCivilBo) {
        return R.ok(iZEngineeringCivilService.getObtainRoomcCompletionInformationList(zEngineeringCivilBo));
    }
   // @SaCheckPermission("zdsz:engineeringCivil:remove")
    @Log(title = "民用工程", businessType = BusinessType.DELETE)
    @GetMapping("/getAreaCompletionInformationList")
    public TableDataInfo getAreaCompletionInformationList(ZEngineeringCivilBo bo,PageQuery pageQuery) {
        return iZEngineeringCivilService.getAreaCompletionInformationList(bo,pageQuery);
    }
    @Log(title = "民用工程", businessType = BusinessType.DELETE)
    @GetMapping("/getsumStatus")
    public R getsumStatus(ZEngineeringCivilBo bo) {
        return R.ok(iZEngineeringCivilService.getsumStatus(bo));
    }
}
