@@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams ;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult ;
import cn.hutool.core.collection.CollUtil ;
import cn.hutool.core.collection.CollectionUtil ;
import cn.hutool.core.util.StrUtil ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper ;
@@ -11,9 +12,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl ;
import com.njcn.common.pojo.dto.SimpleDTO ;
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.device.biz.enums.DeviceResponseEnum ;
import com.njcn.device.biz.pojo.bo.excel.PmsOracleTerminalExcel ;
import com.njcn.device.biz.pojo.dto.DeptGetChildrenDTO ;
import com.njcn.device.biz.pojo.param.DeptGetLineParam ;
import com.njcn.device.biz.utils.COverlimit ;
@@ -29,11 +33,12 @@ import com.njcn.device.pms.pojo.vo.MonitorVO;
import com.njcn.device.pms.pojo.vo.PmsMonitorVO ;
import com.njcn.device.pms.service.majornetwork.IDistributionMonitorService ;
import com.njcn.device.pms.service.majornetwork.IMonitorService ;
import com.njcn.device.pq.pojo.bo.excel.NodeEx cel ;
import com.njcn.device.pq.pojo.bo.excel.OverLimitExcel ;
import com.njcn.device.pq.pojo.p o.Line ;
import com.njcn.device.pq.pojo.po.LineDetail ;
import com.njcn.device.pq.pojo.po.Voltage ;
import com.njcn.device.pms.service.majornetwork.IPowerDistributionareaServi ce ;
import com.njcn.device.pq.pojo.b o.excel.OracleTerminalExcel ;
import com.njcn.device.pq.pojo.po.LineBak ;
import com.njcn.poi.excel.ExcelUtil ;
import com.njcn.poi.util.PoiUtil ;
import com.njcn.system.enums.DicDataEnum ;
import com.njcn.system.enums.DicDataTypeEnum ;
@@ -54,6 +59,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile ;
import javax.servlet.http.HttpServletResponse ;
import java.math.BigDecimal ;
import java.util.* ;
import java.util.function.Function ;
import java.util.stream.Collectors ;
@@ -86,6 +92,11 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
private final IDistributionMonitorService iDistributionMonitorService ;
private final StatationStatMapper statationStatMapper ;
private final TerminalMapper terminalMapper ;
private final LineBakMapper lineBakMapper ;
@Override
@@ -180,8 +191,8 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
Page < Monitor > page = this . page ( new Page < > ( PageFactory . getPageNum ( baseParam ) , PageFactory . getPageSize ( baseParam ) ) , lambdaQueryWrapper ) ;
List < DictData > dictDataList = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . DEV_VOLTAGE . getCode ( ) ) . getData ( ) ;
Map < String , DictData > map = dictDataList . stream ( ) . collect ( Collectors . toMap ( DictData : : getId , Function . identity ( ) ) ) ;
List < Monitor > tem = page . getRecords ( ) . stream ( ) . peek ( item - > item . setStandShortCapacity ( COverlimit . getStandShortCap ( map . get ( item . getVoltageLevel ( ) ) . getValue ( ) ) ) ) . collect ( Collectors . toList ( ) ) ;
Map < String , DictData > map = dictDataList . stream ( ) . collect ( Collectors . toMap ( DictData : : getId , Function . identity ( ) ) ) ;
List < Monitor > tem = page . getRecords ( ) . stream ( ) . peek ( item - > item . setStandShortCapacity ( COverlimit . getStandShortCap ( map . get ( item . getVoltageLevel ( ) ) . getValue ( ) ) ) ) . collect ( Collectors . toList ( ) ) ;
page . setRecords ( tem ) ;
return page ;
}
@@ -222,7 +233,7 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
monitor . setStatus ( DataStateEnum . ENABLE . getCode ( ) ) ;
//主网测点限值计算
Overlimit overlimit = overLimitCal ( monitorParam , monitor ) ;
Overlimit overlimit = overLimitCal ( monitorParam , monitor ) ;
this . save ( monitor ) ;
//新增监测点同时新增pms_special_monitor
@@ -257,7 +268,7 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
//修改主网监测点如何配网表中也存在需要同时修改
DistributionMonitor distributionMonitor = iDistributionMonitorService . getById ( monitor . getId ( ) ) ;
if ( Objects . nonNull ( distributionMonitor ) ) {
if ( Objects . nonNull ( distributionMonitor ) ) {
distributionMonitor . setTerminalId ( monitor . getTerminalId ( ) ) ;
distributionMonitor . setTerminalWiringMethod ( monitor . getTerminalWiringMethod ( ) ) ;
distributionMonitor . setVoltageLevel ( monitor . getVoltageLevel ( ) ) ;
@@ -265,7 +276,7 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
iDistributionMonitorService . updateById ( distributionMonitor ) ;
}
Overlimit overlimit = overLimitCal ( monitorParam , monitor ) ;
Overlimit overlimit = overLimitCal ( monitorParam , monitor ) ;
overlimitMapper . deleteById ( monitor . getId ( ) ) ;
overlimit . setId ( monitor . getId ( ) ) ;
overlimitMapper . insert ( overlimit ) ;
@@ -332,15 +343,15 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
}
String terminalWiringMethod = monitorTerminal . getTerminalWiringMethod ( ) ;
DictData data = dicDataFeignClient . getDicDataById ( terminalWiringMethod ) . getData ( ) ;
if ( DicDataEnum . STAR . getCode ( ) . equals ( data . getCode ( ) ) ) {
if ( DicDataEnum . STAR . getCode ( ) . equals ( data . getCode ( ) ) ) {
monitorTerminal . setTerminalWiringMethod ( " 0 " ) ;
}
if ( DicDataEnum . STAR_TRIANGLE . getCode ( ) . equals ( data . getCode ( ) ) ) {
if ( DicDataEnum . STAR_TRIANGLE . getCode ( ) . equals ( data . getCode ( ) ) ) {
monitorTerminal . setTerminalWiringMethod ( " 1 " ) ;
}
if ( DicDataEnum . OPEN_DELTA . getCode ( ) . equals ( data . getCode ( ) ) ) {
if ( DicDataEnum . OPEN_DELTA . getCode ( ) . equals ( data . getCode ( ) ) ) {
monitorTerminal . setTerminalWiringMethod ( " 2 " ) ;
} else {
} else {
monitorTerminal . setTerminalWiringMethod ( " -1 " ) ;
}
return monitorTerminal ;
@@ -350,7 +361,7 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
public List < DeptGetChildrenDTO > deptMonitor ( DeptGetLineParam param ) {
//返回主网和配网监测信息
List < DeptGetChildrenDTO > deviceInfos = new ArrayList < > ( ) ;
List < DeptDTO > deptInfos = deptFeignClient . getDeptDescendantIndexes ( param . getDeptId ( ) , Stream . of ( 0 , 1 ) . collect ( Collectors . toList ( ) ) ) . getData ( ) ;
List < DeptDTO > deptInfos = deptFeignClient . getDeptDescendantIndexes ( param . getDeptId ( ) , Stream . of ( 0 , 1 ) . collect ( Collectors . toList ( ) ) ) . getData ( ) ;
List < DeptDTO > directDeptInfos = deptInfos . stream ( )
. filter ( deptDTO - > deptDTO . getPid ( ) . equals ( param . getDeptId ( ) ) )
. collect ( Collectors . toList ( ) ) ;
@@ -360,7 +371,7 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
. filter ( deptDTO - > deptDTO . getId ( ) . equals ( param . getDeptId ( ) ) )
. collect ( Collectors . toList ( ) ) ;
deviceInfos . add ( getPmsMonitor ( dept . get ( 0 ) , Collections . singletonList ( dept . get ( 0 ) . getCode ( ) ) ) ) ;
} else {
} else {
for ( DeptDTO deptDTO : directDeptInfos ) {
//筛选上级部门pids包含该id的所有部门
List < DeptDTO > descendantDeptDTO = deptInfos . stream ( )
@@ -379,12 +390,13 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
}
@Override
public void importOracleLedgerToMysql ( MultipartFile file , HttpServletResponse response ) {
/* ImportParams importParams = new ImportParams();
public boolean importOracleLedgerToMysql ( MultipartFile file , HttpServletResponse response ) {
ImportParams importParams = new ImportParams( ) ;
importParams . setHeadRows ( 1 ) ;
importParams . setTitleRows ( 1 ) ;
importParams . setNeedVerify ( true ) ;
try {
ExcelImportResult < OracleTerminalExcel > terminalExcelExcelImportResult = ExcelImportUtil . importExcelMore ( file . getInputStream ( ) , OracleTerminalExcel . class , importParams ) ;
@@ -393,28 +405,19 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
PoiUtil . exportFileByWorkbook ( terminalExcelExcelImportResult . getFailWorkbook ( ) , " 非法台账信息.xlsx " , response ) ;
} else {
//执行台账信息导入(不考虑,存在监测点却不存在限值信息)
dealData ( terminalExcelExcelImportResult . getList ( ) ) ;
}
} catch ( Exception e ) {
e . printStackTrace ( ) ;
throw new BusinessException ( DeviceResponseEnum . IMPORT_ORACLE_EXCEPTION ) ;
}*/
}
return true ;
}
/*private void dealData(List<OracleTerminalExcel> oracleTerminalExcelList){
List<DeptDTO> allDept = deptFeignClient.getDeptDescendantIndexes(deptFeignClient.getRootDept().getData().getId(),Stream.of(0,1,2).collect(Collectors.toList())).getData();
Map<String, DeptDTO> mapDept = allDept.stream().collect(Collectors.toMap(DeptDTO::getName,Function.identity()));
for(OracleTerminalExcel oracleTerminalExcel : oracleTerminalExcelList){
//单位
if(oracleTerminalExcel.get)
//电站
}
}*/
/**
* 获取主配网监测点id集合
*
* @param deptDTO
* @param deptIdList
* @return
@@ -428,15 +431,15 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
pmsDeptGetChildrenDTO . setDeptName ( deptDTO . getName ( ) ) ;
}
pmsDeptGetChildrenDTO . setDeptChildren ( deptIdList ) ;
if ( CollUtil . isNotEmpty ( deptIdList ) ) {
if ( CollUtil . isNotEmpty ( deptIdList ) ) {
//主网监测点
List < Monitor > monitorList = this . list ( new LambdaQueryWrapper < Monitor > ( ) . in ( CollUtil . isNotEmpty ( deptIdList ) , Monitor : : getOrgId , deptIdList ) ) ;
List < Monitor > monitorList = this . list ( new LambdaQueryWrapper < Monitor > ( ) . in ( CollUtil . isNotEmpty ( deptIdList ) , Monitor : : getOrgId , deptIdList ) ) ;
//配网监测点
List < PmsMonitorBaseDTO > pwMonitorList = iDistributionMonitorService . getMonitorByCondition ( deptIdList , null ) ;
List < PmsMonitorBaseDTO > pwMonitorList = iDistributionMonitorService . getMonitorByCondition ( deptIdList , null ) ;
pmsDeptGetChildrenDTO . setLineIds ( monitorList . stream ( ) . map ( Monitor : : getId ) . distinct ( ) . collect ( Collectors . toList ( ) ) ) ;
pmsDeptGetChildrenDTO . setPwMonitorIds ( pwMonitorList . stream ( ) . map ( PmsMonitorBaseDTO : : getMonitorId ) . distinct ( ) . collect ( Collectors . toList ( ) ) ) ;
} else {
} else {
pmsDeptGetChildrenDTO . setLineIds ( new ArrayList < > ( ) ) ;
pmsDeptGetChildrenDTO . setPwMonitorIds ( new ArrayList < > ( ) ) ;
}
@@ -534,29 +537,389 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
/**
* 监测点限值计算
*/
public Overlimit overLimitCal ( MonitorParam monitorParam , Monitor monitor ) {
public Overlimit overLimitCal ( MonitorParam monitorParam , Monitor monitor ) {
//主网测点限值计算
DictData dictData = dicDataFeignClient . getDicDataById ( monitor . getVoltageLevel ( ) ) . getData ( ) ;
float voltageLevel = Float . parseFloat ( dictData . getValue ( ) ) ;
Overlimit overlimit = COverlimitUtil . globalAssemble ( voltageLevel , monitor . getUserAgreementCapacity ( ) , monitor . getPowerSupplyEqCapacity ( ) , monitor . getMinShortCircuitCapacity ( ) , 1 , 0 ) ;
if ( Objects . nonNull ( monitorParam . getVoltageDeviationUpperLimit ( ) ) ) {
Overlimit overlimit = COverlimitUtil . globalAssemble ( voltageLevel , monitor . getUserAgreementCapacity ( ) , monitor . getPowerSupplyEqCapacity ( ) , monitor . getMinShortCircuitCapacity ( ) , 1 , 0 ) ;
if ( Objects . nonNull ( monitorParam . getVoltageDeviationUpperLimit ( ) ) ) {
monitor . setVoltageDeviationUpperLimit ( monitorParam . getVoltageDeviationUpperLimit ( ) ) ;
overlimit . setVoltageDev ( monitorParam . getVoltageDeviationUpperLimit ( ) ) ;
} else {
} else {
monitor . setVoltageDeviationUpperLimit ( overlimit . getVoltageDev ( ) ) ;
}
if ( Objects . nonNull ( monitorParam . getVoltageDeviationLowerLimit ( ) ) ) {
if ( Objects . nonNull ( monitorParam . getVoltageDeviationLowerLimit ( ) ) ) {
monitor . setVoltageDeviationLowerLimit ( monitorParam . getVoltageDeviationLowerLimit ( ) ) ;
overlimit . setUvoltageDev ( monitorParam . getVoltageDeviationLowerLimit ( ) ) ;
} else {
} else {
monitor . setVoltageDeviationLowerLimit ( overlimit . getUvoltageDev ( ) ) ;
}
return overlimit ;
}
private String dealData ( List < OracleTerminalExcel > oracleTerminalExcelList ) {
List < OracleTerminalExcel . OracleTerminalExcelMsg > oracleTerminalExcelMsg = new ArrayList < > ( ) ;
List < DeptDTO > allDept = deptFeignClient . getDeptDescendantIndexes ( deptFeignClient . getRootDept ( ) . getData ( ) . getId ( ) , Stream . of ( 0 , 1 , 2 ) . collect ( Collectors . toList ( ) ) ) . getData ( ) ;
Map < String , DeptDTO > mapDept = allDept . stream ( ) . collect ( Collectors . toMap ( DeptDTO : : getName , Function . identity ( ) ) ) ;
List < DictData > voltageLevelDic = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . DEV_VOLTAGE . getCode ( ) ) . getData ( ) ;
Map < String , DictData > voltageLevelMap = voltageLevelDic . stream ( ) . collect ( Collectors . toMap ( DictData : : getName , Function . identity ( ) ) ) ;
//装置型号
List < DictData > devTypelDic = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . DEV_TYPE . getCode ( ) ) . getData ( ) ;
Map < String , DictData > devTypelDicMap = devTypelDic . stream ( ) . collect ( Collectors . toMap ( DictData : : getName , Function . identity ( ) ) ) ;
//装置类别
DictData devCategoryDic = dicDataFeignClient . getDicDataByNameAndTypeName ( DicDataTypeEnum . DEV_CATEGORY . getName ( ) , DicDataEnum . Monitor_Terminals . getName ( ) ) . getData ( ) ;
//装置状态
List < DictData > devStatelDic = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . DEV_STATUS . getCode ( ) ) . getData ( ) ;
Map < String , DictData > devStateDicMap = devStatelDic . stream ( ) . collect ( Collectors . toMap ( DictData : : getName , Function . identity ( ) ) ) ;
//监测点状态
List < DictData > monitorStatelDic = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . LINE_STATE . getCode ( ) ) . getData ( ) ;
Map < String , DictData > monitorStateDicMap = monitorStatelDic . stream ( ) . collect ( Collectors . toMap ( DictData : : getName , Function . identity ( ) ) ) ;
//检测点对象类型(原监测点标签)
List < DictData > objTypeList = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . MONITORING_LABELS . getCode ( ) ) . getData ( ) ;
Map < String , DictData > objTypeDicMap = objTypeList . stream ( ) . collect ( Collectors . toMap ( DictData : : getName , Function . identity ( ) ) ) ;
//装置厂家
List < DictData > manList = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . DEV_MANUFACTURER . getCode ( ) ) . getData ( ) ;
Map < String , DictData > manDicMap = manList . stream ( ) . collect ( Collectors . toMap ( DictData : : getName , Function . identity ( ) ) ) ;
for ( OracleTerminalExcel oracleTerminalExcel : oracleTerminalExcelList ) {
//单位
if ( ! mapDept . containsKey ( oracleTerminalExcel . getGdName ( ) ) ) {
oracleTerminalExcelMsg . add ( assembleMsg ( oracleTerminalExcel , " 单位名称不存在,请确认单位名称是否正确 " ) ) ;
continue ;
}
//判断是否操作过该条记录
LineBak lineBak = lineBakMapper . selectById ( oracleTerminalExcel . getId ( ) ) ;
if ( Objects . nonNull ( lineBak ) ) {
//不为空默认已经存在监测点,提示先删除对应监测点
oracleTerminalExcelMsg . add ( assembleMsg ( oracleTerminalExcel , " mysql库中已经存在该监测点, 请先删除监测点 " ) ) ;
continue ;
}
//单位
DeptDTO deptDTO = mapDept . get ( oracleTerminalExcel . getGdName ( ) ) ;
//电站
String stationId = null , stationName = null ;
LambdaQueryWrapper < StatationStat > statLambdaQueryWrapper = new LambdaQueryWrapper < > ( ) ;
statLambdaQueryWrapper . eq ( StatationStat : : getPowerName , oracleTerminalExcel . getSubstationName ( ) )
. eq ( StatationStat : : getOrgId , deptDTO . getCode ( ) ) ;
StatationStat statationStat = statationStatMapper . selectOne ( statLambdaQueryWrapper ) ;
if ( Objects . isNull ( statationStat ) ) {
StatationStat statationStatPO = new StatationStat ( ) ;
statationStatPO . setOrgId ( deptDTO . getCode ( ) ) ;
statationStatPO . setOrgName ( deptDTO . getName ( ) ) ;
statationStatPO . setPowerName ( oracleTerminalExcel . getSubstationName ( ) ) ;
statationStatPO . setLongitude ( oracleTerminalExcel . getLng ( ) . doubleValue ( ) ) ;
statationStatPO . setLatitude ( oracleTerminalExcel . getLat ( ) . doubleValue ( ) ) ;
statationStatPO . setShouldBeNum ( 100 ) ;
statationStatPO . setStatus ( DataStateEnum . ENABLE . getCode ( ) ) ;
String dicVoltage = dealVoltageLevel ( oracleTerminalExcel . getSubStationScale ( ) ) ;
if ( voltageLevelMap . containsKey ( dicVoltage ) ) {
statationStatPO . setVoltageLevel ( voltageLevelMap . get ( dicVoltage ) . getId ( ) ) ;
} else {
oracleTerminalExcelMsg . add ( assembleMsg ( oracleTerminalExcel , " 变电站电压等级不存在,请确认电压等级存在 " ) ) ;
continue ;
}
statationStatMapper . insert ( statationStatPO ) ;
stationId = statationStatPO . getPowerId ( ) ;
stationName = statationStatPO . getPowerName ( ) ;
} else {
stationId = statationStat . getPowerId ( ) ;
stationName = statationStat . getPowerName ( ) ;
}
//装置
String devId = null ;
LambdaQueryWrapper < PmsTerminal > terminalLambdaQueryWrapper = new LambdaQueryWrapper < > ( ) ;
terminalLambdaQueryWrapper . eq ( PmsTerminal : : getName , oracleTerminalExcel . getDeviceName ( ) )
. eq ( PmsTerminal : : getPowerStationId , stationId ) ;
PmsTerminal pmsTerminal = terminalMapper . selectOne ( terminalLambdaQueryWrapper ) ;
if ( Objects . isNull ( pmsTerminal ) ) {
PmsTerminal pmsTerminalPO = new PmsTerminal ( ) ;
pmsTerminalPO . setOrgId ( deptDTO . getCode ( ) ) ;
pmsTerminalPO . setOrgName ( deptDTO . getName ( ) ) ;
pmsTerminalPO . setName ( oracleTerminalExcel . getDeviceName ( ) ) ;
pmsTerminalPO . setOperationId ( deptDTO . getCode ( ) ) ;
pmsTerminalPO . setOperationName ( deptDTO . getName ( ) ) ;
pmsTerminalPO . setPowerrName ( stationName ) ;
pmsTerminalPO . setPowerStationId ( stationId ) ;
pmsTerminalPO . setIp ( oracleTerminalExcel . getIp ( ) ) ;
pmsTerminalPO . setUseDate ( oracleTerminalExcel . getLoginTime ( ) ) ;
pmsTerminalPO . setVerificationDate ( oracleTerminalExcel . getThisTimeCheck ( ) ) ;
pmsTerminalPO . setDeviceCategory ( devCategoryDic . getId ( ) ) ;
if ( devTypelDicMap . containsKey ( oracleTerminalExcel . getDevType ( ) ) ) {
pmsTerminalPO . setDeviceModel ( devTypelDicMap . get ( oracleTerminalExcel . getDevType ( ) ) . getId ( ) ) ;
} else {
oracleTerminalExcelMsg . add ( assembleMsg ( oracleTerminalExcel , " 装置类型不存在,请确认后重试 " ) ) ;
continue ;
}
//终端状态
if ( devTypelDicMap . containsKey ( oracleTerminalExcel . getDevType ( ) ) ) {
pmsTerminalPO . setDeviceModel ( devTypelDicMap . get ( oracleTerminalExcel . getDevType ( ) ) . getId ( ) ) ;
} else {
oracleTerminalExcelMsg . add ( assembleMsg ( oracleTerminalExcel , " 字典装置类型不存在,请确认后重试 " ) ) ;
continue ;
}
String devState = null ;
switch ( oracleTerminalExcel . getRunFlag ( ) ) {
case 0 :
devState = DicDataEnum . RUNNING . getName ( ) ;
break ;
case 1 :
devState = DicDataEnum . NOT_OPERATION . getName ( ) ;
break ;
case 2 :
devState = DicDataEnum . RETIRE . getName ( ) ;
break ;
}
if ( devStateDicMap . containsKey ( devState ) ) {
pmsTerminalPO . setTerminalState ( devTypelDicMap . get ( oracleTerminalExcel . getDevType ( ) ) . getId ( ) ) ;
} else {
oracleTerminalExcelMsg . add ( assembleMsg ( oracleTerminalExcel , " 字典装置运行状态不存在,请确认后重试 " ) ) ;
continue ;
}
DictData devGrade = dicDataFeignClient . getDicDataByNameAndTypeName ( DicDataTypeEnum . DEV_GRADE . getName ( ) , DicDataEnum . MOST_IMPORMENT . getName ( ) ) . getData ( ) ;
pmsTerminalPO . setTerminalLevel ( devGrade . getId ( ) ) ;
DictData devInputType = dicDataFeignClient . getDicDataByNameAndTypeName ( DicDataTypeEnum . INPUT_SIGNAL . getName ( ) , DicDataEnum . SIMULATION_SIGNAL . getName ( ) ) . getData ( ) ;
pmsTerminalPO . setInputType ( devInputType . getId ( ) ) ;
pmsTerminalPO . setStatus ( DataStateEnum . ENABLE . getCode ( ) ) ;
pmsTerminalPO . setPort ( oracleTerminalExcel . getPort ( ) . toString ( ) ) ;
pmsTerminalPO . setIsUpToGrid ( 0 ) ;
if ( manDicMap . containsKey ( oracleTerminalExcel . getManufacturer ( ) ) ) {
pmsTerminalPO . setManufacture ( manDicMap . get ( oracleTerminalExcel . getManufacturer ( ) ) . getId ( ) ) ;
} else {
oracleTerminalExcelMsg . add ( assembleMsg ( oracleTerminalExcel , " 字典制造厂商不存在,请确认后重试 " ) ) ;
continue ;
}
terminalMapper . insert ( pmsTerminalPO ) ;
devId = pmsTerminalPO . getId ( ) ;
} else {
devId = pmsTerminal . getId ( ) ;
}
//线路
LambdaQueryWrapper < GeneratrixWire > generatrixWireLambdaQueryWrapper = new LambdaQueryWrapper < > ( ) ;
generatrixWireLambdaQueryWrapper . eq ( GeneratrixWire : : getName , oracleTerminalExcel . getSubvName ( ) )
. eq ( GeneratrixWire : : getStationId , stationId ) ;
GeneratrixWire generatrixWire = generatrixWireMapper . selectOne ( generatrixWireLambdaQueryWrapper ) ;
String lineId = null , lineName = null , genScale = null ;
if ( Objects . isNull ( generatrixWire ) ) {
GeneratrixWire generatrixWirePO = new GeneratrixWire ( ) ;
generatrixWirePO . setGeneratrixName ( oracleTerminalExcel . getSubvName ( ) ) ;
generatrixWirePO . setStatus ( DataStateEnum . ENABLE . getCode ( ) ) ;
generatrixWirePO . setName ( oracleTerminalExcel . getSubvName ( ) ) ;
generatrixWirePO . setOrgId ( deptDTO . getCode ( ) ) ;
generatrixWirePO . setStationId ( stationId ) ;
generatrixWirePO . setStationName ( stationName ) ;
String dicVoltage = dealVoltageLevel ( oracleTerminalExcel . getSubvScale ( ) ) ;
if ( voltageLevelMap . containsKey ( dicVoltage ) ) {
DictData temVoltage = voltageLevelMap . get ( dicVoltage ) ;
generatrixWirePO . setScale ( temVoltage . getId ( ) ) ;
}
generatrixWireMapper . insert ( generatrixWirePO ) ;
lineId = generatrixWirePO . getId ( ) ;
lineName = generatrixWirePO . getName ( ) ;
genScale = generatrixWirePO . getScale ( ) ;
} else {
lineId = generatrixWire . getId ( ) ;
lineName = generatrixWire . getName ( ) ;
genScale = generatrixWire . getScale ( ) ;
}
//监测点
LambdaQueryWrapper < Monitor > monitorLambdaQueryWrapper = new LambdaQueryWrapper < > ( ) ;
monitorLambdaQueryWrapper . eq ( Monitor : : getPowerrId , stationId )
. eq ( Monitor : : getName , oracleTerminalExcel . getLineName ( ) ) ;
Monitor monitor = monitorMapper . selectOne ( monitorLambdaQueryWrapper ) ;
if ( Objects . isNull ( monitor ) ) {
//当前电站下面没有监测点,可以新增
Monitor monitorPO = new Monitor ( ) ;
monitorPO . setName ( oracleTerminalExcel . getLineName ( ) ) ;
monitorPO . setPowerrName ( stationName ) ;
monitorPO . setPowerrId ( stationId ) ;
monitorPO . setOperationName ( deptDTO . getName ( ) ) ;
monitorPO . setOperationId ( deptDTO . getCode ( ) ) ;
monitorPO . setOrgName ( deptDTO . getName ( ) ) ;
monitorPO . setOrgId ( deptDTO . getCode ( ) ) ;
monitorPO . setLineName ( lineName ) ;
monitorPO . setLineId ( lineId ) ;
monitorPO . setVoltageLevel ( genScale ) ;
String monitorState = null ;
switch ( oracleTerminalExcel . getRunFlag ( ) ) {
case 0 :
monitorState = DicDataEnum . RUN . getName ( ) ;
break ;
case 1 :
monitorState = DicDataEnum . DEBUGGING . getName ( ) ;
break ;
case 2 :
monitorState = DicDataEnum . DECOMMISSIONING . getName ( ) ;
break ;
default :
oracleTerminalExcelMsg . add ( assembleMsg ( oracleTerminalExcel , " 字典监测点状态不存在,请确认后重试 " ) ) ;
break ;
}
if ( monitorStateDicMap . containsKey ( monitorState ) ) {
monitorPO . setMonitorState ( monitorStateDicMap . get ( monitorState ) . getId ( ) ) ;
} else {
oracleTerminalExcelMsg . add ( assembleMsg ( oracleTerminalExcel , " 字典监测点运行状态不存在,请确认后重试 " ) ) ;
continue ;
}
DictData monitorType = dicDataFeignClient . getDicDataByNameAndTypeName ( DicDataTypeEnum . LINE_TYPE . getName ( ) , DicDataEnum . Power_Supply_Point . getName ( ) ) . getData ( ) ;
monitorPO . setMonitorType ( monitorType . getId ( ) ) ;
monitorPO . setStandShortCapacity ( oracleTerminalExcel . getStandardCapacity ( ) ) ;
monitorPO . setMinShortCircuitCapacity ( oracleTerminalExcel . getShortCapacity ( ) ) ;
monitorPO . setUserAgreementCapacity ( oracleTerminalExcel . getDealCapacity ( ) ) ;
monitorPO . setPowerSupplyEqCapacity ( oracleTerminalExcel . getDevCapacity ( ) ) ;
DictData scale = dicDataFeignClient . getDicDataById ( monitorPO . getVoltageLevel ( ) ) . getData ( ) ;
Overlimit overlimitTem = new Overlimit ( ) ;
COverlimitUtil . voltageDeviation ( overlimitTem , Float . parseFloat ( scale . getValue ( ) ) ) ;
monitorPO . setVoltageDeviationLowerLimit ( overlimitTem . getVoltageDev ( ) ) ;
monitorPO . setVoltageDeviationUpperLimit ( overlimitTem . getUvoltageDev ( ) ) ;
DictData potentialDic = dicDataFeignClient . getDicDataByNameAndTypeName ( DicDataTypeEnum . VOLTAGE_TRANSFORMER . getName ( ) , DicDataEnum . Cap_V . getName ( ) ) . getData ( ) ;
monitorPO . setPotentialTransFormerType ( potentialDic . getId ( ) ) ;
DictData neutralDic = dicDataFeignClient . getDicDataByNameAndTypeName ( DicDataTypeEnum . Neutral_Point . getName ( ) , DicDataEnum . Ground_Res . getName ( ) ) . getData ( ) ;
monitorPO . setNeutralGroundingMode ( neutralDic . getId ( ) ) ;
monitorPO . setIsSpecialSupplyElectricity ( 0 ) ;
if ( objTypeDicMap . containsKey ( oracleTerminalExcel . getLoadType ( ) ) ) {
String objTypeId = objTypeDicMap . get ( oracleTerminalExcel . getLoadType ( ) ) . getId ( ) ;
monitorPO . setMonitorTag ( objTypeId ) ;
monitorPO . setMonitorObjectType ( objTypeId ) ;
} else {
oracleTerminalExcelMsg . add ( assembleMsg ( oracleTerminalExcel , " 字典监测对象类型不存在,请确认后重试 " ) ) ;
continue ;
}
monitorPO . setStatisticalInterval ( oracleTerminalExcel . getTimeInterval ( ) ) ;
monitorPO . setTerminalId ( devId ) ;
//接线方式
List < DictData > wireList = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . DEV_CONNECT . getCode ( ) ) . getData ( ) ;
Map < String , DictData > wireListMap = wireList . stream ( ) . collect ( Collectors . toMap ( DictData : : getName , Function . identity ( ) ) ) ;
String wireMethod = " " ;
switch ( oracleTerminalExcel . getPtType ( ) ) {
case 0 :
wireMethod = DicDataEnum . STAR . getName ( ) ;
break ;
case 1 :
wireMethod = DicDataEnum . STAR_TRIANGLE . getName ( ) ;
break ;
case 2 :
wireMethod = DicDataEnum . OPEN_DELTA . getName ( ) ;
break ;
default :
oracleTerminalExcelMsg . add ( assembleMsg ( oracleTerminalExcel , " 字典接线方式不存在,请确认后重试 " ) ) ;
break ;
}
if ( wireListMap . containsKey ( wireMethod ) ) {
monitorPO . setTerminalWiringMethod ( wireListMap . get ( wireMethod ) . getId ( ) ) ;
} else {
oracleTerminalExcelMsg . add ( assembleMsg ( oracleTerminalExcel , " 字典接线方式不存在,请确认后重试 " ) ) ;
continue ;
}
monitorPO . setIsUpToGrid ( 0 ) ;
monitorPO . setStatus ( DataStateEnum . ENABLE . getCode ( ) ) ;
monitorPO . setIsSpecialMonitor ( 0 ) ;
monitorPO . setPt1 ( oracleTerminalExcel . getPt1 ( ) ) ;
monitorPO . setPt2 ( oracleTerminalExcel . getPt2 ( ) ) ;
monitorPO . setCt1 ( oracleTerminalExcel . getCt1 ( ) ) ;
monitorPO . setCt2 ( oracleTerminalExcel . getCt2 ( ) ) ;
monitorMapper . insert ( monitorPO ) ;
Overlimit overlimit = COverlimitUtil . globalAssemble ( Float . parseFloat ( scale . getValue ( ) ) , oracleTerminalExcel . getDealCapacity ( ) , oracleTerminalExcel . getDevCapacity ( ) , oracleTerminalExcel . getShortCapacity ( ) , 0 , 0 ) ;
overlimit . setId ( monitorPO . getId ( ) ) ;
Overlimit overlimitRes = overlimitMapper . selectById ( monitorPO . getId ( ) ) ;
if ( Objects . isNull ( overlimitRes ) ) {
overlimitMapper . insert ( overlimit ) ;
} else {
overlimitMapper . updateById ( overlimit ) ;
}
LineBak lineBakPO = new LineBak ( ) ;
lineBakPO . setId ( monitorPO . getId ( ) ) ;
lineBakPO . setLineId ( oracleTerminalExcel . getId ( ) ) ;
lineBakMapper . insert ( lineBakPO ) ;
}
}
if ( CollectionUtil . isNotEmpty ( oracleTerminalExcelMsg ) ) {
ExcelUtil . exportExcel ( " 失败列表.xlsx " , OracleTerminalExcel . OracleTerminalExcelMsg . class , oracleTerminalExcelMsg ) ;
return null ;
}
return CommonResponseEnum . SUCCESS . getMessage ( ) ;
}
private String dealVoltageLevel ( String voltage ) {
int scale = Integer . parseInt ( voltage . substring ( 0 , voltage . indexOf ( " kV " ) ) ) ;
if ( scale < 500 ) {
return " 交流 " + voltage ;
} else {
return " 直流 " + voltage ;
}
}
/**
* 组装不能正常插入的记录,稍后导出给用户
*
* @param oracleTerminalExcel 记录信息
* @param msg 错误信息
*/
private OracleTerminalExcel . OracleTerminalExcelMsg assembleMsg ( OracleTerminalExcel oracleTerminalExcel , String msg ) {
OracleTerminalExcel . OracleTerminalExcelMsg oracleTerminalExcelMsg = new OracleTerminalExcel . OracleTerminalExcelMsg ( ) ;
BeanUtils . copyProperties ( oracleTerminalExcel , oracleTerminalExcelMsg ) ;
oracleTerminalExcelMsg . setMsg ( msg ) ;
return oracleTerminalExcelMsg ;
}
}