package io.renren.modules.dataSet.controller;


import io.renren.common.utils.R;
import io.renren.datasource.annotation.DataSource;
import io.renren.modules.dataSet.service.impl.SubsystemServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

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

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author allen
 * @since 2021-06-15
 */
@RestController


@RequestMapping("/dataset/tree")
public class SubsystemController {
    @Autowired
    private SubsystemServiceImpl subsystemService;

    //查询现有的煤矿数据
    @RequestMapping("getcoal")
    public R getCoal(@RequestBody Map map){
        List getcoal = subsystemService.getcoal((Integer) map.get("userID"));
//        return getcoal;
//        System.out.println(getcoal);
        return R.ok().put("info",getcoal);
    }
    //根据煤矿id 查询对应的系统
    @RequestMapping("getfisystem")
    public String getfiSystem(@RequestBody Map map){
        String system = subsystemService.getSystem((Integer) map.get("coalid"),(Integer) map.get("userID"));
        System.out.println(system);
        return system;
    }
    //根据系统ID 查询对应的子系统
    @RequestMapping("getsubSystem")
    public String demo(@RequestBody Map map){
        String demo = subsystemService.getsubSystem((Integer) map.get("systemid"),(Integer) map.get("userID"));
        System.out.println("=====================================");
//        System.out.println((Integer) map.get("systemid"));
//        System.out.println(demo);
        return demo;
    }
    //根据子系统id 查询对应的设备
    @RequestMapping("getequipment")
    public  String getequipment(@RequestBody Map map){
        String equipment = subsystemService.getEquipment((Integer) map.get("subSystemid"),(Integer) map.get("userID"));
//        System.out.println((Integer) map.get("subSystemid"));
//        System.out.println(equipment);
        return equipment;
    }

    //    根据设备ID 查询对应的子设备
    @RequestMapping("getsubequipment")
    public String getsubequipment(@RequestBody Map map){
        String subEquiment = subsystemService.getSubequipment((Integer) map.get("equipment"),(Integer) map.get("userID"));
        return subEquiment;
    }


}

