package com.zcloud.controller.eightwork;

import com.zcloud.controller.base.BaseController;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.logs.LogAnno;
import com.zcloud.service.eightwork.CutRoadService;
import com.zcloud.util.Jurisdiction;
import com.zcloud.util.Tools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 说明：断路作业
 * 官网：www.zcloudchina.com
 */
@Controller
@RequestMapping("/cutroad")
public class CutRoadController extends BaseController {

    @Autowired
    private CutRoadService cutroadService;


    /**列表
     * @param page
     * @throws Exception
     */
    @RequestMapping(value="/list")
    @ResponseBody
	@LogAnno(menuType= "高危作业管理",menuServer= "断路作业",instructionsOperate = "断路作业",instructionsType = "列表")
    public Object list(Page page) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        String errInfo = "success";
        PageData pd = new PageData();
        pd = this.getPageData();
        String KEYWORDS = pd.getString("KEYWORDS");						//关键词检索条件
        if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim());
        pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
        page.setPd(pd);
        List<PageData>	varList = cutroadService.list(page);	//列出cutroad列表
        map.put("varList", varList);
        map.put("page", page);
        map.put("result", errInfo);

        return map;
    }

    /**获取断路作业流程
     * @param
     * @throws Exception
     */
    @RequestMapping(value="/getFlowList")
    @ResponseBody
    @LogAnno(menuType= "高危作业管理",menuServer= "断路作业",instructionsOperate = "断路作业",instructionsType = "获取断路作业流程")
    public Object getFlowList() throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        String errInfo = "success";
        PageData pd = new PageData();
        pd = this.getPageData();
        List<PageData> flowList = cutroadService.getFlowList(pd);
        map.put("flowList", flowList);
        map.put("result", errInfo);				//返回结果
        return map;
    }

    @RequestMapping("/findById")
    @ResponseBody
    @LogAnno(menuType= "高危作业管理",menuServer= "断路作业",instructionsOperate = "断路作业",instructionsType = "获取详情")
    public Object findById() throws Exception {
        Map<String,Object> map = new HashMap<>();
        String errInfo = "success";
        PageData pd = new PageData();
        pd = this.getPageData();
        pd = cutroadService.findById(pd);
        PageData signs = cutroadService.listSignFinished(pd);
        List<PageData> finishMeasuresList = cutroadService.listSignFinishMeasures(pd);
        map.put("measuresList",finishMeasuresList);
        map.put("signs",signs);
        map.put("pd",pd);
        map.put("result",errInfo);
        return map;
    }

}
