Ver código fonte

新增高低温阈值设置2

zhuoning 2 anos atrás
pai
commit
911013e057

+ 6 - 0
huimv-env-platform/huimv-env-common/src/main/java/com/huimv/env/common/service/ITempThresholdService.java

@@ -0,0 +1,6 @@
+package com.huimv.env.common.service;
+
+public interface ITempThresholdService {
+    //
+    String getTempThresholdByDeviceCode(String deviceCode);
+}

+ 61 - 0
huimv-env-platform/huimv-env-common/src/main/java/com/huimv/env/common/service/impl/TempThresholdServiceImpl.java

@@ -0,0 +1,61 @@
+package com.huimv.env.common.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.huimv.env.common.dao.entity.EnvDeviceRegisterEntity;
+import com.huimv.env.common.dao.entity.EnvSprayTimeEntity;
+import com.huimv.env.common.dao.entity.EnvTempThresholdEntity;
+import com.huimv.env.common.dao.repo.EnvTempThresholdEntityRepo;
+import com.huimv.env.common.service.IDeviceRegisterService;
+import com.huimv.env.common.service.ITempThresholdService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.stereotype.Service;
+
+import java.sql.Timestamp;
+import java.util.Optional;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Service
+@Slf4j
+public class TempThresholdServiceImpl implements ITempThresholdService {
+    @Autowired
+    private EnvTempThresholdEntityRepo envTempThresholdEntityRepo;
+    @Autowired
+    private IDeviceRegisterService deviceRegisterService;
+
+    @Override
+    public String getTempThresholdByDeviceCode(String deviceCode){
+        //读取设备注册信息
+//        EnvDeviceRegisterEntity envDeviceRegisterEntity = deviceRegisterService.getDeviceRegisterByDeviceCode(deviceCode);
+//        if (envDeviceRegisterEntity == null) {
+//            log.error("该设备[" + deviceCode + "]未注册.");
+//            return "0";
+//        }else{
+//            java.sql.Date todayDate = new java.sql.Date(new java.util.Date().getTime());
+//            Timestamp nowTimestamp = new Timestamp(new java.util.Date().getTime());
+//            String farmCode = envDeviceRegisterEntity.getFarmCode();
+
+            EnvTempThresholdEntity envTempThresholdEntity = new EnvTempThresholdEntity();
+            envTempThresholdEntity.setDeviceCode(deviceCode);
+//            envTempThresholdEntity.setFarmCode(farmCode);
+            Example<EnvTempThresholdEntity> example = Example.of(envTempThresholdEntity);
+            Optional<EnvTempThresholdEntity> optional = envTempThresholdEntityRepo.findOne(example);
+            if(!optional.isPresent()){
+                log.error("deviceCode["+deviceCode+"]高温低温阈值设置记录不存在;");
+                return "0";
+            }else{
+                EnvTempThresholdEntity tempThresholdEntity = optional.get();
+                return tempThresholdEntity.getHighTemp()+"+"+tempThresholdEntity.getLowTemp();
+            }
+//        }
+    }
+}