初始化
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.energy.pojo.param.AirStrategyParam;
|
||||
import com.njcn.energy.pojo.param.NetDevParam;
|
||||
import com.njcn.energy.pojo.po.AirStrategy;
|
||||
import com.njcn.energy.pojo.po.NetDev;
|
||||
import com.njcn.energy.pojo.vo.AirStrategyVO;
|
||||
import com.njcn.energy.pojo.vo.EnergyDeviceTreeVO;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/4/21
|
||||
*/
|
||||
public interface EleAirStrategyService extends IService<AirStrategy> {
|
||||
|
||||
Page<AirStrategy> listAirStrategy(AirStrategyParam.AirStrategyQueryParam airStrategyQueryParam);
|
||||
|
||||
/**
|
||||
* 新增空调策略
|
||||
*
|
||||
* @param airStrategyParam 空调策略数据
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean addAirStrategy(AirStrategyParam airStrategyParam);
|
||||
|
||||
/**
|
||||
* 修改空调策略
|
||||
*
|
||||
* @param updateParam 空调策略数据
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean updateAirStrategy(AirStrategyParam.AirUpdateParam updateParam);
|
||||
|
||||
/**
|
||||
* 批量逻辑删除空调策略数据
|
||||
* @param id id
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean deleteAirStrategy(String id);
|
||||
|
||||
/**
|
||||
* 获取空调策略信息
|
||||
* @param id id
|
||||
* @return NetDev
|
||||
*/
|
||||
AirStrategyVO findById(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 停止执行任务
|
||||
* @author cdf
|
||||
* @date 2022/4/22
|
||||
*/
|
||||
boolean startAirStrategy(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 定时执行任务
|
||||
* @author cdf
|
||||
* @date 2022/4/22
|
||||
*/
|
||||
void dealAirStrategyId(String id,String operation);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.param.EleParam;
|
||||
import com.njcn.energy.pojo.vo.EleLoadSetTreeVO;
|
||||
import com.njcn.energy.pojo.vo.EleLoadSetVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年04月15日 14:24
|
||||
*/
|
||||
public interface EleLoadSetService {
|
||||
|
||||
/**
|
||||
* 详情
|
||||
* @return 结果
|
||||
*/
|
||||
List<EleLoadSetVO> getEleLoadSetDetail();
|
||||
|
||||
/**
|
||||
* 绑定监测点树
|
||||
* @return 结果
|
||||
*/
|
||||
EleLoadSetTreeVO getEleLoadTree(EleLoadSetVO eleLoadSetVO);
|
||||
|
||||
Boolean add(EleParam eleParam);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.po.EleRateSet;
|
||||
import com.njcn.energy.pojo.vo.EleRateVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 费率配置
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年04月13日 19:36
|
||||
*/
|
||||
public interface EleRateSetService {
|
||||
|
||||
/**
|
||||
* 获取费率配置
|
||||
* @return 结果
|
||||
*/
|
||||
List<EleRateVO> getEleRateDetail();
|
||||
|
||||
boolean add(EleRateSet eleRateSet);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.param.EleParam;
|
||||
import com.njcn.energy.pojo.vo.EleStatisticalTreeVO;
|
||||
import com.njcn.energy.pojo.vo.EleStatisticalVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用能统计类型配置
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年04月14日 15:15
|
||||
*/
|
||||
public interface EleStatisticalSetService {
|
||||
/**
|
||||
* 详情
|
||||
* @return 结果
|
||||
*/
|
||||
List<EleStatisticalVO> getEleStatisticalDetail();
|
||||
|
||||
/**
|
||||
* 树
|
||||
* @param eleStatisticalVO 参数
|
||||
* @return 结果
|
||||
*/
|
||||
EleStatisticalTreeVO getEleStatisticalTree(EleStatisticalVO eleStatisticalVO);
|
||||
|
||||
/**
|
||||
* 绑定
|
||||
* @param id id
|
||||
* @param ids ids
|
||||
* @return 结果
|
||||
*/
|
||||
Boolean add(EleParam eleParam);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.param.ElectComparaParam;
|
||||
import com.njcn.energy.pojo.param.JobInfoParam;
|
||||
import com.njcn.energy.pojo.param.LoadStatisticParam;
|
||||
import com.njcn.energy.pojo.vo.ElectCompareVO;
|
||||
import com.njcn.energy.pojo.vo.LoadStatisticVO;
|
||||
import com.njcn.energy.pojo.vo.LoadTendencyVO;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/4/14
|
||||
*/
|
||||
public interface HighAnalyticService {
|
||||
|
||||
|
||||
/**
|
||||
* 获取负荷趋势分析
|
||||
* @author cdf
|
||||
* @date 2022/4/15
|
||||
*/
|
||||
List<LoadTendencyVO> getLoadTendency(String loadType,String start,String end);
|
||||
|
||||
|
||||
List<LoadTendencyVO> getLoadDetail(String loadType,String start,String end);
|
||||
|
||||
/**
|
||||
* 负荷占比
|
||||
* @author cdf
|
||||
* @date 2022/4/28
|
||||
*/
|
||||
List<Map<String, String>> getLoadRate(String loadType,String start);
|
||||
|
||||
/**
|
||||
* 负荷统计分析
|
||||
* @author cdf
|
||||
* @date 2022/4/18
|
||||
*/
|
||||
List<LoadStatisticVO> getLoadStatistics(LoadStatisticParam loadStatisticParam);
|
||||
|
||||
|
||||
/**
|
||||
* 获取电度趋势分析
|
||||
* @author cdf
|
||||
* @date 2022/4/15
|
||||
*/
|
||||
List<LoadTendencyVO> getElectTendency(String loadType,Integer type,String start,String end);
|
||||
|
||||
|
||||
/**
|
||||
* 获取电度比较分析
|
||||
* @author cdf
|
||||
* @date 2022/4/15
|
||||
*/
|
||||
List<ElectCompareVO> getElectCompare(ElectComparaParam electComparaParam);
|
||||
|
||||
|
||||
/**
|
||||
* 电度占比
|
||||
* @author cdf
|
||||
* @date 2022/4/27
|
||||
*/
|
||||
List<Map<String, String>> getElectRate(ElectComparaParam electComparaParam);
|
||||
|
||||
/**
|
||||
* 电度统计分析
|
||||
* @author cdf
|
||||
* @date 2022/4/19
|
||||
*/
|
||||
List<LoadStatisticVO> getElectStatistic(ElectComparaParam electComparaParam);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取空调趋势
|
||||
* @author cdf
|
||||
* @date 2022/4/15
|
||||
*/
|
||||
List<LoadTendencyVO> getAirTendency(String start,String end);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.param.DataArrayParam;
|
||||
import com.njcn.energy.pojo.po.DataArray;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IDataArrayService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增装置详细模板数据
|
||||
*
|
||||
* @param dataArrayParam
|
||||
* @return com.njcn.energy.pojo.po.DataArray
|
||||
* @author xy
|
||||
* @date 2022/3/9 15:51
|
||||
*/
|
||||
DataArray addDataArray(DataArrayParam dataArrayParam);
|
||||
|
||||
|
||||
/**
|
||||
* 功能描述: 新增装置详细模板数据
|
||||
*
|
||||
* @param list
|
||||
* @return com.njcn.energy.pojo.po.DataArray
|
||||
* @author xy
|
||||
* @date 2022/3/9 15:51
|
||||
*/
|
||||
boolean deleteDataArray(List<String> list);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.param.DataGroupParam;
|
||||
import com.njcn.energy.pojo.po.DataGroup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IDataGroupService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增分组数据
|
||||
*
|
||||
* @param dataGroupParam 分组参数
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/16 9:27
|
||||
*/
|
||||
DataGroup addDataGroup(DataGroupParam dataGroupParam);
|
||||
|
||||
/**
|
||||
* 批量新增组
|
||||
* @author cdf
|
||||
* @date 2022/3/17
|
||||
* @param list 分组参数
|
||||
* @return boolean
|
||||
*/
|
||||
boolean batchAdd(List<DataGroup> list);
|
||||
/**
|
||||
* 功能描述: 根据数据集id查询分组信息
|
||||
*
|
||||
* @param list
|
||||
* @return java.util.List<com.njcn.energy.pojo.po.DataGroup>
|
||||
* @author xy
|
||||
* @date 2022/3/17 10:41
|
||||
*/
|
||||
List<DataGroup> findGroupById(List<String> list);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据数据集id查询分组信息
|
||||
*
|
||||
* @param list 数据集id
|
||||
* @return java.util.List<com.njcn.energy.pojo.po.DataGroup>
|
||||
* @author xy
|
||||
* @date 2022/3/17 10:41
|
||||
*/
|
||||
boolean deleteDataGroup(List<String> list);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.param.DataSetParam;
|
||||
import com.njcn.energy.pojo.po.DataSet;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IDataSetService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增数据集
|
||||
*
|
||||
* @param dataSetParam
|
||||
* @return com.njcn.energy.pojo.po.DataSet
|
||||
* @author xy
|
||||
* @date 2022/3/9 10:18
|
||||
*/
|
||||
DataSet add(DataSetParam dataSetParam);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据id删除数据集
|
||||
*
|
||||
* @param id 主键
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/17 9:39
|
||||
*/
|
||||
boolean delete(String id);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据id查询数据集
|
||||
*
|
||||
* @param id
|
||||
* @return java.util.List<com.njcn.energy.pojo.po.DataSet>
|
||||
* @author xy
|
||||
* @date 2022/3/17 10:30
|
||||
*/
|
||||
List<DataSet> findSetById(String id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.param.DataModelParam;
|
||||
import com.njcn.energy.pojo.po.DataMould;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IDevModelService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增设备数据模板表
|
||||
*
|
||||
* @param dataModelParam
|
||||
* @return com.njcn.energy.pojo.po.DataMould
|
||||
* @author xy
|
||||
* @date 2022/3/8 20:44
|
||||
*/
|
||||
DataMould addDataMould(DataModelParam dataModelParam);
|
||||
|
||||
/**
|
||||
* 功能描述: 删除模板
|
||||
*
|
||||
* @param id
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/17 14:15
|
||||
*/
|
||||
boolean deleteById(String id);
|
||||
|
||||
/**
|
||||
* 功能描述: 查找模板
|
||||
*
|
||||
* @param name
|
||||
* @param version
|
||||
* @param time
|
||||
* @return com.njcn.energy.pojo.po.DataMould
|
||||
* @author xy
|
||||
* @date 2022/3/23 19:29
|
||||
*/
|
||||
DataMould findMould(String name, String version, String time);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.param.DevVersionParam;
|
||||
import com.njcn.energy.pojo.po.DevVersion;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IDevVersionService {
|
||||
|
||||
/**
|
||||
* 新增网关设备
|
||||
*
|
||||
* @param devVersionParam 设备版本信息
|
||||
* @return 操作结果
|
||||
*/
|
||||
DevVersion addDevVersion(DevVersionParam devVersionParam);
|
||||
|
||||
/**
|
||||
* 功能描述: 删除设备版本信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @author xy
|
||||
* @date 2022/3/17 16:30
|
||||
*/
|
||||
boolean deleteDevVersion(String id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.po.EleActrl;
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IEleActrlService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param eleActrl
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean addActrl(EleActrl eleActrl);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param eleActrl
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean updateActrl(EleActrl eleActrl);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param name
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
EleActrl findByName(String name);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.po.EleALM;
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/15 18:48
|
||||
*/
|
||||
|
||||
public interface IEleAlmService {
|
||||
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param eleAlM
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean addAlm(EleALM eleAlM);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param eleAlM
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean updateAlm(EleALM eleAlM);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param name
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
EleALM findByName(String name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.param.ElDataBindParam;
|
||||
import com.njcn.energy.pojo.po.EleBind;
|
||||
import com.njcn.energy.pojo.vo.YunCaiDataVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/3/30
|
||||
*/
|
||||
public interface IEleBindService {
|
||||
|
||||
/**
|
||||
* 新增绑定关系
|
||||
* @author cdf
|
||||
* @date 2022/3/30
|
||||
*/
|
||||
boolean addBind(ElDataBindParam elDataBindParam);
|
||||
|
||||
/**
|
||||
* 获取所有绑定关系
|
||||
* @author cdf
|
||||
* @date 2022/3/30
|
||||
*/
|
||||
List<EleBind> getList(String ndid);
|
||||
|
||||
/**
|
||||
* 获取指定系统下的数据
|
||||
* @author cdf
|
||||
* @date 2022/3/30
|
||||
*/
|
||||
List<YunCaiDataVO> getLineListDetail(List<String> lineList);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.po.EleCtrl;
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IEleCtrlService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param eleCtrl
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean addCtrl(EleCtrl eleCtrl);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param eleCtrl
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean updateCtrl(EleCtrl eleCtrl);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param name
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
EleCtrl findByName(String name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.po.EleDi;
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IEleDiService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param eleDi
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean addDi(EleDi eleDi);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param eleDi
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean updateDi(EleDi eleDi);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param name
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
EleDi findByName(String name);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.energy.pojo.param.DictParam;
|
||||
import com.njcn.energy.pojo.po.EleDict;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/24 10:59
|
||||
*/
|
||||
|
||||
public interface IEleDictService {
|
||||
|
||||
/**
|
||||
* 功能描述: 根据名称查询字段数据
|
||||
*
|
||||
* @param name 字典名称
|
||||
* @return com.njcn.energy.pojo.po.EleDict
|
||||
* @author xy
|
||||
* @date 2022/3/24 11:08
|
||||
*/
|
||||
EleDict findDictByName(String name);
|
||||
|
||||
/**
|
||||
* 功能描述: 查询influxDB表名
|
||||
*
|
||||
* @param name 字典名称
|
||||
* @return com.njcn.energy.pojo.po.EleDict
|
||||
* @author xy
|
||||
* @date 2022/3/24 11:08
|
||||
*/
|
||||
EleDict findTableName(String name);
|
||||
|
||||
|
||||
/**
|
||||
* 新增字典
|
||||
* @author cdf
|
||||
* @date 2022/3/22
|
||||
*/
|
||||
boolean add(DictParam dictParam);
|
||||
|
||||
/**
|
||||
* 修改字典
|
||||
* @author cdf
|
||||
* @date 2022/3/22
|
||||
*/
|
||||
boolean update(DictParam.DictUpdateParam dictUpdateParam);
|
||||
|
||||
|
||||
/**
|
||||
* 删除字典
|
||||
* @author cdf
|
||||
* @date 2022/3/22
|
||||
*/
|
||||
boolean delete(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 查询字典列表
|
||||
* @author cdf
|
||||
* @date 2022/3/22
|
||||
*/
|
||||
Page<EleDict> getList(DictParam.DictQueryParam dictQueryParam);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询字典
|
||||
* @author cdf
|
||||
* @date 2022/3/22
|
||||
*/
|
||||
EleDict getById(String id);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.po.EleDo;
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IEleDoService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param eleDo
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean addDo(EleDo eleDo);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param eleDo
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean updateDo(EleDo eleDo);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param name
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
EleDo findByName(String name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.dto.EpdPqdDTO;
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IEleEpdPqdService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param eleEpdPqd
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean addEpd(EleEpdPqd eleEpdPqd);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param eleEpdPqd
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean updateEpd(EleEpdPqd eleEpdPqd);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param name
|
||||
* @param name
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
EleEpdPqd findByName(String name,String phase);
|
||||
|
||||
/**
|
||||
* 获取所有负荷指标
|
||||
* @author cdf
|
||||
* @date 2022/4/15
|
||||
*/
|
||||
List<EleEpdPqd> getAllEpd();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.po.EleEvt;
|
||||
import com.njcn.energy.pojo.po.EleEvtParm;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/15 16:19
|
||||
*/
|
||||
|
||||
public interface IEleEvtParamService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增eleEvt数据
|
||||
*
|
||||
* @param eleEvtParam
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean addEleEvtParam(EleEvtParm eleEvtParam);
|
||||
|
||||
/**
|
||||
* 功能描述: 修改eleEvt数据
|
||||
*
|
||||
* @param eleEvtParam
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean updateEleEvtParam(EleEvtParm eleEvtParam);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据名称查找
|
||||
*
|
||||
* @param name
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
EleEvtParm findByName(String name);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据id删除
|
||||
*
|
||||
* @param id
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean deleteById(String id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
import com.njcn.energy.pojo.po.EleEvt;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IEleEvtService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增eleEvt数据
|
||||
*
|
||||
* @param eleEvt
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
EleEvt addEvt(EleEvt eleEvt);
|
||||
|
||||
/**
|
||||
* 功能描述: 修改eleEvt数据
|
||||
*
|
||||
* @param eleEvt
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean updateEvt(EleEvt eleEvt);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据名称查找
|
||||
*
|
||||
* @param name
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
EleEvt findByName(String name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.dto.OnlineRateDTO;
|
||||
import com.njcn.energy.pojo.po.EleInformation;
|
||||
import com.njcn.energy.pojo.vo.EleIntegrityVO;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/4/19 10:49
|
||||
*/
|
||||
|
||||
public interface IEleInformationService {
|
||||
|
||||
/**
|
||||
* 功能描述: 记录装置上线、下线信息
|
||||
* @param list 集合
|
||||
* @author xy
|
||||
* @date 2022/4/19 10:53
|
||||
* @return
|
||||
*/
|
||||
void addInformation(List<EleInformation> list);
|
||||
|
||||
/**
|
||||
* 功能描述: 获取装置上下线时间
|
||||
* @author xy
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @date 2022/4/20 9:17
|
||||
* @return
|
||||
*/
|
||||
List<OnlineRateDTO> getDeviceTime(String startTime, String endTime);
|
||||
|
||||
/**
|
||||
* 功能描述:
|
||||
* @author xy
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @date 2022/4/20 18:53
|
||||
* @return
|
||||
*/
|
||||
List<EleIntegrityVO> getOnlineRateTree(String startTime, String endTime);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.vo.EleIntegrityVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/31 19:39
|
||||
*/
|
||||
|
||||
public interface IEleIntegrityService {
|
||||
|
||||
/**
|
||||
* 功能描述:获取用能数据完整性树表
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return java.util.List<com.njcn.energy.pojo.vo.EleIntegrityVO>
|
||||
* @author xy
|
||||
* @date 2022/4/13 10:52
|
||||
*/
|
||||
List<EleIntegrityVO> getIntegrityTree(String startTime, String endTime);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.param.LineParam;
|
||||
import com.njcn.energy.pojo.po.EleLine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IEleLineService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增监测点数据
|
||||
*
|
||||
* @param lineParam
|
||||
* @return com.njcn.energy.pojo.po.EleLine
|
||||
* @author xy
|
||||
* @date 2022/3/8 14:34
|
||||
*/
|
||||
EleLine add( LineParam lineParam);
|
||||
|
||||
/**
|
||||
* 功能描述: 删除监测点信息
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
* @author xy
|
||||
* @date 2022/3/17 16:42
|
||||
*/
|
||||
boolean deleteByList(List<String> list);
|
||||
|
||||
/**
|
||||
* 根据网关获取网关下所有已注册监测点
|
||||
* @author cdf
|
||||
* @date 2022/3/29
|
||||
*/
|
||||
List<EleLine> getAllLine(String netDevString);
|
||||
|
||||
/**
|
||||
* 功能描述:获取装置下所有的监测点信息
|
||||
* @param list 逻辑设备集合
|
||||
* @author xy
|
||||
* @date 2022/4/13 11:17
|
||||
* @return 监测点信息
|
||||
*/
|
||||
List<EleLine> getAllLines(List<String> list);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据监测点id获取监测点信息
|
||||
* @author xy
|
||||
* @param list
|
||||
* @date 2022/4/26 13:55
|
||||
* @return
|
||||
*/
|
||||
List<EleLine> getLineInfo(List<String> list);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.po.EleLogs;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IEleLogsService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增日志
|
||||
*
|
||||
* @param eleLogs
|
||||
* @return void
|
||||
* @author xy
|
||||
* @date 2022/4/6 20:00
|
||||
*/
|
||||
void addLogs(EleLogs eleLogs);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
import com.njcn.energy.pojo.po.EleMd;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IEleMdService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增MD数据
|
||||
*
|
||||
* @param eleMd
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean addMd(EleMd eleMd);
|
||||
|
||||
/**
|
||||
* 功能描述: 修改MD数据
|
||||
*
|
||||
* @param eleMd
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean updateMd(EleMd eleMd);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @param phase
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
EleMd findByName(String name,String phase);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
import com.njcn.energy.pojo.po.EleParm;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/15 19:44
|
||||
*/
|
||||
|
||||
public interface IEleParmService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param eleParm
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean addParm(EleParm eleParm);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param eleParm
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean updateParm(EleParm eleParm);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param name
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
EleParm findByName(String name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.energy.pojo.po.AirSet;
|
||||
import com.njcn.energy.pojo.po.NetDev;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/4/21
|
||||
*/
|
||||
public interface IEleSetService extends IService<AirSet>{
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
import com.njcn.energy.pojo.po.EleSts;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IEleStsService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param eleSts
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean addSts(EleSts eleSts);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param eleSts
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
boolean updateSts(EleSts eleSts);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增EPD PQD数据
|
||||
*
|
||||
* @param name
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/15 10:11
|
||||
*/
|
||||
EleSts findByName(String name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.po.EleTopic;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IEleTopicService {
|
||||
|
||||
/**
|
||||
* 功能描述: 新增网管主题信息
|
||||
*
|
||||
* @param eleTopic
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/22 19:05
|
||||
*/
|
||||
boolean addTopic(EleTopic eleTopic);
|
||||
|
||||
/**
|
||||
* 功能描述: 查询网管主题信息
|
||||
*
|
||||
* @param id
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/22 19:05
|
||||
*/
|
||||
List<EleTopic> list(String id);
|
||||
|
||||
/**
|
||||
* 功能描述: 删除网管主题信息
|
||||
*
|
||||
* @param id
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/22 19:05
|
||||
*/
|
||||
boolean delete(String id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.po.GroupArray;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IGroupArrayService {
|
||||
|
||||
/**
|
||||
* 功能描述: 分配组和数据的关系
|
||||
*
|
||||
* @param groupId
|
||||
* @param arrId
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/16 13:33
|
||||
*/
|
||||
void groupArrayRelation(String groupId,String arrId);
|
||||
|
||||
|
||||
/**
|
||||
* 批量新增组
|
||||
* @author cdf
|
||||
* @date 2022/3/17
|
||||
* @param list 分组参数
|
||||
* @return boolean
|
||||
*/
|
||||
boolean batchAdd(List<GroupArray> list);
|
||||
/**
|
||||
* 功能描述: 删除组和详细数据关系
|
||||
*
|
||||
* @param list 组集合
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/16 13:33
|
||||
*/
|
||||
boolean deleteGroupArray(List<String> list);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.param.HardwareParam;
|
||||
import com.njcn.energy.pojo.po.Hardware;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IHardwareService {
|
||||
|
||||
/**
|
||||
* 功能描述: 存储硬件信息
|
||||
*
|
||||
* @param hardwareParam
|
||||
* @return com.njcn.energy.pojo.po.Hardware
|
||||
* @author xy
|
||||
* @date 2022/3/8 10:53
|
||||
*/
|
||||
Hardware addHardware(HardwareParam hardwareParam);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据id删除已有硬件信息
|
||||
*
|
||||
* @param list
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/3/16 19:54
|
||||
*/
|
||||
boolean deleteHardware(List<String> list);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
import com.njcn.energy.pojo.po.LogicAccess;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface ILogicAccessService {
|
||||
|
||||
/**
|
||||
* 功能描述: 根据pid获取逻辑装置
|
||||
* @return java.util.List<com.njcn.energy.pojo.po.LogicAccess>
|
||||
* @author xy
|
||||
* @date 2022/3/23 21:59
|
||||
*/
|
||||
List<LogicAccess> findAccessDev(List<String> did);
|
||||
|
||||
/**
|
||||
* 功能描述: 新增
|
||||
* @return java.util.List<com.njcn.energy.pojo.po.LogicAccess>
|
||||
* @author xy
|
||||
* @date 2022/3/23 21:59
|
||||
*/
|
||||
boolean add(LogicAccess logicAccess);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据did查询逻辑设备
|
||||
* @return
|
||||
* @author xy
|
||||
* @date 2022/3/17 14:45
|
||||
*/
|
||||
LogicAccess getAccessDev(String did);
|
||||
|
||||
/**
|
||||
* 功能描述: 逻辑设备取消注册
|
||||
* @author xy
|
||||
* @date 2022/3/17 14:45
|
||||
*/
|
||||
void deleteByDid(List<String> list);
|
||||
|
||||
/**
|
||||
* 功能描述: 逻辑设备下线
|
||||
* @author xy
|
||||
* @date 2022/3/17 14:45
|
||||
*/
|
||||
void offlineByDid(List<String> list);
|
||||
|
||||
/**
|
||||
* 功能描述: 查找已经取消注册的装置
|
||||
* @return java.util.List<com.njcn.energy.pojo.po.LogicAccess>
|
||||
* @author xy
|
||||
* @date 2022/3/24 8:54
|
||||
*/
|
||||
LogicAccess findCancelAccessDev(String did);
|
||||
|
||||
/**
|
||||
* 功能描述: 注册 取消注册过的装置
|
||||
* @author xy
|
||||
* @date 2022/3/24 8:54
|
||||
*/
|
||||
void accessCancelDev(String did);
|
||||
|
||||
/**
|
||||
* 功能描述: 调整装置为接入状态
|
||||
* @author xy
|
||||
* @date 2022/3/24 8:54
|
||||
*/
|
||||
void accessDev(LogicAccess logicAccess);
|
||||
|
||||
/**
|
||||
* 功能描述: 获取在线上的装置
|
||||
*
|
||||
* @param ndid 网关id
|
||||
* @param list 装置id集合
|
||||
* @return java.util.List<com.njcn.energy.pojo.po.LogicAccess>
|
||||
* @author xy
|
||||
* @date 2022/3/31 20:01
|
||||
*/
|
||||
List<LogicAccess> getLogicAccess(String ndid,List<String> list);
|
||||
|
||||
/**
|
||||
* 功能描述: 查询当前网关所有在线的装置
|
||||
* @param ndid 网关id
|
||||
* @return java.util.List<com.njcn.energy.pojo.po.LogicAccess>
|
||||
* @author xy
|
||||
* @date 2022/3/31 20:01
|
||||
*/
|
||||
List<LogicAccess> getAllOnlineDevice(String ndid);
|
||||
|
||||
/**
|
||||
* 功能描述: 查询当前网关所有掉线的装置
|
||||
* @param ndid 网关id
|
||||
* @return java.util.List<com.njcn.energy.pojo.po.LogicAccess>
|
||||
* @author xy
|
||||
* @date 2022/3/31 20:01
|
||||
*/
|
||||
List<LogicAccess> getAllOfflineDevice(String ndid);
|
||||
|
||||
/**
|
||||
* 功能描述:将当前网关所有在线的装置置为下线
|
||||
* @author xy
|
||||
* @date 2022/3/29 14:19
|
||||
*/
|
||||
void offAllDevice(String ndid);
|
||||
|
||||
/**
|
||||
* 功能描述: 获取当前集合里在线的设备
|
||||
*
|
||||
* @param list
|
||||
* @return java.util.List<com.njcn.energy.pojo.po.LogicAccess>
|
||||
* @author xy
|
||||
* @date 2022/4/6 15:31
|
||||
*/
|
||||
List<LogicAccess> getOnlineByList(List<String> list);
|
||||
|
||||
/**
|
||||
* 功能描述:根据网关集合获取所有装置信息
|
||||
* @param list 网关集合
|
||||
* @author xy
|
||||
* @date 2022/4/13 13:48
|
||||
* @return 接入过的装置信息
|
||||
*/
|
||||
List<LogicAccess> getLogicDevByList(List<String> list);
|
||||
|
||||
/**
|
||||
* 功能描述: 获取在线、离线的装置
|
||||
* @author xy
|
||||
* @date 2022/4/18 11:45
|
||||
* @return
|
||||
*/
|
||||
List<LogicAccess> getAllDev();
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.njcn.energy.pojo.dto.NetAndDevByLineDTO;
|
||||
import com.njcn.energy.pojo.param.DataHisParam;
|
||||
import com.njcn.energy.pojo.param.DevCfgParam;
|
||||
import com.njcn.energy.pojo.param.EnergyBaseParam;
|
||||
import com.njcn.energy.pojo.param.GroupArrParam;
|
||||
import com.njcn.energy.pojo.po.DataSet;
|
||||
import com.njcn.energy.pojo.po.LogicDev;
|
||||
import com.njcn.energy.pojo.vo.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/2/24
|
||||
*/
|
||||
public interface ILogicDeviceLineService {
|
||||
|
||||
/**
|
||||
* 获取网关设备树
|
||||
* @author cdf
|
||||
* @date 2022/3/1
|
||||
*/
|
||||
List<EnergyDeviceTreeVO> getEnergyTree();
|
||||
|
||||
/**
|
||||
* 获取监测点树
|
||||
* @return 结果
|
||||
*/
|
||||
EleLoadSetTreeVO getEnergyLoadTree(String id);
|
||||
|
||||
/**
|
||||
* 获取空调监测点树
|
||||
* @author cdf
|
||||
* @date 2022/4/21
|
||||
*/
|
||||
List<EnergyDeviceTreeVO> getAirLineTree();
|
||||
|
||||
/**
|
||||
* 获取设备详情
|
||||
* @author cdf
|
||||
* @date 2022/3/1
|
||||
*/
|
||||
LogicDeviceLineInfoVO getEnergyDevInfoById(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 根据数据集id获取设备模板详情详情
|
||||
* @author cdf
|
||||
* @date 2022/3/1
|
||||
*/
|
||||
IPage<EnergyTemplateVO> getEnergyTemplateById(String id, Integer pageNum, Integer pageSize);
|
||||
|
||||
|
||||
/**
|
||||
* 获取分组数据详情
|
||||
* @author cdf
|
||||
* @date 2022/3/1
|
||||
*/
|
||||
IPage<DataGroupTemplateVO> getRealGroupTemplateById(String id,Integer pageNum, Integer pageSize);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取历史设备数据详情
|
||||
* @author cdf
|
||||
* @date 2022/3/1
|
||||
*/
|
||||
IPage<DataGroupTemplateVO> getHistoryTemplateById(EnergyBaseParam energyBaseParam);
|
||||
|
||||
/**
|
||||
* 获取准实时数据详情
|
||||
* @author cdf
|
||||
* @date 2022/3/1
|
||||
*/
|
||||
IPage<DataGroupTemplateVO> getStatisTemplateById(String id, Integer pageNum, Integer pageSize,String lineId);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取设备tab模板
|
||||
* @author cdf
|
||||
* @date 2022/3/1
|
||||
*/
|
||||
List<DataSet> getTabTemplateById(String id);
|
||||
|
||||
/**
|
||||
* 获取当前数据集的分组情况
|
||||
* @author cdf
|
||||
* @date 2022/3/16
|
||||
*/
|
||||
List<DataGroupTemplateVO> getGroupDetailList(String setId);
|
||||
|
||||
|
||||
|
||||
boolean addGroupArr(GroupArrParam groupArrParam);
|
||||
|
||||
|
||||
/**
|
||||
* 获取解析模板
|
||||
* @author cdf
|
||||
* @date 2022/3/18
|
||||
*/
|
||||
List<String> getParseTemplate(String setId);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 功能描述: 新增逻辑设备
|
||||
*
|
||||
* @param devCfgParam
|
||||
* @return com.njcn.energy.pojo.po.LogicDev
|
||||
* @author xy
|
||||
* @date 2022/3/8 14:27
|
||||
*/
|
||||
LogicDev add(DevCfgParam devCfgParam);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据did查询逻辑设备
|
||||
*
|
||||
* @param did
|
||||
* @return
|
||||
* @author xy
|
||||
* @date 2022/3/17 14:45
|
||||
*/
|
||||
LogicDev getLogicDev(String did);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据pid批量查询逻辑设备
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
* @author xy
|
||||
* @date 2022/3/17 14:45
|
||||
*/
|
||||
List<LogicDev> getLogicDevByList(List<String> list);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据did批量查询逻辑设备
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
* @author xy
|
||||
* @date 2022/3/17 14:45
|
||||
*/
|
||||
List<LogicDev> getLogicDev(List<String> list);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据网关id查询逻辑设备
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
* @author xy
|
||||
* @date 2022/3/17 14:45
|
||||
*/
|
||||
List<LogicDev> getLogicDevByPid(List<String> list);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据版本id删除逻辑设备
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @author xy
|
||||
* @date 2022/3/17 14:45
|
||||
*/
|
||||
boolean deleteByVersionId(String id);
|
||||
|
||||
/**
|
||||
* 功能描述: 根据版本id查询逻辑设备
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @author xy
|
||||
* @date 2022/3/17 14:45
|
||||
*/
|
||||
List<LogicDev> getLogicDevByVersionId(String id);
|
||||
|
||||
/**
|
||||
* 功能描述: 更新逻辑设备信息
|
||||
*
|
||||
* @param logicDev
|
||||
* @author xy
|
||||
* @date 2022/3/23 19:32
|
||||
*/
|
||||
void updateLogicDeviceLine(LogicDev logicDev);
|
||||
|
||||
/**
|
||||
* 功能描述: 更新装置模板id
|
||||
* @param oldMouldId 老模板id
|
||||
* @param newMouldId 新模板id
|
||||
* @author xy
|
||||
* @date 2022/4/18 15:34
|
||||
* @return
|
||||
*/
|
||||
void updateLogicDevice(String oldMouldId, String newMouldId);
|
||||
|
||||
|
||||
List<DataHisVO> getHisData(DataHisParam dataHisParam);
|
||||
|
||||
|
||||
/**
|
||||
* 通过监测点获取设备网关
|
||||
* @author cdf
|
||||
* @date 2022/4/22
|
||||
*/
|
||||
List<NetAndDevByLineDTO> getNetAndDevByLineIds(List<String> lineIds);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IModelService {
|
||||
|
||||
/**
|
||||
* 功能描述: 联网装置注册请求
|
||||
*
|
||||
* @param json mqtt数据
|
||||
* @return boolean
|
||||
* @author xy
|
||||
* @date 2022/2/28 15:04
|
||||
*/
|
||||
String deviceRegister(String json);
|
||||
|
||||
/**
|
||||
* 功能描述:联网装置向平台发送设备接入请求
|
||||
*
|
||||
* @param json mqtt数据
|
||||
* @param ndid ndid
|
||||
* @return java.lang.String
|
||||
* @author xy
|
||||
* @date 2022/3/4 13:41
|
||||
*/
|
||||
String deviceAccess(String json,String ndid);
|
||||
|
||||
/**
|
||||
* 功能描述: 询问设备的模板数据
|
||||
* @return java.lang.String
|
||||
* @author xy
|
||||
* @date 2022/3/7 14:07
|
||||
*/
|
||||
String deviceData(String json);
|
||||
|
||||
|
||||
/**
|
||||
* 功能描述: 获取当前网关订阅的主题
|
||||
* @param json mqtt数据
|
||||
* @param ndid ndid
|
||||
* @author xy
|
||||
* @date 2022/3/7 14:07
|
||||
*/
|
||||
void subscribeTopic(String json, String ndid);
|
||||
|
||||
/**
|
||||
* 功能描述: 监听心跳
|
||||
* @param ndid ndid
|
||||
* @param time 数据时间
|
||||
* @return java.lang.String
|
||||
* @author xy
|
||||
* @date 2022/3/30 18:42
|
||||
*/
|
||||
List<String> monitorHeartbeat(String ndid, String time);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.njcn.energy.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.energy.pojo.param.NetDevParam;
|
||||
import com.njcn.energy.pojo.po.NetDev;
|
||||
import com.njcn.energy.pojo.vo.NetDevInfoVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
* @since 2022-02-22
|
||||
*/
|
||||
public interface INetDevService extends IService<NetDev> {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据前台传递参数,分页查询网关数据
|
||||
* @param queryParam 查询参数
|
||||
* @return 网关设备列表
|
||||
*/
|
||||
Page<NetDev> listNetDev(NetDevParam.NetDevQueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 新增网关设备
|
||||
*
|
||||
* @param netDevParam 网关设备数据
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean addNetDev(NetDevParam netDevParam);
|
||||
|
||||
/**
|
||||
* 修改网关设备
|
||||
*
|
||||
* @param updateParam 网关设备数据
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean updateNetDev(NetDevParam.NetDevUpdateParam updateParam);
|
||||
|
||||
/**
|
||||
* 批量逻辑删除网关设备数据
|
||||
* @param ids ids
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean deleteNetDev(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据ndid获取网关信息
|
||||
* @param ndid ndid
|
||||
* @return NetDev
|
||||
*/
|
||||
NetDev findByNdid(String ndid);
|
||||
|
||||
/**
|
||||
* 获取网关详细信息
|
||||
* @author cdf
|
||||
* @date 2022/3/28
|
||||
*/
|
||||
NetDevInfoVO getNetDevInfo(String id);
|
||||
|
||||
/**
|
||||
* 功能描述: 网关下线
|
||||
*
|
||||
* @param netDev 网关id
|
||||
* @return void
|
||||
* @author xy
|
||||
* @date 2022/4/6 18:00
|
||||
*/
|
||||
void offlineNetDev(String netDev);
|
||||
|
||||
/**
|
||||
* 功能描述: 网关上线
|
||||
*
|
||||
* @param netDev 网关id
|
||||
* @return void
|
||||
* @author xy
|
||||
* @date 2022/4/6 18:00
|
||||
*/
|
||||
void onlineNetDev(String netDev);
|
||||
|
||||
/**
|
||||
* 功能描述:获取所有正常的网关信息
|
||||
* @author xy
|
||||
* @date 2022/4/13 11:02
|
||||
* @return list
|
||||
*/
|
||||
List<NetDev> getAllNetDev();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.DataArrayMapper;
|
||||
import com.njcn.energy.pojo.param.DataArrayParam;
|
||||
import com.njcn.energy.pojo.po.DataArray;
|
||||
import com.njcn.energy.service.IDataArrayService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/9 15:48
|
||||
*/
|
||||
@Service
|
||||
public class DataArrayServiceImpl extends ServiceImpl<DataArrayMapper, DataArray> implements IDataArrayService {
|
||||
|
||||
@Override
|
||||
public DataArray addDataArray(DataArrayParam dataArrayParam) {
|
||||
DataArray dataArray = new DataArray();
|
||||
BeanUtil.copyProperties(dataArrayParam,dataArray);
|
||||
this.save(dataArray);
|
||||
return dataArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDataArray(List<String> list) {
|
||||
QueryWrapper<DataArray> dataArrayQueryWrapper = new QueryWrapper<>();
|
||||
dataArrayQueryWrapper.in("Pid",list);
|
||||
return this.remove(dataArrayQueryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.DataGroupMapper;
|
||||
import com.njcn.energy.pojo.param.DataGroupParam;
|
||||
import com.njcn.energy.pojo.po.DataArray;
|
||||
import com.njcn.energy.pojo.po.DataGroup;
|
||||
import com.njcn.energy.pojo.po.DataSet;
|
||||
import com.njcn.energy.service.IDataGroupService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/16 9:05
|
||||
*/
|
||||
@Service
|
||||
public class DataGroupServiceImpl extends ServiceImpl<DataGroupMapper, DataGroup> implements IDataGroupService {
|
||||
@Override
|
||||
public DataGroup addDataGroup(DataGroupParam dataGroupParam) {
|
||||
DataGroup dataGroup = new DataGroup();
|
||||
BeanUtil.copyProperties(dataGroupParam,dataGroup);
|
||||
this.save(dataGroup);
|
||||
return dataGroup;
|
||||
}
|
||||
@Override
|
||||
public boolean batchAdd(List<DataGroup> list){
|
||||
return this.saveBatch(list);
|
||||
}
|
||||
@Override
|
||||
public List<DataGroup> findGroupById(List<String> list) {
|
||||
return this.lambdaQuery().in(DataGroup::getPid,list).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDataGroup(List<String> list) {
|
||||
QueryWrapper<DataGroup> dataGroupQueryWrapper = new QueryWrapper<>();
|
||||
dataGroupQueryWrapper.in("Pid",list);
|
||||
return this.remove(dataGroupQueryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.DataSetMapper;
|
||||
import com.njcn.energy.pojo.param.DataSetParam;
|
||||
import com.njcn.energy.pojo.po.DataSet;
|
||||
import com.njcn.energy.pojo.po.Hardware;
|
||||
import com.njcn.energy.service.IDataSetService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/9 10:16
|
||||
*/
|
||||
@Service
|
||||
public class DataSetServiceImpl extends ServiceImpl<DataSetMapper, DataSet> implements IDataSetService {
|
||||
|
||||
@Override
|
||||
public DataSet add(DataSetParam dataSetParam) {
|
||||
DataSet dataSet = new DataSet();
|
||||
BeanUtil.copyProperties(dataSetParam,dataSet);
|
||||
this.save(dataSet);
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(String id) {
|
||||
QueryWrapper<DataSet> dataSetQueryWrapper = new QueryWrapper<>();
|
||||
dataSetQueryWrapper.eq("Pid",id);
|
||||
return this.remove(dataSetQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataSet> findSetById(String id) {
|
||||
return this.lambdaQuery().eq(DataSet::getPid,id).list();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.energy.mapper.DataMouldMapper;
|
||||
import com.njcn.energy.pojo.param.DataModelParam;
|
||||
import com.njcn.energy.pojo.po.DataMould;
|
||||
import com.njcn.energy.pojo.po.EleLine;
|
||||
import com.njcn.energy.service.IDevModelService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/8 20:41
|
||||
*/
|
||||
@Service
|
||||
public class DevModelServiceImpl extends ServiceImpl<DataMouldMapper, DataMould> implements IDevModelService {
|
||||
|
||||
@Override
|
||||
public DataMould addDataMould(DataModelParam dataModelParam) {
|
||||
DataMould dataMould = new DataMould();
|
||||
BeanUtil.copyProperties(dataModelParam,dataMould);
|
||||
dataMould.setState(DataStateEnum.ENABLE.getCode());
|
||||
this.save(dataMould);
|
||||
return dataMould;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteById(String id) {
|
||||
return this.removeById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataMould findMould(String name, String version, String time) {
|
||||
return this.lambdaQuery().eq(DataMould::getName,name).eq(DataMould::getVersion,version).eq(DataMould::getTime,time).one();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.energy.mapper.DevVersionMapper;
|
||||
import com.njcn.energy.pojo.param.DevVersionParam;
|
||||
import com.njcn.energy.pojo.po.DevVersion;
|
||||
import com.njcn.energy.service.IDevVersionService;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/7 18:58
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class DevVersionServiceImpl extends ServiceImpl<DevVersionMapper, DevVersion> implements IDevVersionService {
|
||||
|
||||
|
||||
@Override
|
||||
public DevVersion addDevVersion(DevVersionParam devVersionParam) {
|
||||
DevVersion devVersion = new DevVersion();
|
||||
BeanUtils.copyProperties(devVersionParam, devVersion);
|
||||
devVersion.setState(DataStateEnum.ENABLE.getCode());
|
||||
this.save(devVersion);
|
||||
return devVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDevVersion(String id) {
|
||||
return this.removeById(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleParmMapper;
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
import com.njcn.energy.pojo.po.EleParm;
|
||||
import com.njcn.energy.service.IEleParmService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/15 19:44
|
||||
*/
|
||||
@Service
|
||||
public class ELeParmServiceImpl extends ServiceImpl<EleParmMapper, EleParm> implements IEleParmService {
|
||||
@Override
|
||||
public boolean addParm(EleParm eleParm) {
|
||||
return this.save(eleParm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateParm(EleParm eleParm) {
|
||||
return this.updateById(eleParm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EleParm findByName(String name) {
|
||||
return this.lambdaQuery().eq(EleParm::getName,name).one();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleActrlMapper;
|
||||
import com.njcn.energy.pojo.po.EleActrl;
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
import com.njcn.energy.service.IEleActrlService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/15 20:14
|
||||
*/
|
||||
@Service
|
||||
public class EleActrlServiceImpl extends ServiceImpl<EleActrlMapper, EleActrl> implements IEleActrlService {
|
||||
@Override
|
||||
public boolean addActrl(EleActrl eleActrl) {
|
||||
return this.save(eleActrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateActrl(EleActrl eleActrl) {
|
||||
return this.updateById(eleActrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EleActrl findByName(String name) {
|
||||
return this.lambdaQuery().eq(EleActrl::getName,name).one();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.AirSetMapper;
|
||||
import com.njcn.energy.pojo.po.AirSet;
|
||||
|
||||
|
||||
import com.njcn.energy.service.IEleSetService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/4/21
|
||||
*/
|
||||
@Service
|
||||
public class EleAirSetServiceImpl extends ServiceImpl<AirSetMapper,AirSet> implements IEleSetService {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,509 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.db.constant.DbConstant;
|
||||
import com.njcn.energy.mapper.AirSetMapper;
|
||||
import com.njcn.energy.mapper.AirStrategyMapper;
|
||||
import com.njcn.energy.mapper.LogicAccessMapper;
|
||||
import com.njcn.energy.mapper.LogicDeviceLineMapper;
|
||||
import com.njcn.energy.pojo.dto.AirStrategyDTO;
|
||||
import com.njcn.energy.pojo.dto.NetAndDevByLineDTO;
|
||||
import com.njcn.energy.pojo.enums.EnergyResponseEnum;
|
||||
import com.njcn.energy.pojo.param.AirStrategyParam;
|
||||
import com.njcn.energy.pojo.param.NetDevParam;
|
||||
import com.njcn.energy.pojo.po.AirSet;
|
||||
import com.njcn.energy.pojo.po.AirStrategy;
|
||||
import com.njcn.energy.pojo.po.NetDev;
|
||||
import com.njcn.energy.pojo.vo.AirStrategyVO;
|
||||
import com.njcn.energy.pojo.vo.EnergyDeviceTreeVO;
|
||||
import com.njcn.energy.service.EleAirStrategyService;
|
||||
import com.njcn.energy.service.IEleSetService;
|
||||
import com.njcn.job.api.JobFeignClient;
|
||||
import com.njcn.job.model.XxlJobInfo;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.TemporalField;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/4/21
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, AirStrategy> implements EleAirStrategyService {
|
||||
|
||||
private final IEleSetService iEleSetService;
|
||||
|
||||
private final JobFeignClient jobFeignClient;
|
||||
|
||||
private final LogicDeviceLineMapper logicDeviceLineMapper;
|
||||
|
||||
|
||||
private final MqttPublisher publisher;
|
||||
|
||||
private final AirStrategyMapper airStrategyMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public Page<AirStrategy> listAirStrategy(AirStrategyParam.AirStrategyQueryParam queryParam) {
|
||||
QueryWrapper<AirStrategy> queryWrapper = new QueryWrapper<>();
|
||||
if (Objects.nonNull(queryParam)) {
|
||||
//查询参数不为空,进行条件填充
|
||||
if (StrUtil.isNotBlank(queryParam.getSearchValue())) {
|
||||
//字典类型表,仅提供名称、编码模糊查询
|
||||
queryWrapper
|
||||
.and(param -> param.like("ele_air_strategy.name", queryParam.getSearchValue()));
|
||||
}
|
||||
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
} else {
|
||||
//没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序
|
||||
queryWrapper.orderBy(true, true, "ele_air_strategy.sort");
|
||||
}
|
||||
|
||||
}
|
||||
queryWrapper.eq("ele_air_strategy.state", DataStateEnum.ENABLE.getCode());
|
||||
return this.baseMapper.selectPage(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean addAirStrategy(AirStrategyParam airStrategyParam) {
|
||||
checkDicTypeName(airStrategyParam, false);
|
||||
|
||||
LambdaQueryWrapper<AirStrategy> tem = new LambdaQueryWrapper<>();
|
||||
tem.eq(AirStrategy::getState, DataStateEnum.ENABLE.getCode());
|
||||
List<AirStrategy> temList = this.list(tem);
|
||||
if (CollectionUtil.isNotEmpty(temList)) {
|
||||
for (AirStrategy airStrategy : temList) {
|
||||
LocalDateTime start = LocalDateTimeUtil.parse(airStrategy.getStartTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
LocalDateTime startParam = LocalDateTimeUtil.parse(airStrategyParam.getStartTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
long rangeStart = LocalDateTimeUtil.between(start, startParam).toMinutes();
|
||||
LocalDateTime end = LocalDateTimeUtil.parse(airStrategy.getStartTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
LocalDateTime endParam = LocalDateTimeUtil.parse(airStrategyParam.getStartTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
long rangeEnd = LocalDateTimeUtil.between(end, endParam).toMinutes();
|
||||
|
||||
if(rangeStart<=5 ||rangeEnd<=5 ){
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_TIME_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
AirStrategy airStrategy = new AirStrategy();
|
||||
BeanUtils.copyProperties(airStrategyParam, airStrategy);
|
||||
airStrategy.setState(DataStateEnum.ENABLE.getCode());
|
||||
airStrategy.setStatus(0);
|
||||
airStrategy.setCreateBy(RequestUtil.getUserIndex());
|
||||
airStrategy.setCreateTime(LocalDateTime.now());
|
||||
airStrategy.setUpdateTime(LocalDateTime.now());
|
||||
this.save(airStrategy);
|
||||
|
||||
|
||||
|
||||
|
||||
List<AirSet> list = new ArrayList<>();
|
||||
airStrategyParam.getLineIds().forEach((item)->{
|
||||
AirSet airSet = new AirSet(airStrategy.getId(),item);
|
||||
list.add(airSet);
|
||||
});
|
||||
iEleSetService.saveBatch(list);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 此处做示例,手动指定
|
||||
*/
|
||||
XxlJobInfo xxlJobInfo = new XxlJobInfo();
|
||||
//执行器ID,手动指定,此处设置为3,对应xxl_job_group中的executor--测试执行器
|
||||
xxlJobInfo.setJobGroup(5);
|
||||
//任务描述
|
||||
xxlJobInfo.setJobDesc("开启空调");
|
||||
xxlJobInfo.setAuthor("cdf");
|
||||
xxlJobInfo.setScheduleType("CRON");
|
||||
//时间表达式需要处理成 秒 分 时 日 月 ? 年,标志指定时间执行一次
|
||||
LocalDateTime startTime = LocalDateTimeUtil.parse(airStrategy.getStartTime(), DatePattern.NORM_DATETIME_PATTERN);
|
||||
xxlJobInfo.setScheduleConf("" + startTime.getSecond() + CharUtil.SPACE + startTime.getMinute() + CharUtil.SPACE + startTime.getHour() + CharUtil.SPACE + startTime.getDayOfMonth() + CharUtil.SPACE + startTime.getMonthValue() + CharUtil.SPACE + "?" + CharUtil.SPACE + startTime.getYear());
|
||||
xxlJobInfo.setMisfireStrategy("DO_NOTHING");
|
||||
xxlJobInfo.setExecutorRouteStrategy("FIRST");
|
||||
xxlJobInfo.setExecutorBlockStrategy("SERIAL_EXECUTION");
|
||||
//指定处理器
|
||||
xxlJobInfo.setExecutorHandler("airStrategyJob");
|
||||
//传递的参数
|
||||
xxlJobInfo.setExecutorParam("open" + StrUtil.C_COMMA + airStrategy.getId());
|
||||
xxlJobInfo.setGlueType("BEAN");
|
||||
xxlJobInfo.setGlueRemark("GLUE代码初始化");
|
||||
HttpResult result = jobFeignClient.addJob(xxlJobInfo);
|
||||
if (result.getCode().equals(ReturnT.FAIL_CODE)) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* 此处做示例,手动指定
|
||||
*/
|
||||
XxlJobInfo xxlJobInfoEnd = new XxlJobInfo();
|
||||
//执行器ID,手动指定,此处设置为3,对应xxl_job_group中的executor--测试执行器
|
||||
xxlJobInfoEnd.setJobGroup(5);
|
||||
//任务描述
|
||||
xxlJobInfoEnd.setJobDesc("关闭空调");
|
||||
xxlJobInfoEnd.setAuthor("cdf");
|
||||
xxlJobInfoEnd.setScheduleType("CRON");
|
||||
//时间表达式需要处理成 秒 分 时 日 月 ? 年,标志指定时间执行一次
|
||||
LocalDateTime startTimeEnd = LocalDateTimeUtil.parse(airStrategy.getEndTime(), DatePattern.NORM_DATETIME_PATTERN);
|
||||
xxlJobInfoEnd.setScheduleConf("" + startTimeEnd.getSecond() + CharUtil.SPACE + startTimeEnd.getMinute() + CharUtil.SPACE + startTimeEnd.getHour() + CharUtil.SPACE + startTimeEnd.getDayOfMonth() + CharUtil.SPACE + startTimeEnd.getMonthValue() + CharUtil.SPACE + "?" + CharUtil.SPACE + startTimeEnd.getYear());
|
||||
xxlJobInfoEnd.setMisfireStrategy("DO_NOTHING");
|
||||
xxlJobInfoEnd.setExecutorRouteStrategy("FIRST");
|
||||
xxlJobInfoEnd.setExecutorBlockStrategy("SERIAL_EXECUTION");
|
||||
//指定处理器
|
||||
xxlJobInfoEnd.setExecutorHandler("airStrategyJob");
|
||||
//传递的参数
|
||||
xxlJobInfoEnd.setExecutorParam("close"+StrUtil.C_COMMA+airStrategy.getId());
|
||||
xxlJobInfoEnd.setGlueType("BEAN");
|
||||
xxlJobInfoEnd.setGlueRemark("GLUE代码初始化");
|
||||
HttpResult result2 = jobFeignClient.addJob(xxlJobInfoEnd);
|
||||
|
||||
if (result2.getCode().equals(ReturnT.FAIL_CODE)) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||
}
|
||||
|
||||
|
||||
String ids = result.getData().toString() + StrUtil.COMMA + result2.getData().toString();
|
||||
airStrategy.setXxlId(ids);
|
||||
this.updateById(airStrategy);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateAirStrategy(AirStrategyParam.AirUpdateParam updateParam) {
|
||||
AirStrategy airStrategyRes = this.getById(updateParam.getId());
|
||||
if (Objects.isNull(airStrategyRes)) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||
}
|
||||
checkDicTypeName(updateParam, true);
|
||||
AirStrategy airStrategy = new AirStrategy();
|
||||
BeanUtils.copyProperties(updateParam, airStrategy);
|
||||
airStrategy.setUpdateBy(RequestUtil.getUserIndex());
|
||||
airStrategy.setUpdateTime(LocalDateTime.now());
|
||||
this.updateById(airStrategy);
|
||||
|
||||
|
||||
iEleSetService.removeById(airStrategy.getId());
|
||||
|
||||
List<AirSet> list = new ArrayList<>();
|
||||
updateParam.getLineIds().forEach((item) -> {
|
||||
AirSet airSet = new AirSet(airStrategy.getId(), item);
|
||||
list.add(airSet);
|
||||
});
|
||||
iEleSetService.saveBatch(list);
|
||||
/*
|
||||
* 此处做示例,手动指定
|
||||
*/
|
||||
String[] jobIds = airStrategyRes.getXxlId().split(StrUtil.COMMA);
|
||||
XxlJobInfo xxlJobInfo = new XxlJobInfo();
|
||||
//执行器ID,手动指定,此处设置为3,对应xxl_job_group中的executor--测试执行器
|
||||
xxlJobInfo.setId(Integer.parseInt(jobIds[0]));
|
||||
xxlJobInfo.setJobGroup(5);
|
||||
//任务描述
|
||||
xxlJobInfo.setJobDesc("开启空调");
|
||||
xxlJobInfo.setAuthor("cdf");
|
||||
xxlJobInfo.setScheduleType("CRON");
|
||||
//时间表达式需要处理成 秒 分 时 日 月 ? 年,标志指定时间执行一次
|
||||
LocalDateTime startTime = LocalDateTimeUtil.parse(airStrategy.getStartTime(), DatePattern.NORM_DATETIME_PATTERN);
|
||||
xxlJobInfo.setScheduleConf("" + startTime.getSecond() + CharUtil.SPACE + startTime.getMinute() + CharUtil.SPACE + startTime.getHour() + CharUtil.SPACE + startTime.getDayOfMonth() + CharUtil.SPACE + startTime.getMonthValue() + CharUtil.SPACE + "?" + CharUtil.SPACE + startTime.getYear());
|
||||
xxlJobInfo.setMisfireStrategy("DO_NOTHING");
|
||||
xxlJobInfo.setExecutorRouteStrategy("FIRST");
|
||||
xxlJobInfo.setExecutorBlockStrategy("SERIAL_EXECUTION");
|
||||
//指定处理器
|
||||
xxlJobInfo.setExecutorHandler("airStrategyJob");
|
||||
//传递的参数
|
||||
xxlJobInfo.setExecutorParam("open" + StrUtil.C_COMMA + airStrategy.getId());
|
||||
xxlJobInfo.setGlueType("BEAN");
|
||||
xxlJobInfo.setGlueRemark("GLUE代码初始化");
|
||||
HttpResult result = jobFeignClient.updateJob(xxlJobInfo);
|
||||
if (result.getCode().equals(ReturnT.FAIL_CODE)) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* 此处做示例,手动指定
|
||||
*/
|
||||
XxlJobInfo xxlJobInfoEnd = new XxlJobInfo();
|
||||
xxlJobInfoEnd.setId(Integer.parseInt(jobIds[1]));
|
||||
//执行器ID,手动指定,此处设置为3,对应xxl_job_group中的executor--测试执行器
|
||||
xxlJobInfoEnd.setJobGroup(5);
|
||||
//任务描述
|
||||
xxlJobInfoEnd.setJobDesc("关闭空调");
|
||||
xxlJobInfoEnd.setAuthor("cdf");
|
||||
xxlJobInfoEnd.setScheduleType("CRON");
|
||||
//时间表达式需要处理成 秒 分 时 日 月 ? 年,标志指定时间执行一次
|
||||
LocalDateTime startTimeEnd = LocalDateTimeUtil.parse(airStrategy.getEndTime(), DatePattern.NORM_DATETIME_PATTERN);
|
||||
xxlJobInfoEnd.setScheduleConf("" + startTimeEnd.getSecond() + CharUtil.SPACE + startTimeEnd.getMinute() + CharUtil.SPACE + startTimeEnd.getHour() + CharUtil.SPACE + startTimeEnd.getDayOfMonth() + CharUtil.SPACE + startTimeEnd.getMonthValue() + CharUtil.SPACE + "?" + CharUtil.SPACE + startTimeEnd.getYear());
|
||||
xxlJobInfoEnd.setMisfireStrategy("DO_NOTHING");
|
||||
xxlJobInfoEnd.setExecutorRouteStrategy("FIRST");
|
||||
xxlJobInfoEnd.setExecutorBlockStrategy("SERIAL_EXECUTION");
|
||||
//指定处理器
|
||||
xxlJobInfoEnd.setExecutorHandler("airStrategyJob");
|
||||
//传递的参数
|
||||
xxlJobInfoEnd.setExecutorParam("close" + StrUtil.C_COMMA + airStrategy.getId());
|
||||
xxlJobInfoEnd.setGlueType("BEAN");
|
||||
xxlJobInfoEnd.setGlueRemark("GLUE代码初始化");
|
||||
HttpResult result2 = jobFeignClient.updateJob(xxlJobInfoEnd);
|
||||
|
||||
if (result2.getCode().equals(ReturnT.FAIL_CODE)) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_CREATE_ERROR);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean deleteAirStrategy(String id) {
|
||||
AirStrategy airStrategy = this.getById(id);
|
||||
if (Objects.isNull(airStrategy)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (airStrategy.getStatus() == 1) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_RUNING);
|
||||
}
|
||||
|
||||
this.lambdaUpdate()
|
||||
.set(AirStrategy::getState, DataStateEnum.DELETED.getCode())
|
||||
.eq(AirStrategy::getId, id)
|
||||
.update();
|
||||
|
||||
LambdaQueryWrapper<AirSet> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(AirSet::getId, id);
|
||||
iEleSetService.remove(lambdaQueryWrapper);
|
||||
|
||||
String[] arr = airStrategy.getXxlId().split(StrUtil.COMMA);
|
||||
|
||||
for (String xxlId : arr) {
|
||||
HttpResult<String> result = jobFeignClient.removeJob(Integer.parseInt(xxlId));
|
||||
if (result.getCode().equals(StrUtil.toString(ReturnT.FAIL_CODE))) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_DEL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AirStrategyVO findById(String id) {
|
||||
AirStrategy airStrategy = this.lambdaQuery().eq(AirStrategy::getId, id).one();
|
||||
if (Objects.isNull(airStrategy)) {
|
||||
throw new BusinessException(CommonResponseEnum.NO_DATA);
|
||||
}
|
||||
List<AirSet> list = iEleSetService.lambdaQuery().eq(AirSet::getId, id).list();
|
||||
List<String> lineIds = list.stream().map(AirSet::getLineId).collect(Collectors.toList());
|
||||
|
||||
AirStrategyVO airStrategyVO = new AirStrategyVO();
|
||||
BeanUtils.copyProperties(airStrategy, airStrategyVO);
|
||||
airStrategyVO.setLineIds(lineIds);
|
||||
return airStrategyVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startAirStrategy(String id) {
|
||||
AirStrategy airStrategy = getById(id);
|
||||
if (Objects.isNull(airStrategy)) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||
}
|
||||
String[] ids = airStrategy.getXxlId().split(StrUtil.COMMA);
|
||||
if (airStrategy.getStatus() == 0) {
|
||||
//可以启动
|
||||
|
||||
for (String xxlId : ids) {
|
||||
HttpResult<String> result = jobFeignClient.startTask(Integer.parseInt(xxlId));
|
||||
if (result.getCode().equals(StrUtil.toString(ReturnT.FAIL_CODE))) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_RUNING);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.lambdaUpdate().set(AirStrategy::getStatus, 1).eq(AirStrategy::getId, id).update();
|
||||
|
||||
} else if (airStrategy.getStatus() == 1) {
|
||||
//已经执行中
|
||||
|
||||
for (String xxlId : ids) {
|
||||
HttpResult<String> result = jobFeignClient.stopJob(Integer.parseInt(xxlId));
|
||||
if (result.getCode().equals(StrUtil.toString(ReturnT.FAIL_CODE))) {
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_DEL_ERROR);
|
||||
}
|
||||
}
|
||||
this.lambdaUpdate().set(AirStrategy::getStatus, 0).eq(AirStrategy::getId, id).update();
|
||||
} else {
|
||||
//已经完成
|
||||
throw new BusinessException(EnergyResponseEnum.TASK_HAS_START);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dealAirStrategyId(String id, String operation) {
|
||||
try {
|
||||
AirStrategy airStrategy = this.getById(id);
|
||||
if (Objects.isNull(airStrategy)) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||
}
|
||||
LambdaQueryWrapper<AirSet> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(AirSet::getId, id);
|
||||
List<AirSet> list = iEleSetService.list(lambdaQueryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
List<String> lineIds = list.stream().map(AirSet::getLineId).collect(Collectors.toList());
|
||||
List<NetAndDevByLineDTO> netDevList = logicDeviceLineMapper.getNetAndDevByLineIds(lineIds);
|
||||
|
||||
|
||||
if (CollectionUtil.isNotEmpty(netDevList)) {
|
||||
for (NetAndDevByLineDTO netAndDevByLineDTO : netDevList) {
|
||||
|
||||
Gson gson = new Gson();
|
||||
String array = "ACInStat";
|
||||
String power = "";
|
||||
if ("open".equals(operation)) {
|
||||
//开启空调
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (i == 0) {
|
||||
power = "On";
|
||||
array = "ACInStat";
|
||||
} else if (i == 1) {
|
||||
power = airStrategy.getTemperature().toString();
|
||||
array = "ACInSetTmp";
|
||||
} else if (i == 2) {
|
||||
power = airStrategy.getMode();
|
||||
array = "ACInMode";
|
||||
} else {
|
||||
power = airStrategy.getWind();
|
||||
array = "ACInSpeed";
|
||||
}
|
||||
AirStrategyDTO airStrategyDTO = new AirStrategyDTO();
|
||||
airStrategyDTO.setMid(1);
|
||||
airStrategyDTO.setDeviceId(netAndDevByLineDTO.getDevId());
|
||||
airStrategyDTO.setTimestamp(Calendar.getInstance().getTimeInMillis());
|
||||
airStrategyDTO.setExpire(-1);
|
||||
airStrategyDTO.setType("CMD_DEV_CTRL");
|
||||
AirStrategyDTO.Param param = new AirStrategyDTO.Param();
|
||||
param.setLineId(netAndDevByLineDTO.getLineId());
|
||||
param.setAction(array);
|
||||
param.setParm(power);
|
||||
airStrategyDTO.setParam(param);
|
||||
String json = gson.toJson(airStrategyDTO);
|
||||
System.out.println(json);
|
||||
String topic = "/platform/devcmd/v1/" + netAndDevByLineDTO.getNdid();
|
||||
publisher.send(topic, json, 1, false);
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
System.out.println("睡了10s");
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//关闭空调
|
||||
power = "Off";
|
||||
AirStrategyDTO airStrategyDTO = new AirStrategyDTO();
|
||||
airStrategyDTO.setMid(1);
|
||||
airStrategyDTO.setDeviceId(netAndDevByLineDTO.getDevId());
|
||||
airStrategyDTO.setTimestamp(Calendar.getInstance().getTimeInMillis());
|
||||
airStrategyDTO.setExpire(-1);
|
||||
airStrategyDTO.setType("CMD_DEV_CTRL");
|
||||
AirStrategyDTO.Param param = new AirStrategyDTO.Param();
|
||||
param.setLineId(netAndDevByLineDTO.getLineId());
|
||||
param.setAction(array);
|
||||
param.setParm(power);
|
||||
airStrategyDTO.setParam(param);
|
||||
String json = gson.toJson(airStrategyDTO);
|
||||
System.out.println(json);
|
||||
String topic = "/platform/devcmd/v1/" + netAndDevByLineDTO.getNdid();
|
||||
publisher.send(topic, json, 1, false);
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
System.out.println("切换监测点睡了10s");
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
System.out.println(operation);
|
||||
if (operation.equals("close")) {
|
||||
AirStrategy air = new AirStrategy();
|
||||
air.setId(airStrategy.getId());
|
||||
air.setStatus(2);
|
||||
airStrategyMapper.updateById(air);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验参数,检查是否存在相同名称的空调策略
|
||||
*/
|
||||
private void checkDicTypeName(AirStrategyParam airStrategyParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<AirStrategy> netDevLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
netDevLambdaQueryWrapper
|
||||
.eq(AirStrategy::getName, airStrategyParam.getName())
|
||||
.eq(AirStrategy::getState, DataStateEnum.ENABLE.getCode());
|
||||
//更新的时候,需排除当前记录
|
||||
if (isExcludeSelf) {
|
||||
if (airStrategyParam instanceof AirStrategyParam.AirUpdateParam) {
|
||||
netDevLambdaQueryWrapper.ne(AirStrategy::getId, ((AirStrategyParam.AirUpdateParam) airStrategyParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(netDevLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(EnergyResponseEnum.STRATEGY_REPEAT);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleAlmMapper;
|
||||
import com.njcn.energy.pojo.po.EleALM;
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
import com.njcn.energy.service.IEleAlmService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/15 18:49
|
||||
*/
|
||||
@Service
|
||||
public class EleAlmServiceImpl extends ServiceImpl<EleAlmMapper, EleALM> implements IEleAlmService {
|
||||
@Override
|
||||
public boolean addAlm(EleALM eleAlM) {
|
||||
return this.save(eleAlM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateAlm(EleALM eleAlM) {
|
||||
return this.updateById(eleAlM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EleALM findByName(String name) {
|
||||
return this.lambdaQuery().eq(EleALM::getName,name).one();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleBindMapper;
|
||||
import com.njcn.energy.pojo.constant.TableName;
|
||||
import com.njcn.energy.pojo.param.ElDataBindParam;
|
||||
import com.njcn.energy.pojo.po.DataArray;
|
||||
import com.njcn.energy.pojo.po.EleBind;
|
||||
import com.njcn.energy.pojo.vo.EnergyTemplateVO;
|
||||
import com.njcn.energy.pojo.vo.YunCaiDataVO;
|
||||
import com.njcn.energy.service.IEleBindService;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/3/30
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EleBindServiceImpl extends ServiceImpl<EleBindMapper, EleBind> implements IEleBindService {
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
@Override
|
||||
public boolean addBind(ElDataBindParam elDataBindParam) {
|
||||
LambdaQueryWrapper<EleBind> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
List<String> lineList = elDataBindParam.getList().stream().map(EleBind::getLineId).collect(Collectors.toList());
|
||||
lambdaQueryWrapper.in(EleBind::getLineId, lineList);
|
||||
this.remove(lambdaQueryWrapper);
|
||||
return this.saveBatch(elDataBindParam.getList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EleBind> getList(String ndid) {
|
||||
LambdaQueryWrapper<EleBind> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(EleBind::getNdid, ndid);
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<YunCaiDataVO> getLineListDetail(List<String> lineList) {
|
||||
List<YunCaiDataVO> listRes = new ArrayList<>();
|
||||
for (String lineId : lineList) {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
List<DataArray> arrList = this.baseMapper.getArrByLineId(lineId, null);
|
||||
if (CollectionUtil.isNotEmpty(arrList)) {
|
||||
Map<String, List<DataArray>> classMap = new HashMap<>();
|
||||
arrList.stream().filter(item -> item.getClassId() != null).collect(Collectors.groupingBy(DataArray::getClassId, Collectors.toList()))
|
||||
.forEach(classMap::put);
|
||||
classMap.forEach((className, dataArrList) -> {
|
||||
StringBuilder stringBuilderMax = new StringBuilder("select ");
|
||||
for (int j = 0; j < dataArrList.size(); j++) {
|
||||
if (j == dataArrList.size() - 1) {
|
||||
stringBuilderMax.append(dataArrList.get(j).getName()).append(" ");
|
||||
} else {
|
||||
stringBuilderMax.append(dataArrList.get(j).getName()).append(", ");
|
||||
}
|
||||
}
|
||||
if (className.equals(TableName.powerData) || className.equals(TableName.powerQuality)) {
|
||||
stringBuilderMax.append("from ").append(className).append("_Real").append(" where").append(" LineId='" + lineId + "'").append(" and Phase = 'T'");
|
||||
List<Map<String, Object>> mapList = influxDbUtils.getResult(stringBuilderMax.toString());
|
||||
if (CollectionUtil.isNotEmpty(mapList)) {
|
||||
mapList.get(0).forEach((i, k) -> map.put(i, k != null ? k.toString() : "/"));
|
||||
}
|
||||
} else {
|
||||
//空调
|
||||
stringBuilderMax.append("from ").append(className).append("_Real").append(" where").append(" LineId='" + lineId + "'");
|
||||
List<Map<String, Object>> mapList = influxDbUtils.getResult(stringBuilderMax.toString());
|
||||
if (CollectionUtil.isNotEmpty(mapList)) {
|
||||
for (int i = 0; i < mapList.size(); i++) {
|
||||
mapList.get(i).forEach((key, value) -> {
|
||||
if (Objects.nonNull(value)) {
|
||||
map.put(key, value.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
YunCaiDataVO yunCaiDataVO = new YunCaiDataVO();
|
||||
yunCaiDataVO.setLineId(lineId);
|
||||
yunCaiDataVO.setMap(map);
|
||||
listRes.add(yunCaiDataVO);
|
||||
}
|
||||
return listRes;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleCtrlMapper;
|
||||
import com.njcn.energy.pojo.po.EleCtrl;
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
import com.njcn.energy.service.IEleCtrlService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/15 20:02
|
||||
*/
|
||||
@Service
|
||||
public class EleCtrlServiceImpl extends ServiceImpl<EleCtrlMapper, EleCtrl> implements IEleCtrlService {
|
||||
@Override
|
||||
public boolean addCtrl(EleCtrl eleCtrl) {
|
||||
return this.save(eleCtrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateCtrl(EleCtrl eleCtrl) {
|
||||
return this.updateById(eleCtrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EleCtrl findByName(String name) {
|
||||
return this.lambdaQuery().eq(EleCtrl::getName,name).one();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleDiMapper;
|
||||
import com.njcn.energy.pojo.po.EleDi;
|
||||
import com.njcn.energy.service.IEleDiService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/15 19:18
|
||||
*/
|
||||
@Service
|
||||
public class EleDiServiceImpl extends ServiceImpl<EleDiMapper, EleDi> implements IEleDiService {
|
||||
@Override
|
||||
public boolean addDi(EleDi eleDi) {
|
||||
return this.save(eleDi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDi(EleDi eleDi) {
|
||||
return this.updateById(eleDi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EleDi findByName(String name) {
|
||||
return this.lambdaQuery().eq(EleDi::getName,name).one();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.db.constant.DbConstant;
|
||||
import com.njcn.energy.mapper.EleDictMapper;
|
||||
import com.njcn.energy.pojo.enums.EnergyResponseEnum;
|
||||
import com.njcn.energy.pojo.param.DictParam;
|
||||
import com.njcn.energy.pojo.po.EleDict;
|
||||
import com.njcn.energy.service.IEleDictService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/24 10:59
|
||||
*/
|
||||
@Service
|
||||
public class EleDictServiceImpl extends ServiceImpl<EleDictMapper, EleDict> implements IEleDictService {
|
||||
|
||||
@Override
|
||||
public EleDict findDictByName(String name) {
|
||||
return this.lambdaQuery().eq(EleDict::getName,name).eq(EleDict::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EleDict findTableName(String name) {
|
||||
EleDict tableDict = new EleDict();
|
||||
EleDict dict = this.lambdaQuery().eq(EleDict::getName,name).eq(EleDict::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
if (Objects.isNull(dict)){
|
||||
throw new BusinessException(EnergyResponseEnum.NO_DICT);
|
||||
} else {
|
||||
tableDict = this.lambdaQuery().eq(EleDict::getId,dict.getPid()).eq(EleDict::getPid,0).one();
|
||||
}
|
||||
if (Objects.isNull(tableDict)){
|
||||
throw new BusinessException(EnergyResponseEnum.NO_TABLE);
|
||||
}
|
||||
return tableDict;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(String id) {
|
||||
LambdaQueryWrapper<EleDict> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(EleDict::getPid,id).eq(EleDict::getState,DataStateEnum.ENABLE.getCode());
|
||||
int resCount = this.count(lambdaQueryWrapper);
|
||||
if(resCount>0){
|
||||
throw new BusinessException(EnergyResponseEnum.CHILDREN_EXIT);
|
||||
}
|
||||
|
||||
UpdateWrapper<EleDict> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.lambda().eq(EleDict::getState,DataStateEnum.ENABLE.getCode()).set(EleDict::getState,DataStateEnum.DELETED.getCode()).eq(EleDict::getId,id);
|
||||
return this.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<EleDict> getList(DictParam.DictQueryParam dictQueryParam) {
|
||||
QueryWrapper<EleDict> queryWrapper = new QueryWrapper<>();
|
||||
if(Objects.nonNull(dictQueryParam)){
|
||||
//查询参数不为空,进行条件填充
|
||||
if(StrUtil.isNotBlank(dictQueryParam.getSearchValue())){
|
||||
//字典类型表,仅提供名称、编码模糊查询
|
||||
queryWrapper
|
||||
.and(param -> param.like("ele_dict.name",dictQueryParam.getSearchValue())
|
||||
.or().like("ele_dict.another_name",dictQueryParam.getSearchValue()));
|
||||
}
|
||||
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(dictQueryParam.getSortBy(), dictQueryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, dictQueryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(dictQueryParam.getSortBy()));
|
||||
}else{
|
||||
queryWrapper.eq("ele_dict.pid",dictQueryParam.getPid());
|
||||
//没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序
|
||||
queryWrapper.orderBy(true, true, "ele_dict.update_time");
|
||||
}
|
||||
|
||||
}
|
||||
queryWrapper.eq("ele_dict.state", DataStateEnum.ENABLE.getCode());
|
||||
return this.baseMapper.selectPage(new Page<>(PageFactory.getPageNum(dictQueryParam),PageFactory.getPageSize(dictQueryParam)),queryWrapper);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public EleDict getById(String id) {
|
||||
return this.getById(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean add(DictParam dictParam) {
|
||||
checkName(dictParam,true);
|
||||
EleDict eleDict = new EleDict();
|
||||
BeanUtils.copyProperties(dictParam,eleDict);
|
||||
eleDict.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(eleDict);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(DictParam.DictUpdateParam dictUpdateParam) {
|
||||
checkName(dictUpdateParam,false);
|
||||
EleDict eleDict = new EleDict();
|
||||
BeanUtils.copyProperties(dictUpdateParam,eleDict);
|
||||
return this.updateById(eleDict);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 名称重复校验
|
||||
* @author cdf
|
||||
* @date 2022/3/23
|
||||
*/
|
||||
private void checkName(DictParam dictParam,boolean flag){
|
||||
LambdaQueryWrapper<EleDict> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(EleDict::getName,dictParam.getName())
|
||||
.eq(EleDict::getState,DataStateEnum.ENABLE.getCode());
|
||||
//修改
|
||||
if(!flag){
|
||||
if(dictParam instanceof DictParam.DictUpdateParam ){
|
||||
lambdaQueryWrapper.ne(EleDict::getId,((DictParam.DictUpdateParam)dictParam).getId());
|
||||
}
|
||||
}
|
||||
int res = this.count(lambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (res >= 1) {
|
||||
throw new BusinessException(EnergyResponseEnum.DIC_NAME_REPEAT);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleDoMapper;
|
||||
import com.njcn.energy.pojo.po.EleDo;
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
import com.njcn.energy.service.IEleDoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/15 19:29
|
||||
*/
|
||||
@Service
|
||||
public class EleDoServiceImpl extends ServiceImpl<EleDoMapper, EleDo> implements IEleDoService {
|
||||
@Override
|
||||
public boolean addDo(EleDo eleDo) {
|
||||
return this.save(eleDo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDo(EleDo eleDo) {
|
||||
return this.updateById(eleDo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EleDo findByName(String name) {
|
||||
return this.lambdaQuery().eq(EleDo::getName,name).one();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleEpdMapper;
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
import com.njcn.energy.service.IEleEpdPqdService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/15 10:08
|
||||
*/
|
||||
@Service
|
||||
public class EleEpdPqdServiceImpl extends ServiceImpl<EleEpdMapper,EleEpdPqd> implements IEleEpdPqdService {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addEpd(EleEpdPqd eleEpdPqd) {
|
||||
return this.save(eleEpdPqd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateEpd(EleEpdPqd eleEpdPqd) {
|
||||
return this.updateById(eleEpdPqd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EleEpdPqd findByName(String name,String phase) {
|
||||
return this.lambdaQuery().eq(EleEpdPqd::getName,name).eq(EleEpdPqd::getPhase,phase).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EleEpdPqd> getAllEpd() {
|
||||
return this.lambdaQuery().orderByDesc(EleEpdPqd::getIdx).list();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleEvtParamMapper;
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
import com.njcn.energy.pojo.po.EleEvt;
|
||||
import com.njcn.energy.pojo.po.EleEvtParm;
|
||||
import com.njcn.energy.service.IEleEvtParamService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/15 16:20
|
||||
*/
|
||||
@Service
|
||||
public class EleEvtParamServiceImpl extends ServiceImpl<EleEvtParamMapper, EleEvtParm> implements IEleEvtParamService {
|
||||
|
||||
@Override
|
||||
public boolean addEleEvtParam(EleEvtParm eleEvtParam) {
|
||||
return this.save(eleEvtParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateEleEvtParam(EleEvtParm eleEvtParam) {
|
||||
return this.updateById(eleEvtParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EleEvtParm findByName(String name) {
|
||||
return this.lambdaQuery().eq(EleEvtParm::getName,name).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteById(String id) {
|
||||
QueryWrapper<EleEvtParm> eleEvtParamQueryWrapper = new QueryWrapper<>();
|
||||
eleEvtParamQueryWrapper.eq("Pid",id);
|
||||
return this.remove(eleEvtParamQueryWrapper);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleEvtMapper;
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
import com.njcn.energy.pojo.po.EleEvt;
|
||||
import com.njcn.energy.service.IEleEvtService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/15 15:12
|
||||
*/
|
||||
@Service
|
||||
public class EleEvtServiceImpl extends ServiceImpl<EleEvtMapper, EleEvt> implements IEleEvtService {
|
||||
|
||||
@Override
|
||||
public EleEvt addEvt(EleEvt eleEvt) {
|
||||
this.save(eleEvt);
|
||||
return eleEvt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateEvt(EleEvt eleEvt) {
|
||||
return this.updateById(eleEvt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EleEvt findByName(String name) {
|
||||
return this.lambdaQuery().eq(EleEvt::getName,name).one();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.energy.mapper.EleInformationMapper;
|
||||
import com.njcn.energy.pojo.constant.ModelState;
|
||||
import com.njcn.energy.pojo.dto.OnlineRateDTO;
|
||||
import com.njcn.energy.pojo.po.*;
|
||||
import com.njcn.energy.pojo.vo.EleIntegrityVO;
|
||||
import com.njcn.energy.service.IEleInformationService;
|
||||
import com.njcn.energy.service.ILogicAccessService;
|
||||
import com.njcn.energy.service.ILogicDeviceLineService;
|
||||
import com.njcn.energy.service.INetDevService;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.influxdb.impl.InfluxDBResultMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/4/19 10:51
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class EleInformationServiceImpl extends ServiceImpl<EleInformationMapper, EleInformation> implements IEleInformationService {
|
||||
|
||||
private final INetDevService netDevService;
|
||||
|
||||
private final ILogicDeviceLineService logicDeviceLineService;
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
private final ILogicAccessService logicAccessService;
|
||||
|
||||
private final Integer DAY_SECOND = 60*60*24;
|
||||
|
||||
@Override
|
||||
public void addInformation(List<EleInformation> list) {
|
||||
this.saveBatch(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OnlineRateDTO> getDeviceTime(String startTime, String endTime) {
|
||||
List<OnlineRateDTO> result = new ArrayList<>();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
List<String> list = new ArrayList<>();
|
||||
//获取当天information表中的数据
|
||||
List<EleInformation> informationList = this.lambdaQuery().ge(EleInformation::getUpdateTime,startTime).le(EleInformation::getUpdateTime,endTime).list();
|
||||
if (!CollectionUtils.isEmpty(informationList)){
|
||||
list = informationList.stream().map(EleInformation::getDid).collect(Collectors.toList());
|
||||
}
|
||||
//获取所有的装置
|
||||
List<String> onlineList = logicAccessService.getAllDev().stream().map(LogicAccess::getDid).collect(Collectors.toList());
|
||||
onlineList.removeAll(list);
|
||||
//根据装置的id进行分组
|
||||
Map<String,List<EleInformation>> groupMap = informationList.stream().collect(Collectors.groupingBy(EleInformation::getDid));
|
||||
//先处理information表中的数据
|
||||
try {
|
||||
for (String key : groupMap.keySet()) {
|
||||
int offTime = 0;
|
||||
int onTime = 0;
|
||||
OnlineRateDTO onlineRateDTO = new OnlineRateDTO();
|
||||
List<EleInformation> infoList = groupMap.get(key);
|
||||
if (infoList.size() > 1){
|
||||
//获取最早一条记录
|
||||
EleInformation first = infoList.stream().min(Comparator.comparing(EleInformation::getUpdateTime)).get();
|
||||
//频繁的上下线
|
||||
//将上线和下线分组
|
||||
Map<Integer,List<EleInformation>> typeMap = infoList.stream().collect(Collectors.groupingBy(EleInformation::getType));
|
||||
List<EleInformation> off = typeMap.get(0);
|
||||
List<EleInformation> on = typeMap.get(1);
|
||||
if (first.getType() == 0){
|
||||
if (off.size() == on.size()){
|
||||
for (int i = 0; i < off.size(); i++) {
|
||||
offTime = offTime + (int) (on.get(i).getUpdateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() - off.get(i).getUpdateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) / 1000;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < off.size(); i++) {
|
||||
if (i == off.size() - 1){
|
||||
offTime = offTime + (int) (sdf.parse(endTime).getTime() - off.get(i).getUpdateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) / 1000;
|
||||
} else {
|
||||
offTime = offTime + (int) (on.get(i).getUpdateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() - off.get(i).getUpdateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) / 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
onTime = DAY_SECOND-offTime;
|
||||
} else {
|
||||
if (off.size() == on.size()){
|
||||
for (int i = 0; i < on.size(); i++) {
|
||||
onTime = onTime + (int) (off.get(i).getUpdateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() - on.get(i).getUpdateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) / 1000;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < on.size(); i++) {
|
||||
if (i == on.size() - 1){
|
||||
onTime = onTime + (int) (sdf.parse(endTime).getTime() - on.get(i).getUpdateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) / 1000;
|
||||
} else {
|
||||
onTime = onTime + (int) (off.get(i).getUpdateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() - on.get(i).getUpdateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) / 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
offTime = DAY_SECOND-onTime;
|
||||
}
|
||||
} else {
|
||||
LocalDateTime updateTime = infoList.get(0).getUpdateTime();
|
||||
if (Objects.equals(infoList.get(0).getType(),0)) {
|
||||
onTime = (int) (updateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() - sdf.parse(startTime).getTime()) / 1000;
|
||||
offTime = (int) (sdf.parse(endTime).getTime() - updateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) / 1000;
|
||||
} else {
|
||||
offTime = (int) (updateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() - sdf.parse(startTime).getTime()) / 1000;
|
||||
onTime = (int) (sdf.parse(endTime).getTime() - updateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) / 1000;
|
||||
}
|
||||
}
|
||||
onlineRateDTO.setDeviceId(infoList.get(0).getDid());
|
||||
onlineRateDTO.setOnlineTime(onTime);
|
||||
onlineRateDTO.setOfflineTime(offTime);
|
||||
onlineRateDTO.setOnlineRate(Double.parseDouble(String.format("%.2f",onTime*1.0/DAY_SECOND*100)));
|
||||
onlineRateDTO.setTime(sdf.parse(startTime).getTime());
|
||||
result.add(onlineRateDTO);
|
||||
}
|
||||
//后处理information表中没有的数据
|
||||
//1.判断有没有最新的记录,没有则不做记录 2.如果有最新的记录,判断最后一条记录是上线还是下线
|
||||
if(!CollectionUtils.isEmpty(onlineList)){
|
||||
for (String s : onlineList) {
|
||||
List<EleInformation> eleInformationList = this.lambdaQuery().eq(EleInformation::getDid,s).orderByDesc(EleInformation::getUpdateTime).list();
|
||||
if (!CollectionUtils.isEmpty(eleInformationList)){
|
||||
EleInformation pojo = eleInformationList.stream().findFirst().get();
|
||||
OnlineRateDTO onlineRateDTO = new OnlineRateDTO();
|
||||
if (Objects.equals(pojo.getType(), ModelState.offline)){
|
||||
onlineRateDTO.setOfflineTime(DAY_SECOND);
|
||||
onlineRateDTO.setOnlineTime(0);
|
||||
onlineRateDTO.setOnlineRate(0.0);
|
||||
} else {
|
||||
onlineRateDTO.setOfflineTime(0);
|
||||
onlineRateDTO.setOnlineTime(DAY_SECOND);
|
||||
onlineRateDTO.setOnlineRate(100.0);
|
||||
}
|
||||
onlineRateDTO.setTime(sdf.parse(startTime).getTime());
|
||||
onlineRateDTO.setDeviceId(s);
|
||||
result.add(onlineRateDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.getMessage();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EleIntegrityVO> getOnlineRateTree(String startTime, String endTime) {
|
||||
List<EleIntegrityVO> netDevIntegrity = new ArrayList<>(),logicDevIntegrity = new ArrayList<>();
|
||||
Map<String, List<EleOnlineRate>> deviceGroup = new HashMap<>();
|
||||
//获取所有网关
|
||||
List<NetDev> netDevList = netDevService.getAllNetDev();
|
||||
List<String> netDevId = netDevList.stream().map(NetDev::getId).collect(Collectors.toList());
|
||||
//获取网关下所有的逻辑设备
|
||||
List<LogicDev> logicDevList = logicDeviceLineService.getLogicDevByList(netDevId);
|
||||
List<String> devId = logicDevList.stream().map(LogicDev::getDid).collect(Collectors.toList());
|
||||
//获取装置通讯状态
|
||||
List<LogicAccess> logicAccessList = logicAccessService.getLogicDevByList(netDevId);
|
||||
netDevList.forEach(item->{
|
||||
EleIntegrityVO eleIntegrityVO = new EleIntegrityVO();
|
||||
BeanUtil.copyProperties(item,eleIntegrityVO);
|
||||
eleIntegrityVO.setComFlag(item.getComFlag());
|
||||
eleIntegrityVO.setPid("0");
|
||||
netDevIntegrity.add(eleIntegrityVO);
|
||||
});
|
||||
List<EleOnlineRate> devList = getAreaList(startTime,endTime,devId);
|
||||
if (!CollectionUtils.isEmpty(devList)){
|
||||
deviceGroup = devList.stream().collect(Collectors.groupingBy(EleOnlineRate::getDeviceId));
|
||||
}
|
||||
for (LogicDev item : logicDevList) {
|
||||
EleIntegrityVO eleIntegrityVO = new EleIntegrityVO();
|
||||
BeanUtil.copyProperties(item,eleIntegrityVO);
|
||||
eleIntegrityVO.setInfo(item.getPosition());
|
||||
logicAccessList.forEach(item2->{
|
||||
if (Objects.equals(item.getDid(),item2.getDid())){
|
||||
if (Objects.equals(item2.getState(), ModelState.ACCESS)){
|
||||
eleIntegrityVO.setComFlag(DataStateEnum.ENABLE.getCode());
|
||||
} else {
|
||||
eleIntegrityVO.setComFlag(DataStateEnum.DELETED.getCode());
|
||||
}
|
||||
}
|
||||
});
|
||||
for (String device:deviceGroup.keySet()) {
|
||||
if (Objects.equals(device,item.getDid())){
|
||||
double dd = 0.0;
|
||||
List<EleOnlineRate> list = deviceGroup.get(device);
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
dd = BigDecimal.valueOf(Math.min(list.stream().mapToDouble(EleOnlineRate::getOnlineRate).sum()/list.size(), 100.00)).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
eleIntegrityVO.setIntegrity(dd);
|
||||
}
|
||||
}
|
||||
logicDevIntegrity.add(eleIntegrityVO);
|
||||
}
|
||||
dealAverageAndChildrenData(netDevIntegrity,logicDevIntegrity,startTime,endTime);
|
||||
return netDevIntegrity;
|
||||
}
|
||||
|
||||
|
||||
private void dealAverageAndChildrenData(List<EleIntegrityVO> targetData, List<EleIntegrityVO> childrenData,String startTime,String endTime) {
|
||||
Map<String, List<EleIntegrityVO>> groupLine = childrenData.stream().collect(Collectors.groupingBy(EleIntegrityVO::getPid));
|
||||
targetData = targetData.stream().peek(integrityVO -> {
|
||||
if (!CollectionUtils.isEmpty(groupLine.get(integrityVO.getId()))) {
|
||||
List<EleIntegrityVO> integrityVOList = new ArrayList<>();
|
||||
integrityVOList = groupLine.get(integrityVO.getId());
|
||||
integrityVO.setChildren(groupLine.get(integrityVO.getId()));
|
||||
List<String> devList = new ArrayList<>();
|
||||
List<EleOnlineRate> areaList = new ArrayList<>();
|
||||
devList = integrityVOList.stream().map(EleIntegrityVO::getDid).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(devList)){
|
||||
//查询结果
|
||||
areaList = getAreaList(startTime,endTime,devList);
|
||||
if(!CollectionUtils.isEmpty(areaList)){
|
||||
integrityVO.setIntegrity(getAreaData(areaList));
|
||||
}
|
||||
}
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 终端在线率
|
||||
* 区域(日/月统计)
|
||||
*/
|
||||
private List<EleOnlineRate> getAreaList(String startTime, String endTime, List<String> lineList) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("(");
|
||||
for (int i = 0; i < lineList.size(); i++) {
|
||||
if (lineList.size() - i != 1) {
|
||||
stringBuilder.append("device_id = '").append(lineList.get(i)).append("' or ");
|
||||
} else {
|
||||
stringBuilder.append("device_id = '").append(lineList.get(i)).append("')");
|
||||
}
|
||||
}
|
||||
String sql = "SELECT * FROM ele_online_rate where "+stringBuilder+" and time >='"+startTime+"' and time <= '"+endTime+"' tz('Asia/Shanghai')";
|
||||
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||
List<EleOnlineRate> onlineRateList = resultMapper.toPOJO(sqlResult, EleOnlineRate.class);
|
||||
onlineRateList.forEach(item->{
|
||||
item.setTime(item.getTime().plusMillis(TimeUnit.HOURS.toMillis(8)));
|
||||
});
|
||||
return onlineRateList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据时间分组,求区域的终端在线率
|
||||
*/
|
||||
private Double getAreaData(List<EleOnlineRate> list) {
|
||||
double result = 0.0;
|
||||
Map<Instant, List<EleOnlineRate>> map = list.stream().collect(Collectors.groupingBy(EleOnlineRate::getTime));
|
||||
for (Instant key : map.keySet()) {
|
||||
List<EleOnlineRate> value = map.get(key);
|
||||
double data = value.stream().mapToDouble(EleOnlineRate::getOnlineRate).sum();
|
||||
//区域某一天的终端在线率
|
||||
data = data/value.size();
|
||||
//区域时间范围终端在线率之和
|
||||
result = result + data;
|
||||
}
|
||||
return BigDecimal.valueOf(Math.min(result/map.size(), 100.00)).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.energy.mapper.EleIntegrityMapper;
|
||||
import com.njcn.energy.pojo.constant.ModelState;
|
||||
import com.njcn.energy.pojo.dto.ElePublicDTO;
|
||||
import com.njcn.energy.pojo.po.*;
|
||||
import com.njcn.energy.pojo.vo.EleIntegrityVO;
|
||||
import com.njcn.energy.service.*;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.influxdb.impl.InfluxDBResultMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/31 19:40
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Service
|
||||
public class EleIntegrityServiceImpl extends ServiceImpl<EleIntegrityMapper, EleIntegrity> implements IEleIntegrityService {
|
||||
|
||||
private final INetDevService netDevService;
|
||||
|
||||
private final ILogicDeviceLineService logicDeviceLineService;
|
||||
|
||||
private final IEleLineService eleLineService;
|
||||
|
||||
private final ILogicAccessService logicAccessService;
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
@Override
|
||||
public List<EleIntegrityVO> getIntegrityTree(String startTime, String endTime) {
|
||||
List<EleIntegrityVO> netDevIntegrity = new ArrayList<>(),logicDevIntegrity = new ArrayList<>(),lineIntegrity = new ArrayList<>();
|
||||
//获取所有网关
|
||||
List<NetDev> netDevList = netDevService.getAllNetDev();
|
||||
List<String> netDevId = netDevList.stream().map(NetDev::getId).collect(Collectors.toList());
|
||||
//获取网关下所有的逻辑设备
|
||||
List<LogicDev> logicDevList = logicDeviceLineService.getLogicDevByList(netDevId);
|
||||
//获取逻辑设备绑定的监测点
|
||||
List<EleLine> eleLineList = eleLineService.getAllLines(logicDevList.stream().map(LogicDev::getId).collect(Collectors.toList()));
|
||||
//获取装置通讯状态
|
||||
List<LogicAccess> logicAccessList = logicAccessService.getLogicDevByList(netDevId);
|
||||
netDevList.forEach(item->{
|
||||
EleIntegrityVO eleIntegrityVO = new EleIntegrityVO();
|
||||
BeanUtil.copyProperties(item,eleIntegrityVO);
|
||||
eleIntegrityVO.setComFlag(item.getComFlag());
|
||||
eleIntegrityVO.setPid("0");
|
||||
netDevIntegrity.add(eleIntegrityVO);
|
||||
});
|
||||
logicDevList.forEach(item->{
|
||||
EleIntegrityVO eleIntegrityVO = new EleIntegrityVO();
|
||||
BeanUtil.copyProperties(item,eleIntegrityVO);
|
||||
eleIntegrityVO.setInfo(item.getPosition());
|
||||
logicAccessList.forEach(item2->{
|
||||
if (Objects.equals(item.getDid(),item2.getDid())){
|
||||
if (Objects.equals(item2.getState(), ModelState.ACCESS)){
|
||||
eleIntegrityVO.setComFlag(DataStateEnum.ENABLE.getCode());
|
||||
} else {
|
||||
eleIntegrityVO.setComFlag(DataStateEnum.DELETED.getCode());
|
||||
}
|
||||
}
|
||||
});
|
||||
logicDevIntegrity.add(eleIntegrityVO);
|
||||
});
|
||||
List<ElePublicDTO> lineList = getLineData(startTime,endTime);
|
||||
eleLineList.forEach(item->{
|
||||
EleIntegrityVO eleIntegrityVO = new EleIntegrityVO();
|
||||
BeanUtil.copyProperties(item,eleIntegrityVO);
|
||||
eleIntegrityVO.setInfo(item.getPosition());
|
||||
if (!CollectionUtils.isEmpty(lineList)){
|
||||
lineList.forEach(item2->{
|
||||
if (Objects.equals(item.getLineId(),item2.getLineId())){
|
||||
eleIntegrityVO.setIntegrity(item2.getData());
|
||||
}
|
||||
});
|
||||
}
|
||||
lineIntegrity.add(eleIntegrityVO);
|
||||
});
|
||||
dealAverageAndChildrenData(logicDevIntegrity,lineIntegrity,true,startTime,endTime);
|
||||
dealAverageAndChildrenData(netDevIntegrity,logicDevIntegrity,false,startTime,endTime);
|
||||
return netDevIntegrity;
|
||||
}
|
||||
|
||||
private void dealAverageAndChildrenData(List<EleIntegrityVO> targetData, List<EleIntegrityVO> childrenData, boolean isLine,String startTime,String endTime) {
|
||||
Map<String, List<EleIntegrityVO>> groupLine = childrenData.stream().collect(Collectors.groupingBy(EleIntegrityVO::getPid));
|
||||
targetData = targetData.stream().peek(integrityVO -> {
|
||||
if (!CollectionUtils.isEmpty(groupLine.get(integrityVO.getId()))) {
|
||||
List<String> lineList = new ArrayList<>();
|
||||
List<EleIntegrity> areaList = new ArrayList<>();
|
||||
//监测点集合
|
||||
List<EleIntegrityVO> integrityVOList = new ArrayList<>();
|
||||
if (isLine) {
|
||||
integrityVOList = groupLine.get(integrityVO.getId());
|
||||
} else {
|
||||
//子集合,从子集合中拿出所有的监测点集合
|
||||
List<EleIntegrityVO> childIntegrityVOList = groupLine.get(integrityVO.getId());
|
||||
for (EleIntegrityVO vo : childIntegrityVOList) {
|
||||
integrityVOList.addAll(vo.getLineData());
|
||||
}
|
||||
}
|
||||
integrityVO.setLineData(integrityVOList);
|
||||
integrityVO.setChildren(groupLine.get(integrityVO.getId()));
|
||||
lineList = integrityVOList.stream().map(EleIntegrityVO::getLineId).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(lineList)){
|
||||
//查询结果
|
||||
areaList = getAreaList(startTime,endTime,lineList);
|
||||
if(!CollectionUtils.isEmpty(areaList)){
|
||||
integrityVO.setIntegrity(getAreaData(areaList));
|
||||
}
|
||||
}
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 数据完整性
|
||||
* 监测点(日/月统计)
|
||||
* 数据结果已乘以100,作为百分数
|
||||
*/
|
||||
private List<ElePublicDTO> getLineData(String startTime, String endTime) {
|
||||
List<ElePublicDTO> result = new ArrayList<>();
|
||||
String sql = "SELECT sum(real)/sum(due)*100 AS data FROM ele_integrity where time >='"+startTime+"' and time <= '"+endTime+"' group by line_id tz('Asia/Shanghai')";
|
||||
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||
List<QueryResult.Series> list = sqlResult.getResults().get(0).getSeries();
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
list.forEach(po -> {
|
||||
ElePublicDTO publicDTO = new ElePublicDTO();
|
||||
List<List<Object>> valueList = po.getValues();
|
||||
String index = po.getTags().get("line_id");
|
||||
if (!CollectionUtils.isEmpty(valueList)) {
|
||||
for (List<Object> value : valueList) {
|
||||
//数据完整性 保留二位小数
|
||||
double integrity = value.get(1) == null ? 3.14159 : BigDecimal.valueOf(Double.parseDouble(value.get(1).toString())).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
publicDTO.setLineId(index);
|
||||
publicDTO.setData(Math.min(integrity, 100.00));
|
||||
}
|
||||
}
|
||||
result.add(publicDTO);
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据完整性
|
||||
* 区域(日/月统计)
|
||||
*/
|
||||
private List<EleIntegrity> getAreaList(String startTime, String endTime, List<String> lineList) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("(");
|
||||
for (int i = 0; i < lineList.size(); i++) {
|
||||
if (lineList.size() - i != 1) {
|
||||
stringBuilder.append("line_id = '").append(lineList.get(i)).append("' or ");
|
||||
} else {
|
||||
stringBuilder.append("line_id = '").append(lineList.get(i)).append("')");
|
||||
}
|
||||
}
|
||||
String sql = "SELECT * FROM ele_integrity where "+stringBuilder+" and time >='"+startTime+"' and time <= '"+endTime+"' tz('Asia/Shanghai')";
|
||||
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||
List<EleIntegrity> integrityList = resultMapper.toPOJO(sqlResult, EleIntegrity.class);
|
||||
integrityList.forEach(item->{
|
||||
item.setTime(item.getTime().plusMillis(TimeUnit.HOURS.toMillis(8)));
|
||||
});
|
||||
return integrityList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据时间分组,求区域的数据完整性
|
||||
*/
|
||||
private Double getAreaData(List<EleIntegrity> list) {
|
||||
double result = 0.0;
|
||||
Map<Instant, List<EleIntegrity>> map = list.stream().collect(Collectors.groupingBy(EleIntegrity::getTime));
|
||||
for (Instant key : map.keySet()) {
|
||||
double data = 0.0;
|
||||
List<EleIntegrity> value = map.get(key);
|
||||
for (EleIntegrity item : value) {
|
||||
double dayData = (double)item.getReal()/item.getDue();
|
||||
data = data + dayData;
|
||||
}
|
||||
//区域某一天的数据完整性
|
||||
data = data/value.size();
|
||||
//区域时间范围数据完整性之和
|
||||
result = result + data;
|
||||
}
|
||||
return BigDecimal.valueOf(Math.min(result/map.size()*100, 100.00)).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.energy.mapper.EleLineMapper;
|
||||
import com.njcn.energy.pojo.param.LineParam;
|
||||
import com.njcn.energy.pojo.po.EleLine;
|
||||
import com.njcn.energy.service.IEleLineService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/8 14:31
|
||||
*/
|
||||
@Service
|
||||
public class EleLineServiceImpl extends ServiceImpl<EleLineMapper, EleLine> implements IEleLineService {
|
||||
|
||||
@Override
|
||||
public EleLine add(LineParam lineParam) {
|
||||
EleLine line = new EleLine();
|
||||
BeanUtil.copyProperties(lineParam,line);
|
||||
line.setState(DataStateEnum.ENABLE.getCode());
|
||||
this.save(line);
|
||||
return line;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteByList(List<String> list) {
|
||||
QueryWrapper<EleLine> eleLineQueryWrapper = new QueryWrapper<>();
|
||||
eleLineQueryWrapper.in("Pid",list);
|
||||
return this.remove(eleLineQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EleLine> getAllLine(String netDevName){
|
||||
return this.baseMapper.getAllLine(netDevName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EleLine> getAllLines(List<String> list) {
|
||||
return this.lambdaQuery().in(EleLine::getPid,list).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EleLine> getLineInfo(List<String> list) {
|
||||
return this.lambdaQuery().in(EleLine::getLineId,list).list();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleLoadSetMapper;
|
||||
import com.njcn.energy.pojo.param.EleParam;
|
||||
import com.njcn.energy.pojo.po.EleLoadSet;
|
||||
import com.njcn.energy.pojo.po.EleStatisticalSet;
|
||||
import com.njcn.energy.pojo.vo.EleLoadSetTreeVO;
|
||||
import com.njcn.energy.pojo.vo.EleLoadSetVO;
|
||||
import com.njcn.energy.service.EleLoadSetService;
|
||||
import com.njcn.energy.service.ILogicDeviceLineService;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用能负荷类型配置
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年04月15日 14:31
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class EleLoadSetServiceImpl extends ServiceImpl<EleLoadSetMapper, EleLoadSet> implements EleLoadSetService {
|
||||
|
||||
private final ILogicDeviceLineService iLogicDeviceLineService;
|
||||
@Override
|
||||
public List<EleLoadSetVO> getEleLoadSetDetail() {
|
||||
return this.baseMapper.getEleLoadSetDetail(DicDataTypeEnum.ELE_LOAD_TYPE.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EleLoadSetTreeVO getEleLoadTree(EleLoadSetVO eleLoadSetVO) {
|
||||
return iLogicDeviceLineService.getEnergyLoadTree(eleLoadSetVO.getLoadId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean add(EleParam eleParam) {
|
||||
QueryWrapper<EleLoadSet> eleMdQueryWrapper = new QueryWrapper<>();
|
||||
eleMdQueryWrapper.eq("ele_load_set.id", eleParam.getId());
|
||||
this.baseMapper.delete(eleMdQueryWrapper);
|
||||
for (String index : eleParam.getIds()) {
|
||||
EleLoadSet eleLoadSet = new EleLoadSet();
|
||||
eleLoadSet.setId(eleParam.getId());
|
||||
eleLoadSet.setLineId(index);
|
||||
this.baseMapper.insert(eleLoadSet);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleLogsMapper;
|
||||
import com.njcn.energy.pojo.po.EleLogs;
|
||||
import com.njcn.energy.service.IEleLogsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/4/6 19:56
|
||||
*/
|
||||
@Service
|
||||
public class EleLogsServiceImpl extends ServiceImpl<EleLogsMapper,EleLogs> implements IEleLogsService {
|
||||
|
||||
@Override
|
||||
public void addLogs(EleLogs eleLogs) {
|
||||
this.save(eleLogs);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleMdMapper;
|
||||
import com.njcn.energy.pojo.po.EleMd;
|
||||
import com.njcn.energy.service.IEleMdService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/15 13:32
|
||||
*/
|
||||
@Service
|
||||
public class EleMdServiceImpl extends ServiceImpl<EleMdMapper, EleMd> implements IEleMdService {
|
||||
@Override
|
||||
public boolean addMd(EleMd eleMd) {
|
||||
return this.save(eleMd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateMd(EleMd eleMd) {
|
||||
return this.updateById(eleMd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EleMd findByName(String name,String phase) {
|
||||
return this.lambdaQuery().eq(EleMd::getName,name).eq(EleMd::getPhase,phase).one();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleRateSetMappser;
|
||||
import com.njcn.energy.pojo.po.EleRateSet;
|
||||
import com.njcn.energy.pojo.vo.EleRateVO;
|
||||
import com.njcn.energy.service.EleRateSetService;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年04月13日 19:39
|
||||
*/
|
||||
@Service
|
||||
public class EleRateSetServiceImpl extends ServiceImpl<EleRateSetMappser, EleRateSet> implements EleRateSetService {
|
||||
@Override
|
||||
public List<EleRateVO> getEleRateDetail() {
|
||||
//查询费率类型配置
|
||||
return this.baseMapper.getEleRateDetail(DicDataTypeEnum.RATE_TYPE.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(EleRateSet eleRateSet) {
|
||||
//先删除
|
||||
this.baseMapper.deleteById(eleRateSet.getId());
|
||||
//后新增
|
||||
this.baseMapper.insert(eleRateSet);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleEpdMapper;
|
||||
import com.njcn.energy.mapper.EleMdMapper;
|
||||
import com.njcn.energy.mapper.EleStatisticalSetMapper;
|
||||
import com.njcn.energy.pojo.enums.EleStatisticalSetEnum;
|
||||
import com.njcn.energy.pojo.param.EleParam;
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
import com.njcn.energy.pojo.po.EleMd;
|
||||
import com.njcn.energy.pojo.po.EleStatisticalSet;
|
||||
import com.njcn.energy.pojo.vo.EleMdVO;
|
||||
import com.njcn.energy.pojo.vo.EleStatisticalTreeVO;
|
||||
import com.njcn.energy.pojo.vo.EleStatisticalVO;
|
||||
import com.njcn.energy.service.EleStatisticalSetService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用能统计类型配置
|
||||
*
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年04月14日 15:16
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class EleStatisticalSetServiceImpl extends ServiceImpl<EleStatisticalSetMapper, EleStatisticalSet> implements EleStatisticalSetService {
|
||||
|
||||
private final EleMdMapper eleMdMapper;
|
||||
|
||||
private final EleEpdMapper eleEpdMapper;
|
||||
|
||||
private final EleStatisticalSetMapper eleStatisticalSetMapper;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
@Override
|
||||
public List<EleStatisticalVO> getEleStatisticalDetail() {
|
||||
return this.baseMapper.getEleStatisticalDetail(DicDataTypeEnum.ELE_STATISTICAL_TYPE.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EleStatisticalTreeVO getEleStatisticalTree(EleStatisticalVO eleStatisticalVO) {
|
||||
EleStatisticalTreeVO eleStatisticalTreeVO = new EleStatisticalTreeVO();
|
||||
//根据id去查询相对应的类型
|
||||
if (EleStatisticalSetEnum.LOAD_STATISTICS.getName().equals(eleStatisticalVO.getStatisticalName())) {
|
||||
//查询已绑指标
|
||||
List<EleMd> eleMdList = eleMdMapper.getEleMdList(dicDataFeignClient.getDicDataByName(eleStatisticalVO.getStatisticalName()).getData().getId());
|
||||
List<EleMdVO> eleMdVOList = new ArrayList<>();
|
||||
List<EleMdVO> eleMdVONoList = new ArrayList<>();
|
||||
for (EleMd eleMd : eleMdList) {
|
||||
EleMdVO eleMdVO = new EleMdVO();
|
||||
eleMdVO.setId(eleMd.getId());
|
||||
eleMdVO.setName(("T".equals(eleMd.getPhase())) || "M".equals(eleMd.getPhase()) ? eleMd.getAnotherName() : (eleMd.getPhase() + "相" + eleMd.getAnotherName()));
|
||||
eleMdVOList.add(eleMdVO);
|
||||
}
|
||||
//查询未绑指标
|
||||
List<EleMd> eleMdNoList = eleMdMapper.getEleMdNoList(dicDataFeignClient.getDicDataByName(eleStatisticalVO.getStatisticalName()).getData().getId());
|
||||
for (EleMd eleMd : eleMdNoList) {
|
||||
EleMdVO eleMdVO = new EleMdVO();
|
||||
eleMdVO.setId(eleMd.getId());
|
||||
eleMdVO.setName(("T".equals(eleMd.getPhase())) || "M".equals(eleMd.getPhase()) ? eleMd.getAnotherName() : (eleMd.getPhase() + "相" + eleMd.getAnotherName()));
|
||||
eleMdVONoList.add(eleMdVO);
|
||||
}
|
||||
eleStatisticalTreeVO.setBinds(eleMdVOList);
|
||||
eleStatisticalTreeVO.setNoBinds(eleMdVONoList);
|
||||
} else {
|
||||
//查询已绑指标
|
||||
List<EleEpdPqd> eleEpdList = eleEpdMapper.getEleEpdPqdList(dicDataFeignClient.getDicDataByName(eleStatisticalVO.getStatisticalName()).getData().getId());
|
||||
List<EleMdVO> eleEpdVOList = new ArrayList<>();
|
||||
List<EleMdVO> eleEpdVONoList = new ArrayList<>();
|
||||
for (EleEpdPqd eleEpdPqd : eleEpdList) {
|
||||
EleMdVO eleMdVO = new EleMdVO();
|
||||
eleMdVO.setId(eleEpdPqd.getId());
|
||||
eleMdVO.setName(("T".equals(eleEpdPqd.getPhase())) || "M".equals(eleEpdPqd.getPhase()) ? eleEpdPqd.getAnotherName() : (eleEpdPqd.getPhase() + "相" + eleEpdPqd.getAnotherName()));
|
||||
eleEpdVOList.add(eleMdVO);
|
||||
}
|
||||
//查询未绑指标
|
||||
List<EleEpdPqd> eleEpdNoList = eleEpdMapper.getEleEpdPqdNoList(dicDataFeignClient.getDicDataByName(eleStatisticalVO.getStatisticalName()).getData().getId());
|
||||
for (EleEpdPqd eleEpdPqd : eleEpdNoList) {
|
||||
EleMdVO eleMdVO = new EleMdVO();
|
||||
eleMdVO.setId(eleEpdPqd.getId());
|
||||
eleMdVO.setName(("T".equals(eleEpdPqd.getPhase())) || "M".equals(eleEpdPqd.getPhase()) ? eleEpdPqd.getAnotherName() : (eleEpdPqd.getPhase() + "相" + eleEpdPqd.getAnotherName()));
|
||||
eleEpdVONoList.add(eleMdVO);
|
||||
}
|
||||
eleStatisticalTreeVO.setBinds(eleEpdVOList);
|
||||
eleStatisticalTreeVO.setNoBinds(eleEpdVONoList);
|
||||
}
|
||||
return eleStatisticalTreeVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean add(EleParam eleParam) {
|
||||
QueryWrapper<EleStatisticalSet> eleMdQueryWrapper = new QueryWrapper<>();
|
||||
eleMdQueryWrapper.eq("ele_statistical_set.id", eleParam.getId());
|
||||
this.eleStatisticalSetMapper.delete(eleMdQueryWrapper);
|
||||
for (String index : eleParam.getIds()) {
|
||||
EleStatisticalSet eleStatisticalSet = new EleStatisticalSet();
|
||||
eleStatisticalSet.setId(eleParam.getId());
|
||||
eleStatisticalSet.setConId(index);
|
||||
this.eleStatisticalSetMapper.insert(eleStatisticalSet);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleStsMapper;
|
||||
import com.njcn.energy.pojo.po.EleEpdPqd;
|
||||
import com.njcn.energy.pojo.po.EleSts;
|
||||
import com.njcn.energy.service.IEleStsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/15 19:06
|
||||
*/
|
||||
@Service
|
||||
public class EleStsServiceImpl extends ServiceImpl<EleStsMapper, EleSts> implements IEleStsService {
|
||||
@Override
|
||||
public boolean addSts(EleSts eleSts) {
|
||||
return this.save(eleSts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateSts(EleSts eleSts) {
|
||||
return this.updateById(eleSts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EleSts findByName(String name) {
|
||||
return this.lambdaQuery().eq(EleSts::getName,name).one();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.EleTopicMapper;
|
||||
import com.njcn.energy.pojo.po.EleTopic;
|
||||
import com.njcn.energy.service.IEleTopicService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/22 19:04
|
||||
*/
|
||||
@Service
|
||||
public class EleTopicServiceImpl extends ServiceImpl<EleTopicMapper, EleTopic> implements IEleTopicService {
|
||||
|
||||
@Override
|
||||
public boolean addTopic(EleTopic eleTopic) {
|
||||
return this.save(eleTopic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EleTopic> list(String id) {
|
||||
return this.lambdaQuery().eq(EleTopic::getNdid,id).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(String id) {
|
||||
QueryWrapper<EleTopic> topicQueryWrapper = new QueryWrapper<>();
|
||||
topicQueryWrapper.eq("NDID",id);
|
||||
return this.remove(topicQueryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.GroupArrayMapper;
|
||||
import com.njcn.energy.pojo.po.GroupArray;
|
||||
import com.njcn.energy.service.IGroupArrayService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/16 13:27
|
||||
*/
|
||||
@Service
|
||||
public class GroupArrayServiceImpl extends ServiceImpl<GroupArrayMapper, GroupArray> implements IGroupArrayService {
|
||||
|
||||
@Override
|
||||
public void groupArrayRelation(String groupId, String arrId) {
|
||||
GroupArray groupArray = this.lambdaQuery().eq(GroupArray::getGroupId,groupId).eq(GroupArray::getArrId,arrId).one();
|
||||
if (Objects.isNull(groupArray)){
|
||||
GroupArray pojo = new GroupArray();
|
||||
pojo.setGroupId(groupId);
|
||||
pojo.setArrId(arrId);
|
||||
this.save(pojo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean batchAdd(List<GroupArray> list){
|
||||
return this.saveBatch(list);
|
||||
}
|
||||
@Override
|
||||
public boolean deleteGroupArray(List<String> list) {
|
||||
QueryWrapper<GroupArray> groupArrayQueryWrapper = new QueryWrapper<>();
|
||||
groupArrayQueryWrapper.in("Group_Id",list);
|
||||
return this.remove(groupArrayQueryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.energy.mapper.HardwareMapper;
|
||||
import com.njcn.energy.pojo.param.HardwareParam;
|
||||
import com.njcn.energy.pojo.po.Hardware;
|
||||
import com.njcn.energy.service.IHardwareService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/8 10:53
|
||||
*/
|
||||
@Service
|
||||
public class HardwareServiceImpl extends ServiceImpl<HardwareMapper, Hardware> implements IHardwareService {
|
||||
|
||||
@Override
|
||||
public Hardware addHardware(HardwareParam hardwareParam) {
|
||||
Hardware hardware = new Hardware();
|
||||
BeanUtils.copyProperties(hardwareParam, hardware);
|
||||
this.save(hardware);
|
||||
return hardware;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteHardware(List<String> list) {
|
||||
QueryWrapper<Hardware> hardwareQueryWrapper = new QueryWrapper<>();
|
||||
hardwareQueryWrapper.in("Id",list);
|
||||
return this.remove(hardwareQueryWrapper);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,122 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.energy.mapper.LogicAccessMapper;
|
||||
import com.njcn.energy.pojo.constant.ModelState;
|
||||
import com.njcn.energy.pojo.po.LogicAccess;
|
||||
import com.njcn.energy.service.ILogicAccessService;
|
||||
import com.njcn.energy.service.INetDevService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/23 21:56
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class LogicAccessServiceImpl extends ServiceImpl<LogicAccessMapper, LogicAccess> implements ILogicAccessService {
|
||||
|
||||
private final INetDevService netDevService;
|
||||
|
||||
@Override
|
||||
public List<LogicAccess> findAccessDev(List<String> did) {
|
||||
return this.lambdaQuery().in(LogicAccess::getDid,did).ne(LogicAccess::getState, DataStateEnum.DELETED.getCode()).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(LogicAccess logicAccess) {
|
||||
return this.save(logicAccess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LogicAccess getAccessDev(String did) {
|
||||
List<Integer> list = Stream.of(1,2).collect(Collectors.toList());
|
||||
return this.lambdaQuery().eq(LogicAccess::getDid,did).in(LogicAccess::getState,list).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByDid(List<String> list) {
|
||||
this.lambdaUpdate()
|
||||
.set(LogicAccess::getState, ModelState.UNREGISTER)
|
||||
.in(LogicAccess::getDid, list)
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void offlineByDid(List<String> list) {
|
||||
this.lambdaUpdate()
|
||||
.set(LogicAccess::getState, ModelState.REGISTER)
|
||||
.in(LogicAccess::getDid, list)
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LogicAccess findCancelAccessDev(String did) {
|
||||
return this.lambdaQuery().eq(LogicAccess::getDid,did).eq(LogicAccess::getState,DataStateEnum.DELETED.getCode()).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accessCancelDev(String did) {
|
||||
this.lambdaUpdate()
|
||||
.set(LogicAccess::getState, DataStateEnum.ENABLE.getCode())
|
||||
.eq(LogicAccess::getDid, did)
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accessDev(LogicAccess logicAccess) {
|
||||
this.updateById(logicAccess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogicAccess> getLogicAccess(String ndid, List<String> list) {
|
||||
String pid = netDevService.findByNdid(ndid).getId();
|
||||
return this.lambdaQuery().in(LogicAccess::getDid,list).eq(LogicAccess::getState,ModelState.ACCESS).eq(LogicAccess::getPid,pid).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogicAccess> getAllOnlineDevice(String ndid) {
|
||||
String pid = netDevService.findByNdid(ndid).getId();
|
||||
return this.lambdaQuery().eq(LogicAccess::getState,ModelState.ACCESS).eq(LogicAccess::getPid,pid).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogicAccess> getAllOfflineDevice(String ndid) {
|
||||
String pid = netDevService.findByNdid(ndid).getId();
|
||||
return this.lambdaQuery().eq(LogicAccess::getState,ModelState.REGISTER).eq(LogicAccess::getPid,pid).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void offAllDevice(String ndid) {
|
||||
String pid = netDevService.findByNdid(ndid).getId();
|
||||
this.lambdaUpdate()
|
||||
.set(LogicAccess::getState, ModelState.REGISTER)
|
||||
.eq(LogicAccess::getState, ModelState.ACCESS)
|
||||
.eq(LogicAccess::getPid, pid)
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogicAccess> getOnlineByList(List<String> list) {
|
||||
return this.lambdaQuery().in(LogicAccess::getDid,list).eq(LogicAccess::getState,ModelState.ACCESS).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogicAccess> getLogicDevByList(List<String> list) {
|
||||
return this.lambdaQuery().in(LogicAccess::getPid,list).and(item->{item.eq(LogicAccess::getState,ModelState.REGISTER).or().eq(LogicAccess::getState,ModelState.ACCESS);}).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogicAccess> getAllDev() {
|
||||
return this.lambdaQuery().eq(LogicAccess::getState,ModelState.ACCESS).or().eq(LogicAccess::getState,ModelState.REGISTER).list();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,680 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.energy.mapper.*;
|
||||
import com.njcn.energy.pojo.constant.TableName;
|
||||
import com.njcn.energy.pojo.dto.NetAndDevByLineDTO;
|
||||
import com.njcn.energy.pojo.enums.EnergyResponseEnum;
|
||||
import com.njcn.energy.pojo.param.DataHisParam;
|
||||
import com.njcn.energy.pojo.param.DevCfgParam;
|
||||
import com.njcn.energy.pojo.param.EnergyBaseParam;
|
||||
import com.njcn.energy.pojo.param.GroupArrParam;
|
||||
import com.njcn.energy.pojo.po.*;
|
||||
import com.njcn.energy.pojo.vo.*;
|
||||
import com.njcn.energy.service.*;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/2/24
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class LogicDeviceLineServiceImpl extends ServiceImpl<LogicDeviceLineMapper, LogicDev> implements ILogicDeviceLineService {
|
||||
|
||||
private final LogicDeviceLineMapper logicDeviceLineMapper;
|
||||
|
||||
private final DataSetMapper dataSetMapper;
|
||||
|
||||
private final NetDevMapper netDevMapper;
|
||||
|
||||
private final DataGroupMapper dataGroupMapper;
|
||||
|
||||
private final DataArrayMapper dataArrayMapper;
|
||||
|
||||
private final GroupArrayMapper groupArrMapper;
|
||||
|
||||
private final IDataGroupService iDataGroupService;
|
||||
|
||||
private final IGroupArrayService iGroupArrayService;
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
@Override
|
||||
public List<EnergyDeviceTreeVO> getEnergyTree() {
|
||||
List<EnergyDeviceTreeVO> netDevList = netDevMapper.getNetDevList();
|
||||
List<EnergyDeviceTreeVO> logicDevList = logicDeviceLineMapper.getLogicDevList();
|
||||
List<EnergyDeviceTreeVO> elLineList = logicDeviceLineMapper.getEleLineList();
|
||||
if (CollectionUtil.isEmpty(logicDevList) || CollectionUtil.isEmpty(elLineList) || CollectionUtil.isEmpty(netDevList)) {
|
||||
throw new BusinessException(EnergyResponseEnum.DEV_LINE_EMPTY);
|
||||
}
|
||||
List<EnergyDeviceTreeVO> logicAllDevList = logicDevList.stream().peek(item -> item.setChildren(getChildren(item, elLineList))).collect(Collectors.toList());
|
||||
return netDevList.stream().peek(item -> item.setChildren(getChildren(item, logicAllDevList))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EnergyDeviceTreeVO> getAirLineTree(){
|
||||
List<EnergyDeviceTreeVO> netDevList = netDevMapper.getNetDevList();
|
||||
netDevList = netDevList.stream().filter(item-> item.getName().contains("空调")).collect(Collectors.toList());
|
||||
List<EnergyDeviceTreeVO> logicDevList = logicDeviceLineMapper.getLogicDevList();
|
||||
List<EnergyDeviceTreeVO> elLineList = logicDeviceLineMapper.getEleLineList();
|
||||
if (CollectionUtil.isEmpty(logicDevList) || CollectionUtil.isEmpty(elLineList) || CollectionUtil.isEmpty(netDevList)) {
|
||||
throw new BusinessException(EnergyResponseEnum.DEV_LINE_EMPTY);
|
||||
}
|
||||
List<EnergyDeviceTreeVO> logicAllDevList = logicDevList.stream().peek(item -> item.setChildren(getChildren(item, elLineList))).collect(Collectors.toList());
|
||||
|
||||
return netDevList.stream().peek(item -> item.setChildren(getChildren(item, logicAllDevList))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EleLoadSetTreeVO getEnergyLoadTree(String id) {
|
||||
EleLoadSetTreeVO eleLoadSetTreeVO = new EleLoadSetTreeVO();
|
||||
List<EnergyDeviceTreeVO> netDevList = netDevMapper.getNetDevList();
|
||||
netDevList = netDevList.stream().filter(item -> item.getName().indexOf("空调") == -1).collect(Collectors.toList());
|
||||
List<EnergyDeviceTreeVO> logicDevList = logicDeviceLineMapper.getLogicDevList();
|
||||
List<EnergyDeviceTreeVO> netNoDevList = netDevMapper.getNetDevList();
|
||||
netNoDevList = netNoDevList.stream().filter(item -> item.getName().indexOf("空调") == -1).collect(Collectors.toList());
|
||||
List<EnergyDeviceTreeVO> logicNoDevList = logicDeviceLineMapper.getLogicDevList();
|
||||
List<EnergyDeviceTreeVO> elBindsLineList = logicDeviceLineMapper.getEleBindsLineList(id);
|
||||
List<EnergyDeviceTreeVO> elNoBindsLineList = logicDeviceLineMapper.getEleNoBindsLineList();
|
||||
List<EnergyDeviceTreeVO> energyNoBindsDeviceTreeVOList = new ArrayList<>();
|
||||
List<EnergyDeviceTreeVO> energyBindsDeviceTreeVOList = new ArrayList<>();
|
||||
List<EnergyDeviceTreeVO> energyNetTreeVOList = new ArrayList<>();
|
||||
List<EnergyDeviceTreeVO> energyNetNoTreeVOList = new ArrayList<>();
|
||||
if (!CollectionUtil.isEmpty(elBindsLineList)) {
|
||||
List<EnergyDeviceTreeVO> logicBindsDevList = logicDevList.stream().peek(item -> item.setChildren(getChildren(item, elBindsLineList))).collect(Collectors.toList());
|
||||
List<EnergyDeviceTreeVO> energyDeviceTreeVOList = logicBindsDevList.stream().filter(item -> item.getChildren().size() != 0).collect(Collectors.toList());
|
||||
energyBindsDeviceTreeVOList = netDevList.stream().peek(item -> item.setChildren(getChildren(item, energyDeviceTreeVOList))).collect(Collectors.toList());
|
||||
energyNetTreeVOList = energyBindsDeviceTreeVOList.stream().filter(item -> item.getChildren().size() != 0).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
if (!CollectionUtil.isEmpty(elNoBindsLineList)) {
|
||||
List<EnergyDeviceTreeVO> logicNoBindsDevList = logicNoDevList.stream().peek(item -> item.setChildren(getChildren(item, elNoBindsLineList))).collect(Collectors.toList());
|
||||
List<EnergyDeviceTreeVO> energyDeviceNoTreeVOList = logicNoBindsDevList.stream().filter(item -> item.getChildren().size() != 0).collect(Collectors.toList());
|
||||
energyNoBindsDeviceTreeVOList = netNoDevList.stream().peek(item -> item.setChildren(getChildren(item, energyDeviceNoTreeVOList))).collect(Collectors.toList());
|
||||
energyNetNoTreeVOList = energyNoBindsDeviceTreeVOList.stream().filter(item -> item.getChildren().size() != 0).collect(Collectors.toList());
|
||||
}
|
||||
eleLoadSetTreeVO.setBinds(energyNetTreeVOList);
|
||||
eleLoadSetTreeVO.setNoBinds(energyNetNoTreeVOList);
|
||||
return eleLoadSetTreeVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LogicDeviceLineInfoVO getEnergyDevInfoById(String id) {
|
||||
return logicDeviceLineMapper.getDevInfo(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IPage<EnergyTemplateVO> getEnergyTemplateById(String id, Integer pageNum, Integer pageSize) {
|
||||
List<EnergyTemplateVO> listRes = new ArrayList<>();
|
||||
IPage<DataArray> page = new Page<>(pageNum, pageSize);
|
||||
LambdaQueryWrapper<DataArray> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(DataArray::getPid, id);
|
||||
lambdaQueryWrapper.orderByAsc(DataArray::getSort);
|
||||
IPage<DataArray> pageRes = dataArrayMapper.selectPage(page, lambdaQueryWrapper);
|
||||
if (pageRes.getTotal() > 0) {
|
||||
List<DataArray> arrRes = pageRes.getRecords();
|
||||
if (CollectionUtil.isNotEmpty(arrRes)) {
|
||||
Map<String, List<DataArray>> classMap = new HashMap<>();
|
||||
arrRes.stream().collect(Collectors.groupingBy(DataArray::getClassName, Collectors.toList()))
|
||||
.forEach(classMap::put);
|
||||
classMap.forEach((className, dataArrList) -> {
|
||||
|
||||
List<String> arrIds = dataArrList.stream().map(DataArray::getId).collect(Collectors.toList());
|
||||
List<EnergyTemplateVO> listData = logicDeviceLineMapper.getDataList(className, arrIds);
|
||||
if (CollectionUtil.isNotEmpty(listData)) {
|
||||
listRes.addAll(listData);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
List<EnergyTemplateVO> listResEs = listRes.stream().sorted(Comparator.comparing(EnergyTemplateVO::getSort)).collect(Collectors.toList());
|
||||
IPage<EnergyTemplateVO> pageTurn = new Page<>(pageNum, pageSize);
|
||||
pageTurn.setRecords(listResEs);
|
||||
pageTurn.setTotal(pageRes.getTotal());
|
||||
pageTurn.setSize(pageRes.getSize());
|
||||
pageTurn.setCurrent(pageRes.getCurrent());
|
||||
pageTurn.setPages(pageRes.getPages());
|
||||
return pageTurn;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IPage<DataGroupTemplateVO> getRealGroupTemplateById(String id, Integer pageNum, Integer pageSize) {
|
||||
IPage<DataGroupTemplateVO> page = new Page<>(pageNum, pageSize);
|
||||
IPage<DataGroupTemplateVO> pageTurn = new Page<>();
|
||||
IPage<DataGroupTemplateVO> pageRes = dataGroupMapper.getGroupDataList(page, id);
|
||||
if (pageRes.getTotal() > 0) {
|
||||
//查询到分组
|
||||
List<EnergyTemplateVO> listDataAll = new ArrayList<>();
|
||||
List<DataGroupTemplateVO> groupList = pageRes.getRecords();
|
||||
//获取数据集下所有数据项
|
||||
List<DataArray> voList = logicDeviceLineMapper.getGroupDataBySetId(id);
|
||||
if (CollectionUtil.isNotEmpty(voList)) {
|
||||
Map<String, List<DataArray>> classMap = new HashMap<>();
|
||||
voList.stream().collect(Collectors.groupingBy(DataArray::getClassName, Collectors.toList()))
|
||||
.forEach(classMap::put);
|
||||
classMap.forEach((className, dataArrList) -> {
|
||||
List<String> arrIds = dataArrList.stream().map(DataArray::getId).collect(Collectors.toList());
|
||||
|
||||
List<EnergyTemplateVO> listData = logicDeviceLineMapper.getDataList(className, arrIds);
|
||||
if (CollectionUtil.isNotEmpty(listData)) {
|
||||
for (EnergyTemplateVO energyTemplateVO : listData) {
|
||||
|
||||
for (DataArray dataArray : dataArrList) {
|
||||
if (energyTemplateVO.getId().equals(dataArray.getDataId())) {
|
||||
energyTemplateVO.setPid(dataArray.getPid());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
listDataAll.addAll(listData);
|
||||
}
|
||||
|
||||
});
|
||||
List<EnergyTemplateVO> listDataAllRes = listDataAll.stream().sorted(Comparator.comparing(EnergyTemplateVO::getSort)).collect(Collectors.toList());
|
||||
|
||||
List<DataGroupTemplateVO> grList = groupList.stream().peek((item) -> item.setChildren(getChildrenes(item.getId(), listDataAllRes))).collect(Collectors.toList());
|
||||
pageTurn.setRecords(grList);
|
||||
pageTurn.setTotal(pageRes.getTotal());
|
||||
pageTurn.setSize(pageRes.getSize());
|
||||
pageTurn.setCurrent(pageRes.getCurrent());
|
||||
pageTurn.setPages(pageRes.getPages());
|
||||
return pageTurn;
|
||||
} else {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||
}
|
||||
} else {
|
||||
pageTurn.setRecords(new ArrayList<>());
|
||||
pageTurn.setTotal(pageRes.getTotal());
|
||||
pageTurn.setSize(pageRes.getSize());
|
||||
pageTurn.setCurrent(pageRes.getCurrent());
|
||||
pageTurn.setPages(pageRes.getPages());
|
||||
return pageTurn;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IPage<DataGroupTemplateVO> getHistoryTemplateById(EnergyBaseParam energyBaseParam) {
|
||||
LocalDateTime localDateTime = PubUtils.endTimeToLocalDateTime(energyBaseParam.getEndTime());
|
||||
String endTime = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
IPage<DataGroupTemplateVO> page = new Page<>(energyBaseParam.getPageNum(), energyBaseParam.getPageSize());
|
||||
IPage<DataGroupTemplateVO> pageTurn = new Page<>();
|
||||
IPage<DataGroupTemplateVO> pageRes = dataGroupMapper.getGroupDataList(page, energyBaseParam.getId());
|
||||
|
||||
if (pageRes.getTotal() != 0) {
|
||||
//查询到分组
|
||||
List<EnergyTemplateVO> listDataAll = new ArrayList<>();
|
||||
List<DataGroupTemplateVO> groupList = pageRes.getRecords();
|
||||
//获取数据集下所有数据项
|
||||
List<DataArray> voList = logicDeviceLineMapper.getGroupDataBySetId(energyBaseParam.getId());
|
||||
if (CollectionUtil.isNotEmpty(voList)) {
|
||||
Map<String, List<DataArray>> classMap = new HashMap<>();
|
||||
voList.stream().collect(Collectors.groupingBy(DataArray::getClassName, Collectors.toList()))
|
||||
.forEach(classMap::put);
|
||||
classMap.forEach((className, dataArrList) -> {
|
||||
List<String> arrIds = dataArrList.stream().map(DataArray::getId).collect(Collectors.toList());
|
||||
List<EnergyTemplateVO> listData = logicDeviceLineMapper.getDataList(className, arrIds);
|
||||
String tableName = listData.get(0).getClassId();
|
||||
if (CollectionUtil.isNotEmpty(listData)) {
|
||||
for (EnergyTemplateVO energyTemplateVO : listData) {
|
||||
for (DataArray dataArray : dataArrList) {
|
||||
if (energyTemplateVO.getId().equals(dataArray.getDataId())) {
|
||||
energyTemplateVO.setPid(dataArray.getPid());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (listData.size() > 0) {
|
||||
|
||||
|
||||
Map<String, List<EnergyTemplateVO>> classTemMap = new HashMap<>();
|
||||
|
||||
listData.stream().collect(Collectors.groupingBy(EnergyTemplateVO::getPhase, Collectors.toList())).forEach(classTemMap::put);
|
||||
classTemMap.forEach((tmpPhase, enList) -> {
|
||||
StringBuilder stringBuilderMax = new StringBuilder("select ");
|
||||
StringBuilder stringBuilderMin = new StringBuilder("select ");
|
||||
|
||||
StringBuilder condition = new StringBuilder();
|
||||
for (int j = 0; j < enList.size(); j++) {
|
||||
if (j == enList.size() - 1) {
|
||||
stringBuilderMax.append("MAX(").append(enList.get(j).getName()).append(") as ").append(enList.get(j).getName()).append(" ");
|
||||
stringBuilderMin.append("MIN(").append(enList.get(j).getName()).append(") as ").append(enList.get(j).getName()).append(" ");
|
||||
} else {
|
||||
stringBuilderMax.append("MAX(").append(enList.get(j).getName()).append(") as ").append(enList.get(j).getName()).append(", ");
|
||||
stringBuilderMin.append("MIN(").append(enList.get(j).getName()).append(") as ").append(enList.get(j).getName()).append(", ");
|
||||
}
|
||||
condition.append(" and ").append(enList.get(j).getName()).append("!=-1000000");
|
||||
}
|
||||
String tableStr = "";
|
||||
if (TableName.eleEpdPqd.equals(className)) {
|
||||
tableStr = "_add";
|
||||
}
|
||||
|
||||
stringBuilderMax.append("from ").append(tableName).append(tableStr).append(" where").append(" time").append(">='").append(energyBaseParam.getStartTime()).append("' and time < '" + endTime + "'").append(" and LineId='" + energyBaseParam.getLineId() + "'").append(" and Phase='" + tmpPhase + "'");
|
||||
stringBuilderMin.append("from ").append(tableName).append(tableStr).append(" where").append(" time").append(">='").append(energyBaseParam.getStartTime()).append("' and time < '" + endTime + "'").append(" and LineId='" + energyBaseParam.getLineId() + "'").append(" and Phase='" + tmpPhase + "'").append(condition);
|
||||
QueryResult queryResultMax = influxDbUtils.query(stringBuilderMax.toString());
|
||||
QueryResult queryResultMin = influxDbUtils.query(stringBuilderMin.toString());
|
||||
if (CollectionUtil.isNotEmpty(queryResultMax.getResults().get(0).getSeries()) && CollectionUtil.isNotEmpty(queryResultMin.getResults().get(0).getSeries())) {
|
||||
for (int j = 0; j < enList.size(); j++) {
|
||||
enList.get(j).setMaxValue(queryResultMax.getResults().get(0).getSeries().get(0).getValues().get(0).get(j + 1));
|
||||
enList.get(j).setMinValue(queryResultMin.getResults().get(0).getSeries().get(0).getValues().get(0).get(j + 1));
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException(EnergyResponseEnum.ENERGY_EMPTY);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
listDataAll.addAll(listData);
|
||||
}
|
||||
|
||||
});
|
||||
List<DataGroupTemplateVO> grList = groupList.stream().peek((item) -> {
|
||||
item.setChildren(getChildrenes(item.getId(), listDataAll));
|
||||
}).collect(Collectors.toList());
|
||||
pageTurn.setRecords(grList);
|
||||
pageTurn.setTotal(pageRes.getTotal());
|
||||
pageTurn.setSize(pageRes.getSize());
|
||||
pageTurn.setCurrent(pageRes.getCurrent());
|
||||
pageTurn.setPages(pageRes.getPages());
|
||||
return pageTurn;
|
||||
} else {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
pageTurn.setRecords(new ArrayList<>());
|
||||
pageTurn.setTotal(pageRes.getTotal());
|
||||
pageTurn.setSize(pageRes.getSize());
|
||||
pageTurn.setCurrent(pageRes.getCurrent());
|
||||
pageTurn.setPages(pageRes.getPages());
|
||||
return pageTurn;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<DataGroupTemplateVO> getStatisTemplateById(String id, Integer pageNum, Integer pageSize, String lineId) {
|
||||
IPage<DataGroupTemplateVO> pageTurn = new Page<>(); //定义新的返回体
|
||||
IPage<DataGroupTemplateVO> page = new Page<>(pageNum, pageSize);
|
||||
IPage<DataGroupTemplateVO> pageRes = dataGroupMapper.getGroupDataList(page, id);
|
||||
if (pageRes.getTotal() != 0) {
|
||||
//查询到分组
|
||||
List<EnergyTemplateVO> listDataAll = new ArrayList<>();
|
||||
List<DataGroupTemplateVO> groupList = pageRes.getRecords();
|
||||
//获取数据集下所有数据项
|
||||
List<DataArray> voList = logicDeviceLineMapper.getGroupDataBySetId(id);
|
||||
if (CollectionUtil.isNotEmpty(voList)) {
|
||||
Map<String, List<DataArray>> classMap = new HashMap<>();
|
||||
voList.stream().collect(Collectors.groupingBy(DataArray::getClassName, Collectors.toList())).forEach(classMap::put);
|
||||
classMap.forEach((className, dataArrList) -> {
|
||||
List<String> arrIds = dataArrList.stream().map(DataArray::getId).collect(Collectors.toList());
|
||||
List<EnergyTemplateVO> listData = logicDeviceLineMapper.getDataList(className, arrIds);
|
||||
String tableName = listData.get(0).getClassId();
|
||||
if (CollectionUtil.isNotEmpty(listData)) {
|
||||
for (EnergyTemplateVO energyTemplateVO : listData) {
|
||||
for (DataArray dataArray : dataArrList) {
|
||||
if (energyTemplateVO.getId().equals(dataArray.getDataId())) {
|
||||
energyTemplateVO.setPid(dataArray.getPid());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (listData.size() > 0) {
|
||||
if (TableName.eleEpdPqd.equals(className) || TableName.eleMd.equals(className)) {
|
||||
//电能表
|
||||
Map<String, List<EnergyTemplateVO>> classTemMap = new HashMap<>();
|
||||
|
||||
listData.stream().collect(Collectors.groupingBy(EnergyTemplateVO::getPhase, Collectors.toList())).forEach(classTemMap::put);
|
||||
classTemMap.forEach((tmpPhase, enList) -> {
|
||||
StringBuilder stringBuilderMax = new StringBuilder("select ");
|
||||
|
||||
for (int j = 0; j < enList.size(); j++) {
|
||||
if (j == enList.size() - 1) {
|
||||
stringBuilderMax.append(enList.get(j).getName()).append(" ");
|
||||
} else {
|
||||
stringBuilderMax.append(enList.get(j).getName()).append(", ");
|
||||
}
|
||||
}
|
||||
if (tableName.equals(TableName.powerData)) {
|
||||
stringBuilderMax.append("from ").append(tableName).append("_add_Real").append(" where").append(" LineId='").append(lineId).append("'").append(" and Phase='" + tmpPhase + "'").append(" order by time");
|
||||
} else {
|
||||
stringBuilderMax.append("from ").append(tableName).append("_Real").append(" where").append(" LineId='").append(lineId).append("'").append(" and Phase='" + tmpPhase + "'").append(" order by time");
|
||||
}
|
||||
List<Map<String, Object>> list = influxDbUtils.getResult(stringBuilderMax.toString(), "");
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
for(int i=0;i<list.size();i++){
|
||||
Map<String, Object> mapRes = new HashMap<>();
|
||||
list.get(i).forEach((key, value) -> {
|
||||
if(Objects.nonNull(value)){
|
||||
mapRes.put(key,value);
|
||||
}
|
||||
});
|
||||
|
||||
for (int j = 0; j < enList.size(); j++) {
|
||||
if(mapRes.containsKey(enList.get(j).getName())) {
|
||||
|
||||
enList.get(j).setTime(mapRes.get("time").toString());
|
||||
enList.get(j).setDataValue(mapRes.get(enList.get(j).getName()).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
} else if (TableName.eleCtrl.equals(className) || TableName.eleSts.equals(className)) {
|
||||
//展示空调数据
|
||||
StringBuilder stringBuilderMax = new StringBuilder("select ");
|
||||
|
||||
for (int j = 0; j < listData.size(); j++) {
|
||||
if (j == listData.size() - 1) {
|
||||
stringBuilderMax.append(listData.get(j).getName()).append(" ");
|
||||
} else {
|
||||
stringBuilderMax.append(listData.get(j).getName()).append(", ");
|
||||
}
|
||||
}
|
||||
stringBuilderMax.append("from ").append(tableName + "_Real").append(" where").append(" LineId='" + lineId + "'").append(" order by time");
|
||||
List<Map<String, Object>> list = influxDbUtils.getResult(stringBuilderMax.toString(), "");
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
for(int i=0;i<list.size();i++){
|
||||
Map<String, Object> mapRes = new HashMap<>();
|
||||
list.get(i).forEach((key, value) -> {
|
||||
if(Objects.nonNull(value)){
|
||||
mapRes.put(key,value);
|
||||
}
|
||||
});
|
||||
|
||||
for (int j = 0; j < listData.size(); j++) {
|
||||
if(mapRes.containsKey(listData.get(j).getName())) {
|
||||
|
||||
listData.get(j).setTime(mapRes.get("time").toString());
|
||||
listData.get(j).setDataValue(mapRes.get(listData.get(j).getName()).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
listDataAll.addAll(listData);
|
||||
}
|
||||
|
||||
});
|
||||
List<DataGroupTemplateVO> grList = groupList.stream().peek((item) -> {
|
||||
item.setChildren(getChildrenes(item.getId(), listDataAll));
|
||||
}).collect(Collectors.toList());
|
||||
pageTurn.setRecords(grList);
|
||||
pageTurn.setTotal(pageRes.getTotal());
|
||||
pageTurn.setSize(pageRes.getSize());
|
||||
pageTurn.setCurrent(pageRes.getCurrent());
|
||||
pageTurn.setPages(pageRes.getPages());
|
||||
return pageTurn;
|
||||
} else {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
pageTurn.setRecords(new ArrayList<>());
|
||||
pageTurn.setTotal(pageRes.getTotal());
|
||||
pageTurn.setSize(pageRes.getSize());
|
||||
pageTurn.setCurrent(pageRes.getCurrent());
|
||||
pageTurn.setPages(pageRes.getPages());
|
||||
return pageTurn;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DataSet> getTabTemplateById(String id) {
|
||||
return logicDeviceLineMapper.getTabTemplateById(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DataGroupTemplateVO> getGroupDetailList(String setId) {
|
||||
List<DataGroupTemplateVO> groupList = dataGroupMapper.getGroupList(setId);
|
||||
if (CollectionUtil.isNotEmpty(groupList)) {
|
||||
List<EnergyTemplateVO> arrList = logicDeviceLineMapper.getAllDataBySet(setId);
|
||||
if (CollectionUtil.isNotEmpty(arrList)) {
|
||||
return groupList.stream().peek((item -> item.setChildren(getChildrenes(item.getId(), arrList)))).collect(Collectors.toList());
|
||||
} else {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean addGroupArr(GroupArrParam groupArrParam) {
|
||||
List<GroupArrParam.ArrItem> list = groupArrParam.getData();
|
||||
List<String> groupIdList = list.stream().map(GroupArrParam.ArrItem::getId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<GroupArray> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(GroupArray::getGroupId, groupIdList);
|
||||
groupArrMapper.delete(lambdaQueryWrapper);
|
||||
|
||||
dataGroupMapper.deleteBatchIds(groupIdList);
|
||||
|
||||
List<DataGroup> listGroup = new ArrayList<>();
|
||||
List<GroupArray> arrList = new ArrayList<>();
|
||||
|
||||
Integer sort = 0;
|
||||
for (GroupArrParam.ArrItem item : list) {
|
||||
if (CollectionUtil.isNotEmpty(item.getChildren())) {
|
||||
DataGroup dataGroup = new DataGroup();
|
||||
dataGroup.setId(IdUtil.simpleUUID());
|
||||
dataGroup.setName(item.getName());
|
||||
dataGroup.setPid(groupArrParam.getSetId());
|
||||
dataGroup.setSort(sort);
|
||||
sort++;
|
||||
|
||||
listGroup.add(dataGroup);
|
||||
|
||||
for (String idItem : item.getChildren()) {
|
||||
GroupArray groupArr = new GroupArray();
|
||||
groupArr.setGroupId(dataGroup.getId());
|
||||
groupArr.setArrId(idItem);
|
||||
arrList.add(groupArr);
|
||||
}
|
||||
}
|
||||
}
|
||||
iDataGroupService.batchAdd(listGroup);
|
||||
iGroupArrayService.batchAdd(arrList);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getParseTemplate(String setId) {
|
||||
return logicDeviceLineMapper.getParseTemplate(setId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public LogicDev add(DevCfgParam devCfgParam) {
|
||||
LogicDev logicDev = new LogicDev();
|
||||
BeanUtil.copyProperties(devCfgParam, logicDev);
|
||||
logicDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
logicDev.setCreateTime(LocalDateTime.now());
|
||||
this.save(logicDev);
|
||||
return logicDev;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LogicDev getLogicDev(String did) {
|
||||
return this.lambdaQuery().eq(LogicDev::getDid, did).eq(LogicDev::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogicDev> getLogicDevByList(List<String> list) {
|
||||
return this.lambdaQuery().in(LogicDev::getPid, list).ne(LogicDev::getType,"ACgw").list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogicDev> getLogicDev(List<String> list) {
|
||||
return this.lambdaQuery().in(LogicDev::getDid, list).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogicDev> getLogicDevByPid(List<String> list) {
|
||||
return this.lambdaQuery().in(LogicDev::getPid, list).eq(LogicDev::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteByVersionId(String id) {
|
||||
QueryWrapper<LogicDev> logicDevQueryWrapper = new QueryWrapper<>();
|
||||
logicDevQueryWrapper.eq("Version_Id", id);
|
||||
return this.remove(logicDevQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogicDev> getLogicDevByVersionId(String id) {
|
||||
return this.lambdaQuery().eq(LogicDev::getVersionId, id).eq(LogicDev::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLogicDeviceLine(LogicDev logicDev) {
|
||||
this.updateById(logicDev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLogicDevice(String oldMouldId, String newMouldId) {
|
||||
this.lambdaUpdate().set(LogicDev::getIdx, newMouldId).eq(LogicDev::getIdx, oldMouldId).update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataHisVO> getHisData(DataHisParam dataHisParam) {
|
||||
|
||||
LocalDateTime startTime = PubUtils.beginTimeToLocalDateTime(dataHisParam.getStartTime());
|
||||
String start = startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
LocalDateTime endTime = PubUtils.endTimeToLocalDateTime(dataHisParam.getEndTime());
|
||||
String end = endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
|
||||
List<String> arrList = dataHisParam.getArrName();
|
||||
List<DataHisVO> listRes = new ArrayList<>();
|
||||
|
||||
LambdaQueryWrapper<DataArray> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(DataArray::getDataId, arrList);
|
||||
lambdaQueryWrapper.orderByAsc(true,DataArray::getIdx);
|
||||
List<DataArray> list = dataArrayMapper.selectList(lambdaQueryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
String table;
|
||||
if(list.get(0).getClassName().equals(TableName.eleMd)){
|
||||
table = list.get(0).getClassId();
|
||||
}else{
|
||||
table = list.get(0).getClassId()+"_add";
|
||||
}
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder("select ");
|
||||
stringBuilder.append(list.get(i).getName());
|
||||
stringBuilder.append(" from ").append(table).append(" where ").append("LineId='").append(dataHisParam.getLineId()).append("'");
|
||||
String ph = "";
|
||||
if (!"M".equals(list.get(i).getPhase())) {
|
||||
//有相别
|
||||
ph = list.get(i).getPhase();
|
||||
stringBuilder.append("and Phase = '").append(list.get(i).getPhase()).append("'");
|
||||
}
|
||||
stringBuilder.append(" and time>'").append(start).append("'").append(" and time < '").append(end).append("'").append(" ORDER BY time");
|
||||
List<Map<String, Object>> listMap = influxDbUtils.getResult(stringBuilder.toString(),"");
|
||||
|
||||
if (CollectionUtil.isNotEmpty(listMap)) {
|
||||
DataHisVO dataHisVO = new DataHisVO();
|
||||
dataHisVO.setName(list.get(i).getName());
|
||||
dataHisVO.setAnotherName(ph + list.get(i).getAnotherName());
|
||||
|
||||
List<List<String>> temX = new ArrayList<>();
|
||||
|
||||
for(Map<String, Object> map :listMap){
|
||||
if(map.get(list.get(i).getName()).toString().equals("-1000000.0")){
|
||||
continue;
|
||||
}
|
||||
List<String> tem = new ArrayList<>();
|
||||
tem.add(map.get("time").toString());
|
||||
tem.add(map.get(list.get(i).getName()).toString());
|
||||
|
||||
temX.add(tem);
|
||||
}
|
||||
dataHisVO.setValue(temX);
|
||||
listRes.add(dataHisVO);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return listRes;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<NetAndDevByLineDTO> getNetAndDevByLineIds(List<String> lineIds){
|
||||
return logicDeviceLineMapper.getNetAndDevByLineIds(lineIds);
|
||||
}
|
||||
|
||||
private List<EnergyDeviceTreeVO> getChildren(EnergyDeviceTreeVO energyDeviceTreeVO, List<EnergyDeviceTreeVO> all) {
|
||||
return all.stream().filter(item -> item.getPid().equals(energyDeviceTreeVO.getId())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<EnergyTemplateVO> getChildrenes(String tabId, List<EnergyTemplateVO> all) {
|
||||
return all.stream().filter(item -> item.getPid().equals(tabId)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拼接监测点
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,144 @@
|
||||
package com.njcn.energy.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.db.constant.DbConstant;
|
||||
import com.njcn.energy.mapper.NetDevMapper;
|
||||
import com.njcn.energy.pojo.constant.ModelState;
|
||||
import com.njcn.energy.pojo.enums.EnergyResponseEnum;
|
||||
import com.njcn.energy.pojo.param.NetDevParam;
|
||||
import com.njcn.energy.pojo.po.NetDev;
|
||||
import com.njcn.energy.pojo.vo.NetDevInfoVO;
|
||||
import com.njcn.energy.service.INetDevService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
* @since 2022-02-22
|
||||
*/
|
||||
@Service
|
||||
public class NetDevServiceImpl extends ServiceImpl<NetDevMapper, NetDev> implements INetDevService {
|
||||
|
||||
|
||||
@Override
|
||||
public Page<NetDev> listNetDev(NetDevParam.NetDevQueryParam queryParam) {
|
||||
QueryWrapper<NetDev> queryWrapper = new QueryWrapper<>();
|
||||
if(Objects.nonNull(queryParam)){
|
||||
//查询参数不为空,进行条件填充
|
||||
if(StrUtil.isNotBlank(queryParam.getSearchValue())){
|
||||
//字典类型表,仅提供名称、编码模糊查询
|
||||
queryWrapper
|
||||
.and(param -> param.like("ele_net_dev.name",queryParam.getSearchValue())
|
||||
.or().like("ele_net_dev.ndid",queryParam.getSearchValue()));
|
||||
}
|
||||
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
}else{
|
||||
//没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序
|
||||
queryWrapper.orderBy(true, true, "ele_net_dev.sort");
|
||||
}
|
||||
|
||||
}
|
||||
queryWrapper.eq("ele_net_dev.state", DataStateEnum.ENABLE.getCode());
|
||||
return this.baseMapper.selectPage(new Page<>(PageFactory.getPageNum(queryParam),PageFactory.getPageSize(queryParam)),queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addNetDev(NetDevParam netDevParam) {
|
||||
checkDicTypeName(netDevParam,false);
|
||||
NetDev netDev = new NetDev();
|
||||
BeanUtils.copyProperties(netDevParam, netDev);
|
||||
netDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
netDev.setCreateBy(RequestUtil.getUserIndex());
|
||||
return this.save(netDev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateNetDev(NetDevParam.NetDevUpdateParam updateParam) {
|
||||
checkDicTypeName(updateParam,true);
|
||||
NetDev netDev = new NetDev();
|
||||
BeanUtils.copyProperties(updateParam, netDev);
|
||||
netDev.setUpdateBy(RequestUtil.getUserIndex());
|
||||
return this.updateById(netDev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteNetDev(List<String> ids) {
|
||||
return this.lambdaUpdate()
|
||||
.set(NetDev::getState, DataStateEnum.DELETED.getCode())
|
||||
.in(NetDev::getId,ids)
|
||||
.update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public NetDev findByNdid(String ndid) {
|
||||
return this.lambdaQuery().eq(NetDev::getNdid,ndid).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetDevInfoVO getNetDevInfo(String id){
|
||||
return this.baseMapper.getNetDevDetail(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void offlineNetDev(String netDev) {
|
||||
this.lambdaUpdate()
|
||||
.set(NetDev::getComFlag, ModelState.UNREGISTER)
|
||||
.eq(NetDev::getId,netDev)
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onlineNetDev(String netDev) {
|
||||
this.lambdaUpdate()
|
||||
.set(NetDev::getComFlag, DataStateEnum.ENABLE.getCode())
|
||||
.eq(NetDev::getId,netDev)
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetDev> getAllNetDev() {
|
||||
return this.lambdaQuery().eq(NetDev::getState,DataStateEnum.ENABLE.getCode()).list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验参数,检查是否存在相同名称的字典类型
|
||||
*/
|
||||
private void checkDicTypeName(NetDevParam netDevParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<NetDev> netDevLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
netDevLambdaQueryWrapper
|
||||
.eq(NetDev::getName,netDevParam.getName())
|
||||
.eq(NetDev::getState,DataStateEnum.ENABLE.getCode());
|
||||
//更新的时候,需排除当前记录
|
||||
if(isExcludeSelf){
|
||||
if(netDevParam instanceof NetDevParam.NetDevUpdateParam){
|
||||
netDevLambdaQueryWrapper.ne(NetDev::getId,((NetDevParam.NetDevUpdateParam) netDevParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(netDevLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(EnergyResponseEnum.NET_DEV_NAME_REPEAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user