1.河北临时台账处理代码,后期需要删除
This commit is contained in:
@@ -2,7 +2,9 @@ package com.njcn.device.pms.controller.ledgerManger;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
@@ -10,14 +12,13 @@ import com.njcn.device.pms.mapper.majornetwork.StatationStatMapper;
|
||||
import com.njcn.device.pms.pojo.po.*;
|
||||
import com.njcn.device.pms.service.majornetwork.*;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.user.pojo.vo.DeptTreeVO;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.List;
|
||||
@@ -153,5 +154,22 @@ public class PmsLedgerDeptController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取部门树(存在监测点的)
|
||||
* @author cdf
|
||||
* @date 2024/2/26
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/existMonitorDeptTree")
|
||||
@ApiOperation("获取部门树(存在监测点的)")
|
||||
public HttpResult<List<String>> existMonitorDeptTree() {
|
||||
String methodDescribe = getMethodDescribe("existMonitorDeptTree");
|
||||
List<String> result = iMonitorService.existMonitorDeptTree();
|
||||
//删除返回失败,查不到数据返回空数组,兼容治理项目没有部门直接报错的bug
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -291,8 +291,28 @@ public class PmsMonitorController extends BaseController {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 附件批量修改台账信息(地市核验过的台账信息excel通过此接口导入表中,后续3.0完善后需要删除)
|
||||
* @author cdf
|
||||
* @date 2024/2/26
|
||||
*/
|
||||
@PostMapping("/importUpdateLedger")
|
||||
@ApiOperation("附件批量修改台账信息")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.UPLOAD)
|
||||
public HttpResult<Object> importUpdateLedger(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importUpdateLedger");
|
||||
String result = monitorService.importUpdateLedger(file,response);
|
||||
|
||||
if (Objects.isNull(result)) {
|
||||
return null;
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
try {
|
||||
/*try {
|
||||
// 创建一个临时文件,前缀为"temp_",后缀为".txt",存储在默认的临时文件夹中
|
||||
File tempFile = File.createTempFile("temp_", ".txt");
|
||||
|
||||
@@ -303,7 +323,7 @@ public class PmsMonitorController extends BaseController {
|
||||
tempFile.deleteOnExit();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.device.pms.mapper.majornetwork;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.device.pms.pojo.po.ATestRelationMonitor;
|
||||
import com.njcn.device.pq.pojo.po.LineBak;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
* 数据中心监测点与河北pms系统监测点关系实体(后期有数据需要删除)
|
||||
* @author cdf
|
||||
* @since 2022-01-04
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ATestRelationMonitorMapper extends BaseMapper<ATestRelationMonitor> {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -156,6 +156,9 @@ public interface IMonitorService extends IService<Monitor> {
|
||||
String importOracleLedgerToMysql(MultipartFile file, HttpServletResponse response);
|
||||
|
||||
|
||||
String importUpdateLedger(MultipartFile file, HttpServletResponse response);
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 获取所有监测点限值
|
||||
* @param
|
||||
@@ -185,4 +188,12 @@ public interface IMonitorService extends IService<Monitor> {
|
||||
* 批量根据监测点id获取监测点信息
|
||||
*/
|
||||
List<LineDTO> getLineDetailBatch(List<String> ids);
|
||||
|
||||
|
||||
/**
|
||||
* 获取部门树(存在监测点的)
|
||||
* @author cdf
|
||||
* @date 2024/2/26
|
||||
*/
|
||||
List<String> existMonitorDeptTree();
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.njcn.device.pms.mapper.majornetwork.*;
|
||||
import com.njcn.device.pms.pojo.dto.PmsMonitorBaseDTO;
|
||||
import com.njcn.device.pms.pojo.dto.PmsMonitorDTO;
|
||||
import com.njcn.device.pms.pojo.dto.PmsMonitorInfoDTO;
|
||||
import com.njcn.device.pms.pojo.excel.PmsLedgerExcel;
|
||||
import com.njcn.device.pms.pojo.param.*;
|
||||
import com.njcn.device.pms.pojo.po.*;
|
||||
import com.njcn.device.pms.pojo.vo.MonitorVO;
|
||||
@@ -52,6 +53,7 @@ import com.njcn.system.enums.SystemResponseEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.user.pojo.vo.DeptTreeVO;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -487,6 +489,30 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String importUpdateLedger(MultipartFile file, HttpServletResponse response) {
|
||||
ImportParams importParams = new ImportParams();
|
||||
importParams.setHeadRows(1);
|
||||
importParams.setTitleRows(1);
|
||||
importParams.setNeedVerify(true);
|
||||
|
||||
try {
|
||||
ExcelImportResult<PmsLedgerExcel> terminalExcelExcelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), PmsLedgerExcel.class, importParams);
|
||||
|
||||
//如果存在非法数据,将不合格的数据导出
|
||||
if (terminalExcelExcelImportResult.isVerifyFail()) {
|
||||
PoiUtil.exportFileByWorkbook(terminalExcelExcelImportResult.getFailWorkbook(), "非法台账信息.xlsx", response);
|
||||
return null;
|
||||
} else {
|
||||
//执行台账信息导入(不考虑,存在监测点却不存在限值信息)
|
||||
return dealDataBatchUpdate(terminalExcelExcelImportResult.getList());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new BusinessException(DeviceResponseEnum.IMPORT_ORACLE_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Overlimit> getAllLineOverLimit() {
|
||||
return overlimitMapper.selectList(null);
|
||||
@@ -546,6 +572,206 @@ public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> impl
|
||||
return lineDTOS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> existMonitorDeptTree() {
|
||||
DictData dictData = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.LINE_STATE.getName(), DicDataEnum.RUN.getName()).getData();
|
||||
List<Dept> deptList = deptFeignClient.getAllDept().getData();
|
||||
List<String> monitorList = this.lambdaQuery().select(Monitor::getOrgId).eq(Monitor::getMonitorState,dictData.getId()).list().stream().map(Monitor::getOrgId).distinct().collect(Collectors.toList());
|
||||
List<Dept> deptTem = deptList.stream().filter(it->monitorList.contains(it.getCode())).collect(Collectors.toList());
|
||||
|
||||
|
||||
return deptTem.stream().map(Dept::getId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
private String dealDataBatchUpdate(List<PmsLedgerExcel> pmsLedgerExcelList) {
|
||||
List<PmsLedgerExcel> 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()));
|
||||
|
||||
//装作等级
|
||||
DictData devGrade = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.DEV_GRADE.getName(), DicDataEnum.MOST_IMPORMENT.getName()).getData();
|
||||
|
||||
//
|
||||
DictData devInputType = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.INPUT_SIGNAL.getName(), DicDataEnum.SIMULATION_SIGNAL.getName()).getData();
|
||||
|
||||
//监测点类型
|
||||
DictData monitorType = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.LINE_TYPE.getName(), DicDataEnum.Power_Supply_Point.getName()).getData();
|
||||
|
||||
//接线方式
|
||||
List<DictData> wireList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_CONNECT.getCode()).getData();
|
||||
Map<String, DictData> wireListMap = wireList.stream().collect(Collectors.toMap(DictData::getName, Function.identity()));
|
||||
|
||||
//电压互感器类型
|
||||
List<DictData> potentialDic = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.VOLTAGE_TRANSFORMER.getCode()).getData();
|
||||
Map<String, DictData> potentialDicMap = potentialDic.stream().collect(Collectors.toMap(DictData::getName, Function.identity()));
|
||||
|
||||
//中性点接地方式
|
||||
List<DictData> neutralDic = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.Neutral_Point.getCode()).getData();
|
||||
Map<String, DictData> neutralDicMap = neutralDic.stream().collect(Collectors.toMap(DictData::getName, Function.identity()));
|
||||
|
||||
|
||||
//行业分类
|
||||
List<DictData> businessType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.INDUSTRY_TYPE.getCode()).getData();
|
||||
Map<String, DictData> businessDicMap = businessType.stream().collect(Collectors.toMap(DictData::getName, Function.identity()));
|
||||
|
||||
|
||||
//TODO 零时处理
|
||||
List<SysDicTreePO> dicTree = dictTreeFeignClient.queryAll().getData();
|
||||
dicTree = dicTree.stream().filter(item->item.getCode()!="Device_Unit" && !item.getCode().contains("@")).collect(Collectors.toList());
|
||||
Map<String,SysDicTreePO> objTypeMap = dicTree.stream().collect(Collectors.toMap(SysDicTreePO::getName,Function.identity()));
|
||||
|
||||
int count = 0;
|
||||
for (PmsLedgerExcel pmsLedgerExcel : pmsLedgerExcelList) {
|
||||
|
||||
|
||||
LambdaQueryWrapper<Monitor> monitorLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
monitorLambdaQueryWrapper.eq(Monitor::getName,pmsLedgerExcel.getName()).eq(Monitor::getPowerrName,pmsLedgerExcel.getPowerrName());
|
||||
|
||||
Monitor monitor = this.getOne(monitorLambdaQueryWrapper);
|
||||
if(Objects.nonNull(monitor)){
|
||||
|
||||
Monitor po = new Monitor();
|
||||
po.setId(monitor.getId());
|
||||
po.setMinShortCircuitCapacity(pmsLedgerExcel.getMinShortCircuitCapacity());
|
||||
po.setPowerSupplyEqCapacity(pmsLedgerExcel.getPowerSupplyEqCapacity());
|
||||
po.setUserAgreementCapacity(pmsLedgerExcel.getUserAgreementCapacity());
|
||||
|
||||
|
||||
String monitorStateId= monitorStateDicMap.get(pmsLedgerExcel.getMonitorState()).getId();
|
||||
if(StrUtil.isBlank(monitorStateId)){
|
||||
throw new BusinessException("监测点状态为空");
|
||||
}
|
||||
po.setMonitorState(monitorStateId);
|
||||
|
||||
String getPotentialTransFormerTypeId= potentialDicMap.get(pmsLedgerExcel.getPotentialTransFormerType()).getId();
|
||||
|
||||
if(StrUtil.isBlank(getPotentialTransFormerTypeId)){
|
||||
throw new BusinessException("电压互感器类型缺失");
|
||||
}
|
||||
po.setPotentialTransFormerType(getPotentialTransFormerTypeId);
|
||||
|
||||
|
||||
String neutralDicMapId= neutralDicMap.get(pmsLedgerExcel.getNeutralGroundingMode()).getId();
|
||||
|
||||
if(StrUtil.isBlank(neutralDicMapId)){
|
||||
throw new BusinessException("中性点接地方式缺失");
|
||||
}
|
||||
po.setPotentialTransFormerType(getPotentialTransFormerTypeId);
|
||||
po.setIsSpecialSupplyElectricity(pmsLedgerExcel.getIsSpecialSupplyElectricity());
|
||||
|
||||
String getMonitorTagId = objTypeDicMap.get(pmsLedgerExcel.getMonitorTag()).getId();
|
||||
if(StrUtil.isBlank(getMonitorTagId)){
|
||||
throw new BusinessException("监测点标签缺失");
|
||||
}
|
||||
po.setMonitorTag(getMonitorTagId);
|
||||
|
||||
|
||||
String getObjTypeId = objTypeMap.get(pmsLedgerExcel.getObjType()).getId();
|
||||
if(StrUtil.isBlank(getObjTypeId)){
|
||||
throw new BusinessException("对象类型缺少");
|
||||
}
|
||||
po.setObjType(getObjTypeId);
|
||||
|
||||
|
||||
//行业分类
|
||||
if(businessDicMap.containsKey(pmsLedgerExcel.getTradeCode())){
|
||||
String getTradeCodeId = businessDicMap.get(pmsLedgerExcel.getTradeCode()).getId();
|
||||
po.setTradeCode(getTradeCodeId);
|
||||
}else {
|
||||
po.setTradeCode("");
|
||||
}
|
||||
|
||||
|
||||
//监测对象名称
|
||||
po.setMonitorObjectName(pmsLedgerExcel.getMonitorObjectName());
|
||||
|
||||
|
||||
|
||||
|
||||
//装置
|
||||
/* PmsTerminal pmsTerminal = terminalMapper.selectOne(new LambdaQueryWrapper<PmsTerminal>().eq(PmsTerminal::getId,monitor.getTerminalId()));
|
||||
|
||||
if(Objects.nonNull(pmsTerminal)){
|
||||
PmsTerminal t = new PmsTerminal();
|
||||
t.setId(pmsTerminal.getId());
|
||||
t.setTerminalCode(pmsLedgerExcel.getTerminalCode());
|
||||
t.setIp(pmsLedgerExcel.getDevIp());
|
||||
terminalMapper.updateById(t);
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
po.setTerminalCode(pmsLedgerExcel.getTerminalCode());
|
||||
|
||||
|
||||
if(StrUtil.isNotBlank(po.getTerminalCode())){
|
||||
po.setIsUpToGrid(1);
|
||||
}
|
||||
|
||||
|
||||
if(StrUtil.isBlank(pmsLedgerExcel.getBusId())){
|
||||
po.setIsUpToGrid(0);
|
||||
}
|
||||
|
||||
|
||||
this.updateById(po);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
count++;
|
||||
}else {
|
||||
|
||||
System.out.println("4444444444444444");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(oracleTerminalExcelMsg)) {
|
||||
ExcelUtil.exportExcel("失败列表.xlsx", OracleTerminalExcel.OracleTerminalExcelMsg.class, oracleTerminalExcelMsg);
|
||||
return null;
|
||||
}
|
||||
return CommonResponseEnum.SUCCESS.getMessage();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取主配网监测点id集合
|
||||
|
||||
Reference in New Issue
Block a user