|
@@ -0,0 +1,523 @@
|
|
|
+package com.bizmatics.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.bizmatics.common.core.exception.BusinessException;
|
|
|
+import com.bizmatics.common.mvc.base.AbstractCrudService;
|
|
|
+import com.bizmatics.model.*;
|
|
|
+import com.bizmatics.model.system.SysUser;
|
|
|
+import com.bizmatics.model.vo.*;
|
|
|
+import com.bizmatics.persistence.mapper.BulletinCruxConfigMapper;
|
|
|
+import com.bizmatics.service.*;
|
|
|
+import com.bizmatics.service.util.SecurityUtils;
|
|
|
+import org.apache.commons.collections.ExtendedProperties;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 数据看板
|
|
|
+ *
|
|
|
+ * @author ya
|
|
|
+ * @since 2022-06-01
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class BulletinCruxConfigServiceImpl extends AbstractCrudService<BulletinCruxConfigMapper, BulletinCruxConfig> implements BulletinCruxConfigService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DeviceAnalogVariableListService deviceAnalogVariableListService;
|
|
|
+ @Autowired
|
|
|
+ private DeviceService deviceService;
|
|
|
+ @Autowired
|
|
|
+ private DeviceStatusService deviceStatusService;
|
|
|
+ @Autowired
|
|
|
+ private BulletinHistoricalConfigService bulletinHistoricalConfigService;
|
|
|
+ @Autowired
|
|
|
+ private BulletinHistoricalRelationService bulletinHistoricalRelationService;
|
|
|
+ @Autowired
|
|
|
+ private BulletinAlarmConfigService bulletinAlarmConfigService;
|
|
|
+ @Autowired
|
|
|
+ private DeviceAttributeService deviceAttributeService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据看板-数据配置查询
|
|
|
+ *
|
|
|
+ * @param siteId 站点ID
|
|
|
+ * @param id 配置ID
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<Object> getBulletinCruxConfigList(Integer siteId, Integer id, String colorType) {
|
|
|
+ List<Object> list2 = new ArrayList<>();
|
|
|
+ if (id != 0 && colorType.equals("iconText")) {
|
|
|
+ //配置数据查询1
|
|
|
+ List<BulletinCruxConfigVo> lsit1 = this.getbulletinCruxConfig(siteId, id);
|
|
|
+ if (lsit1.size() > 0) {
|
|
|
+ for (int i = 0; i < lsit1.size(); i++) {
|
|
|
+ lsit1.get(i).setIdx("" + (list2.size() + 1));
|
|
|
+ list2.add(lsit1.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (id != 0 && colorType.equals("echarts")) {
|
|
|
+ //配置数据查询2
|
|
|
+ List<BulletinCruxConfigVo> lsit3 = this.getBulletinHistoricalConfig(siteId,id);
|
|
|
+ if (lsit3.size() > 0) {
|
|
|
+ for (int i = 0; i < lsit3.size(); i++) {
|
|
|
+ lsit3.get(i).setColorType("echarts");
|
|
|
+ lsit3.get(i).setIdx("" + (list2.size() + 1));
|
|
|
+ list2.add(lsit3.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (id != 0 && colorType.equals("tabls")) {
|
|
|
+ //配置数据查询3
|
|
|
+ List<BulletinCruxConfigVo> lsit4 = this.getBulletinAlarmConfig(siteId,id);
|
|
|
+ if (lsit4.size() > 0) {
|
|
|
+ for (int i = 0; i < lsit4.size(); i++) {
|
|
|
+ lsit4.get(i).setIdx("" + (list2.size() + 1));
|
|
|
+ list2.add(lsit4.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ id = 0;
|
|
|
+ //配置数据查询1
|
|
|
+ List<BulletinCruxConfigVo> lsit1 = this.getbulletinCruxConfig(siteId, id);
|
|
|
+ if (lsit1.size() > 0) {
|
|
|
+ for (int i = 0; i < lsit1.size(); i++) {
|
|
|
+ lsit1.get(i).setIdx("" + (list2.size() + 1));
|
|
|
+ list2.add(lsit1.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //配置数据查询2
|
|
|
+ List<BulletinCruxConfigVo> lsit3 = this.getBulletinHistoricalConfig(siteId,id);
|
|
|
+ if (lsit3.size() > 0) {
|
|
|
+ for (int i = 0; i < lsit3.size(); i++) {
|
|
|
+ lsit3.get(i).setColorType("echarts");
|
|
|
+ lsit3.get(i).setIdx("" + (list2.size() + 1));
|
|
|
+ list2.add(lsit3.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //配置数据查询3
|
|
|
+ List<BulletinCruxConfigVo> lsit4 = this.getBulletinAlarmConfig(siteId,id);
|
|
|
+ if (lsit4.size() > 0) {
|
|
|
+ for (int i = 0; i < lsit4.size(); i++) {
|
|
|
+ lsit4.get(i).setIdx("" + (list2.size() + 1));
|
|
|
+ list2.add(lsit4.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list2;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 配置数据查询1
|
|
|
+ *
|
|
|
+ * @param siteId
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<BulletinCruxConfigVo> getbulletinCruxConfig(Integer siteId, Integer id) {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ SimpleDateFormat sdfa = new SimpleDateFormat("yyyy");
|
|
|
+ //配置数据查询1
|
|
|
+ LambdaQueryWrapper<BulletinCruxConfig> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(BulletinCruxConfig::getSiteId, siteId);
|
|
|
+ if (id != 0) {
|
|
|
+ queryWrapper.eq(BulletinCruxConfig::getId, id);
|
|
|
+ }
|
|
|
+ List<BulletinCruxConfig> list = this.list(queryWrapper);
|
|
|
+ List<BulletinCruxConfigVo> list1 = new ArrayList<>();
|
|
|
+ if (list.size() > 0) {
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ BulletinCruxConfigVo bulletinCruxConfigVo = new BulletinCruxConfigVo();
|
|
|
+ bulletinCruxConfigVo.setId(list.get(i).getId());
|
|
|
+ bulletinCruxConfigVo.setDataName(list.get(i).getDataName());
|
|
|
+ bulletinCruxConfigVo.setDataType(list.get(i).getDataType());
|
|
|
+ bulletinCruxConfigVo.setDataValue(list.get(i).getDataValue());
|
|
|
+ bulletinCruxConfigVo.setBackgroundColor(list.get(i).getBackgroundColor());
|
|
|
+ bulletinCruxConfigVo.setDataNameColor(list.get(i).getDataNameColor());
|
|
|
+ bulletinCruxConfigVo.setDataValueColor(list.get(i).getDataValueColor());
|
|
|
+ bulletinCruxConfigVo.setDataNameFont(list.get(i).getDataNameFont());
|
|
|
+ bulletinCruxConfigVo.setDataValueFont(list.get(i).getDataValueFont());
|
|
|
+ bulletinCruxConfigVo.setIconPath(list.get(i).getIconPath());
|
|
|
+ bulletinCruxConfigVo.setCreateBy(list.get(i).getCreateBy());
|
|
|
+ bulletinCruxConfigVo.setCreateTime(list.get(i).getCreateTime());
|
|
|
+ bulletinCruxConfigVo.setSiteId(list.get(i).getSiteId());
|
|
|
+ bulletinCruxConfigVo.setCoordinatex(list.get(i).getCoordinatex());
|
|
|
+ bulletinCruxConfigVo.setCoordinatey(list.get(i).getCoordinatey());
|
|
|
+ bulletinCruxConfigVo.setWide(list.get(i).getWide());
|
|
|
+ bulletinCruxConfigVo.setHigh(list.get(i).getHigh());
|
|
|
+// bulletinCruxConfigVo.setIdx(""+(list2.size()+1));
|
|
|
+ bulletinCruxConfigVo.setColorType("iconText");
|
|
|
+ if (list.get(i).getDataType() == 1) {//普通文本
|
|
|
+
|
|
|
+ } else if (list.get(i).getDataType() == 2) {//站点管理信息
|
|
|
+ List<SiteData> site = baseMapper.getSiteData(list.get(i).getSiteId());
|
|
|
+ //1名称 2地址 3联系电话 4额定容量 5供电类型 6电压等级 7投运时间 8运行天数
|
|
|
+ if (list.get(i).getDataValue() == 1) {
|
|
|
+ bulletinCruxConfigVo.setTextValue(site.get(0).getSiteName());
|
|
|
+ } else if (list.get(i).getDataValue() == 2) {
|
|
|
+ bulletinCruxConfigVo.setTextValue(site.get(0).getSiteAddress());
|
|
|
+ } else if (list.get(i).getDataValue() == 3) {
|
|
|
+ bulletinCruxConfigVo.setTextValue(site.get(0).getPhone());
|
|
|
+ } else if (list.get(i).getDataValue() == 4) {
|
|
|
+ bulletinCruxConfigVo.setTextValue(site.get(0).getInstalledCapacity());
|
|
|
+ } else if (list.get(i).getDataValue() == 5) {
|
|
|
+ if (site.get(0).getPowerSupplyType() == 1) {
|
|
|
+ bulletinCruxConfigVo.setTextValue("单路");
|
|
|
+ } else if (site.get(0).getPowerSupplyType() == 2) {
|
|
|
+ bulletinCruxConfigVo.setTextValue("双路");
|
|
|
+ }
|
|
|
+ } else if (list.get(i).getDataValue() == 6) {
|
|
|
+ bulletinCruxConfigVo.setTextValue(site.get(0).getVoltageLevel());
|
|
|
+ } else if (list.get(i).getDataValue() == 7) {
|
|
|
+ bulletinCruxConfigVo.setTextValue("" + site.get(0).getOperationTime());
|
|
|
+ } else if (list.get(i).getDataValue() == 8) {
|
|
|
+ int time = daysBetween(site.get(0).getCreateTime(), new Date());
|
|
|
+ bulletinCruxConfigVo.setTextValue("" + time);
|
|
|
+ }
|
|
|
+ } else if (list.get(i).getDataType() == 3) {//智能设备数据
|
|
|
+ LambdaQueryWrapper<DeviceAnalogVariableList> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.eq(DeviceAnalogVariableList::getId, list.get(i).getVariableId());
|
|
|
+ List<DeviceAnalogVariableList> deviceAttributelist = deviceAnalogVariableListService.list(queryWrapper1);
|
|
|
+ String[] deviceAttribute = deviceAttributelist.get(0).getVariableCoding().split("_");
|
|
|
+ String deviceCode = deviceAttribute[0];
|
|
|
+ String field = deviceAttribute[1];
|
|
|
+ String fieldData = null;
|
|
|
+ if (list.get(i).getMethod() == 1) {//平均
|
|
|
+ fieldData = " avg(" + field + ") as textValue ";
|
|
|
+ } else if (list.get(i).getMethod() == 2) {//最大
|
|
|
+ fieldData = " max(" + field + ") as textValue ";
|
|
|
+ } else if (list.get(i).getMethod() == 3) {//最小
|
|
|
+ fieldData = " min(" + field + ") as textValue ";
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<Device> queryWrapper2 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper2.eq(Device::getDeviceCode, deviceCode);
|
|
|
+ List<Device> Devicelist = deviceService.list(queryWrapper2);
|
|
|
+ String table = "ht_analog_data";
|
|
|
+ String table1 = "rt_analog_data";
|
|
|
+ if (Devicelist.get(0).getDeviceType().equals("1")) {
|
|
|
+ table = "ht_analog_data";
|
|
|
+ table1 = "rt_analog_data";
|
|
|
+ } else if (Devicelist.get(0).getDeviceType().equals("3")) {
|
|
|
+ table = "ht_analog_171_data";
|
|
|
+ table1 = "rt_analog_171_data";
|
|
|
+ } else if (Devicelist.get(0).getDeviceType().equals("4")) {
|
|
|
+ table = "ht_analog_173_data";
|
|
|
+ table1 = "rt_analog_173_data";
|
|
|
+ }
|
|
|
+ String startHms = "00:00:00";
|
|
|
+ String endHms = "23:59:59";
|
|
|
+ if (list.get(i).getCycle() == 1) {//本日
|
|
|
+ String time = sdf.format(new Date());
|
|
|
+ String startTime = time + " " + startHms;
|
|
|
+ String endTime = time + " " + endHms;
|
|
|
+ List<RtData> rtData = baseMapper.getTextData(table, fieldData, deviceCode, startTime, endTime);
|
|
|
+ bulletinCruxConfigVo.setTextValue(rtData.get(0).getTextValue());
|
|
|
+ } else if (list.get(i).getCycle() == 2) {//本月
|
|
|
+ Calendar calendar = new GregorianCalendar();
|
|
|
+ calendar.setTime(new Date());
|
|
|
+ //获得本月第一天
|
|
|
+ calendar.add(Calendar.MONTH, 0);
|
|
|
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ String startTime = sdf.format(calendar.getTime()) + " " + startHms;
|
|
|
+ //获得本月最后一天
|
|
|
+ calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
+ String endTime = sdf.format(calendar.getTime()) + " " + endHms;
|
|
|
+ List<RtData> rtData = baseMapper.getTextData(table, fieldData, deviceCode, startTime, endTime);
|
|
|
+ bulletinCruxConfigVo.setTextValue(rtData.get(0).getTextValue());
|
|
|
+ } else if (list.get(i).getCycle() == 3) {//本年
|
|
|
+ String time = sdfa.format(new Date());
|
|
|
+ String startTime = time + "-01-01 00:00:00";
|
|
|
+ String endTime = time + "-12-31 23:59:59";
|
|
|
+ List<RtData> rtData = baseMapper.getTextData(table, fieldData, deviceCode, startTime, endTime);
|
|
|
+ bulletinCruxConfigVo.setTextValue(rtData.get(0).getTextValue());
|
|
|
+ } else if (list.get(i).getCycle() == 3) {//实时值
|
|
|
+ List<RtData> rtData = baseMapper.getTextData(table1, field + " as textValue ", deviceCode, null, null);
|
|
|
+ bulletinCruxConfigVo.setTextValue(rtData.get(0).getTextValue());
|
|
|
+ }
|
|
|
+ } else if (list.get(i).getDataType() == 4) {//站点告警状态
|
|
|
+ Integer alarCount = baseMapper.getAlarmCount(siteId);
|
|
|
+ bulletinCruxConfigVo.setTextValue("无告警");
|
|
|
+ if (alarCount > 0) {
|
|
|
+ bulletinCruxConfigVo.setTextValue("告警");
|
|
|
+ }
|
|
|
+ } else if (list.get(i).getDataType() == 5) {//站点通信状态
|
|
|
+ LambdaQueryWrapper<DeviceStatus> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.eq(DeviceStatus::getSiteId, siteId);
|
|
|
+ List<DeviceStatus> deviceStatusList = deviceStatusService.list(queryWrapper1);
|
|
|
+ if (deviceStatusList.size() > 0) {
|
|
|
+ for (int j = 0; j < deviceStatusList.size(); j++) {
|
|
|
+ bulletinCruxConfigVo.setTextValue("在线");
|
|
|
+ if (deviceStatusList.get(j).getDeviceStatus() == 1) {
|
|
|
+ bulletinCruxConfigVo.setTextValue("离线");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ bulletinCruxConfigVo.setTextValue("离线");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list1.add(bulletinCruxConfigVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list1;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 配置数据查询2
|
|
|
+ *
|
|
|
+ * @param siteId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<BulletinCruxConfigVo> getBulletinHistoricalConfig(Integer siteId,Integer id) {
|
|
|
+ List<BulletinCruxConfigVo> bulletinCruxConfigVoList = baseMapper.getBulletinHistoricalConfig(siteId,id);
|
|
|
+ List<BulletinHistoricalRelationVo> bulletinHistoricalRelationList = this.getBulletinHistoricalRelationVo(siteId);
|
|
|
+ if (bulletinCruxConfigVoList.size() > 0) {
|
|
|
+ for (int i = 0; i < bulletinCruxConfigVoList.size(); i++) {
|
|
|
+ List<Object> bulletinHistoricalRelationList1 = new ArrayList<>();
|
|
|
+ for (int j = 0; j < bulletinHistoricalRelationList.size(); j++) {
|
|
|
+ if (bulletinCruxConfigVoList.get(i).getId() == bulletinHistoricalRelationList.get(j).getHistoricalId()) {
|
|
|
+ bulletinHistoricalRelationList1.add(bulletinHistoricalRelationList.get(j));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bulletinCruxConfigVoList.get(i).setRelationData(bulletinHistoricalRelationList1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return bulletinCruxConfigVoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 配置2变量数据
|
|
|
+ *
|
|
|
+ * @param siteId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<BulletinHistoricalRelationVo> getBulletinHistoricalRelationVo(Integer siteId) {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm:ss");
|
|
|
+ List<BulletinHistoricalRelationVo> bulletinHistoricalRelationList = baseMapper.getRelationData(siteId);
|
|
|
+ if (bulletinHistoricalRelationList.size() > 0) {
|
|
|
+ for (int i = 0; i < bulletinHistoricalRelationList.size(); i++) {
|
|
|
+ List<DeviceDataVo> deviceData = baseMapper.getDeviceData(bulletinHistoricalRelationList.get(i).getVariableId());
|
|
|
+ String table = "ht_analog_data";
|
|
|
+ if (deviceData.get(0).getDeviceType().equals("3")) {
|
|
|
+ table = "ht_analog_171_data";
|
|
|
+ } else if (deviceData.get(0).getDeviceType().equals("4")) {
|
|
|
+ table = "ht_analog_173_data";
|
|
|
+ }
|
|
|
+
|
|
|
+ String deviceCode = deviceData.get(0).getDeviceCode();
|
|
|
+ String time = sdf.format(new Date());
|
|
|
+ String startTime = time + " 00:00:00";
|
|
|
+ String endTime = time + " 23:59:59";
|
|
|
+ String field = " " + deviceData.get(0).getVariableCoding().split("_")[1] + " as textValue ,dataTime";
|
|
|
+ String group = " group by dataTime ";
|
|
|
+ if (bulletinHistoricalRelationList.get(i).getQueryCycle() == 2) {
|
|
|
+ Calendar calendar = new GregorianCalendar();
|
|
|
+ calendar.setTime(new Date());
|
|
|
+ //获得本月第一天
|
|
|
+ calendar.add(Calendar.MONTH, 0);
|
|
|
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ startTime = sdf.format(calendar.getTime()) + " 00:00:00";
|
|
|
+ //获得本月最后一天
|
|
|
+ calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
+ endTime = sdf.format(calendar.getTime()) + " 23:59:59";
|
|
|
+ group = " group by freezingTime ";
|
|
|
+ if (bulletinHistoricalRelationList.get(i).getQueryType() == 1) {
|
|
|
+ field = " avg(" + deviceData.get(0).getVariableCoding().split("_")[1] + ") as textValue ,freezingTime as dataTime";
|
|
|
+ } else if (bulletinHistoricalRelationList.get(i).getQueryType() == 2) {
|
|
|
+ field = " max(" + deviceData.get(0).getVariableCoding().split("_")[1] + ") as textValue ,freezingTime as dataTime";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<RtData> RtData = baseMapper.getHtAnalogData(table, field, deviceCode, startTime, endTime, group);
|
|
|
+ List<String> timeKeys = new ArrayList<>();
|
|
|
+ List<String> datas = new ArrayList<>();
|
|
|
+ if (RtData.size() > 0) {
|
|
|
+ for (int j = 0; j < RtData.size(); j++) {
|
|
|
+ datas.add(RtData.get(j).getTextValue());
|
|
|
+ if (bulletinHistoricalRelationList.get(i).getQueryCycle() == 1) {
|
|
|
+ timeKeys.add("" + sdf1.format(RtData.get(j).getDataTime()));
|
|
|
+ } else if (bulletinHistoricalRelationList.get(i).getQueryCycle() == 2) {
|
|
|
+ timeKeys.add("" + sdf.format(RtData.get(j).getDataTime()));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ bulletinHistoricalRelationList.get(i).setDatas(datas);
|
|
|
+ bulletinHistoricalRelationList.get(i).setTimeKeys(timeKeys);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return bulletinHistoricalRelationList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<BulletinCruxConfigVo> getBulletinAlarmConfig(Integer siteId, Integer id) {
|
|
|
+ List<BulletinCruxConfigVo> bulletinAlarmConfigList = baseMapper.getBulletinAlarmConfig(siteId, id);
|
|
|
+ if (bulletinAlarmConfigList.size() > 0) {
|
|
|
+ for (int i = 0; i < bulletinAlarmConfigList.size(); i++) {
|
|
|
+ bulletinAlarmConfigList.get(i).setColorType("tabls");
|
|
|
+ List<AlarmPowerVo> AlarmPowerVoList = baseMapper.getAlarmPower(siteId, bulletinAlarmConfigList.get(i).getAlarmType());
|
|
|
+ bulletinAlarmConfigList.get(i).setTextValue(AlarmPowerVoList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return bulletinAlarmConfigList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public int daysBetween(Date smdate, Date bdate) {
|
|
|
+ try {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ smdate = sdf.parse(sdf.format(smdate));
|
|
|
+ bdate = sdf.parse(sdf.format(bdate));
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.setTime(smdate);
|
|
|
+ long time1 = cal.getTimeInMillis();
|
|
|
+ cal.setTime(bdate);
|
|
|
+ long time2 = cal.getTimeInMillis();
|
|
|
+ long between_days = (time2 - time1) / (1000 * 3600 * 24);
|
|
|
+ return Integer.parseInt(String.valueOf(between_days));
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BusinessException("时间计算错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据看板-数据配置1编辑新增
|
|
|
+ *
|
|
|
+ * @param bulletinCruxConfig
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void editBulletinCruxConfig(BulletinCruxConfig bulletinCruxConfig) {
|
|
|
+ if (bulletinCruxConfig.getId() != 0) {
|
|
|
+ this.updateById(bulletinCruxConfig);
|
|
|
+ } else {
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
+ bulletinCruxConfig.setCreateTime(LocalDateTime.now());
|
|
|
+ bulletinCruxConfig.setCreateBy(user.getUserName());
|
|
|
+ this.save(bulletinCruxConfig);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据看板-数据配置2编辑新增
|
|
|
+ * @param bulletinHistoricalConfigAddVo
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void editBulletinHistoricalConfig(BulletinHistoricalConfigAddVo bulletinHistoricalConfigAddVo){
|
|
|
+ List<BulletinHistoricalRelation> bulletinHistoricalRelation = bulletinHistoricalConfigAddVo.getBulletinHistoricalRelationList();
|
|
|
+ BulletinHistoricalConfig bulletinHistoricalConfig = new BulletinHistoricalConfig();
|
|
|
+ bulletinHistoricalConfig.setId(bulletinHistoricalConfigAddVo.getId());
|
|
|
+ bulletinHistoricalConfig.setDataTitle(bulletinHistoricalConfigAddVo.getDataTitle());
|
|
|
+ bulletinHistoricalConfig.setIconPath(bulletinHistoricalConfigAddVo.getIconPath());
|
|
|
+ bulletinHistoricalConfig.setQueryCycle(bulletinHistoricalConfigAddVo.getQueryCycle());
|
|
|
+ bulletinHistoricalConfig.setQueryType(bulletinHistoricalConfigAddVo.getQueryType());
|
|
|
+ bulletinHistoricalConfig.setMaxDimension(bulletinHistoricalConfigAddVo.getMaxDimension());
|
|
|
+ bulletinHistoricalConfig.setMinDimension(bulletinHistoricalConfigAddVo.getMinDimension());
|
|
|
+ bulletinHistoricalConfig.setMeanDimension(bulletinHistoricalConfigAddVo.getMeanDimension());
|
|
|
+ bulletinHistoricalConfig.setLonAdaptation(bulletinHistoricalConfigAddVo.getLonAdaptation());
|
|
|
+ bulletinHistoricalConfig.setSiteId(bulletinHistoricalConfigAddVo.getSiteId());
|
|
|
+ bulletinHistoricalConfig.setCoordinatex(bulletinHistoricalConfigAddVo.getCoordinatex());
|
|
|
+ bulletinHistoricalConfig.setCoordinatey(bulletinHistoricalConfigAddVo.getCoordinatey());
|
|
|
+ bulletinHistoricalConfig.setWide(bulletinHistoricalConfigAddVo.getWide());
|
|
|
+ bulletinHistoricalConfig.setHigh(bulletinHistoricalConfigAddVo.getHigh());
|
|
|
+ if (bulletinHistoricalConfigAddVo.getId() != 0) {
|
|
|
+ bulletinHistoricalConfigService.updateById(bulletinHistoricalConfig);
|
|
|
+ if (bulletinHistoricalRelation.size()>0){
|
|
|
+ Integer historicalId = bulletinHistoricalConfigAddVo.getId();
|
|
|
+ baseMapper.delBulletinHistoricalRelation(historicalId);
|
|
|
+ for (int i = 0; i < bulletinHistoricalRelation.size(); i++) {
|
|
|
+ bulletinHistoricalRelation.get(i).setHistoricalId(bulletinHistoricalConfigAddVo.getId());
|
|
|
+ bulletinHistoricalRelationService.save(bulletinHistoricalRelation.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
+ bulletinHistoricalConfig.setCreateTime(LocalDateTime.now());
|
|
|
+ bulletinHistoricalConfig.setCreateBy(user.getUserName());
|
|
|
+ bulletinHistoricalConfigService.save(bulletinHistoricalConfig);
|
|
|
+ Integer historicalId = bulletinHistoricalConfig.getId();
|
|
|
+ if (bulletinHistoricalRelation.size()>0){
|
|
|
+ for (int i = 0; i < bulletinHistoricalRelation.size(); i++) {
|
|
|
+ bulletinHistoricalRelation.get(i).setHistoricalId(historicalId);
|
|
|
+ bulletinHistoricalRelationService.save(bulletinHistoricalRelation.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据看板-数据配置3编辑新增
|
|
|
+ * @param bulletinAlarmConfig
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void editBulletinAlarmConfig(BulletinAlarmConfig bulletinAlarmConfig){
|
|
|
+ if (bulletinAlarmConfig.getId() != 0) {
|
|
|
+ bulletinAlarmConfigService.updateById(bulletinAlarmConfig);
|
|
|
+ } else {
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
+ bulletinAlarmConfig.setCreateTime(LocalDateTime.now());
|
|
|
+ bulletinAlarmConfig.setCreateBy(user.getUserName());
|
|
|
+ bulletinAlarmConfigService.save(bulletinAlarmConfig);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据看板-数据配置1删除
|
|
|
+ *
|
|
|
+ * @param id 配置ID
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void delBulletinCruxConfig(Integer id) {
|
|
|
+ baseMapper.delBulletinCruxConfig(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据看板-数据配置2删除
|
|
|
+ * @param id 配置ID
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void delBulletinHistoricalConfig(Integer id) {
|
|
|
+ baseMapper.delBulletinHistoricalConfig(id);
|
|
|
+ baseMapper.delBulletinHistoricalRelation(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据看板-数据配置3删除
|
|
|
+ * @param id 配置ID
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void delBulletinAlarmConfig(Integer id) {
|
|
|
+ baseMapper.delBulletinAlarmConfig(id);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<DeviceAttribute> getDeviceAttribute(Integer siteId){
|
|
|
+ LambdaQueryWrapper<DeviceAttribute> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(DeviceAttribute::getSiteId, siteId);
|
|
|
+ List<DeviceAttribute> list = deviceAttributeService.list(queryWrapper);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<DeviceAnalogVariableList> getDeviceAnalogVariableList(Integer monitoringEquipment){
|
|
|
+ LambdaQueryWrapper<DeviceAnalogVariableList> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(DeviceAnalogVariableList::getMonitoringEquipment, monitoringEquipment);
|
|
|
+ List<DeviceAnalogVariableList> list = deviceAnalogVariableListService.list(queryWrapper);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+}
|