package org.jeecg.modules.device.controller;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.device.entity.BuDevice;
import org.jeecg.modules.device.entity.BuDeviceOnline;
import org.jeecg.modules.device.entity.BuDeviceType;
import org.jeecg.modules.device.model.DeviceRate;
import org.jeecg.modules.device.model.DeviceSensorStatus;
import org.jeecg.modules.device.model.QRCodeUtils;
import org.jeecg.modules.device.service.*;
import org.jeecg.modules.sensor.entity.BuSensor;
import org.jeecg.modules.sensor.entity.BuSensorData;
import org.jeecg.modules.sensor.entity.BuStatus;
import org.jeecg.modules.sensor.service.IBuItemExplainService;
import org.jeecg.modules.sensor.service.IBuSensorDataService;
import org.jeecg.modules.sensor.service.IBuSensorService;
import org.jeecg.modules.sensor.service.IBuStatusService;
import org.jeecg.modules.system.model.TreeModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.testng.annotations.Test;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @Description: 设备信息表
 * @Author: jeecg-boot
 * @Date:   2020-12-11
 * @Version: V1.0
 */
@Api(tags="设备信息表")
@RestController
@RequestMapping("/device/buDevice")
@Slf4j
public class BuDeviceController extends JeecgController<BuDevice, IBuDeviceService> {
	@Autowired
	private IBuDeviceService buDeviceService;
	@Autowired
	private IBuDeviceOnlineService buDeviceOnlineService;
	@Autowired
	private IBuDeviceLifeCircleService buDeviceLifeCircleService;
	@Autowired
	private IBuSensorDataService buSensorDataService;
	@Autowired
	private IBuItemExplainService buItemExplainService;
	@Autowired
	private IBuDeviceTypeService buDeviceTypeService;
	@Autowired
	private IBuSensorService buSensorService;
	@Autowired
	private IBuStatusService buStatusService;
	@Autowired
	private IBuRiskItemValueService buRiskItemValueService;

	private final BuRiskItemValueController buRiskItemValueController;
	@Autowired
    public BuDeviceController(BuRiskItemValueController buRiskItemValueController) {
        this.buRiskItemValueController = buRiskItemValueController;
    }

