|
@@ -17,7 +17,11 @@ import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.awt.*;
|
|
|
|
+import java.text.DecimalFormat;
|
|
|
|
+import java.text.NumberFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -272,20 +276,39 @@ public class BasePigpenServiceImpl extends ServiceImpl<BasePigpenDao, BasePigpen
|
|
basePigpenEntity.setPigpenTemp(null);
|
|
basePigpenEntity.setPigpenTemp(null);
|
|
baseMapper.updateById(basePigpenEntity);
|
|
baseMapper.updateById(basePigpenEntity);
|
|
}else {
|
|
}else {
|
|
- CollectorRegisterEntity collectorRegisterEntity = collectorRegisterEntities.get(0);
|
|
|
|
- String deviceCode = collectorRegisterEntity.getDeviceCode();
|
|
|
|
- QueryWrapper<DeviceTempEntity> deviceTempEntityQueryWrapper = new QueryWrapper<>();
|
|
|
|
-
|
|
|
|
- deviceTempEntityQueryWrapper.eq("device_code",deviceCode);
|
|
|
|
- deviceTempEntityQueryWrapper.orderByDesc("id");
|
|
|
|
- deviceTempEntityQueryWrapper.last("limit 1");
|
|
|
|
- DeviceTempEntity deviceTempEntity = deviceTempDao.selectOne(deviceTempEntityQueryWrapper);
|
|
|
|
- Double tempValue = deviceTempEntity.getTempValue();
|
|
|
|
- basePigpenEntity.setPigpenTemp( tempValue );
|
|
|
|
- if (tempValue > 35.0||tempValue<10.0){
|
|
|
|
- basePigpenEntity.setTempAnomaly(0);
|
|
|
|
|
|
+ Double tempValue =0.0;
|
|
|
|
+ Integer count = 0;
|
|
|
|
+ for (CollectorRegisterEntity collectorRegisterEntity : collectorRegisterEntities) {
|
|
|
|
+ String deviceCode = collectorRegisterEntity.getDeviceCode();
|
|
|
|
+ QueryWrapper<DeviceTempEntity> deviceTempEntityQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ deviceTempEntityQueryWrapper.eq("device_code",deviceCode);
|
|
|
|
+ deviceTempEntityQueryWrapper.orderByDesc("id");
|
|
|
|
+ deviceTempEntityQueryWrapper.last("limit 1");
|
|
|
|
+ DeviceTempEntity deviceTempEntity = deviceTempDao.selectOne(deviceTempEntityQueryWrapper);
|
|
|
|
+ if (deviceTempEntity == null){
|
|
|
|
+ collectorRegisterEntity.setAcqStatus(2);
|
|
|
|
+ collectorRegisterDao.updateById(collectorRegisterEntity);
|
|
|
|
+ }
|
|
|
|
+ if (deviceTempEntity != null){
|
|
|
|
+ tempValue += deviceTempEntity.getTempValue();
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- baseMapper.updateById(basePigpenEntity);
|
|
|
|
|
|
+
|
|
|
|
+ if (count != 0){
|
|
|
|
+ NumberFormat nf = NumberFormat.getNumberInstance();
|
|
|
|
+
|
|
|
|
+ nf.setMaximumFractionDigits(2);
|
|
|
|
+ double temp = Double.parseDouble(nf.format(tempValue / count));
|
|
|
|
+ System.out.println(temp);
|
|
|
|
+ basePigpenEntity.setPigpenTemp( temp);
|
|
|
|
+ if (temp > 35.0||temp<10.0){
|
|
|
|
+ basePigpenEntity.setTempAnomaly(0);
|
|
|
|
+ }
|
|
|
|
+ baseMapper.updateById(basePigpenEntity);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|