diff --git a/psdc-business/src/main/java/com/psdc/mapper/PsdcDeviceMapper.java b/psdc-business/src/main/java/com/psdc/mapper/PsdcDeviceMapper.java index e15136e..cb8538b 100644 --- a/psdc-business/src/main/java/com/psdc/mapper/PsdcDeviceMapper.java +++ b/psdc-business/src/main/java/com/psdc/mapper/PsdcDeviceMapper.java @@ -96,4 +96,10 @@ public interface PsdcDeviceMapper{ void saveDevicesData(@Param(value = "devRecord") List<PsdcDevice> devRecord); + /** + * 控制页面查询设备查询可操作设备列表 + * @param userId + * @return + */ + List<PsdcDevice> controlQueryByUserId(Long userId); } \ No newline at end of file diff --git a/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java b/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java index 0ee25ca..7c60ada 100644 --- a/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java +++ b/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java @@ -154,9 +154,15 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService { /** * 控制设备启动停止 +<<<<<<< HEAD + * @param deviceId 主键 + * @param runStatus 状态 + * @return 条数 +======= * @param deviceId * @param runStatus * @return +>>>>>>> d15c6d60ec068ceda12ba3aa1cf4c980940216a5 */ @Override public int controlDeviceStartAndStop(Integer deviceId, Integer runStatus, String controlBy, Integer controlMethod) { @@ -175,6 +181,10 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService { psdcControlLogMapper.insert(new PsdcControlLog(deviceId, null, null, "设备启停", value, controlMethod, 3, "未找到该设备", controlBy)); throw new ControlException("控制失败,未找到该设备"); } + if (psdcDevice.getIsControl() != 2 ){ + throw new ControlException("该设备无法控制,请联系管理员"); + } + // TODO 发送MQTT指令 // psdcControlLogMapper.insert(new PsdcControlLog(deviceId,psdcDevice.getDeviceName(),psdcDevice.getDeviceSn(),"设备启停",value,controlMethod,3,"手动控制,等待终端响应超时",controlBy)); @@ -198,6 +208,9 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService { psdcControlLogMapper.insert(new PsdcControlLog(deviceId, null, null, "设定温度", null, controlMethod, 3, "未找到该设备", controlBy)); throw new ControlException("控制失败,未找到该设备"); } + if (psdcDevice.getIsControl() != 2 ){ + throw new ControlException("该设备无法控制,请联系管理员"); + } AtomicInteger atomicInteger = new AtomicInteger(0); @@ -243,6 +256,7 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService { } + //TODO 发送MQTT指令 // psdcControlLogMapper.insert(new PsdcControlLog(deviceId,psdcDevice.getDeviceName(),psdcDevice.getDeviceSn(),controlContext,value,controlMethod,2,"控制成功",controlBy)); // psdcControlLogMapper.insert(new PsdcControlLog(deviceId,psdcDevice.getDeviceName(),psdcDevice.getDeviceSn(),controlContext,value,controlMethod,3,"等待终端响应超时",controlBy)); diff --git a/psdc-business/src/main/java/com/psdc/service/impl/PsdcTimerServiceImpl.java b/psdc-business/src/main/java/com/psdc/service/impl/PsdcTimerServiceImpl.java index 2b2a8fb..2f52d20 100644 --- a/psdc-business/src/main/java/com/psdc/service/impl/PsdcTimerServiceImpl.java +++ b/psdc-business/src/main/java/com/psdc/service/impl/PsdcTimerServiceImpl.java @@ -7,6 +7,7 @@ import com.psdc.entity.request.PsdcTimerRequest; import com.psdc.entity.request.PsdcTimerRunTimeRequest; import com.psdc.entity.vo.PsdcTimerVo; import com.psdc.enums.ControlKeyEnum; +import com.psdc.exception.ControlException; import com.psdc.exception.ServiceException; import com.psdc.exception.job.TaskException; import com.psdc.mapper.PsdcTimerMapper; @@ -119,6 +120,9 @@ public class PsdcTimerServiceImpl implements IPsdcTimerService { if(psdcDevice == null){ throw new ServiceException("创建定时任务失败,未找到该设备"); } + if (psdcDevice.getIsControl() != 2 ){ + throw new ControlException("该设备无法控制,请联系管理员"); + } String[] split1 = runtime.split(":"); cronArr[0] = "0"; //分 diff --git a/psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml b/psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml index c61ab24..aef6622 100644 --- a/psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml +++ b/psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml @@ -292,4 +292,25 @@ select device_name from psdc_device where device_id = #{deviceId} </select> + <select id="controlQueryByUserId" resultMap="PsdcDeviceMap" > + select device_id, + user_id, + device_type, + device_sn, + device_name, + hard_version, + soft_version, + device_address, + start_time, + device_status, + device_runstatus, + photo_url, + create_by, + create_time, + update_by, + update_time + from psdc_device + where user_id = #{userId} and is_control = 2 + </select> + </mapper> \ No newline at end of file