@@ -18,6 +18,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl ;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl ;
import com.njcn.advance.enums.AdvanceResponseEnum ;
import com.njcn.advance.enums.AdvanceResponseEnum ;
import com.njcn.advance.mapper.responsibility.RespDataMapper ;
import com.njcn.advance.mapper.responsibility.RespDataMapper ;
import com.njcn.advance.model.responsibility.CacheQvvrData ;
import com.njcn.advance.model.responsibility.HKDataStruct ;
import com.njcn.advance.model.responsibility.PDataStruct ;
import com.njcn.advance.model.responsibility.QvvrStruct ;
import com.njcn.advance.pojo.bo.responsibility.* ;
import com.njcn.advance.pojo.bo.responsibility.* ;
import com.njcn.advance.pojo.dto.responsibility.CustomerData ;
import com.njcn.advance.pojo.dto.responsibility.CustomerData ;
import com.njcn.advance.pojo.dto.responsibility.CustomerResponsibility ;
import com.njcn.advance.pojo.dto.responsibility.CustomerResponsibility ;
@@ -31,12 +35,9 @@ import com.njcn.advance.pojo.po.responsibility.RespUserData;
import com.njcn.advance.service.responsibility.IRespDataResultService ;
import com.njcn.advance.service.responsibility.IRespDataResultService ;
import com.njcn.advance.service.responsibility.IRespDataService ;
import com.njcn.advance.service.responsibility.IRespDataService ;
import com.njcn.advance.service.responsibility.IRespUserDataService ;
import com.njcn.advance.service.responsibility.IRespUserDataService ;
import com.njcn.advance.utils.JnaCallBalance ;
import com.njcn.advance.utils.JnaCallDllOrSo ;
import com.njcn.advance.utils.ResponsibilityCallDllOrSo ;
import com.njcn.advance.utils.ResponsibilityCallDllOrSo ;
import com.njcn.common.pojo.enums.common.DataStateEnum ;
import com.njcn.common.pojo.enums.common.DataStateEnum ;
import com.njcn.common.pojo.exception.BusinessException ;
import com.njcn.common.pojo.exception.BusinessException ;
import com.njcn.common.pojo.response.HttpResult ;
import com.njcn.common.utils.FileUtil ;
import com.njcn.common.utils.FileUtil ;
import com.njcn.common.utils.PubUtils ;
import com.njcn.common.utils.PubUtils ;
import com.njcn.db.constant.DbConstant ;
import com.njcn.db.constant.DbConstant ;
@@ -49,13 +50,10 @@ import com.njcn.harmonic.pojo.param.HistoryHarmParam;
import com.njcn.influx.pojo.dto.HarmData ;
import com.njcn.influx.pojo.dto.HarmData ;
import com.njcn.influx.pojo.dto.HarmHistoryDataDTO ;
import com.njcn.influx.pojo.dto.HarmHistoryDataDTO ;
import com.njcn.oss.constant.OssPath ;
import com.njcn.oss.constant.OssPath ;
import com.njcn.oss.enums.OssResponseEnum ;
import com.njcn.oss.utils.FileStorageUtil ;
import com.njcn.oss.utils.FileStorageUtil ;
import com.njcn.system.pojo.vo.DictDataVO ;
import com.njcn.web.factory.PageFactory ;
import com.njcn.web.factory.PageFactory ;
import com.njcn.web.pojo.param.BaseParam ;
import com.njcn.web.pojo.param.BaseParam ;
import lombok.RequiredArgsConstructor ;
import lombok.RequiredArgsConstructor ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Service ;
import org.springframework.util.CollectionUtils ;
import org.springframework.util.CollectionUtils ;
@@ -86,8 +84,6 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
private final HarmDataFeignClient harmDataFeignClient ;
private final HarmDataFeignClient harmDataFeignClient ;
private final GetQvvrData getQvvrData ;
private final IRespDataResultService respDataResultService ;
private final IRespDataResultService respDataResultService ;
@Override
@Override
@@ -106,16 +102,16 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
//没有排序参数, 默认根据sort字段排序, 没有排序字段的, 根据updateTime更新时间排序
//没有排序参数, 默认根据sort字段排序, 没有排序字段的, 根据updateTime更新时间排序
queryWrapper . orderBy ( true , false , " pqs_resp_data.create_time " ) ;
queryWrapper . orderBy ( true , false , " pqs_resp_data.create_time " ) ;
}
}
queryWrapper . between ( " pqs_resp_data.create_time " , queryParam . getSearchBeginTime ( ) , queryParam . getSearchEndTime ( ) ) ;
queryWrapper . between ( " pqs_resp_data.create_time " , queryParam . getSearchBeginTime ( ) , queryParam . getSearchEndTime ( ) ) ;
}
}
queryWrapper . eq ( " pqs_resp_data.state " , DataStateEnum . ENABLE . getCode ( ) ) ;
queryWrapper . eq ( " pqs_resp_data.state " , DataStateEnum . ENABLE . getCode ( ) ) ;
Page < RespDataDTO > page = this . baseMapper . page ( new Page < > ( PageFactory . getPageNum ( queryParam ) , PageFactory . getPageSize ( queryParam ) ) , queryWrapper ) ;
Page < RespDataDTO > page = this . baseMapper . page ( new Page < > ( PageFactory . getPageNum ( queryParam ) , PageFactory . getPageSize ( queryParam ) ) , queryWrapper ) ;
List < RespDataDTO > records = page . getRecords ( ) ;
List < RespDataDTO > records = page . getRecords ( ) ;
if ( CollectionUtil . isNotEmpty ( records ) ) {
if ( CollectionUtil . isNotEmpty ( records ) ) {
//获取该监测点的详细信息
//获取该监测点的详细信息
for ( RespDataDTO respDataDTO : records ) {
for ( RespDataDTO respDataDTO : records ) {
LineDetailVO lineSubGdDetail = lineFeignClient . getLineSubGdDetail ( respDataDTO . getLineId ( ) ) . getData ( ) ;
LineDetailVO lineSubGdDetail = lineFeignClient . getLineSubGdDetail ( respDataDTO . getLineId ( ) ) . getData ( ) ;
BeanUtil . copyProperties ( lineSubGdDetail , respDataDTO ) ;
BeanUtil . copyProperties ( lineSubGdDetail , respDataDTO ) ;
}
}
}
}
return page . setRecords ( records ) ;
return page . setRecords ( records ) ;
@@ -133,7 +129,6 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
}
}
@Override
@Override
public ResponsibilityResult getDynamicData ( ResponsibilityCalculateParam responsibilityCalculateParam ) {
public ResponsibilityResult getDynamicData ( ResponsibilityCalculateParam responsibilityCalculateParam ) {
ResponsibilityResult result = new ResponsibilityResult ( ) ;
ResponsibilityResult result = new ResponsibilityResult ( ) ;
@@ -153,7 +148,6 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
if ( CollectionUtils . isEmpty ( userDataExcels ) ) {
if ( CollectionUtils . isEmpty ( userDataExcels ) ) {
throw new BusinessException ( AdvanceResponseEnum . USER_DATA_NOT_FOUND ) ;
throw new BusinessException ( AdvanceResponseEnum . USER_DATA_NOT_FOUND ) ;
}
}
//开始处理,根据接口参数需求,需要节点数(用户数,用户名+监测点号为一个用户),时间范围内功率数据
//开始处理,根据接口参数需求,需要节点数(用户数,用户名+监测点号为一个用户),时间范围内功率数据
DealDataResult dealDataResult = RespUserDataServiceImpl . getStanderData ( userDataExcels , 1 ) ;
DealDataResult dealDataResult = RespUserDataServiceImpl . getStanderData ( userDataExcels , 1 ) ;
Map < String /*户号@监测点号@户名*/ , Map < String /*yyyy-MM-dd天日期*/ , List < UserDataExcel > > > totalData = dealDataResult . getTotalListData ( ) ;
Map < String /*户号@监测点号@户名*/ , Map < String /*yyyy-MM-dd天日期*/ , List < UserDataExcel > > > totalData = dealDataResult . getTotalListData ( ) ;
@@ -263,8 +257,7 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
qvvrStruct . harm_mk = harmMk ;
qvvrStruct . harm_mk = harmMk ;
qvvrStruct . p_data = pData ;
qvvrStruct . p_data = pData ;
qvvrStruct . harm_data = harmData ;
qvvrStruct . harm_data = harmData ;
ResponsibilityCallDllOrSo responsibilityCallDllOrSo = new ResponsibilityCallDllOrSo ( " harm_response " ) ;
ResponsibilityCallDllOrSo responsibilityCallDllOrSo = new ResponsibilityCallDllOrSo ( " harm_response.dll " ) ;
responsibilityCallDllOrSo . setPath ( ) ;
responsibilityCallDllOrSo . setPath ( ) ;
ResponsibilityCallDllOrSo . ResponsibilityLibrary responsibilityLibrary = ResponsibilityCallDllOrSo . ResponsibilityLibrary . INSTANTCE ;
ResponsibilityCallDllOrSo . ResponsibilityLibrary responsibilityLibrary = ResponsibilityCallDllOrSo . ResponsibilityLibrary . INSTANTCE ;
responsibilityLibrary . harm_response ( qvvrStruct ) ;
responsibilityLibrary . harm_response ( qvvrStruct ) ;
@@ -402,16 +395,16 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
LambdaQueryWrapper < RespDataResult > respDataResultLambdaQueryWrapper = new LambdaQueryWrapper < > ( ) ;
LambdaQueryWrapper < RespDataResult > respDataResultLambdaQueryWrapper = new LambdaQueryWrapper < > ( ) ;
respDataResultLambdaQueryWrapper . eq ( RespDataResult : : getResDataId , responsibilityData . getId ( ) )
respDataResultLambdaQueryWrapper . eq ( RespDataResult : : getResDataId , responsibilityData . getId ( ) )
. eq ( RespDataResult : : getTime , responsibilityCalculateParam . getTime ( ) )
. eq ( RespDataResult : : getTime , responsibilityCalculateParam . getTime ( ) )
. eq ( RespDataResult : : getStartTime , DateUtil . parse ( responsibilityCalculateParam . getSearchBeginTime ( ) + " 00:00:00 " , DatePattern . NORM_DATETIME_PATTERN ) )
. eq ( RespDataResult : : getStartTime , DateUtil . parse ( responsibilityCalculateParam . getSearchBeginTime ( ) + " 00:00:00 " , DatePattern . NORM_DATETIME_PATTERN ) )
. eq ( RespDataResult : : getEndTime , DateUtil . parse ( responsibilityCalculateParam . getSearchEndTime ( ) + " 23:59:59 " , DatePattern . NORM_DATETIME_PATTERN ) )
. eq ( RespDataResult : : getEndTime , DateUtil . parse ( responsibilityCalculateParam . getSearchEndTime ( ) + " 23:59:59 " , DatePattern . NORM_DATETIME_PATTERN ) )
. eq ( RespDataResult : : getLimitValue , data . getOverLimit ( ) ) ;
. eq ( RespDataResult : : getLimitValue , data . getOverLimit ( ) ) ;
RespDataResult respDataResult = respDataResultService . getOne ( respDataResultLambdaQueryWrapper ) ;
RespDataResult respDataResult = respDataResultService . getOne ( respDataResultLambdaQueryWrapper ) ;
if ( Objects . isNull ( respDataResult ) ) {
if ( Objects . isNull ( respDataResult ) ) {
respDataResult = new RespDataResult ( ) ;
respDataResult = new RespDataResult ( ) ;
respDataResult . setResDataId ( responsibilityData . getId ( ) ) ;
respDataResult . setResDataId ( responsibilityData . getId ( ) ) ;
respDataResult . setTime ( responsibilityCalculateParam . getTime ( ) ) ;
respDataResult . setTime ( responsibilityCalculateParam . getTime ( ) ) ;
respDataResult . setStartTime ( DateUtil . parse ( responsibilityCalculateParam . getSearchBeginTime ( ) + " 00:00:00 " , DatePattern . NORM_DATETIME_PATTERN ) ) ;
respDataResult . setStartTime ( DateUtil . parse ( responsibilityCalculateParam . getSearchBeginTime ( ) + " 00:00:00 " , DatePattern . NORM_DATETIME_PATTERN ) ) ;
respDataResult . setEndTime ( DateUtil . parse ( responsibilityCalculateParam . getSearchEndTime ( ) + " 23:59:59 " , DatePattern . NORM_DATETIME_PATTERN ) ) ;
respDataResult . setEndTime ( DateUtil . parse ( responsibilityCalculateParam . getSearchEndTime ( ) + " 23:59:59 " , DatePattern . NORM_DATETIME_PATTERN ) ) ;
respDataResult . setLimitValue ( data . getOverLimit ( ) ) ;
respDataResult . setLimitValue ( data . getOverLimit ( ) ) ;
//时间横轴数据 timeDatas
//时间横轴数据 timeDatas
JSONArray timeDataJson = JSONArray . parseArray ( JSON . toJSONString ( timeDatas ) ) ;
JSONArray timeDataJson = JSONArray . parseArray ( JSON . toJSONString ( timeDatas ) ) ;
@@ -480,8 +473,8 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
//谐波横轴所有的时间
//谐波横轴所有的时间
List < Long > times = cacheQvvrData . getTimes ( ) ;
List < Long > times = cacheQvvrData . getTimes ( ) ;
//首先根据窗口判断限值时间范围是否满足最小窗口
//首先根据窗口判断限值时间范围是否满足最小窗口
Long limitSL = DateUtil . parse ( responsibilitySecondCalParam . getLimitStartTime ( ) , DatePattern . NORM_DATETIME_PATTERN ) . getTime ( ) ;
Long limitSL = DateUtil . parse ( responsibilitySecondCalParam . getLimitStartTime ( ) , DatePattern . NORM_DATETIME_PATTERN ) . getTime ( ) ;
Long limitEL = DateUtil . parse ( responsibilitySecondCalParam . getLimitEndTime ( ) , DatePattern . NORM_DATETIME_PATTERN ) . getTime ( ) ;
Long limitEL = DateUtil . parse ( responsibilitySecondCalParam . getLimitEndTime ( ) , DatePattern . NORM_DATETIME_PATTERN ) . getTime ( ) ;
List < Integer > temp = getTimes ( times , limitSL , limitEL ) ;
List < Integer > temp = getTimes ( times , limitSL , limitEL ) ;
//在动态责任数据中,时间的起始索引位置和截止索引位置
//在动态责任数据中,时间的起始索引位置和截止索引位置
Integer timeStartIndex = temp . get ( 0 ) ;
Integer timeStartIndex = temp . get ( 0 ) ;
@@ -559,7 +552,10 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
qvvrStruct . setFKdata ( FKdata ) ;
qvvrStruct . setFKdata ( FKdata ) ;
qvvrStruct . setHKdata ( HKdata ) ;
qvvrStruct . setHKdata ( HKdata ) ;
}
}
qvvrStruct = getQvvrData . getResponsibilityResult ( qvvrStruct ) ;
ResponsibilityCallDllOrSo responsibilityCallDllOrSo = new ResponsibilityCallDllOrSo ( " harm_response " ) ;
responsibilityCallDllOrSo . setPath ( ) ;
ResponsibilityCallDllOrSo . ResponsibilityLibrary responsibilityLibrary = ResponsibilityCallDllOrSo . ResponsibilityLibrary . INSTANTCE ;
responsibilityLibrary . harm_response ( qvvrStruct ) ;
if ( qvvrStruct . cal_ok = = 0 ) {
if ( qvvrStruct . cal_ok = = 0 ) {
throw new BusinessException ( AdvanceResponseEnum . RESPONSIBILITY_PARAMETER_ERROR ) ;
throw new BusinessException ( AdvanceResponseEnum . RESPONSIBILITY_PARAMETER_ERROR ) ;
}
}
@@ -651,16 +647,16 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
LambdaQueryWrapper < RespDataResult > respDataResultLambdaQueryWrapper1 = new LambdaQueryWrapper < > ( ) ;
LambdaQueryWrapper < RespDataResult > respDataResultLambdaQueryWrapper1 = new LambdaQueryWrapper < > ( ) ;
respDataResultLambdaQueryWrapper1 . eq ( RespDataResult : : getResDataId , responsibilityData . getId ( ) )
respDataResultLambdaQueryWrapper1 . eq ( RespDataResult : : getResDataId , responsibilityData . getId ( ) )
. eq ( RespDataResult : : getTime , responsibilitySecondCalParam . getTime ( ) )
. eq ( RespDataResult : : getTime , responsibilitySecondCalParam . getTime ( ) )
. eq ( RespDataResult : : getStartTime , DateUtil . parse ( responsibilitySecondCalParam . getLimitStartTime ( ) , DatePattern . NORM_DATETIME_PATTERN ) )
. eq ( RespDataResult : : getStartTime , DateUtil . parse ( responsibilitySecondCalParam . getLimitStartTime ( ) , DatePattern . NORM_DATETIME_PATTERN ) )
. eq ( RespDataResult : : getEndTime , DateUtil . parse ( responsibilitySecondCalParam . getLimitEndTime ( ) , DatePattern . NORM_DATETIME_PATTERN ) )
. eq ( RespDataResult : : getEndTime , DateUtil . parse ( responsibilitySecondCalParam . getLimitEndTime ( ) , DatePattern . NORM_DATETIME_PATTERN ) )
. eq ( RespDataResult : : getLimitValue , responsibilitySecondCalParam . getLimitValue ( ) ) ;
. eq ( RespDataResult : : getLimitValue , responsibilitySecondCalParam . getLimitValue ( ) ) ;
RespDataResult respDataResult = respDataResultService . getOne ( respDataResultLambdaQueryWrapper1 ) ;
RespDataResult respDataResult = respDataResultService . getOne ( respDataResultLambdaQueryWrapper1 ) ;
if ( Objects . isNull ( respDataResult ) ) {
if ( Objects . isNull ( respDataResult ) ) {
respDataResult = new RespDataResult ( ) ;
respDataResult = new RespDataResult ( ) ;
respDataResult . setResDataId ( responsibilityData . getId ( ) ) ;
respDataResult . setResDataId ( responsibilityData . getId ( ) ) ;
respDataResult . setTime ( responsibilitySecondCalParam . getTime ( ) ) ;
respDataResult . setTime ( responsibilitySecondCalParam . getTime ( ) ) ;
respDataResult . setStartTime ( DateUtil . parse ( responsibilitySecondCalParam . getLimitStartTime ( ) , DatePattern . NORM_DATETIME_PATTERN ) ) ;
respDataResult . setStartTime ( DateUtil . parse ( responsibilitySecondCalParam . getLimitStartTime ( ) , DatePattern . NORM_DATETIME_PATTERN ) ) ;
respDataResult . setEndTime ( DateUtil . parse ( responsibilitySecondCalParam . getLimitEndTime ( ) , DatePattern . NORM_DATETIME_PATTERN ) ) ;
respDataResult . setEndTime ( DateUtil . parse ( responsibilitySecondCalParam . getLimitEndTime ( ) , DatePattern . NORM_DATETIME_PATTERN ) ) ;
respDataResult . setLimitValue ( responsibilitySecondCalParam . getLimitValue ( ) ) ;
respDataResult . setLimitValue ( responsibilitySecondCalParam . getLimitValue ( ) ) ;
//时间横轴数据 timeDatas
//时间横轴数据 timeDatas
JSONArray timeDataJson = JSONArray . parseArray ( JSON . toJSONString ( timeDatas ) ) ;
JSONArray timeDataJson = JSONArray . parseArray ( JSON . toJSONString ( timeDatas ) ) ;
@@ -686,7 +682,6 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
}
}
/**
/**
* 监测点测量间隔获取最后用于计算的功率数据
* 监测点测量间隔获取最后用于计算的功率数据
*
*