package com.pqs9900.controller.DataInfo;

import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.terminal.DeviceUnitPO;
import com.njcn.pojo.terminal.DeviceUnitVO;
import com.njcn.utils.PubUtils;
import com.pqs9900.service.DataInfo.DeviceUnitService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * system
 * 装置层单位管理
 * @author cdf
 * @date 2023/8/17
 */
@RestController
@RequestMapping("deviceUnit")
public class DeviceUnitController {

    @Resource
    private DeviceUnitService deviceUnitService;

    /**
     * 新增装置单位
     * @author cdf
     * @date 2023/8/17
     */
    @PostMapping("addUnit")
    public HttpResult addUnit(@RequestBody DeviceUnitPO deviceUnitPO){
        deviceUnitService.addUnit(deviceUnitPO);
        return PubUtils.assignmentResult(null,200,"装置单位配置成功");
    }


    /**
     * 装置单位主列表
     * @author cdf
     * @date 2023/8/17
     */
    @GetMapping("unitTable")
    public HttpResult unitTable(@RequestParam("devFlag")Integer devFlag){
        List<DeviceUnitVO> deviceUnitVOList =  deviceUnitService.unitTable(devFlag);
        return PubUtils.assignmentResult(deviceUnitVOList,200,"装置单位配置成功");
    }

    /**
     * 根据监测点获取监测点的单位信息
     * @author cdf
     * @date 2023/8/17
     */
    @GetMapping("lineUnitDetail")
    public HttpResult lineUnitDetail(@RequestParam("lineId")Integer lineId){
        DeviceUnitVO deviceUnitVO =  deviceUnitService.lineUnitDetail(lineId);
        return PubUtils.assignmentResult(deviceUnitVO,200,"获取单位成功");
    }

    /**
     * 根据监测点获取监测点的单位信息
     * @author cdf
     * @date 2023/8/17
     */
    @GetMapping("devUnitDetail")
    public HttpResult devUnitDetail(@RequestParam("devId")Integer devId){
        DeviceUnitPO deviceUnitPO =  deviceUnitService.devUnitDetail(devId);
        return PubUtils.assignmentResult(deviceUnitPO,200,"获取单位成功");
    }



}
