@@ -11,7 +11,6 @@ import cn.hutool.core.text.StrBuilder;
import cn.hutool.core.util.IdUtil ;
import cn.hutool.core.util.IdUtil ;
import cn.hutool.core.util.ObjectUtil ;
import cn.hutool.core.util.ObjectUtil ;
import cn.hutool.core.util.StrUtil ;
import cn.hutool.core.util.StrUtil ;
import cn.hutool.http.HttpRequest ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper ;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper ;
@@ -55,10 +54,8 @@ import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum ;
import com.njcn.system.enums.DicDataTypeEnum ;
import com.njcn.system.pojo.po.Area ;
import com.njcn.system.pojo.po.Area ;
import com.njcn.system.pojo.po.DictData ;
import com.njcn.system.pojo.po.DictData ;
import com.njcn.web.utils.HttpServletUtil ;
import com.njcn.web.utils.RequestUtil ;
import com.njcn.web.utils.RequestUtil ;
import com.njcn.web.utils.RestTemplateUtil ;
import com.njcn.web.utils.RestTemplateUtil ;
import io.swagger.annotations.ApiModelProperty ;
import lombok.RequiredArgsConstructor ;
import lombok.RequiredArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.commons.lang3.StringUtils ;
@@ -118,6 +115,9 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
@Value ( " ${oracle.syncLedgerUpdateLine} " )
@Value ( " ${oracle.syncLedgerUpdateLine} " )
private String updateUrl ;
private String updateUrl ;
@Value ( " ${oracle.syncLedgerDeleteLine} " )
private String urlDelete ;
/**
/**
* 终端新增操作
* 终端新增操作
*
*
@@ -503,8 +503,8 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
@Override
@Override
@Transactional ( rollbackFor = Exception . class )
@Transactional ( rollbackFor = Exception . class )
public Boolean updateTerminal ( UpdateTerminalParam updateTerminalParam ) {
public Boolean updateTerminal ( UpdateTerminalParam updateTerminalParam ) {
String oldSubName = " " ;
String oldSubName = " " ;
String gbName = " " ;
String gbName = " " ;
LambdaQueryWrapper < Line > lambdaQueryWrapper = new LambdaQueryWrapper < > ( ) ;
LambdaQueryWrapper < Line > lambdaQueryWrapper = new LambdaQueryWrapper < > ( ) ;
//项目
//项目
if ( Objects . nonNull ( updateTerminalParam . getProjectUpdateParam ( ) ) ) {
if ( Objects . nonNull ( updateTerminalParam . getProjectUpdateParam ( ) ) ) {
@@ -535,7 +535,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
//供电公司
//供电公司
if ( Objects . nonNull ( updateTerminalParam . getGdInformationUpdateParam ( ) ) ) {
if ( Objects . nonNull ( updateTerminalParam . getGdInformationUpdateParam ( ) ) ) {
Line gdRes = this . getById ( updateTerminalParam . getGdInformationUpdateParam ( ) . getGdIndex ( ) ) ;
Line gdRes = this . getById ( updateTerminalParam . getGdInformationUpdateParam ( ) . getGdIndex ( ) ) ;
gbName = gdRes . getName ( ) ;
gbName = gdRes . getName ( ) ;
if ( Objects . isNull ( gdRes ) ) {
if ( Objects . isNull ( gdRes ) ) {
throw new BusinessException ( DeviceResponseEnum . GD_NO ) ;
throw new BusinessException ( DeviceResponseEnum . GD_NO ) ;
}
}
@@ -553,7 +553,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
if ( Objects . isNull ( subStationRes ) ) {
if ( Objects . isNull ( subStationRes ) ) {
throw new BusinessException ( DeviceResponseEnum . SUB_NO ) ;
throw new BusinessException ( DeviceResponseEnum . SUB_NO ) ;
}
}
oldSubName = subStationRes . getName ( ) ;
oldSubName = subStationRes . getName ( ) ;
Line subStation = new Line ( ) ;
Line subStation = new Line ( ) ;
subStation . setId ( updateTerminalParam . getSubStationUpdateParam ( ) . getSubIndex ( ) ) ;
subStation . setId ( updateTerminalParam . getSubStationUpdateParam ( ) . getSubIndex ( ) ) ;
subStation . setName ( updateTerminalParam . getSubStationUpdateParam ( ) . getName ( ) ) ;
subStation . setName ( updateTerminalParam . getSubStationUpdateParam ( ) . getName ( ) ) ;
@@ -798,8 +798,8 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
/***
/***
* oracle http远程调用接口
* oracle http远程调用接口
*/
*/
SyncLedgerUpdate syncLedger = oracleSyncLedgerUpdate ( updateTerminalParam , oldSubName , gbName ) ;
SyncLedgerUpdate syncLedger = oracleSyncLedgerUpdate ( updateTerminalParam , oldSubName , gbName ) ;
ResponseEntity < Map > userEntity = RestTemplateUtil . post ( updateUrl , syncLedger , Map . class ) ;
ResponseEntity < String > userEntity = RestTemplateUtil . post ( updateUrl , syncLedger , String . class ) ;
}
}
return true ;
return true ;
}
}
@@ -1360,6 +1360,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
List < Line > deviceList = this . list ( lambdaQueryWrapper ) ;
List < Line > deviceList = this . list ( lambdaQueryWrapper ) ;
if ( CollectionUtil . isNotEmpty ( deviceList ) ) {
if ( CollectionUtil . isNotEmpty ( deviceList ) ) {
List < String > devIndexList = deviceList . stream ( ) . map ( Line : : getId ) . collect ( Collectors . toList ( ) ) ;
List < String > devIndexList = deviceList . stream ( ) . map ( Line : : getId ) . collect ( Collectors . toList ( ) ) ;
this . removeByIds ( devIndexList ) ;
this . removeByIds ( devIndexList ) ;
deviceMapper . deleteBatchIds ( devIndexList ) ;
deviceMapper . deleteBatchIds ( devIndexList ) ;
devFuctionMapper . deleteBatchIds ( devIndexList ) ;
devFuctionMapper . deleteBatchIds ( devIndexList ) ;
@@ -1455,6 +1456,10 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
} else {
} else {
throw new BusinessException ( CommonResponseEnum . FAIL ) ;
throw new BusinessException ( CommonResponseEnum . FAIL ) ;
}
}
if ( isSync ) {
SyncLedgerDelete delete = oracleSyncLedgerDelete ( obj ) ;
ResponseEntity < String > userEntity = RestTemplateUtil . post ( urlDelete , delete , String . class ) ;
}
return true ;
return true ;
}
}
@@ -1843,6 +1848,21 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
@Override
@Override
@Transactional ( rollbackFor = Exception . class )
@Transactional ( rollbackFor = Exception . class )
public String terminalSync ( SyncTerminalParam syncTerminalParam ) {
public String terminalSync ( SyncTerminalParam syncTerminalParam ) {
if ( isSync ) {
/***
* oracle http远程调用接口
*/
SyncLedger syncLedger = oracleSyncLedger ( syncTerminalParam ) ;
ResponseEntity < Map > userEntity = RestTemplateUtil . post ( url , syncLedger , Map . class ) ;
if ( HttpURLConnection . HTTP_OK = = userEntity . getStatusCodeValue ( ) ) {
//获取返回体
Map body = userEntity . getBody ( ) ;
Integer oracleLineId = Integer . valueOf ( body . get ( " oracleLineId " ) . toString ( ) ) ;
Integer oracleDevId = Integer . valueOf ( body . get ( " oracleDevId " ) . toString ( ) ) ;
syncTerminalParam . setOracleLineId ( oracleLineId ) ;
syncTerminalParam . setOracleDevId ( oracleDevId ) ;
}
}
String projectIndex = null ;
String projectIndex = null ;
String provinceIndex = null ;
String provinceIndex = null ;
String gdIndex = null ;
String gdIndex = null ;
@@ -2024,21 +2044,6 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
deptLine . setId ( syncTerminalParam . getDeptId ( ) ) ;
deptLine . setId ( syncTerminalParam . getDeptId ( ) ) ;
deptLine . setLineId ( line . getId ( ) ) ;
deptLine . setLineId ( line . getId ( ) ) ;
deptLineMapper . insert ( deptLine ) ;
deptLineMapper . insert ( deptLine ) ;
if ( isSync ) {
/***
* oracle http远程调用接口
*/
SyncLedger syncLedger = oracleSyncLedger ( syncTerminalParam ) ;
ResponseEntity < Map > userEntity = RestTemplateUtil . post ( url , syncLedger , Map . class ) ;
if ( HttpURLConnection . HTTP_OK = = userEntity . getStatusCodeValue ( ) ) {
//获取返回体
Map body = userEntity . getBody ( ) ;
Integer oracleLineId = Integer . valueOf ( body . get ( " oracleLineId " ) . toString ( ) ) ;
Integer oracleDevId = Integer . valueOf ( body . get ( " oracleDevId " ) . toString ( ) ) ;
syncTerminalParam . setOracleLineId ( oracleLineId ) ;
syncTerminalParam . setOracleDevId ( oracleDevId ) ;
}
}
return subIndex ;
return subIndex ;
}
}
@@ -3085,41 +3090,85 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
terminalVO . setSubStationVO ( subStationVO ) ;
terminalVO . setSubStationVO ( subStationVO ) ;
}
}
private SyncLedgerUpda te oracleSyncLedgerUpda te ( UpdateTerminalParam param , String oldSubName , String gdName ) {
private SyncLedgerDele te oracleSyncLedgerDele te ( Line obj ) {
SyncLedgerUpda te update = new SyncLedgerUpda te ( ) ;
SyncLedgerDele te delete = new SyncLedgerDele te ( ) ;
delete . setLevel ( obj . getLevel ( ) ) ;
/**
* 3-变电站; 4-终端; 5-母线; 6-监测点
*/
switch ( obj . getLevel ( ) ) {
case 3 :
Line byId = this . getById ( obj . getPid ( ) ) ;
if ( Objects . isNull ( byId ) ) {
throw new BusinessException ( CommonResponseEnum . NO_DATA ) ;
}
delete . setSuperName ( byId . getName ( ) ) ;
delete . setName ( obj . getName ( ) ) ;
break ;
case 4 :
DeviceBak deviceBak = deviceBakService . getById ( obj . getId ( ) ) ;
delete . setId ( deviceBak . getDevId ( ) ) ;
delete . setName ( obj . getName ( ) ) ;
break ;
case 5 :
DeviceBak bak = deviceBakService . getById ( obj . getPid ( ) ) ;
delete . setName ( obj . getName ( ) ) ;
delete . setSuperId ( bak . getDevId ( ) ) ;
break ;
case 6 :
LineBak lineBak = lineBakService . getById ( obj . getId ( ) ) ;
delete . setId ( lineBak . getLineId ( ) ) ;
delete . setName ( obj . getName ( ) ) ;
break ;
}
return delete ;
}
private SyncLedgerUpdate oracleSyncLedgerUpdate ( UpdateTerminalParam param , String oldSubName , String gdName ) {
SyncLedgerUpdate update = new SyncLedgerUpdate ( ) ;
/**
/**
* 先更新变电站信息,然后根据变电站信息查询终端信息
* 先更新变电站信息,然后根据变电站信息查询终端信息
*/
*/
//变电站信息
//变电站信息
SubStationParam . SubStationUpdateParam sub = param . getSubStationUpdateParam ( ) ;
SubStationParam . SubStationUpdateParam sub = param . getSubStationUpdateParam ( ) ;
List < DeviceParam > deviceUpdateParamList = param . getDeviceUpdateParamList ( ) ;
List < DeviceParam > deviceUpdateParamList = param . getDeviceUpdateParamList ( ) ;
PqSubstation substation = new PqSubstation ( ) ;
PqSubstation substation = new PqSubstation ( ) ;
if ( ObjectUtil . isNull ( sub ) ) {
if ( ObjectUtil . isNull ( sub ) ) {
//因为查出来的数据电压等级是转换过的所有不需要替换
//因为查出来的数据电压等级是转换过的所有不需要替换
Line byId = this . getById ( deviceUpdateParamList . get ( 0 ) . getDevIndex ( ) ) ;
Line byId = this . getById ( deviceUpdateParamList . get ( 0 ) . getDevIndex ( ) ) ;
PollutionSubstationDTO substationInfo = lineMapper . getSubstationInfo ( byId . getPid ( ) ) ;
PollutionSubstationDTO substationInfo = lineMapper . getSubstationInfo ( byId . getPid ( ) ) ;
sub = new SubStationParam . SubStationUpdateParam ( ) ;
sub = new SubStationParam . SubStationUpdateParam ( ) ;
sub . setName ( substationInfo . getName ( ) ) ;
sub . setName ( substationInfo . getName ( ) ) ;
oldSubName = substationInfo . getName ( ) ;
oldSubName = substationInfo . getName ( ) ;
sub . setLng ( substationInfo . getLng ( ) ) ;
sub . setLng ( substationInfo . getLng ( ) ) ;
sub . setLat ( substationInfo . getLat ( ) ) ;
sub . setLat ( substationInfo . getLat ( ) ) ;
substation . setScale ( sub . getScale ( ) ) ;
sub . setSubIndex ( substationInfo . getId ( ) ) ;
} else {
substation . setScale ( substationInfo . getVoltageLevel ( ) ) ;
} else {
substation . setScale ( dictName ( sub . getScale ( ) ) ) ;
substation . setScale ( dictName ( sub . getScale ( ) ) ) ;
}
}
substation . setName ( sub . getName ( ) ) ;
substation . setName ( sub . getName ( ) ) ;
substation . setOldName ( oldSubName ) ;
substation . setOldName ( oldSubName ) ;
substation . setGdName ( gdName ) ;
if ( StrUtil . isNotBlank ( gdName ) ) {
substation . setGdName ( gdName ) ;
} else {
Line byId = this . getById ( sub . getSubIndex ( ) ) ;
Line byId1 = this . getById ( byId . getPid ( ) ) ;
if ( ObjectUtil . isNull ( byId1 ) ) {
throw new BusinessException ( PvDeviceResponseEnum . GD_OR_NOT ) ;
}
substation . setGdName ( byId1 . getName ( ) ) ;
}
update . setPqSubstation ( substation ) ;
update . setPqSubstation ( substation ) ;
PqsMap pqsMap = new PqsMap ( ) ;
PqsMap pqsMap = new PqsMap ( ) ;
pqsMap . setLongitude ( sub . getLng ( ) . doubleValue ( ) ) ;
pqsMap . setLongitude ( sub . getLng ( ) . doubleValue ( ) ) ;
pqsMap . setLatitude ( sub . getLat ( ) . doubleValue ( ) ) ;
pqsMap . setLatitude ( sub . getLat ( ) . doubleValue ( ) ) ;
update . setPqsMap ( pqsMap ) ;
update . setPqsMap ( pqsMap ) ;
//修改终端信息
//修改终端信息
List < PqDevice > deviceList = new ArrayList < > ( ) ;
List < PqDevice > deviceList = new ArrayList < > ( ) ;
List < PqDevicedetail > deviceDetailList = new ArrayList < > ( ) ;
List < PqDevicedetail > deviceDetailList = new ArrayList < > ( ) ;
List < PqLinedetail > lineDeatailList = new ArrayList < > ( ) ;
List < PqLinedetail > lineDeatailList = new ArrayList < > ( ) ;
List < String > devMysqlIds = deviceUpdateParamList . stream ( ) . map ( DeviceParam : : getDevIndex ) . collect ( Collectors . toList ( ) ) ;
List < String > devMysqlIds = deviceUpdateParamList . stream ( ) . map ( DeviceParam : : getDevIndex ) . collect ( Collectors . toList ( ) ) ;
List < DeviceBak > deviceBaks = deviceBakService . listByIds ( devMysqlIds ) ;
List < DeviceBak > deviceBaks = deviceBakService . listByIds ( devMysqlIds ) ;
@@ -3128,10 +3177,10 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
for ( DeviceParam device : deviceUpdateParamList ) {
for ( DeviceParam device : deviceUpdateParamList ) {
String devIndex = device . getDevIndex ( ) ;
String devIndex = device . getDevIndex ( ) ;
if ( deviceBakMap . containsKey ( devIndex ) ) {
if ( deviceBakMap . containsKey ( devIndex ) ) {
Integer devOracleId = deviceBakMap . get ( devIndex ) ;
Integer devOracleId = deviceBakMap . get ( devIndex ) ;
//终端
//终端
PqDevice pqDevice = new PqDevice ( ) ;
PqDevice pqDevice = new PqDevice ( ) ;
pqDevice . setDevIndex ( devOracleId ) ;
pqDevice . setDevIndex ( devOracleId ) ;
pqDevice . setName ( device . getName ( ) ) ;
pqDevice . setName ( device . getName ( ) ) ;
pqDevice . setStatus ( 1 ) ;
pqDevice . setStatus ( 1 ) ;
@@ -3167,8 +3216,8 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
deviceDetailList . add ( pqDevicedetail ) ;
deviceDetailList . add ( pqDevicedetail ) ;
//处理母线信息
//处理母线信息
List < PqSubvoltage > pqSubVoltages = new ArrayList < > ( ) ;
List < PqSubvoltage > pqSubVoltages = new ArrayList < > ( ) ;
for ( SubVoltageParam subVoltage : device . getSubVoltageParam ( ) ) {
for ( SubVoltageParam subVoltage : device . getSubVoltageParam ( ) ) {
//母线
//母线
PqSubvoltage pqSubvoltage = new PqSubvoltage ( ) ;
PqSubvoltage pqSubvoltage = new PqSubvoltage ( ) ;
pqSubvoltage . setName ( subVoltage . getName ( ) ) ;
pqSubvoltage . setName ( subVoltage . getName ( ) ) ;
@@ -3178,10 +3227,10 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
pqSubvoltage . setSubvmodel ( subVoltage . getModel ( ) ) ;
pqSubvoltage . setSubvmodel ( subVoltage . getModel ( ) ) ;
pqSubVoltages . add ( pqSubvoltage ) ;
pqSubVoltages . add ( pqSubvoltage ) ;
//监测点
//监测点
List < PqLine > pqLines = new ArrayList < > ( ) ;
List < PqLine > pqLines = new ArrayList < > ( ) ;
for ( LineParam line : subVoltage . getLineParam ( ) ) {
for ( LineParam line : subVoltage . getLineParam ( ) ) {
LineBak byId = lineBakService . getById ( line . getLineIndex ( ) ) ;
LineBak byId = lineBakService . getById ( line . getLineIndex ( ) ) ;
if ( ObjectUtil . isNotNull ( byId ) ) {
if ( ObjectUtil . isNotNull ( byId ) ) {
//监测点
//监测点
PqLine pqLine = new PqLine ( ) ;
PqLine pqLine = new PqLine ( ) ;
pqLine . setLineIndex ( byId . getLineId ( ) ) ;
pqLine . setLineIndex ( byId . getLineId ( ) ) ;
@@ -3195,7 +3244,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
pqLine . setJzcmp ( line . getStandardCapacity ( ) . doubleValue ( ) ) ;
pqLine . setJzcmp ( line . getStandardCapacity ( ) . doubleValue ( ) ) ;
pqLine . setXycmp ( line . getDealCapacity ( ) . doubleValue ( ) ) ;
pqLine . setXycmp ( line . getDealCapacity ( ) . doubleValue ( ) ) ;
pqLine . setScale ( dictName ( subVoltage . getScale ( ) ) ) ;
pqLine . setScale ( dictName ( subVoltage . getScale ( ) ) ) ;
pqLine . setStatus ( 1 ) ;
pqLine . setStatus ( 0 ) ;
pqLines . add ( pqLine ) ;
pqLines . add ( pqLine ) ;
PqLinedetail pqLinedetail = new PqLinedetail ( ) ;
PqLinedetail pqLinedetail = new PqLinedetail ( ) ;
@@ -3235,6 +3284,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
update . setPqLinedetail ( lineDeatailList ) ;
update . setPqLinedetail ( lineDeatailList ) ;
return update ;
return update ;
}
}
/**
/**
* oracle远程台账同步
* oracle远程台账同步
*
*
@@ -3365,7 +3415,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
pqLine . setJzcmp ( line . getStandardCapacity ( ) . doubleValue ( ) ) ;
pqLine . setJzcmp ( line . getStandardCapacity ( ) . doubleValue ( ) ) ;
pqLine . setXycmp ( line . getDealCapacity ( ) . doubleValue ( ) ) ;
pqLine . setXycmp ( line . getDealCapacity ( ) . doubleValue ( ) ) ;
pqLine . setScale ( dictName ( subVoltage . getScale ( ) ) ) ;
pqLine . setScale ( dictName ( subVoltage . getScale ( ) ) ) ;
pqLine . setStatus ( 1 ) ;
pqLine . setStatus ( 0 ) ;
ledger . setPqLine ( pqLine ) ;
ledger . setPqLine ( pqLine ) ;
PqLinedetail pqLinedetail = new PqLinedetail ( ) ;
PqLinedetail pqLinedetail = new PqLinedetail ( ) ;
pqLinedetail . setLineName ( line . getName ( ) ) ;
pqLinedetail . setLineName ( line . getName ( ) ) ;