    /**
	 * 分页列表查询
	 *
	 * @param buDevice
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	@AutoLog(value = "设备信息表-分页列表查询")
	@ApiOperation(value="设备信息表-分页列表查询", notes="设备信息表-分页列表查询")
	@GetMapping(value = "/list")
	public Result<?> queryPageList(BuDevice buDevice,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
		QueryWrapper<BuDevice> queryWrapper = QueryGenerator.initQueryWrapper(buDevice, req.getParameterMap());
////		LambdaQueryWrapper<BuDevice> queryWrapper = new LambdaQueryWrapper<>();
//		Page<BuDevice> page = new Page<BuDevice>(pageNo, pageSize);
		IPage<BuDevice> pageList = buDeviceService.queryPageList(buDevice, pageNo, pageSize, req);

//		List<String> deviceIds = pageList.getRecords().stream().map(BuDevice::getId).collect(Collectors.toList());
//		QueryWrapper<BuSensor> sensorWrapper = new QueryWrapper<>();
//		sensorWrapper.in("device_id",deviceIds);
//		List<BuSensor> buSensors = buSensorService.list(sensorWrapper);
//
//		List<String> sensorIds = buSensors.stream().map(BuSensor::getId).collect(Collectors.toList());
//		QueryWrapper<BuSensorMeasurements> sensorMeasWrapper = new QueryWrapper<>();
//		sensorMeasWrapper.in("sensor_id",sensorIds);
//
//
//		pageList.getRecords().forEach(item-> {
//			List<BuSensor> tempBuSensor = buSensors.stream().filter(s->s.getDeviceId().equals(item.getId())).collect(Collectors.toList());
//		});


		return Result.OK(pageList);

	}

	 //参考代码 loadTree
	 @GetMapping("/treeTest")
	 public List<BuDeviceType> tree(){
		 LambdaQueryWrapper<BuDeviceType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
		 lambdaQueryWrapper.orderByAsc(BuDeviceType::getCreateTime);
		 lambdaQueryWrapper.eq(BuDeviceType::getCalss,1);
		 List<BuDeviceType> buDeviceTypes = buDeviceTypeService.list(lambdaQueryWrapper);
		 List<BuDeviceType> result = new ArrayList<>(); // 过滤结果使用，不过滤就返回 buDeviceTypes
		 LambdaQueryWrapper<BuDevice> queryWrapper = new LambdaQueryWrapper<>();
//		 queryWrapper.orderByDesc(BuDevice::getDeviceCode);
		 List<BuDevice> buDevices = buDeviceService.list(queryWrapper);
		 for (BuDeviceType buDeviceType : buDeviceTypes) {
			 List<BuDevice> buDevices1 = new ArrayList<>();
			 for (BuDevice buDevice : buDevices) {
				 if(buDevice.getDeviceTypeId().equals(buDeviceType.getId())){
					 buDevices1.add(buDevice);
				 }
			 }
			 if(!buDevices1.isEmpty()){
				 buDeviceType.setChildren(buDevices1);
				 result.add(buDeviceType);
			 }
		 }
		 return result;
	 }
//	 //构建二级树
//	 private static List<BuDevice> buildTree(List<BuDevice> deviceList){
//		 HashMap<String, BuDevice> map = new HashMap<>();
//		 ArrayList<BuDevice> list = new ArrayList<>();
//		 for (BuDevice device : deviceList) {
//			 map.put(device.getDeviceTypeId(),device);
//		 }
//		 for (BuDevice device : deviceList) {
//			 if (device.getDeviceTypeId() != null){
//				 BuDevice parentUser = map.get(device.getDeviceTypeId());
//				 if (parentUser.getChildUser()==null){
//					 parentUser.setChildUser(new ArrayList<>());
//				 }
//				 parentUser.getChildUser().add(device);
//			 }else {
//				 list.add(device);
//			 }
//		 }
//		 return list;
//	 }

	 /**
	  * 分页列表查询
	  *
	  * @param buDevice
	  * @param pageNo
	  * @param pageSize
	  * @param req
	  * @return
	  */
	 @AutoLog(value = "设备信息表-分页列表查询")
	 @ApiOperation(value="设备信息表-分页列表查询", notes="设备信息表-分页列表查询")
	 @GetMapping(value = "/selectList")
	 public Result<?> selectList(BuDevice buDevice,
									@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
									@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
									HttpServletRequest req) {
//		 QueryWrapper<BuDevice> queryWrapper = QueryGenerator.initQueryWrapper(buDevice, req.getParameterMap());
		 LambdaQueryWrapper<BuDevice> queryWrapper = new LambdaQueryWrapper<>();
		 queryWrapper.like(StringUtils.isNotBlank(buDevice.getDeviceName()),BuDevice::getDeviceName,buDevice.getDeviceName());
		 queryWrapper.orderByDesc(BuDevice::getDeviceName);
		 Page<BuDevice> page = new Page<BuDevice>(pageNo, pageSize);
		 IPage<BuDevice> pageList = buDeviceService.page(page, queryWrapper);
		 return Result.OK(pageList);
	 }
	@GetMapping(value = "/getAllDeviceStatus")
	public Result<?> getAllDeviceStatus(){
		LambdaQueryWrapper<BuDevice> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.orderByDesc(BuDevice::getDeviceName);
		List<BuDevice> list = buDeviceService.list(queryWrapper);
		for (BuDevice buDevice : list){
			int count = buDeviceOnlineService.getFaultDataNumber(buDevice.getId());
			if(count>0){
				buDevice.setCount(count);
			}else {
				buDevice.setCount(0);
			}
			List<BuSensor> buSensorElectric = buSensorService.getByCheckName(buDevice.getId(),"%电能%");
			if(buSensorElectric.size()>0){
				BuStatus buStatus = buStatusService.getDataBySensorId(buSensorElectric.get(0).getId());
				if(buStatus!=null){
					if (buStatus.getSensorStatus() == 0){
						buDevice.setStatus("0");
					}else if(buStatus.getSensorStatus() == 1) {
						buDevice.setStatus("1");
					}else {
						buDevice.setStatus("2");
					}
				}
				//设备故障状态
				List<List<Object>> lists = buRiskItemValueController.queryRiskItems(buDevice.getId());
				if(lists!=null){
					List<Object> statusList = new ArrayList<>();
					lists.stream().filter(objects -> statusList.add(objects.get(2))).collect(Collectors.toList());
					String result = statusList.stream().anyMatch(number -> number.toString().equals("0")) ? "Y" : "N";
					if(result.equals("Y")){
						buDevice.setStatus("3");
					}
				}

			}

		}
		return Result.OK(list);
	}
	 @AutoLog(value = "设备信息表-列表查询")
	 @ApiOperation(value="设备信息表-列表查询", notes="设备信息表-列表查询")
	 @GetMapping(value = "/listwithnopage")
	 public Result<?> listwithnopage(BuDevice buDevice,
								 HttpServletRequest req) {
		 List<BuDevice> pageList = buDeviceService.list();
		 return Result.OK(pageList);
	 }

