|
@@ -5,15 +5,20 @@ import cn.hutool.core.util.RandomUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.huimv.common.utils.Result;
|
|
|
import com.huimv.common.utils.ResultCode;
|
|
|
+import com.huimv.env.common.dao.entity.EnvDeviceRegisterEntity;
|
|
|
+import com.huimv.env.common.dao.entity.EnvTempThresholdEntity;
|
|
|
+import com.huimv.env.common.dao.repo.EnvDeviceRegisterEntityRepo;
|
|
|
import com.huimv.env.common.entity.BaseThreshold;
|
|
|
import com.huimv.env.common.mapper.BaseThresholdMapper;
|
|
|
import com.huimv.env.common.service.IBaseThresholdService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Example;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -29,6 +34,9 @@ public class BaseThresholdServiceImpl extends ServiceImpl<BaseThresholdMapper, B
|
|
|
@Autowired
|
|
|
private BaseThresholdMapper baseThresholdMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private EnvDeviceRegisterEntityRepo envDeviceRegisterEntityRepo;
|
|
|
+
|
|
|
@Override
|
|
|
public Result listThreshold(Map<String,String> map) {
|
|
|
String farmCode = map.get("farmCode");
|
|
@@ -52,4 +60,18 @@ public class BaseThresholdServiceImpl extends ServiceImpl<BaseThresholdMapper, B
|
|
|
|
|
|
return new Result(ResultCode.SUCCESS,baseThreshold);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getTempThresholdByDeviceCode(String idCode) {
|
|
|
+ EnvDeviceRegisterEntity envDeviceRegisterEntity = new EnvDeviceRegisterEntity();
|
|
|
+ envDeviceRegisterEntity.setDeviceCode(idCode);
|
|
|
+ Example<EnvDeviceRegisterEntity> example = Example.of(envDeviceRegisterEntity);
|
|
|
+ EnvDeviceRegisterEntity envDeviceRegisterEntity1 = envDeviceRegisterEntityRepo.findOne(example).get();
|
|
|
+ String farmCode = envDeviceRegisterEntity1.getFarmCode();
|
|
|
+ BaseThreshold baseThreshold = baseThresholdMapper.selectOne(new QueryWrapper<BaseThreshold>().eq("farm_code", farmCode));
|
|
|
+ if (ObjectUtil.isNotEmpty(baseThreshold)){
|
|
|
+ return (baseThreshold.getMaxTemp().multiply(new BigDecimal(10))).intValue() +"+"+(baseThreshold.getMinTemp().multiply(new BigDecimal(10))).intValue();
|
|
|
+ }
|
|
|
+ return "0";
|
|
|
+ }
|
|
|
}
|