package com.siwei.rsmonitoring.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.siwei.common.log.annotation.Log;
import com.siwei.common.log.enums.BusinessType;
import com.siwei.common.security.annotation.RequiresPermissions;
import com.siwei.rsmonitoring.domain.TDkFieldwork;
import com.siwei.rsmonitoring.service.ITDkFieldworkService;
import com.siwei.common.core.web.controller.BaseController;
import com.siwei.common.core.web.domain.AjaxResult;
import com.siwei.common.core.utils.poi.ExcelUtil;
import com.siwei.common.core.web.page.TableDataInfo;

/**
 * 地块外业分配Controller
 *
 * @author siwei
 * @date 2025-01-21
 */
@RestController
@RequestMapping("/dkjbxx/fieldwork")
public class TDkFieldworkController extends BaseController {
    @Autowired
    private ITDkFieldworkService tDkFieldworkService;

    /**
     * 查询地块外业分配列表
     */
//    @RequiresPermissions("rsmonitoring:fieldwork:list")
//    @GetMapping("/list")
//    public TableDataInfo list(TDkFieldwork tDkFieldwork) {
//        startPage();
//        List<TDkFieldwork> list = tDkFieldworkService.selectTDkFieldworkList(tDkFieldwork);
//        return getDataTable(list);
//    }
//
//    /**
//     * 导出地块外业分配列表
//     */
//    @RequiresPermissions("rsmonitoring:fieldwork:export")
//    @Log(title = "地块外业分配", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, TDkFieldwork tDkFieldwork) {
//        List<TDkFieldwork> list = tDkFieldworkService.selectTDkFieldworkList(tDkFieldwork);
//        ExcelUtil<TDkFieldwork> util = new ExcelUtil<TDkFieldwork>(TDkFieldwork.class);
//        util.exportExcel(response, list, "地块外业分配数据");
//    }
//
//    /**
//     * 获取地块外业分配详细信息
//     */
//    @RequiresPermissions("rsmonitoring:fieldwork:query")
//    @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@PathVariable("id") String id) {
//        return success(tDkFieldworkService.selectTDkFieldworkById(id));
//    }

    /**
     * 新增地块外业分配
     */
//    @RequiresPermissions("rsmonitoring:fieldwork:add")
//    @Log(title = "地块外业分配", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody TDkFieldwork tDkFieldwork)
//    {
//        return toAjax(tDkFieldworkService.insertTDkFieldwork(tDkFieldwork));
//    }

    /**
     * 分配地块给外业人员
     */
//    @RequiresPermissions("rsmonitoring:fieldwork:adds")
    @Log(title = "下发地块外业分配", businessType = BusinessType.INSERT)
    @PostMapping(value = "/adds")
    public AjaxResult adds(@RequestBody TDkFieldwork tDkFieldwork) {
        return toAjax(tDkFieldworkService.addSTDkFieldwork(tDkFieldwork));
    }

    //    @RequiresPermissions("rsmonitoring:fieldwork:adds")
    @Log(title = "取消地块外业分配", businessType = BusinessType.INSERT)
    @PostMapping(value = "/removes")
    public AjaxResult removes(@RequestBody TDkFieldwork tDkFieldwork) {
        return toAjax(tDkFieldworkService.removeSTDkFieldwork(tDkFieldwork));
    }

//    /**
//     * 修改地块外业分配
//     */
//    @RequiresPermissions("rsmonitoring:fieldwork:edit")
//    @Log(title = "地块外业分配", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody TDkFieldwork tDkFieldwork) {
//        return toAjax(tDkFieldworkService.updateTDkFieldwork(tDkFieldwork));
//    }
//
//    /**
//     * 删除地块外业分配
//     */
//    @RequiresPermissions("rsmonitoring:fieldwork:remove")
//    @Log(title = "地块外业分配", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable String[] ids) {
//        return toAjax(tDkFieldworkService.deleteTDkFieldworkByIds(ids));
//    }
}
