package com.bzd.web.controller.dtp;

import com.bzd.common.config.dao.PageData;
import com.bzd.common.core.controller.BaseController;
import com.bzd.common.core.domain.AjaxResult;
import com.bzd.common.core.page.TableDataInfo;
import com.bzd.system.service.DTPService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * DTP处方登记概
 * creator wsp
 */
@Controller
@RequestMapping("/dtp/report")
public class RecipeReportController extends BaseController {
    private String prefix = "dtp/recipe";

    @Autowired
    private DTPService dtpService;
    @RequiresPermissions("dtp:report:view")
    @GetMapping()
    public String view()
    {
        return prefix + "/view";
    }

    /**
     * DTP处方登记概览详情
     * @return
     */
    @RequiresPermissions("dtp:report:list")
    @GetMapping("/viewDetail/{id}")
    @ResponseBody
    public AjaxResult viewDetail(@PathVariable("id") Long id)
    {
        PageData pd1 = new PageData();
        PageData pd2 = new PageData();
        PageData pd3 = new PageData();
        PageData pd4 = new PageData();
        List<PageData> pageData = new ArrayList<>();

            // 第一条数据
        pd1.put("id", id);
        pd1.put("chain", id+"花果园分店");
        pd1.put("orderCount", "88");
        pd1.put("pendingCount", "10");
        pd1.put("completedCount", "8");
        pd1.put("completionRate", "65%");
        pageData.add(pd1);
        // 第二条数据
        pd2.put("id", "102");
        pd2.put("chain", id+"1分店");
        pd2.put("orderCount", "120");
        pd2.put("pendingCount", "15");
        pd2.put("completedCount", "105");
        pd2.put("completionRate", "87.5%");
        pageData.add(pd2);
        // 第三条数据
        pd3.put("id","103");
        pd3.put("chain",id+"2分店");
        pd3.put("orderCount","89");
        pd3.put("pendingCount","15");
        pd3.put("completedCount","11");
        pd3.put("completionRate","58%");
        pageData.add(pd3);
        // 第4条数据
        pd4.put("id", "104");
        pd4.put("chain", id+"3分店");
        pd4.put("orderCount", "110");
        pd4.put("pendingCount", "16");
        pd4.put("completedCount", "95");
        pd4.put("completionRate", "80.5%");
        pageData.add(pd4);
         return  AjaxResult.success("cg",pageData);
    }
    /**
     *
     * DTP处方登记概 查询报表柱状图
     */
    @RequiresPermissions("dtp:report:list")
    @PostMapping("/listReport")
    @ResponseBody
    public AjaxResult listReport() throws Exception {
        PageData pd1 = new PageData();
        PageData pd2 = new PageData();
        PageData pd3 = new PageData();
        PageData pd4 = new PageData();
        PageData pd5 = new PageData();
        PageData pd6 = new PageData();
        PageData pd7 = new PageData();
        PageData pd8 = new PageData();
        PageData pd9 = new PageData();
        PageData pd10 = new PageData();
        startPage();

        List<PageData> pageData = new ArrayList<>();
        // 第一条数据
        pd1.put("id", "1");
        pd1.put("chain", "花果园店");
        pd1.put("orderCount", "88");
        pd1.put("pendingCount", "10");
        pd1.put("completedCount", "8");
        pd1.put("completionRate", "65%");
        pageData.add(pd1);
        // 第二条数据
        pd2.put("id", "2");
        pd2.put("chain", "龙阳路店");
        pd2.put("orderCount", "120");
        pd2.put("pendingCount", "15");
        pd2.put("completedCount", "105");
        pd2.put("completionRate", "87.5%");
        pageData.add(pd2);
        // 第三条数据
        pd3.put("id","3");
        pd3.put("chain","观山湖店");
        pd3.put("orderCount","89");
        pd3.put("pendingCount","15");
        pd3.put("completedCount","11");
        pd3.put("completionRate","58%");
        pageData.add(pd3);
        // 第4条数据
        pd4.put("id", "4");
        pd4.put("chain", "青云路店");
        pd4.put("orderCount", "110");
        pd4.put("pendingCount", "16");
        pd4.put("completedCount", "95");
        pd4.put("completionRate", "80.5%");
        pageData.add(pd4);
        // 第5条数据
        pd5.put("id","5");
        pd5.put("chain","白云区店");
        pd5.put("orderCount","59");
        pd5.put("pendingCount","5");
        pd5.put("completedCount","5");
        pd5.put("completionRate","70%");
        pageData.add(pd5);
        // 第1条数据
        pd7.put("id", "7");
        pd7.put("chain", "天河区店");
        pd7.put("orderCount", "120");
        pd7.put("pendingCount", "10");
        pd7.put("completedCount", "110");
        pd7.put("completionRate", "91.67%");
        pageData.add(pd7);

        // 第2条数据
        pd8.put("id", "8");
        pd8.put("chain", "海珠区店");
        pd8.put("orderCount", "95");
        pd8.put("pendingCount", "7");
        pd8.put("completedCount", "88");
        pd8.put("completionRate", "92.63%");
        pageData.add(pd8);

        // 第3条数据
        pd9.put("id", "9");
        pd9.put("chain", "荔湾区店");
        pd9.put("orderCount", "75");
        pd9.put("pendingCount", "5");
        pd9.put("completedCount", "70");
        pd9.put("completionRate", "93.33%");
        pageData.add(pd9);

        // 第4条数据
        pd10.put("id", "10");
        pd10.put("chain", "黄埔区店");
        pd10.put("orderCount", "65");
        pd10.put("pendingCount", "4");
        pd10.put("completedCount", "61");
        pd10.put("completionRate", "93.85%");
        pageData.add(pd10);
        // 第6条数据
        pd6.put("id", "6");
        pd6.put("chain", "白云区店");
        pd6.put("orderCount", "59");
        pd6.put("pendingCount", "5");
        pd6.put("completedCount", "5");
        pd6.put("completionRate", "70%");
        pageData.add(pd6);
        return   AjaxResult.success("cg",pageData);
    }