	 // 设备使用状态复位方法，状态手动改为正常,操作检测项配置表
	 @GetMapping(value = "/getDeviceReset")
	 public Result<?> getDeviceReset(String name){
	 	 BuDevice buDevice = buDeviceService.getDeviceByName(name);
		 buItemExplainService.getUpdateReset(name);
//	 	 buDevice.setUseStatus("0");
	 	 buDeviceService.updateById(buDevice);
	 	 return Result.OK("操作成功!");
	 }

	/**
	 *   添加
	 *
	 * @param buDevice
	 * @return
	 */
	@AutoLog(value = "设备信息表-添加")
	@ApiOperation(value="设备信息表-添加", notes="设备信息表-添加")
	@PostMapping(value = "/add")
	public Result<?> add(@RequestBody BuDevice buDevice) throws Exception {
//		buDevice.setUseStatus("0");
//		buDevice.setDeviceUse("0");
		buDeviceService.save(buDevice);
//		LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
		// 故障预测和寿命预测导入设备信息
//		BuFaultPrediction buFaultPrediction = new BuFaultPrediction();
//		BuLifePrediction buLifePrediction = new BuLifePrediction();
//		buFaultPrediction.setDeviceId(buDevice.getId());
//		buLifePrediction.setDeviceId(buDevice.getId());
//		buFaultPredictionService.save(buFaultPrediction);
//		buLifePredictionService.save(buLifePrediction);

		//设备生命周期导入设备信息
//		BuDeviceLifeCircle buDeviceLifeCircle = new BuDeviceLifeCircle();
//		buDeviceLifeCircle.setDeviceId(buDevice.getId());
//		buDeviceLifeCircle.setDeviceCode(buDevice.getDeviceCode());
//		switch (buDevice.getUseStatus()) {
//			case "0":
//				buDeviceLifeCircle.setBuyOperatorId(user.getUsername());
//				buDeviceLifeCircle.setBuyTime(new Date());
//				buDeviceLifeCircle.setBuyDes(buDevice.getStatusChange());
//				break;
//			case "1":
//				buDeviceLifeCircle.setSealUpOperatorId(user.getUsername());
//				buDeviceLifeCircle.setSealUpTime(new Date());
//				buDeviceLifeCircle.setSealUpReason(buDevice.getStatusChange());
//				break;
//			case "2":
//				buDeviceLifeCircle.setUnsealUpOperatorId(user.getUsername());
//				buDeviceLifeCircle.setUnsealUpTime(new Date());
//				buDeviceLifeCircle.setUnsealUpReason(buDevice.getStatusChange());
//				break;
//			case "3":
//				buDeviceLifeCircle.setScrapOperatorId(user.getUsername());
//				buDeviceLifeCircle.setScrapTime(new Date());
//				buDeviceLifeCircle.setScrapReason(buDevice.getStatusChange());
//				break;
//		}
//		buDeviceLifeCircleService.save(buDeviceLifeCircle);

		// 设备状态表导入基本信息
//		BuDeviceOnline buDeviceOnline = new BuDeviceOnline();
//		buDeviceOnline.setDeviceId(buDevice.getId());
//		buDeviceOnline.setDeviceCode(buDevice.getDeviceCode());
//		buDeviceOnline.setDeviceStatus("0");
//		buDeviceOnlineService.save(buDeviceOnline);

		// 设备状态配置表增加新设备
		BuSensorData buSensorData = new BuSensorData();
		buSensorData.setDeviceId(buDevice.getId());
		buSensorData.setDeviceName(buDevice.getDeviceName());
		buSensorData.setHjhx("2");
		buSensorData.setHjt("2");
		buSensorData.setSyq("2");
		buSensorData.setSyt("2");
		buSensorDataService.save(buSensorData);

//		generateCode(buDevice.getId());// 生成二维码
		return Result.OK("添加成功！");
	}

