| | |
| | | package com.ruoyi.iot.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.iot.domain.Device; |
| | | import com.ruoyi.iot.dto.DeviceFilterDto; |
| | | import com.ruoyi.iot.model.DeviceAllShortOutput; |
| | | import com.ruoyi.iot.model.DeviceRelateUserInput; |
| | | import com.ruoyi.iot.model.DeviceShortOutput; |
| | | import com.ruoyi.iot.model.ThingsModels.ThingsModelValueItem; |
| | | import com.ruoyi.iot.mqtt.EmqxService; |
| | | import com.ruoyi.iot.service.IDeviceService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询滤芯寿命清单列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('iot:device:list')") |
| | | @GetMapping("/cartridgeList") |
| | | @ApiOperation("滤芯寿命清单列表") |
| | | public TableDataInfo selectCartridgeLifeList(Device device) throws Exception { |
| | | //把device表中每一条数据的things_model_value物模型值json解析为ThingsModelValueItem对象 |
| | | List<DeviceFilterDto> list = new ArrayList<>(); |
| | | Long deviceId = 0L; |
| | | ThingsModelValueItem thingsModelValueItem = null; |
| | | //查询所有的设备 |
| | | List<Device> deviceList = deviceService.selectDeviceAll(); |
| | | for (Device devices : deviceList) { |
| | | //拿到物模型值 |
| | | String thingsModelValue = devices.getThingsModelValue(); |
| | | deviceId = devices.getDeviceId(); |
| | | if (thingsModelValue != null) { |
| | | //JSONObject.parseObject方法用于将一个JSON字符串解析为一个JSONObject对象 |
| | | JSONObject jsonObject = JSONObject.parseObject(thingsModelValue); |
| | | //toJavaObject方法是用于将JSON字符串转换为Java对象的静态方法。这个方法可以将JSON格式的字符串转换为对应的Java对象。 |
| | | thingsModelValueItem = jsonObject.toJavaObject(ThingsModelValueItem.class); |
| | | //拿到物模型的id——FilterA |
| | | String thingsModelId = thingsModelValueItem.getId(); |
| | | //拿到物模型id是FilterA的值 |
| | | int thingsModelValues = Integer.parseInt(thingsModelValueItem.getValue()); |
| | | if ("FilterA".equals(thingsModelId) && thingsModelValues <= 5 || "FilterB".equals(thingsModelId) && thingsModelValues <= 5 || "FilterC".equals(thingsModelId) && thingsModelValues <= 5 || "FilterD".equals(thingsModelId) && thingsModelValues <= 5) { |
| | | //根据滤芯寿命A小于等于5的设备id去查询设备信息 |
| | | Device deviceA = deviceService.selectDeviceByDeviceId(deviceId); |
| | | DeviceFilterDto deviceFilterDto = new DeviceFilterDto(deviceA.getDeviceId(), deviceA.getDeviceName(), deviceA.getDeviceOrder().getUserName(), deviceA.getDeviceOrder().getUserPhone(), thingsModelValues, null, null, null); |
| | | list.add(deviceFilterDto); |
| | | break; |
| | | } |
| | | } else { |
| | | return null; |
| | | } |
| | | } |
| | | startPage(); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 查询未分配授权码设备列表 |