    /**
     *
     * DTP处方登记概 查询报表
     */
    @RequiresPermissions("dtp:report:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list() throws Exception {
        PageData pd = this.getPageData();
        startPage();

        System.out.println(pd.get("beginTime"));
        System.out.println(pd.get("endTime"));
        PageData pd1 = new PageData();
        PageData pd2 = new PageData();
        PageData pd3 = new PageData();
        PageData pd4 = new PageData();
        PageData pd5 = new PageData();
        PageData pd6 = new PageData();
        PageData pd7 = new PageData();
        PageData pd8 = new PageData();
        PageData pd9 = new PageData();
        PageData pd10 = new PageData();
        startPage();
        List<PageData> pageData = new ArrayList<>();
        if(!pd.get("id").equals("")){
            pd1.put("id", pd.get("id"));
            pd1.put("chain", pd.get("id")+"花果园分店");
            pd1.put("orderCount", "88");
            pd1.put("pendingCount", "10");
            pd1.put("completedCount", "8");
            pd1.put("completionRate", "65%");
            pageData.add(pd1);
            // 第二条数据
            pd2.put("id", "102");
            pd2.put("chain", pd.get("id")+"1分店");
            pd2.put("orderCount", "120");
            pd2.put("pendingCount", "15");
            pd2.put("completedCount", "105");
            pd2.put("completionRate", "87.5%");
            pageData.add(pd2);
            // 第三条数据
            pd3.put("id","103");
            pd3.put("chain",pd.get("id")+"2分店");
            pd3.put("orderCount","89");
            pd3.put("pendingCount","15");
            pd3.put("completedCount","11");
            pd3.put("completionRate","58%");
            pageData.add(pd3);
            // 第4条数据
            pd4.put("id", "104");
            pd4.put("chain", pd.get("id")+"3分店");
            pd4.put("orderCount", "110");
            pd4.put("pendingCount", "16");
            pd4.put("completedCount", "95");
            pd4.put("completionRate", "80.5%");
            pageData.add(pd4);

            return   getDataTable(pageData);
        }else {



        // 第一条数据
        pd1.put("id", "1");
        pd1.put("chain", "花果园店");
        pd1.put("orderCount", "88");
        pd1.put("pendingCount", "10");
        pd1.put("completedCount", "8");
        pd1.put("completionRate", "65%");
        pageData.add(pd1);

        // 第二条数据
        pd2.put("id", "2");
        pd2.put("chain", "龙阳路店");
        pd2.put("orderCount", "120");
        pd2.put("pendingCount", "15");
        pd2.put("completedCount", "105");
        pd2.put("completionRate", "87.5%");
        pageData.add(pd2);
        // 第三条数据
        pd3.put("id","3");
        pd3.put("chain","观山湖店");
        pd3.put("orderCount","89");
        pd3.put("pendingCount","15");
        pd3.put("completedCount","11");
        pd3.put("completionRate","58%");
        pageData.add(pd3);
        // 第4条数据
        pd4.put("id", "4");
        pd4.put("chain", "青云路店");
        pd4.put("orderCount", "110");
        pd4.put("pendingCount", "16");
        pd4.put("completedCount", "95");
        pd4.put("completionRate", "80.5%");
        pageData.add(pd4);
        // 第5条数据
        pd5.put("id","5");
        pd5.put("chain","白云区店");
        pd5.put("orderCount","59");
        pd5.put("pendingCount","5");
        pd5.put("completedCount","5");
        pd5.put("completionRate","70%");
        pageData.add(pd5);

        // 第1条数据
        pd7.put("id", "7");
        pd7.put("chain", "天河区店");
        pd7.put("orderCount", "120");
        pd7.put("pendingCount", "10");
        pd7.put("completedCount", "110");
        pd7.put("completionRate", "91.67%");
        pageData.add(pd7);

        // 第2条数据
        pd8.put("id", "8");
        pd8.put("chain", "海珠区店");
        pd8.put("orderCount", "95");
        pd8.put("pendingCount", "7");
        pd8.put("completedCount", "88");
        pd8.put("completionRate", "92.63%");
        pageData.add(pd8);

        // 第3条数据
        pd9.put("id", "9");
        pd9.put("chain", "荔湾区店");
        pd9.put("orderCount", "75");
        pd9.put("pendingCount", "5");
        pd9.put("completedCount", "70");
        pd9.put("completionRate", "93.33%");
        pageData.add(pd9);

        // 第4条数据
        pd10.put("id", "10");
        pd10.put("chain", "黄埔区店");
        pd10.put("orderCount", "65");
        pd10.put("pendingCount", "4");
        pd10.put("completedCount", "61");
        pd10.put("completionRate", "93.85%");
        pageData.add(pd10);
        // 第6条数据
        pd6.put("id", "6");
        pd6.put("chain", "白云区店");
        pd6.put("orderCount", "59");
        pd6.put("pendingCount", "5");
        pd6.put("completedCount", "5");
        pd6.put("completionRate", "70%");
        pageData.add(pd6);
            System.out.println("=====================查询所有"+pageData.size());
        return   getDataTable(pageData);
        }
    }



}