	/**
	 *  编辑
	 *
	 * @param buDevice
	 * @return
	 */
	@AutoLog(value = "设备信息表-编辑")
	@ApiOperation(value="设备信息表-编辑", notes="设备信息表-编辑")
	@PutMapping(value = "/edit")
	public Result<?> edit(@RequestBody BuDevice buDevice) throws Exception {
//		LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//		BuDeviceLifeCircle buDeviceLifeCircle = buDeviceLifeCircleService.getLifeCircleByIdCode(buDevice.getDeviceName(),buDevice.getDeviceCode());
//		BuDevice buDevice1 = buDeviceService.getDeviceById(buDevice.getId());

		// 设备状态更改时同步到设备生命周期表
//		if (!buDevice1.getUseStatus().equals(buDevice.getUseStatus())) {
//			switch (buDevice.getUseStatus()) {
//				case "0":
//					buDeviceLifeCircle.setBuyOperatorId(user.getUsername());
//					buDeviceLifeCircle.setBuyTime(new Date());
//					buDeviceLifeCircle.setBuyDes(buDevice.getStatusChange());
//					break;
//				case "2":
//					buDeviceLifeCircle.setUnsealUpOperatorId(user.getUsername());
//					buDeviceLifeCircle.setUnsealUpTime(new Date());
//					buDeviceLifeCircle.setUnsealUpReason(buDevice.getStatusChange());
//					break;
//				case "1":
//					buDeviceLifeCircle.setSealUpOperatorId(user.getUsername());
//					buDeviceLifeCircle.setSealUpTime(new Date());
//					buDeviceLifeCircle.setSealUpReason(buDevice.getStatusChange());
//					break;
//				case "3":
//					buDeviceLifeCircle.setScrapOperatorId(user.getUsername());
//					buDeviceLifeCircle.setScrapTime(new Date());
//					buDeviceLifeCircle.setScrapReason(buDevice.getStatusChange());
//					break;
//			}
//			buDeviceLifeCircleService.updateById(buDeviceLifeCircle);
//		}
		buDeviceService.updateById(buDevice);
//		generateCode(buDevice.getId());
		return Result.OK("编辑成功!");
	}

	 /***
	  * 自动生成二维码
	  * @param id
	  * @return
	  */
//	 @GetMapping(value = "/generateCode")
	 public void generateCode(@RequestParam(name="id",required=true) String id) throws Exception {
	 	 BuDevice buDevice = buDeviceService.getById(id);
	 	 String name = buDevice.getDeviceName();
	 	 String code = buDevice.getDeviceCode();
	 	 String location = buDevice.getLocation();
		 String text = name + "，编号为" + code + ",安装在" + location;  //这里设置自定义网站url或文字
		 String logoPath = "D:\\zxc\\1.jpg"; //二维码中间插入的图片
		 String destPath = "E:\\zxc\\";		//保存地址
//		 String file = id + ".jpg";
//		 String logoCode = "temp/" + id + ".jpg";
		 //调用工具类
//		 String file = QRCodeUtils.encode(text, logoPath, destPath, true);
//		 String imgCode = (destPath + file);
//		 buDevice.setCode(imgCode);
//		 buDeviceService.updateById(buDevice);
		 QRCodeUtils.encode(text, destPath, true);

	 }


