|
@@ -0,0 +1,243 @@
|
|
|
+package com.welampiot.service.impl;
|
|
|
+
|
|
|
+import com.welampiot.dao.TranshInfoDao;
|
|
|
+import com.welampiot.dto.TranshInfoDTO;
|
|
|
+import com.welampiot.service.TranshInfoService;
|
|
|
+import com.welampiot.vo.TranshInfoVO;
|
|
|
+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: TranshInfoServiceImpl
|
|
|
+ * Package: com.welampiot.service.impl
|
|
|
+ * Description:
|
|
|
+ *
|
|
|
+ * @Author: zhj_Start
|
|
|
+ * @Create: 2023/4/7 - 11:36
|
|
|
+ * @Version: v1.0
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class TranshInfoServiceImpl implements TranshInfoService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TranshInfoDao transhInfoDao;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TranshInfoVO getTotalBySectionList(List<TranshInfoDTO> sectionList) {
|
|
|
+ TranshInfoVO vo = new TranshInfoVO();
|
|
|
+ vo.setTotal(transhInfoDao.getTotalBySectionList(sectionList));
|
|
|
+ vo.setOnlineCount(transhInfoDao.getOnlineTotalBySectionList(sectionList));
|
|
|
+ vo.setAlarmCount(transhInfoDao.getAlarmTotalBySectionList(sectionList));
|
|
|
+ vo.setNormalCount(transhInfoDao.getNormalTotalBySectionList(sectionList));
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TranshInfoVO getTranshList(TranshInfoDTO dto, Integer version) {
|
|
|
+ TranshInfoVO vo = new TranshInfoVO();
|
|
|
+ List<TranshInfoDTO> transhList = transhInfoDao.getTranshListByDTO(dto);
|
|
|
+ List<TranshInfoDTO> list = new ArrayList<>();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ transhList.forEach(transhInfoDTO ->{
|
|
|
+ //网络状态:0 离线,1 在线
|
|
|
+ if (transhInfoDTO.getOnline() != null && transhInfoDTO.getOnline() == 1){
|
|
|
+ transhInfoDTO.setOnline(1);
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setOnline(0);
|
|
|
+ }
|
|
|
+ //设备注册状态
|
|
|
+ if (transhInfoDTO.getDeviceId() != null && !transhInfoDTO.getDeviceId().equals("")){
|
|
|
+ transhInfoDTO.setStatus(1);
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setStatus(0);
|
|
|
+ }
|
|
|
+ //盖子打开状态:0 关,1 开
|
|
|
+ if (transhInfoDTO.getState() != null && transhInfoDTO.getState() == 1){
|
|
|
+ transhInfoDTO.setState(1);
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setState(0);
|
|
|
+ }
|
|
|
+ //垃圾桶是否满溢:0 空,1 满
|
|
|
+ if (transhInfoDTO.getFull() != null && transhInfoDTO.getFull() == 1){
|
|
|
+ transhInfoDTO.setFull(1);
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setFull(0);
|
|
|
+ }
|
|
|
+ //报警状态:0 正常,1 报警(前提是网络在线)
|
|
|
+ if (transhInfoDTO.getOnline() == 1){
|
|
|
+ if (transhInfoDTO.getState() == 1 || transhInfoDTO.getFull() == 1){
|
|
|
+ transhInfoDTO.setAlarmStatus(1);
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setAlarmStatus(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //报警信息内容
|
|
|
+ if (transhInfoDTO.getAlarmStatus() != null && transhInfoDTO.getAlarmStatus() == 1){
|
|
|
+ if (transhInfoDTO.getState() == 1 && transhInfoDTO.getFull() == 1){
|
|
|
+ transhInfoDTO.setAlarmInfo("满溢告警,翻盖告警");
|
|
|
+ }else if (transhInfoDTO.getState() == 1 && transhInfoDTO.getFull() == 0){
|
|
|
+ transhInfoDTO.setAlarmInfo("翻盖告警");
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setAlarmInfo("满溢告警");
|
|
|
+ }
|
|
|
+ }else if (transhInfoDTO.getAlarmStatus() != null && transhInfoDTO.getAlarmStatus() == 0){
|
|
|
+ transhInfoDTO.setAlarmInfo("");
|
|
|
+ }
|
|
|
+ //数据更新时间
|
|
|
+ if (transhInfoDTO.getUpdateTime() != null && !transhInfoDTO.getUpdateTime().equals("")){
|
|
|
+ Date cmdTime;
|
|
|
+ try {
|
|
|
+ cmdTime = simpleDateFormat.parse(transhInfoDTO.getUpdateTime());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ //判断时区,为null默认东八区
|
|
|
+ long timezone = transhInfoDTO.getTimezone() == null ? 8 : transhInfoDTO.getTimezone();
|
|
|
+ long l = cmdTime.getTime() + timezone * 3600 * 1000;
|
|
|
+ cmdTime = new Date(l);
|
|
|
+ transhInfoDTO.setUpdateTime(simpleDateFormat.format(cmdTime));
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setUpdateTime("");
|
|
|
+ }
|
|
|
+ //设备创建时间
|
|
|
+ if (transhInfoDTO.getCreateTime() != null){
|
|
|
+ try {
|
|
|
+ transhInfoDTO.setCreateTime(simpleDateFormat.format(simpleDateFormat.parse(transhInfoDTO.getCreateTime())));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setCreateTime("");
|
|
|
+ }
|
|
|
+ //获取设备位置信息
|
|
|
+ if (version == 0){
|
|
|
+ //获取区域的中文名称
|
|
|
+ if (transhInfoDTO.getChineseName() != null && !transhInfoDTO.getChineseName().equals("")){
|
|
|
+ transhInfoDTO.setArea(transhInfoDTO.getChineseName());
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setArea("");
|
|
|
+ }
|
|
|
+ //获取城市的中文名称
|
|
|
+ if (transhInfoDTO.getChCity() != null && !transhInfoDTO.getChCity().equals("")){
|
|
|
+ transhInfoDTO.setCity(transhInfoDTO.getChCity());
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setCity("");
|
|
|
+ }
|
|
|
+ //获取路段
|
|
|
+ if (transhInfoDTO.getSection() == null){
|
|
|
+ transhInfoDTO.setSection("");
|
|
|
+ }
|
|
|
+ //组合设备位置名称:城市 + 区域 + 路段
|
|
|
+ transhInfoDTO.setLocation(transhInfoDTO.getCity() + " " + transhInfoDTO.getArea() + " " + transhInfoDTO.getSection());
|
|
|
+ }else if (version == 1){
|
|
|
+ //获取区域的英文名称
|
|
|
+ if (transhInfoDTO.getEnglishName() != null && !transhInfoDTO.getEnglishName().equals("")){
|
|
|
+ transhInfoDTO.setArea(transhInfoDTO.getEnglishName());
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setArea("");
|
|
|
+ }
|
|
|
+ //获取城市的英文名称
|
|
|
+ if (transhInfoDTO.getEnCity() != null && !transhInfoDTO.getEnCity().equals("")){
|
|
|
+ transhInfoDTO.setCity(transhInfoDTO.getEnCity());
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setCity("");
|
|
|
+ }
|
|
|
+ //获取路段
|
|
|
+ if (transhInfoDTO.getSection() == null){
|
|
|
+ transhInfoDTO.setSection("");
|
|
|
+ }
|
|
|
+ //组合设备位置名称:城市 + 区域 + 路段
|
|
|
+ transhInfoDTO.setLocation(transhInfoDTO.getCity() + " " + transhInfoDTO.getArea() + " " + transhInfoDTO.getSection());
|
|
|
+ }else {
|
|
|
+ //获取区域的俄文名称
|
|
|
+ if (transhInfoDTO.getRuName() != null && !transhInfoDTO.getRuName().equals("")){
|
|
|
+ transhInfoDTO.setArea(transhInfoDTO.getRuName());
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setArea("");
|
|
|
+ }
|
|
|
+ //获取城市的俄文名称
|
|
|
+ if (transhInfoDTO.getRuCity() != null && !transhInfoDTO.getRuCity().equals("")){
|
|
|
+ transhInfoDTO.setCity(transhInfoDTO.getRuCity());
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setCity("");
|
|
|
+ }
|
|
|
+ //获取路段
|
|
|
+ if (transhInfoDTO.getSection() == null){
|
|
|
+ transhInfoDTO.setSection("");
|
|
|
+ }
|
|
|
+ //组合设备位置名称:城市 + 区域 + 路段
|
|
|
+ transhInfoDTO.setLocation(transhInfoDTO.getCity() + " " + transhInfoDTO.getArea() + " " + transhInfoDTO.getSection());
|
|
|
+ }
|
|
|
+ list.add(transhInfoDTO);
|
|
|
+ });
|
|
|
+ vo.setList(list);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TranshInfoVO getHistoryListByDTO(TranshInfoDTO dto) {
|
|
|
+ TranshInfoVO vo = new TranshInfoVO();
|
|
|
+ List<TranshInfoDTO> historyList = transhInfoDao.getHistoryListByDTO(dto);
|
|
|
+ List<TranshInfoDTO> list = new ArrayList<>();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ historyList.forEach(transhInfoDTO ->{
|
|
|
+ if (transhInfoDTO.getState() != null && transhInfoDTO.getState() == 1){
|
|
|
+ transhInfoDTO.setState(1);
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setState(0);
|
|
|
+ }
|
|
|
+ if (transhInfoDTO.getFull() != null && transhInfoDTO.getFull() == 1){
|
|
|
+ transhInfoDTO.setFull(1);
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setFull(0);
|
|
|
+ }
|
|
|
+ if (transhInfoDTO.getOnline() != null && transhInfoDTO.getOnline() == 1){
|
|
|
+ transhInfoDTO.setOnline(1);
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setOnline(0);
|
|
|
+ }
|
|
|
+ if (transhInfoDTO.getOnline() == 1){
|
|
|
+ if (transhInfoDTO.getFull() == 1 || transhInfoDTO.getState() == 1){
|
|
|
+ transhInfoDTO.setAlarmStatus(1);
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setAlarmStatus(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (transhInfoDTO.getAlarmStatus() != null && transhInfoDTO.getAlarmStatus() == 1){
|
|
|
+ if (transhInfoDTO.getFull() == 1 && transhInfoDTO.getState() == 1){
|
|
|
+ transhInfoDTO.setAlarmInfo("满溢告警,翻盖告警");
|
|
|
+ }else if (transhInfoDTO.getFull() == 1 && transhInfoDTO.getState() == 0){
|
|
|
+ transhInfoDTO.setAlarmInfo("满溢告警");
|
|
|
+ }else {
|
|
|
+ transhInfoDTO.setAlarmInfo("翻盖告警");
|
|
|
+ }
|
|
|
+ }else if (transhInfoDTO.getAlarmStatus() != null && transhInfoDTO.getAlarmStatus() == 0){
|
|
|
+ transhInfoDTO.setAlarmInfo("");
|
|
|
+ }
|
|
|
+ if (transhInfoDTO.getUpdateTime() == null){
|
|
|
+ transhInfoDTO.setUpdateTime("");
|
|
|
+ }else {
|
|
|
+ Date cmdTime;
|
|
|
+ try {
|
|
|
+ cmdTime = simpleDateFormat.parse(transhInfoDTO.getUpdateTime());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ //判断时区,为null默认东八区
|
|
|
+ long timezone = transhInfoDTO.getTimezone() == null ? 8 : transhInfoDTO.getTimezone();
|
|
|
+ long l = cmdTime.getTime() + timezone * 3600 * 1000;
|
|
|
+ cmdTime = new Date(l);
|
|
|
+ transhInfoDTO.setUpdateTime(simpleDateFormat.format(cmdTime));
|
|
|
+ }
|
|
|
+ list.add(transhInfoDTO);
|
|
|
+ });
|
|
|
+ vo.setList(list);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+}
|