@@ -1,5 +1,9 @@
package com.njcn.supervision.service.device.impl ;
import cn.afterturn.easypoi.excel.ExcelImportUtil ;
import cn.afterturn.easypoi.excel.entity.ExportParams ;
import cn.afterturn.easypoi.excel.entity.ImportParams ;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult ;
import cn.hutool.core.collection.CollectionUtil ;
import cn.hutool.core.date.DateUtil ;
import cn.hutool.core.text.StrPool ;
@@ -16,10 +20,19 @@ import com.njcn.bpm.pojo.dto.BpmProcessInstanceCreateReqDTO;
import com.njcn.bpm.pojo.param.instance.BpmProcessInstanceCancelParam ;
import com.njcn.common.pojo.enums.common.DataStateEnum ;
import com.njcn.common.pojo.exception.BusinessException ;
import com.njcn.device.pms.utils.PubUtil ;
import com.njcn.device.pq.api.LineFeignClient ;
import com.njcn.device.pq.api.NodeClient ;
import com.njcn.device.pq.pojo.po.Node ;
import com.njcn.poi.excel.ExcelUtil ;
import com.njcn.poi.excel.PullDown ;
import com.njcn.poi.util.PoiUtil ;
import com.njcn.supervision.enums.FlowStatusEnum ;
import com.njcn.supervision.enums.SupervisionKeyEnum ;
import com.njcn.supervision.enums.SupervisionResponseEnum ;
import com.njcn.supervision.mapper.device.SupervisionDevMainReportPOMapper ;
import com.njcn.supervision.pojo.dto.SensitiveUserSExcel ;
import com.njcn.supervision.pojo.dto.SupervisionDevMainReportExcel ;
import com.njcn.supervision.pojo.param.device.SupervisionDevMainReportParam ;
import com.njcn.supervision.pojo.param.device.SupervisionTempDeviceReportParam ;
import com.njcn.supervision.pojo.po.device.SupervisionDevMainReportPO ;
@@ -28,22 +41,30 @@ import com.njcn.supervision.pojo.vo.device.SupervisionDevMainReportVO;
import com.njcn.supervision.service.device.SupervisionDevMainReportPOService ;
import com.njcn.supervision.service.device.SupervisionTempDeviceReportService ;
import com.njcn.supervision.utils.InstanceUtil ;
import com.njcn.system.api.DicDataFeignClient ;
import com.njcn.system.enums.DicDataTypeEnum ;
import com.njcn.system.pojo.po.DictData ;
import com.njcn.user.api.DeptFeignClient ;
import com.njcn.user.api.UserFeignClient ;
import com.njcn.user.pojo.dto.DeptDTO ;
import com.njcn.user.pojo.vo.UserVO ;
import com.njcn.web.factory.PageFactory ;
import com.njcn.web.utils.RequestUtil ;
import com.njcn.web.utils.WebUtil ;
import lombok.RequiredArgsConstructor ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.beans.BeanUtils ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.web.multipart.MultipartFile ;
import javax.servlet.http.HttpServletResponse ;
import java.time.LocalDate ;
import java.util.* ;
import java.util.stream.Collectors ;
import java.util.stream.Stream ;
/**
*
* Description:
* Date: 2024/5/10 18:10【需求编号】
*
@@ -55,12 +76,13 @@ import java.util.stream.Collectors;
public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl < SupervisionDevMainReportPOMapper , SupervisionDevMainReportPO > implements SupervisionDevMainReportPOService {
private final BpmProcessFeignClient bpmProcessFeignClient ;
private final SupervisionTempDeviceReportService supervisionTempDeviceReportService ;
private final DeptFeignClient deptFeignClient ;
private final UserFeignClient userFeignClient ;
private final LineFeignClient lineFeignClient ;
private final DicDataFeignClient dicDataFeignClient ;
private final NodeClient nodeClient ;
@Override
@Transactional ( rollbackFor = Exception . class )
@@ -68,12 +90,11 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
SupervisionDevMainReportPO supervisionDevMainReportPO = new SupervisionDevMainReportPO ( ) ;
BeanUtils . copyProperties ( supervisionDevMainReportParam , supervisionDevMainReportPO ) ;
if ( Objects . equals ( supervisionDevMainReportParam . getSaveOrCheckflag ( ) , " 2 " ) ) {
if ( StringUtils . isEmpty ( supervisionDevMainReportParam . getId ( ) ) ) {
if ( Objects . equals ( supervisionDevMainReportParam . getSaveOrCheckflag ( ) , " 2 " ) ) {
if ( StringUtils . isEmpty ( supervisionDevMainReportParam . getId ( ) ) ) {
//设备校验ip
checkIp ( supervisionDevMainReportParam , false ) ;
} else {
} else {
//设备校验ip
checkIp ( supervisionDevMainReportParam , true ) ;
@@ -81,10 +102,10 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
}
//设置状态
if ( Objects . equals ( supervisionDevMainReportParam . getSaveOrCheckflag ( ) , " 1 " ) ) {
if ( Objects . equals ( supervisionDevMainReportParam . getSaveOrCheckflag ( ) , " 1 " ) ) {
supervisionDevMainReportPO . setStatus ( BpmTaskStatusEnum . WAIT . getStatus ( ) ) ;
} else {
} else {
supervisionDevMainReportPO . setStatus ( BpmTaskStatusEnum . RUNNING . getStatus ( ) ) ;
}
@@ -110,7 +131,7 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
// supervisionTempLineReportService.save(supervisionTempLineReport);
// 发起 BPM 流程
// 如何未提交审则不需要发起 BPM 流程
if ( Objects . equals ( supervisionDevMainReportParam . getSaveOrCheckflag ( ) , " 2 " ) ) {
if ( Objects . equals ( supervisionDevMainReportParam . getSaveOrCheckflag ( ) , " 2 " ) ) {
Map < String , Object > processInstanceVariables = new HashMap < > ( ) ;
BpmProcessInstanceCreateReqDTO bpmProcessInstanceCreateReqDTO = new BpmProcessInstanceCreateReqDTO ( ) ;
bpmProcessInstanceCreateReqDTO . setProcessDefinitionKey ( SupervisionKeyEnum . DEVICE_INFO_ADD . getKey ( ) ) ;
@@ -129,10 +150,10 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
public String updateDevReport ( SupervisionDevMainReportParam . SupervisionDevMainReportParamUpdate supervisionDevMainReportParam ) {
SupervisionDevMainReportPO supervisionDevMainReportPO = this . baseMapper . selectById ( supervisionDevMainReportParam . getId ( ) ) ;
//判断是否有权限操作
InstanceUtil . judgeUserPower ( RequestUtil . getUserIndex ( ) , supervisionDevMainReportPO . getCreateBy ( ) ) ;
InstanceUtil . judgeUserPower ( RequestUtil . getUserIndex ( ) , supervisionDevMainReportPO . getCreateBy ( ) ) ;
supervisionDevMainReportParam . setProcessInstanceId ( supervisionDevMainReportPO . getProcessInstanceId ( ) ) ;
supervisionDevMainReportParam . setHistoryInstanceId ( supervisionDevMainReportPO . getHistoryInstanceId ( ) ) ;
BeanUtils . copyProperties ( supervisionDevMainReportParam , supervisionDevMainReportPO ) ;
BeanUtils . copyProperties ( supervisionDevMainReportParam , supervisionDevMainReportPO ) ;
supervisionDevMainReportPO . setStatus ( BpmTaskStatusEnum . RUNNING . getStatus ( ) ) ;
supervisionDevMainReportPO . setState ( DataStateEnum . ENABLE . getCode ( ) ) ;
//处理历史流程id列表
@@ -154,8 +175,6 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
}
@Override
public boolean auditDevReport ( SupervisionDevMainReportParam . SupervisionDevMainReportParamUpdate supervisionDevMainReportParamUpdate ) {
return true ;
@@ -183,13 +202,13 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
queryWrapper . eq ( " supervision_dev_main_report.status " , supervisionDevMainReportQuery . getStatus ( ) ) ;
}
if ( StrUtil . isNotBlank ( supervisionDevMainReportQuery . getSearchValue ( ) ) ) {
queryWrapper . and ( x - > x
queryWrapper . and ( x - > x
. like ( " dev.substation_name " , supervisionDevMainReportQuery . getSearchValue ( ) )
. or ( )
. like ( " dev.monitoring_terminal_code " , supervisionDevMainReportQuery . getSearchValue ( ) )
. or ( )
. like ( " dev.monitoring_terminal_name " , supervisionDevMainReportQuery . getSearchValue ( ) )
) ;
) ;
}
//添加上时间范围
queryWrapper . between ( " supervision_dev_main_report.Create_Time " ,
@@ -197,7 +216,7 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
DateUtil . endOfDay ( DateUtil . parse ( supervisionDevMainReportQuery . getSearchEndTime ( ) ) ) ) ;
queryWrapper . orderByDesc ( " supervision_dev_main_report.Update_Time " ) ;
Page < SupervisionDevMainReportVO > page = this . baseMapper . page ( new Page < > ( PageFactory . getPageNum ( supervisionDevMainReportQuery ) , PageFactory . getPageSize ( supervisionDevMainReportQuery ) ) , queryWrapper ) ;
page . getRecords ( ) . stream ( ) . forEach ( temp - > {
page . getRecords ( ) . stream ( ) . forEach ( temp - > {
// temp.setOrgName((deptFeignClient.getDeptById(temp.getOrgId()).getData().getName()));
//处理特殊字段,用户名、部门名
UserVO userVO = userFeignClient . getUserById ( temp . getReporter ( ) ) . getData ( ) ;
@@ -209,7 +228,7 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
@Override
public void updateProcessStatus ( String businessKey , Integer status ) {
this . lambdaUpdate ( ) . set ( SupervisionDevMainReportPO : : getStatus , status ) . eq ( SupervisionDevMainReportPO : : getId , businessKey ) . update ( ) ;
this . lambdaUpdate ( ) . set ( SupervisionDevMainReportPO : : getStatus , status ) . eq ( SupervisionDevMainReportPO : : getId , businessKey ) . update ( ) ;
}
@Override
@@ -247,7 +266,7 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
. eq ( SupervisionDevMainReportPO : : getStatus , 2 )
. in ( CollectionUtil . isNotEmpty ( data ) , SupervisionDevMainReportPO : : getOrgId , data )
. list ( ) ;
if ( CollectionUtil . isNotEmpty ( list ) ) {
if ( CollectionUtil . isNotEmpty ( list ) ) {
List < String > collect = list . stream ( ) . map ( SupervisionDevMainReportPO : : getId ) . collect ( Collectors . toList ( ) ) ;
List < SupervisionTempDeviceReport > list1 = supervisionTempDeviceReportService . lambdaQuery ( ) . in ( SupervisionTempDeviceReport : : getId , collect ) . list ( ) ;
return list1 ;
@@ -260,30 +279,362 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
public SupervisionDevMainReportVO querySurveyDetail ( String id ) {
SupervisionDevMainReportVO supervisionDevMainReportVO = new SupervisionDevMainReportVO ( ) ;
SupervisionDevMainReportPO byId = this . getById ( id ) ;
BeanUtils . copyProperties ( byId , supervisionDevMainReportVO ) ;
BeanUtils . copyProperties ( byId , supervisionDevMainReportVO ) ;
UserVO userVO = userFeignClient . getUserById ( byId . getReporter ( ) ) . getData ( ) ;
supervisionDevMainReportVO . setReporter ( userVO . getName ( ) ) ;
supervisionDevMainReportVO . setOrgName ( deptFeignClient . getDeptById ( byId . getOrgId ( ) ) . getData ( ) . getName ( ) ) ;
SupervisionTempDeviceReport supervisionTempDeviceReport = supervisionTempDeviceReportService . lambdaQuery ( ) . eq ( SupervisionTempDeviceReport : : getId , id ) . one ( ) ;
// supervisionTempDeviceReport.setSubstation(lineFeignClient.getSubstationInfo(supervisionTempDeviceReport.getSubstation()).getData().getName());
if ( StringUtils . isNotEmpty ( supervisionTempDeviceReport . getPowerCompany ( ) ) ) {
supervisionTempDeviceReport . setPowerCompany ( deptFeignClient . getDeptById ( supervisionTempDeviceReport . getPowerCompany ( ) ) . getData ( ) . getName ( ) ) ;
if ( StringUtils . isNotEmpty ( supervisionTempDeviceReport . getPowerCompany ( ) ) ) {
supervisionTempDeviceReport . setPowerCompany ( deptFeignClient . getDeptById ( supervisionTempDeviceReport . getPowerCompany ( ) ) . getData ( ) . getName ( ) ) ;
}
supervisionDevMainReportVO . setSupervisionTempDeviceReport ( supervisionTempDeviceReport ) ;
return supervisionDevMainReportVO ;
}
@Override
public void downloadDevTemplate ( ) {
ExportParams exportParams = new ExportParams ( " 终端入网检测数据模板(带*字段均是必填,请严格按照模板标准填入数据) " , " 终端入网检测数据信息 " ) ;
//所属地市
List < DictData > jiBeiArea = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . JIBEI_AREA . getCode ( ) ) . getData ( ) ;
//所属供电公司 RequestUtil.getDeptIndex()
List < DeptDTO > depts = deptFeignClient . getDepSonDetailByDeptId ( " 0d52f9f6e43ec0ee83013cd32da93f66 " ) . getData ( ) ;
//终端型号
List < DictData > devType = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . DEV_TYPE . getCode ( ) ) . getData ( ) ;
//通讯类型
List < DictData > frontType = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . FRONT_TYPE . getCode ( ) ) . getData ( ) ;
//获取所有前置机
List < Node > nodes = nodeClient . nodeAllList ( ) . getData ( ) ;
//接线方式
List < DictData > devConnect = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . DEV_CONNECT . getCode ( ) ) . getData ( ) ;
//厂家
List < DictData > devManufacturer = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . DEV_MANUFACTURER . getCode ( ) ) . getData ( ) ;
//电压互感器类型
List < DictData > voltageTransformer = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . VOLTAGE_TRANSFORMER . getCode ( ) ) . getData ( ) ;
//中性点接线方式
List < DictData > neutralPoint = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . Neutral_Point . getCode ( ) ) . getData ( ) ;
List < PullDown > pullDowns = new ArrayList < > ( ) ;
PullDown pullDown ;
pullDown = new PullDown ( ) ;
pullDown . setFirstCol ( 1 ) ;
pullDown . setLastCol ( 1 ) ;
pullDown . setStrings ( jiBeiArea . stream ( ) . map ( DictData : : getName ) . distinct ( ) . collect ( Collectors . toList ( ) ) ) ;
pullDowns . add ( pullDown ) ;
//缺少变电站名称
// pullDown = new PullDown();
// pullDown.setFirstCol(2);
// pullDown.setLastCol(2);
// pullDown.setStrings();
// pullDowns.add(pullDown);
pullDown = new PullDown ( ) ;
pullDown . setFirstCol ( 3 ) ;
pullDown . setLastCol ( 3 ) ;
pullDown . setStrings ( depts . stream ( ) . map ( DeptDTO : : getName ) . distinct ( ) . collect ( Collectors . toList ( ) ) ) ;
pullDowns . add ( pullDown ) ;
pullDown = new PullDown ( ) ;
pullDown . setFirstCol ( 4 ) ;
pullDown . setLastCol ( 4 ) ;
pullDown . setStrings ( devType . stream ( ) . map ( DictData : : getName ) . distinct ( ) . collect ( Collectors . toList ( ) ) ) ;
pullDowns . add ( pullDown ) ;
pullDown = new PullDown ( ) ;
pullDown . setFirstCol ( 6 ) ;
pullDown . setLastCol ( 6 ) ;
pullDown . setStrings ( frontType . stream ( ) . filter ( x - > " CLD " . equals ( x . getCode ( ) ) | | " 61850 " . equals ( x . getCode ( ) ) ) . map ( DictData : : getName ) . distinct ( ) . collect ( Collectors . toList ( ) ) ) ;
pullDowns . add ( pullDown ) ;
pullDown = new PullDown ( ) ;
pullDown . setFirstCol ( 12 ) ;
pullDown . setLastCol ( 12 ) ;
pullDown . setStrings ( nodes . stream ( ) . map ( Node : : getName ) . distinct ( ) . collect ( Collectors . toList ( ) ) ) ;
pullDowns . add ( pullDown ) ;
//监测终端安装位置 0: 电网侧 1: 用户侧
pullDown = new PullDown ( ) ;
pullDown . setFirstCol ( 13 ) ;
pullDown . setLastCol ( 13 ) ;
pullDown . setStrings ( Stream . of ( " 电网侧 " , " 用户侧 " ) . collect ( Collectors . toList ( ) ) ) ;
pullDowns . add ( pullDown ) ;
//终端模型 0: 虚拟终端 1: 实际终端 2: 离线
pullDown = new PullDown ( ) ;
pullDown . setFirstCol ( 16 ) ;
pullDown . setLastCol ( 16 ) ;
pullDown . setStrings ( Stream . of ( " 实际终端 " , " 虚拟终端 " , " 离线 " ) . collect ( Collectors . toList ( ) ) ) ;
pullDowns . add ( pullDown ) ;
//数据类型 0: 暂态系统 1: 稳态系统 2: 两个系统
pullDown = new PullDown ( ) ;
pullDown . setFirstCol ( 17 ) ;
pullDown . setLastCol ( 17 ) ;
pullDown . setStrings ( Stream . of ( " 两个系统 " , " 暂态系统 " , " 稳态系统 " ) . collect ( Collectors . toList ( ) ) ) ;
pullDowns . add ( pullDown ) ;
pullDown = new PullDown ( ) ;
pullDown . setFirstCol ( 18 ) ;
pullDown . setLastCol ( 18 ) ;
pullDown . setStrings ( devConnect . stream ( ) . map ( DictData : : getName ) . distinct ( ) . collect ( Collectors . toList ( ) ) ) ;
pullDowns . add ( pullDown ) ;
pullDown = new PullDown ( ) ;
pullDown . setFirstCol ( 19 ) ;
pullDown . setLastCol ( 19 ) ;
pullDown . setStrings ( devManufacturer . stream ( ) . map ( DictData : : getName ) . distinct ( ) . collect ( Collectors . toList ( ) ) ) ;
pullDowns . add ( pullDown ) ;
pullDown = new PullDown ( ) ;
pullDown . setFirstCol ( 21 ) ;
pullDown . setLastCol ( 21 ) ;
pullDown . setStrings ( voltageTransformer . stream ( ) . map ( DictData : : getName ) . distinct ( ) . collect ( Collectors . toList ( ) ) ) ;
pullDowns . add ( pullDown ) ;
pullDown = new PullDown ( ) ;
pullDown . setFirstCol ( 22 ) ;
pullDown . setLastCol ( 22 ) ;
pullDown . setStrings ( neutralPoint . stream ( ) . map ( DictData : : getName ) . distinct ( ) . collect ( Collectors . toList ( ) ) ) ;
pullDowns . add ( pullDown ) ;
pullDown = new PullDown ( ) ;
pullDown . setFirstCol ( 25 ) ;
pullDown . setLastCol ( 25 ) ;
pullDown . setStrings ( Stream . of ( " 关闭 " , " 开启 " ) . collect ( Collectors . toList ( ) ) ) ;
pullDowns . add ( pullDown ) ;
pullDown = new PullDown ( ) ;
pullDown . setFirstCol ( 26 ) ;
pullDown . setLastCol ( 26 ) ;
pullDown . setStrings ( Stream . of ( " 关闭 " , " 开启 " ) . collect ( Collectors . toList ( ) ) ) ;
pullDowns . add ( pullDown ) ;
//召唤标志 0: 周期触发 1: 变位触发
pullDown = new PullDown ( ) ;
pullDown . setFirstCol ( 27 ) ;
pullDown . setLastCol ( 27 ) ;
pullDown . setStrings ( Stream . of ( " 周期触发 " , " 变位触发 " ) . collect ( Collectors . toList ( ) ) ) ;
pullDowns . add ( pullDown ) ;
pullDown = new PullDown ( ) ;
pullDown . setFirstCol ( 28 ) ;
pullDown . setLastCol ( 28 ) ;
pullDown . setStrings ( Stream . of ( " 否 " , " 是 " ) . collect ( Collectors . toList ( ) ) ) ;
pullDowns . add ( pullDown ) ;
ExcelUtil . exportExcelPullDown ( exportParams , " 终端入网检测数据模板.xlsx " , pullDowns , SupervisionDevMainReportExcel . class , new ArrayList < > ( ) ) ;
}
@Override
public void importDevData ( MultipartFile file , HttpServletResponse response ) {
ImportParams params = new ImportParams ( ) ;
params . setHeadRows ( 1 ) ; //表头
params . setTitleRows ( 1 ) ; //标题
params . setNeedVerify ( true ) ;
params . setStartSheetIndex ( 0 ) ;
params . setSheetNum ( 1 ) ;
List < SupervisionDevMainReportExcel > devExcels = new ArrayList < > ( ) ;
try {
ExcelImportResult < SupervisionDevMainReportExcel > sensitiveUserExcelExcelImportResult = ExcelImportUtil . importExcelMore ( file . getInputStream ( ) , SensitiveUserSExcel . class , params ) ;
//如果存在非法数据,将不合格的数据导出
if ( sensitiveUserExcelExcelImportResult . isVerifyFail ( ) ) {
PoiUtil . exportFileByWorkbook ( sensitiveUserExcelExcelImportResult . getFailWorkbook ( ) , " 非法数据.xlsx " , response ) ;
} else {
devExcels = sensitiveUserExcelExcelImportResult . getList ( ) ;
}
} catch ( Exception e ) {
throw new BusinessException ( SupervisionResponseEnum . IMPORT_DEV_ERROR ) ;
}
List < SupervisionDevMainReportExcel . ExcelMsg > devMsgList = new ArrayList < > ( ) ;
//所属地市
List < DictData > jiBeiArea = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . JIBEI_AREA . getCode ( ) ) . getData ( ) ;
//所属供电公司
List < DeptDTO > deptS = deptFeignClient . getDeptDescendantIndexes ( RequestUtil . getDeptIndex ( ) , WebUtil . filterDeptType ( ) ) . getData ( ) ;
Map < String , String > deptMap = deptS . stream ( ) . collect ( Collectors . toMap ( DeptDTO : : getName , DeptDTO : : getId , ( k1 , k2 ) - > k1 ) ) ;
//终端型号
List < DictData > devType = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . DEV_TYPE . getCode ( ) ) . getData ( ) ;
//通讯类型
List < DictData > frontType = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . FRONT_TYPE . getCode ( ) ) . getData ( ) ;
//获取所有前置机
List < Node > nodes = nodeClient . nodeAllList ( ) . getData ( ) ;
Map < String , String > nodeMap = nodes . stream ( ) . collect ( Collectors . toMap ( Node : : getName , Node : : getId , ( k1 , k2 ) - > k1 ) ) ;
//接线方式
List < DictData > devConnect = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . DEV_CONNECT . getCode ( ) ) . getData ( ) ;
//厂家
List < DictData > devManufacturer = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . DEV_MANUFACTURER . getCode ( ) ) . getData ( ) ;
//电压互感器类型
List < DictData > voltageTransformer = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . VOLTAGE_TRANSFORMER . getCode ( ) ) . getData ( ) ;
//中性点接线方式
List < DictData > neutralPoint = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . Neutral_Point . getCode ( ) ) . getData ( ) ;
SupervisionDevMainReportPO po ;
if ( CollectionUtil . isNotEmpty ( devExcels ) ) {
for ( SupervisionDevMainReportExcel dev : devExcels ) {
//todo 需要根据变电站id进行匹配
LambdaQueryWrapper < SupervisionTempDeviceReport > lambdaQueryWrapper = new LambdaQueryWrapper < > ( ) ;
lambdaQueryWrapper
. eq ( SupervisionTempDeviceReport : : getSubstation , dev . getSubstation ( ) )
. eq ( SupervisionTempDeviceReport : : getTerminalIp , dev . getTerminalIp ( ) ) ;
List < SupervisionTempDeviceReport > list = supervisionTempDeviceReportService . getBaseMapper ( ) . selectList ( lambdaQueryWrapper ) ;
if ( CollectionUtil . isNotEmpty ( list ) ) {
//过滤已取消的申请和删除的
List < String > collect = list . stream ( ) . map ( SupervisionTempDeviceReport : : getId ) . collect ( Collectors . toList ( ) ) ;
List < SupervisionDevMainReportPO > list1 = this . lambdaQuery ( ) . in ( SupervisionDevMainReportPO : : getId , collect ) . list ( ) ;
list1 = list1 . stream ( )
. filter ( userReportPO - > ! userReportPO . getStatus ( ) . equals ( FlowStatusEnum . CANCEL . getCode ( ) ) )
. filter ( userReportPO - > userReportPO . getState ( ) . equals ( DataStateEnum . ENABLE . getCode ( ) ) )
. collect ( Collectors . toList ( ) ) ;
//如果还存在,则说明有人申请过了
if ( CollectionUtil . isNotEmpty ( list1 ) ) {
//该用户已经录入
SupervisionDevMainReportExcel . ExcelMsg sensitiveUserExcelMsg = new SupervisionDevMainReportExcel . ExcelMsg ( ) ;
BeanUtils . copyProperties ( dev , sensitiveUserExcelMsg ) ;
sensitiveUserExcelMsg . setMsg ( dev . getTerminalIp ( ) . concat ( " Ip已占用 " ) ) ;
devMsgList . add ( sensitiveUserExcelMsg ) ;
continue ;
}
}
//基础报告信息
po = new SupervisionDevMainReportPO ( ) ;
po . setReporter ( RequestUtil . getUserIndex ( ) ) ;
po . setReportDate ( LocalDate . now ( ) ) ;
po . setOrgId ( RequestUtil . getDeptIndex ( ) ) ;
po . setExpectedProductionDate ( dev . getExpectedProductionDate ( ) ) ;
po . setCity ( PubUtil . getDicById ( dev . getCity ( ) , jiBeiArea ) ) ;
po . setUserStatus ( " 1 " ) ;
// po.setAcceptanceInspectionReport();
// po.setAcceptanceInspectionReportSingle();
// po.setTypeExperimentReport();
// po.setFactoryInspectionReport();
// po.setPerformanceTestReport();
// po.setInformationSecurityTestReport();
// po.setOtherAttachments();
po . setImportType ( 1 ) ;
po . setStatus ( 2 ) ;
po . setState ( DataStateEnum . ENABLE . getCode ( ) ) ;
this . save ( po ) ;
//终端基础信息
StringBuilder msg = new StringBuilder ( ) ;
SupervisionTempDeviceReport devDetails = new SupervisionTempDeviceReport ( ) ;
devDetails . setId ( po . getId ( ) ) ;
if ( deptMap . containsKey ( dev . getPowerCompany ( ) ) ) {
devDetails . setPowerCompany ( deptMap . get ( dev . getPowerCompany ( ) ) ) ;
} else {
msg . append ( " 所属供电公司不存在! " ) ;
}
//todo 需要根据变电站id进行匹配
// devDetails.setCustomSubstationFlag();
// devDetails.setSubstation();
// devDetails.setSubstationName();
// devDetails.setSubstationVoltageLevel();
// devDetails.setLongitude();
// devDetails.setLatitude();
devDetails . setMonitoringTerminalCode ( dev . getMonitoringTerminalName ( ) ) ;
devDetails . setMonitoringTerminalName ( dev . getMonitoringTerminalName ( ) ) ;
String dy = PubUtil . getDicById ( dev . getVoltageTransformerType ( ) , voltageTransformer ) ;
if ( StrUtil . isNotBlank ( dy ) ) {
devDetails . setVoltageTransformerType ( dy ) ;
} else {
msg . append ( " 电压互感器类型不存在! " ) ;
}
String jx = PubUtil . getDicById ( dev . getTerminalWiringMethodType ( ) , devConnect ) ;
if ( StrUtil . isNotBlank ( jx ) ) {
devDetails . setTerminalWiringMethodType ( jx ) ;
} else {
msg . append ( " 终端接线方式类型不存在! " ) ;
}
String zx = PubUtil . getDicById ( dev . getNeutralPointWiringMethod ( ) , neutralPoint ) ;
if ( StrUtil . isNotBlank ( zx ) ) {
devDetails . setNeutralPointWiringMethod ( zx ) ;
} else {
msg . append ( " 中性点接线方式不存在! " ) ;
}
String cj = PubUtil . getDicById ( dev . getManufacturer ( ) , devManufacturer ) ;
if ( StrUtil . isNotBlank ( cj ) ) {
devDetails . setManufacturer ( cj ) ;
} else {
msg . append ( " 厂家不存在! " ) ;
}
devDetails . setManufacturerDeviceNumber ( dev . getManufacturerDeviceNumber ( ) ) ;
devDetails . setTerminalIp ( dev . getTerminalIp ( ) ) ;
String xh = PubUtil . getDicById ( dev . getTerminalType ( ) , devType ) ;
if ( StrUtil . isNotBlank ( xh ) ) {
devDetails . setTerminalType ( xh ) ;
} else {
msg . append ( " 终端型号不存在! " ) ;
}
devDetails . setTerminalPort ( dev . getTerminalPort ( ) ) ;
if ( nodeMap . containsKey ( dev . getFrontEndMachine ( ) ) ) {
devDetails . setFrontEndMachine ( nodeMap . get ( dev . getFrontEndMachine ( ) ) ) ;
} else {
msg . append ( " 所属前置机不存在! " ) ;
}
devDetails . setCurrentTerminalDetectionTime ( dev . getCurrentTerminalDetectionTime ( ) ) ;
devDetails . setNextTerminalInspectionTime ( dev . getCurrentTerminalDetectionTime ( ) . plusYears ( 5 ) ) ;
devDetails . setIdentificationCode ( dev . getIdentificationCode ( ) ) ;
devDetails . setTerminalSecretKey ( dev . getTerminalSecretKey ( ) ) ;
devDetails . setTerminalModel ( dev . getTerminalModel ( ) ) ;
devDetails . setDataType ( dev . getDataType ( ) ) ;
devDetails . setCommunicationStatus ( " 0 " ) ;
devDetails . setSimCardNumber ( dev . getSimCardNumber ( ) ) ;
devDetails . setCommissioningTime ( dev . getCommissioningTime ( ) ) ;
devDetails . setDataUpdateTime ( dev . getDataUpdateTime ( ) ) ;
devDetails . setTimeSyncFunction ( Integer . parseInt ( dev . getTimeSyncFunction ( ) ) ) ;
devDetails . setElectroplatingFunction ( Integer . parseInt ( dev . getElectroplatingFunction ( ) ) ) ;
devDetails . setMonitoringDeviceInstallationPosition ( dev . getMonitoringDeviceInstallationPosition ( ) ) ;
devDetails . setSummonFlag ( dev . getSummonFlag ( ) ) ;
devDetails . setAlarmFunction ( dev . getAlarmFunction ( ) ) ;
devDetails . setContractNumber ( dev . getContractNumber ( ) ) ;
String tx = PubUtil . getDicById ( dev . getFrontType ( ) , frontType ) ;
if ( StrUtil . isNotBlank ( tx ) ) {
devDetails . setFrontType ( tx ) ;
} else {
msg . append ( " 通讯类型不存在! " ) ;
}
String string = msg . toString ( ) ;
if ( StrUtil . isNotBlank ( string ) ) {
SupervisionDevMainReportExcel . ExcelMsg sensitiveUserExcelMsg = new SupervisionDevMainReportExcel . ExcelMsg ( ) ;
BeanUtils . copyProperties ( dev , sensitiveUserExcelMsg ) ;
sensitiveUserExcelMsg . setMsg ( string ) ;
devMsgList . add ( sensitiveUserExcelMsg ) ;
continue ;
}
supervisionTempDeviceReportService . saveOrUpdate ( devDetails ) ;
}
}
//判断有没有错误信息
if ( CollectionUtil . isNotEmpty ( devMsgList ) ) {
ExcelUtil . exportExcel ( " 失败列表.xlsx " , SupervisionDevMainReportExcel . ExcelMsg . class , devMsgList ) ;
}
}
/**
* @Description: 判断设备ip是否重复, 如果重复提示
* @Param: supervisionDevMainReportParam终端详情 isExcludeSelf是否排除自己, 一般新增不排除, 更新时需要排除自己
* @return: void
* @Author: clam
* @Date: 2024/5/11
*/
* @Description: 判断设备ip是否重复, 如果重复提示
* @Param: supervisionDevMainReportParam终端详情 isExcludeSelf是否排除自己, 一般新增不排除, 更新时需要排除自己
* @return: void
* @Author: clam
* @Date: 2024/5/11
*/
private void checkIp ( SupervisionDevMainReportParam supervisionDevMainReportParam , boolean isExcludeSelf ) {
//如果保存不填ip则不校验
if ( ! StringUtils . isEmpty ( supervisionDevMainReportParam . getSupervisionTempDeviceReportParam ( ) . getTerminalIp ( ) ) ) {
if ( ! StringUtils . isEmpty ( supervisionDevMainReportParam . getSupervisionTempDeviceReportParam ( ) . getTerminalIp ( ) ) ) {
LambdaQueryWrapper < SupervisionTempDeviceReport > lambdaQueryWrapper = new LambdaQueryWrapper < > ( ) ;
lambdaQueryWrapper
@@ -293,12 +644,11 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
if ( isExcludeSelf ) {
if ( supervisionDevMainReportParam instanceof SupervisionDevMainReportParam . SupervisionDevMainReportParamUpdate ) {
lambdaQueryWrapper . ne ( SupervisionTempDeviceReport : : getId , ( ( SupervisionDevMainReportParam . SupervisionDevMainReportParamUpdate ) supervisionDevMainReportParam ) . getId ( ) ) ;
} else {
} else {
lambdaQueryWrapper . ne ( SupervisionTempDeviceReport : : getId , ( supervisionDevMainReportParam ) . getId ( ) ) ;
}
}
List < SupervisionTempDeviceReport > list = supervisionTempDeviceReportService . getBaseMapper ( ) . selectList ( lambdaQueryWrapper ) ;
if ( CollectionUtil . isNotEmpty ( list ) ) {