	/**
	 *   通过id删除
	 *
	 * @param id
	 * @return
	 */
	@AutoLog(value = "设备信息表-通过id删除")
	@ApiOperation(value="设备信息表-通过id删除", notes="设备信息表-通过id删除")
	@DeleteMapping(value = "/delete")
	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
		buDeviceService.removeById(id);
		return Result.OK("删除成功!");
	}

	/**
	 *  批量删除
	 *
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "设备信息表-批量删除")
	@ApiOperation(value="设备信息表-批量删除", notes="设备信息表-批量删除")
	@DeleteMapping(value = "/deleteBatch")
	public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
		this.buDeviceService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}

	/**
	 * 通过id查询
	 *
	 * @param id
	 * @return
	 */
	@AutoLog(value = "设备信息表-通过id查询")
	@ApiOperation(value="设备信息表-通过id查询", notes="设备信息表-通过id查询")
	@GetMapping(value = "/queryById")
	public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
		BuDevice buDevice = buDeviceService.getById(id);
		if(buDevice==null) {
			return Result.error("未找到对应数据");
		}
		return Result.OK(buDevice);
	}

    /**
    * 导出excel
    *
    * @param request
    * @param buDevice
    */
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, BuDevice buDevice) {
        return super.exportXls(request, buDevice, BuDevice.class, "设备信息表");
    }

    /**
      * 通过excel导入数据
    *
    * @param request
    * @param response
    * @return
    */
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, BuDevice.class);
    }

	 @AutoLog(value = "设备信息状态-首页查询")
	 @ApiOperation(value="设备信息状态-首页查询", notes="设备信息状态-首页查询")
	 @GetMapping(value = "/queryDeviceStatus")//实时状态页面
	 public Result<?> queryDeviceStatus() {
		 List<DeviceSensorStatus> deviceSensorStatuses = buDeviceService.queryDeviceStatus();
		 List<List<String>> lists = new ArrayList<>();
		 for (DeviceSensorStatus deviceSensorStatus : deviceSensorStatuses) {
			 List<String> list = new ArrayList<>();
			 if(deviceSensorStatus.getDeviceName()!=null){
				 if(deviceSensorStatus.getDeviceCode()!=null){
					 list.add(deviceSensorStatus.getDeviceName()+deviceSensorStatus.getDeviceCode());
			 	}
			 }

			 if(deviceSensorStatus.getSupplierName()!=null){
				 list.add(deviceSensorStatus.getSupplierName());
			 }
//			 if(deviceSensorStatus.getDeviceCode()!=null){
//				 list.add(deviceSensorStatus.getDeviceCode());
//			 }
			 if(deviceSensorStatus.getTypeId()!=null){
				 list.add(deviceSensorStatus.getTypeId());
			 }
			 if(deviceSensorStatus.getLocation()!=null){
				 list.add(deviceSensorStatus.getLocation());
			 }



			 lists.add(list);
		 }
		 return Result.OK(lists);
	 }
	 @AutoLog(value = "设备类型-数量查询-首页查询")
	 @ApiOperation(value="设备类型-数量查询-首页查询", notes="设备类型-数量查询-首页查询")
	 @GetMapping(value = "/queryDevice")
	 public Result<?> queryDevice() {
		 List<DeviceSensorStatus> deviceSensorStatuses = buDeviceService.queryDevice();
		 return Result.OK(deviceSensorStatuses);
	 }

	 @AutoLog(value = "传感器信息状态-首页查询")
	 @ApiOperation(value="传感器信息状态-首页查询", notes="传感器信息状态-首页查询")
	 @GetMapping(value = "/querySensorStatus")
	 public Result<?> querySensorStatus() {
		 List<DeviceSensorStatus> deviceSensorStatuses = buDeviceService.querySensorStatus();
		 List<List<String>> lists = new ArrayList<>();
		 for (DeviceSensorStatus deviceSensorStatus : deviceSensorStatuses) {
			 deviceSensorStatus.setDeviceName(deviceSensorStatus.getDeviceName()+deviceSensorStatus.getDeviceCode());
			 if(deviceSensorStatus.getSensorStatus()==0){
				 deviceSensorStatus.setSensorStatusName("不在线");
			 }else {
				 deviceSensorStatus.setSensorStatusName("在线");
			 }
//			 List<String> list = new ArrayList<>();
//				 if(deviceSensorStatus.getDeviceCode()!=null){
//					 list.add(deviceSensorStatus.getDeviceName()+deviceSensorStatus.getDeviceCode());
//				 }
//				 list.add(deviceSensorStatus.getName());
//				 Integer sensorStatus = deviceSensorStatus.getSensorStatus();
//				 if (sensorStatus == 0){
//					 list.add("不在线");
//				 }else {
//					 list.add("在线");
//
//			 }
//			 lists.add(list);
		 }
		 return Result.OK(deviceSensorStatuses);
	 }
	 @AutoLog(value = "设备故障信息状态-首页查询")
	 @ApiOperation(value="设备故障信息状态-首页查询", notes="设备故障信息状态-首页查询")
	 @GetMapping(value = "/getDeviceTypeCount")
	 public Result<?> getDeviceTypeCount() {
		 List<DeviceSensorStatus> deviceSensorStatuses = buDeviceService.getDeviceTypeCount();
		 return Result.OK(deviceSensorStatuses);
	 }



	/**
	 * 统计设备正常率异常率
	 */
	@AutoLog(value = "统计设备正常率异常率-首页查询")
	@ApiOperation(value="统计设备正常率异常率-首页查询", notes="统计设备正常率异常率-首页查询")
	@GetMapping(value = "/getDeviceAbnormalCount")
	public Result<?> getDeviceAbnormalCount() {
		long deviceAbnormalCount = buRiskItemValueService.getDeviceAbnormalCount();
		long deviceCount = buDeviceService.count();
		double result = (deviceAbnormalCount / (double) deviceCount) * 100;
		String formattedResult = String.format("%.2f", result);
//		long finalResult = Math.round(Double.parseDouble(formattedResult));
		return Result.OK(formattedResult+"%");
	}


	@AutoLog(value = "每类设备的合格率和风险数-首页查询")
	@ApiOperation(value="每类设备的合格率和风险数-首页查询", notes="每类设备的合格率和风险数-首页查询")
	@GetMapping(value = "/getDeviceRiskRate")
	public Result<?> getDeviceRiskRate() {
		List<DeviceRate> deviceRiskRate = buRiskItemValueService.getDeviceRiskRate();
		return Result.OK(deviceRiskRate);
	}

	@AutoLog(value = "每类设备接入情况-首页查询")
	@ApiOperation(value="每类设备接入情况-首页查询", notes="每类设备接入情况-首页查询")
	@GetMapping(value = "/getDeviceAccEssRate")
	public Result<?> getDeviceAccEssRate() {
		List<DeviceRate> deviceRiskRate = buRiskItemValueService.getDeviceAccEssRate();
		return Result.OK(deviceRiskRate);
	}

	@AutoLog(value = "设备故障率-首页查询")
	@ApiOperation(value="设备故障率-首页查询", notes="设备故障率-首页查询")
	@GetMapping(value = "/getDeviceFaultRate")
	public Result<?> getDeviceFaultRate() {
		List<DeviceRate> deviceRiskRate = buRiskItemValueService.getDeviceFaultRate();
		return Result.OK(deviceRiskRate);
	}




}

