|
@@ -0,0 +1,143 @@
|
|
|
+package com.welampiot.service.impl;
|
|
|
+
|
|
|
+import com.welampiot.dao.EnvmonitorDao;
|
|
|
+import com.welampiot.dto.EnvmonitorDTO;
|
|
|
+import com.welampiot.service.EnvmonitorService;
|
|
|
+import com.welampiot.vo.EnvmonitorVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * ClassName: EnvmonitorServiceImpl
|
|
|
+ * Package: com.welampiot.service.impl
|
|
|
+ * Description:
|
|
|
+ *
|
|
|
+ * @Author: zhj_Start
|
|
|
+ * @Create: 2023/4/13 - 15:21
|
|
|
+ * @Version: v1.0
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class EnvmonitorServiceImpl implements EnvmonitorService {
|
|
|
+ @Autowired
|
|
|
+ private EnvmonitorDao envmonitorDao;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public EnvmonitorVO getWeatherList(EnvmonitorDTO dto) {
|
|
|
+ EnvmonitorVO vo = new EnvmonitorVO();
|
|
|
+ vo.setTotal(envmonitorDao.getTotalBySectionList(dto));
|
|
|
+ List<EnvmonitorDTO> weatherList = envmonitorDao.getWeatherListByDTO(dto);
|
|
|
+ List<EnvmonitorDTO> list = new ArrayList<>();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ weatherList.forEach(envmonitorDTO ->{
|
|
|
+ if (envmonitorDTO.getLampPoleName() == null){
|
|
|
+ envmonitorDTO.setLampPoleName("");
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getNetStatus() != null && envmonitorDTO.getNetStatus() == 1){
|
|
|
+ envmonitorDTO.setNetStatus(1);
|
|
|
+ }else {
|
|
|
+ envmonitorDTO.setNetStatus(0);
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getNetType() != null && envmonitorDTO.getNetType() == 2){
|
|
|
+ envmonitorDTO.setNetType(2);
|
|
|
+ }else if (envmonitorDTO.getNetType() != null && envmonitorDTO.getNetType() == 1){
|
|
|
+ envmonitorDTO.setNetType(1);
|
|
|
+ }else {
|
|
|
+ envmonitorDTO.setNetType(0);
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getUpdateTime() != null && !envmonitorDTO.getUpdateTime().equals("")){
|
|
|
+ Date cmdTime;
|
|
|
+ try {
|
|
|
+ cmdTime = simpleDateFormat.parse(envmonitorDTO.getUpdateTime());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ //判断时区,为null默认东八区
|
|
|
+ long timezone = envmonitorDTO.getTimezone() == null ? 8 : envmonitorDTO.getTimezone();
|
|
|
+ long l = cmdTime.getTime() + timezone * 3600 * 1000;
|
|
|
+ cmdTime = new Date(l);
|
|
|
+ envmonitorDTO.setUpdateTime(simpleDateFormat.format(cmdTime));
|
|
|
+ }else {
|
|
|
+ envmonitorDTO.setUpdateTime("");
|
|
|
+ }
|
|
|
+ //获取设备安装时间
|
|
|
+ if (envmonitorDTO.getInstallDate() == null){
|
|
|
+ envmonitorDTO.setInstallDate("");
|
|
|
+ }else {
|
|
|
+ try {
|
|
|
+ envmonitorDTO.setInstallDate(simpleDateFormat.format(simpleDateFormat.parse(envmonitorDTO.getInstallDate())));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取设备过期时间
|
|
|
+ if (envmonitorDTO.getExpirationDate() == null){
|
|
|
+ envmonitorDTO.setExpirationDate("");
|
|
|
+ }else {
|
|
|
+ try {
|
|
|
+ envmonitorDTO.setExpirationDate(simpleDateFormat.format(simpleDateFormat.parse(envmonitorDTO.getExpirationDate())));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getHumidity() == null){
|
|
|
+ envmonitorDTO.setHumidity(0.0f);
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getTemperature() == null){
|
|
|
+ envmonitorDTO.setTemperature(0.0f);
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getPM10() == null){
|
|
|
+ envmonitorDTO.setPM10(0.0f);
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getNoise() == null){
|
|
|
+ envmonitorDTO.setNoise(0.0f);
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getPM25() == null){
|
|
|
+ envmonitorDTO.setPM25(0.0f);
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getIllumination() == null){
|
|
|
+ envmonitorDTO.setIllumination(0);
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getWindSpeed() == null){
|
|
|
+ envmonitorDTO.setWindSpeed(0.0f);
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getWindDire() == null){
|
|
|
+ envmonitorDTO.setWindDire(0);
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getRainfall() == null){
|
|
|
+ envmonitorDTO.setRainfall(0.0f);
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getRadiation() == null){
|
|
|
+ envmonitorDTO.setRadiation(0);
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getCo() == null){
|
|
|
+ envmonitorDTO.setCo(0);
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getCo2() == null){
|
|
|
+ envmonitorDTO.setCo2(0);
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getTsp() == null){
|
|
|
+ envmonitorDTO.setTsp(0);
|
|
|
+ }
|
|
|
+ if (envmonitorDTO.getAtmosPressue() == null){
|
|
|
+ envmonitorDTO.setAtmosPressue(0.0f);
|
|
|
+ }
|
|
|
+ list.add(envmonitorDTO);
|
|
|
+ });
|
|
|
+ vo.setList(list);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public EnvmonitorVO getDeviceCountBySectionList(EnvmonitorDTO dto) {
|
|
|
+ EnvmonitorVO vo = new EnvmonitorVO();
|
|
|
+ vo.setDeviceCount(envmonitorDao.getTotalBySectionList(dto));
|
|
|
+ vo.setOnlineCount(envmonitorDao.getOnlineTotalBySectionList(dto));
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+}
|