fix:
1.完成输运模拟任务导入功能 2.完成测试数据处理功能
This commit is contained in:
parent
16c8ef3d34
commit
e4fbc2fe69
|
|
@ -3,6 +3,12 @@ package org.jeecg.modules.base.mapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.jeecg.modules.base.entity.configuration.GardsStations;
|
import org.jeecg.modules.base.entity.configuration.GardsStations;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface GardsStationsMapper extends BaseMapper<GardsStations> {
|
public interface GardsStationsMapper extends BaseMapper<GardsStations> {
|
||||||
|
|
||||||
|
List<Map<String, Object>> getAllNuclearFacilitiesAndReactors();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="org.jeecg.modules.base.mapper.GardsStationsMapper">
|
||||||
|
|
||||||
|
<select id="getAllNuclearFacilitiesAndReactors" resultType="java.util.Map">
|
||||||
|
SELECT
|
||||||
|
gnr.UNIT_NAME as "facilityName",
|
||||||
|
gnr.LONGITUDE as "longitude",
|
||||||
|
gnr.LATITUDE as "latitude"
|
||||||
|
FROM
|
||||||
|
CONFIGURATION.GARDS_NUCLEAR_REACTORS gnr
|
||||||
|
UNION ALL
|
||||||
|
SELECT
|
||||||
|
grr.FACILITY_NAME as "facilityName",
|
||||||
|
grr.LONGITUDE as "longitude",
|
||||||
|
grr.LATITUDE as "latitude"
|
||||||
|
FROM
|
||||||
|
CONFIGURATION.GARDS_RESEARCH_REACTORS grr
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package org.jeecg.controller;
|
package org.jeecg.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
@ -18,13 +19,16 @@ import org.jeecg.service.TransportTaskService;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import java.io.File;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import java.io.FileInputStream;
|
import ucar.ma2.ArrayDouble;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
import java.io.*;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeParseException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|
@ -125,4 +129,26 @@ public class TransportTaskController {
|
||||||
log.error("下载模版异常,原因为:{}",e.getMessage());
|
log.error("下载模版异常,原因为:{}",e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("importTask")
|
||||||
|
public Result<?> importTask(MultipartFile file){
|
||||||
|
List<String> importResult = new ArrayList<>();
|
||||||
|
try{
|
||||||
|
importResult = transportTaskService.importTask(file);
|
||||||
|
if (CollUtil.isEmpty(importResult)){
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
if(e instanceof DateTimeParseException){
|
||||||
|
importResult.add("时间参数格式化异常");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.error("导入失败", importResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("handleNPPExcelReleaseData")
|
||||||
|
public void handleNPPExcelReleaseData(HttpServletResponse res) throws Exception {
|
||||||
|
transportTaskService.handleExcelReleaseData(res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,4 +39,10 @@ public interface StationDataService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
GardsStations getStationById(Integer stationId);
|
GardsStations getStationById(Integer stationId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有核设施和反应堆信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Map<String,Object>> getAllNuclearFacilitiesAndReactors();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,13 @@ package org.jeecg.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import jakarta.validation.constraints.Null;
|
|
||||||
import org.jeecg.common.system.query.PageRequest;
|
import org.jeecg.common.system.query.PageRequest;
|
||||||
import org.jeecg.modules.base.entity.TransportTask;
|
import org.jeecg.modules.base.entity.TransportTask;
|
||||||
import org.jeecg.modules.base.entity.TransportTaskLog;
|
import org.jeecg.modules.base.entity.TransportTaskLog;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -91,4 +93,12 @@ public interface TransportTaskService extends IService<TransportTask> {
|
||||||
* @param status
|
* @param status
|
||||||
*/
|
*/
|
||||||
void updateTaskStatus(Integer taskId, Integer status);
|
void updateTaskStatus(Integer taskId, Integer status);
|
||||||
|
|
||||||
|
void handleExcelReleaseData(HttpServletResponse res) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入任务
|
||||||
|
* @param file
|
||||||
|
*/
|
||||||
|
List<String> importTask(MultipartFile file) throws IOException;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,4 +115,14 @@ public class StationDataServiceImpl implements StationDataService {
|
||||||
return stationsMapper.selectById(stationId);
|
return stationsMapper.selectById(stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有核设施和反应堆信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getAllNuclearFacilitiesAndReactors() {
|
||||||
|
return stationsMapper.getAllNuclearFacilitiesAndReactors();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,36 +2,47 @@ package org.jeecg.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
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 jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jeecg.common.constant.enums.TransportReleaseDataSource;
|
import org.apache.poi.ss.usermodel.*;
|
||||||
import org.jeecg.common.constant.enums.TransportTaskModeEnum;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import org.jeecg.common.constant.enums.TransportTaskStatusEnum;
|
import org.jeecg.common.constant.enums.*;
|
||||||
import org.jeecg.common.constant.enums.TransportTaskTypeEnum;
|
|
||||||
import org.jeecg.common.properties.DataFusionProperties;
|
import org.jeecg.common.properties.DataFusionProperties;
|
||||||
import org.jeecg.common.properties.SystemStorageProperties;
|
import org.jeecg.common.properties.SystemStorageProperties;
|
||||||
import org.jeecg.common.properties.TransportSimulationProperties;
|
import org.jeecg.common.properties.TransportSimulationProperties;
|
||||||
import org.jeecg.common.system.query.PageRequest;
|
import org.jeecg.common.system.query.PageRequest;
|
||||||
import org.jeecg.common.util.RedisUtil;
|
import org.jeecg.common.util.RedisUtil;
|
||||||
import org.jeecg.modules.base.entity.*;
|
import org.jeecg.modules.base.entity.*;
|
||||||
|
import org.jeecg.modules.base.entity.configuration.GardsNuclearReactors;
|
||||||
import org.jeecg.modules.base.mapper.*;
|
import org.jeecg.modules.base.mapper.*;
|
||||||
import org.jeecg.properties.ServerProperties;
|
import org.jeecg.properties.ServerProperties;
|
||||||
|
import org.jeecg.service.StationDataService;
|
||||||
import org.jeecg.service.TransportTaskService;
|
import org.jeecg.service.TransportTaskService;
|
||||||
import org.jeecg.task.flexparttask.AbstractTaskExec;
|
import org.jeecg.task.flexparttask.AbstractTaskExec;
|
||||||
import org.jeecg.task.flexparttask.BackwardTaskExec;
|
import org.jeecg.task.flexparttask.BackwardTaskExec;
|
||||||
import org.jeecg.task.flexparttask.ForwardTaskExec;
|
import org.jeecg.task.flexparttask.ForwardTaskExec;
|
||||||
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.TransactionDefinition;
|
||||||
|
import org.springframework.transaction.TransactionStatus;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Objects;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 输运模拟任务管理
|
* 输运模拟任务管理
|
||||||
|
|
@ -51,6 +62,10 @@ public class TransportTaskServiceImpl extends ServiceImpl<TransportTaskMapper,Tr
|
||||||
private final TransportTaskForwardChildMapper taskForwardChildMapper;
|
private final TransportTaskForwardChildMapper taskForwardChildMapper;
|
||||||
private final TransportTaskForwardSpeciesMapper taskForwardSpeciesMapper;
|
private final TransportTaskForwardSpeciesMapper taskForwardSpeciesMapper;
|
||||||
private final ServerProperties serverProperties;
|
private final ServerProperties serverProperties;
|
||||||
|
private final GardsNuclearReactorsMapper gardsNuclearReactorsMapper;
|
||||||
|
private final DataSourceTransactionManager transactionManager;
|
||||||
|
private final TransactionDefinition transactionDefinition;
|
||||||
|
private final StationDataService stationDataService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询任务列表
|
* 分页查询任务列表
|
||||||
|
|
@ -112,11 +127,13 @@ public class TransportTaskServiceImpl extends ServiceImpl<TransportTaskMapper,Tr
|
||||||
for (TransportTaskForwardChild child : transportTask.getForwardChild()) {
|
for (TransportTaskForwardChild child : transportTask.getForwardChild()) {
|
||||||
child.setTaskId(transportTask.getId());
|
child.setTaskId(transportTask.getId());
|
||||||
taskForwardChildMapper.insert(child);
|
taskForwardChildMapper.insert(child);
|
||||||
child.getForwardReleaseChild().forEach(forwardReleaseChild -> {
|
if (CollUtil.isNotEmpty(child.getForwardReleaseChild())){
|
||||||
forwardReleaseChild.setForwardChildId(child.getId());
|
child.getForwardReleaseChild().forEach(forwardReleaseChild -> {
|
||||||
forwardReleaseChild.setTaskId(transportTask.getId());
|
forwardReleaseChild.setForwardChildId(child.getId());
|
||||||
});
|
forwardReleaseChild.setTaskId(transportTask.getId());
|
||||||
taskForwardReleaseMapper.insert(child.getForwardReleaseChild());
|
});
|
||||||
|
taskForwardReleaseMapper.insert(child.getForwardReleaseChild());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
transportTask.getForwardChild().forEach(transportTaskChild -> {
|
transportTask.getForwardChild().forEach(transportTaskChild -> {
|
||||||
|
|
@ -424,4 +441,620 @@ public class TransportTaskServiceImpl extends ServiceImpl<TransportTaskMapper,Tr
|
||||||
transportTask.setTaskStatus(status);
|
transportTask.setTaskStatus(status);
|
||||||
this.baseMapper.updateById(transportTask);
|
this.baseMapper.updateById(transportTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param res
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void handleExcelReleaseData(HttpServletResponse res) throws Exception{
|
||||||
|
String outputFilePath = "F://forwordTemplate.xlsx";
|
||||||
|
InputStream outputFileInputStream = new FileInputStream(outputFilePath);
|
||||||
|
Workbook outputWorkBook = new XSSFWorkbook(outputFileInputStream);
|
||||||
|
Map<String, CellStyle> styles = this.createStyles(outputWorkBook);
|
||||||
|
|
||||||
|
StringBuilder stations = new StringBuilder();
|
||||||
|
|
||||||
|
this.handleNPPExcelReleaseData(outputWorkBook,styles,stations);
|
||||||
|
this.handleNRRExcelReleaseData(outputWorkBook,styles,stations);
|
||||||
|
this.handleMIPFNRRExcelReleaseData(outputWorkBook,styles,stations);
|
||||||
|
this.handleMIPFExcelReleaseData(outputWorkBook,styles,stations);
|
||||||
|
this.handleTaskBaseInfo(outputWorkBook,stations);
|
||||||
|
|
||||||
|
res.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
|
res.setCharacterEncoding("UTF-8");
|
||||||
|
res.setHeader("Content-Disposition", "attachment; filename=NPP_Releases.xlsx");
|
||||||
|
res.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
|
outputWorkBook.write(res.getOutputStream());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理基础信息
|
||||||
|
* @param outputWorkBook
|
||||||
|
* @param stations
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private void handleTaskBaseInfo(Workbook outputWorkBook,StringBuilder stations) throws Exception {
|
||||||
|
Sheet sheet = outputWorkBook.getSheetAt(0);
|
||||||
|
//设置任务名称
|
||||||
|
sheet.getRow(1).getCell(1).setCellValue("test");
|
||||||
|
//设置任务模式
|
||||||
|
sheet.getRow(1).getCell(3).setCellValue(1);
|
||||||
|
//设置气象数据来源
|
||||||
|
sheet.getRow(1).getCell(5).setCellValue(4);
|
||||||
|
//设置释放下部高度
|
||||||
|
sheet.getRow(2).getCell(1).setCellValue(20);
|
||||||
|
//设置释放上部高度
|
||||||
|
sheet.getRow(2).getCell(3).setCellValue(30);
|
||||||
|
//设置粒子数量
|
||||||
|
sheet.getRow(2).getCell(5).setCellValue(500000);
|
||||||
|
//设置开始时间
|
||||||
|
sheet.getRow(3).getCell(1).setCellValue("2014-01-01 00:00:00");
|
||||||
|
//设置结束时间
|
||||||
|
sheet.getRow(3).getCell(3).setCellValue("2014-03-30 00:00:00");
|
||||||
|
//设置释放数据来源
|
||||||
|
sheet.getRow(3).getCell(5).setCellValue(2);
|
||||||
|
//设置释放核素
|
||||||
|
sheet.getRow(4).getCell(1).setCellValue(52);
|
||||||
|
//设置设施列表
|
||||||
|
String result = stations.toString();
|
||||||
|
if (result.endsWith(",")) {
|
||||||
|
result = result.substring(0, result.length() - 1);
|
||||||
|
}
|
||||||
|
sheet.getRow(5).getCell(1).setCellValue(result);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理NPPexcel数据
|
||||||
|
* @param outputWorkBook
|
||||||
|
* @param styles
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private void handleNPPExcelReleaseData(Workbook outputWorkBook,Map<String, CellStyle> styles,StringBuilder stations) throws Exception {
|
||||||
|
String inputFilePath = "F://工作//五木//放射性核素监测数据综合分析及氙本底源解析系统//其他资料//排放数据//NPP_Stackdata//NPP_Releases1.xlsx";
|
||||||
|
InputStream inputFileInputStream = new FileInputStream(inputFilePath);
|
||||||
|
Workbook inputWorkBook = new XSSFWorkbook(inputFileInputStream);
|
||||||
|
|
||||||
|
Sheet sheet = inputWorkBook.getSheetAt(0);
|
||||||
|
for(int i=1;i<=sheet.getLastRowNum();i++) {
|
||||||
|
Row row = sheet.getRow(i);
|
||||||
|
//设施名称
|
||||||
|
Cell siteCell = row.getCell(1);
|
||||||
|
String cellValue = siteCell.getStringCellValue().toUpperCase();
|
||||||
|
if(cellValue.contains("/")) {
|
||||||
|
cellValue = cellValue.replace("/","");
|
||||||
|
}
|
||||||
|
//站点名称
|
||||||
|
stations.append(cellValue);
|
||||||
|
stations.append(",");
|
||||||
|
//排放数据
|
||||||
|
Cell releaseCell = row.getCell(7);
|
||||||
|
double releaseCellValue = releaseCell.getNumericCellValue();
|
||||||
|
|
||||||
|
Sheet releaseDataSheet = outputWorkBook.createSheet(cellValue);
|
||||||
|
Row zeroRow = releaseDataSheet.createRow(0);
|
||||||
|
zeroRow.setHeightInPoints(20);
|
||||||
|
Cell cell0 = zeroRow.createCell(0, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(0, 20*256);
|
||||||
|
cell0.setCellValue("开始时间");
|
||||||
|
cell0.setCellStyle(styles.get("header"));
|
||||||
|
Cell cell1 = zeroRow.createCell(1, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(1, 20*256);
|
||||||
|
cell1.setCellValue("结束时间");
|
||||||
|
cell1.setCellStyle(styles.get("header"));
|
||||||
|
Cell cell2 = zeroRow.createCell(2, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(2, 20*256);
|
||||||
|
cell2.setCellValue("排放量");
|
||||||
|
cell2.setCellStyle(styles.get("header"));
|
||||||
|
|
||||||
|
LocalDateTime startDate = LocalDateTime.of(2014,1,1,0,0,0);
|
||||||
|
LocalDateTime endDate = LocalDateTime.of(2014,1,6,0,0,0);
|
||||||
|
|
||||||
|
int rowNum = 1;
|
||||||
|
while(startDate.isBefore(endDate)) {
|
||||||
|
Row bodyRow = releaseDataSheet.createRow(rowNum);
|
||||||
|
Cell bodyCell0 = bodyRow.createCell(0, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(0, 20*256);
|
||||||
|
bodyCell0.setCellValue(startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
|
bodyCell0.setCellStyle(styles.get("data"));
|
||||||
|
|
||||||
|
startDate = startDate.plusDays(1);
|
||||||
|
Cell bodyCell1 = bodyRow.createCell(1, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(1, 20*256);
|
||||||
|
bodyCell1.setCellValue(startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
|
bodyCell1.setCellStyle(styles.get("data"));
|
||||||
|
|
||||||
|
Cell bodyCell2 = bodyRow.createCell(2, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(2, 20*256);
|
||||||
|
bodyCell2.setCellValue(releaseCellValue);
|
||||||
|
bodyCell2.setCellStyle(styles.get("scientific"));
|
||||||
|
rowNum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理NRRexcel数据
|
||||||
|
* @param outputWorkBook
|
||||||
|
* @param styles
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private void handleNRRExcelReleaseData(Workbook outputWorkBook,Map<String, CellStyle> styles,StringBuilder stations) throws Exception {
|
||||||
|
String inputFilePath = "F://工作//五木//放射性核素监测数据综合分析及氙本底源解析系统//其他资料//排放数据//NRR_Stackdata//NRR_Releases1.xlsx";
|
||||||
|
InputStream inputFileInputStream = new FileInputStream(inputFilePath);
|
||||||
|
Workbook inputWorkBook = new XSSFWorkbook(inputFileInputStream);
|
||||||
|
|
||||||
|
Sheet sheet = inputWorkBook.getSheetAt(0);
|
||||||
|
for(int i=2;i<=31;i++) {//此excel只有31行可用,索引从0开始,33行是说明
|
||||||
|
Row row = sheet.getRow(i);
|
||||||
|
//设施名称
|
||||||
|
Cell siteCell = row.getCell(1);
|
||||||
|
String cellValue = siteCell.getStringCellValue().toUpperCase();
|
||||||
|
if(cellValue.contains("/")) {
|
||||||
|
cellValue = cellValue.replace("/","");
|
||||||
|
}
|
||||||
|
//站点名称
|
||||||
|
stations.append(cellValue);
|
||||||
|
stations.append(",");
|
||||||
|
//排放数据
|
||||||
|
Cell releaseCell = row.getCell(17);
|
||||||
|
double releaseCellValue = releaseCell.getNumericCellValue();
|
||||||
|
BigDecimal releaseCellValueBG = new BigDecimal(releaseCellValue);
|
||||||
|
BigDecimal days = new BigDecimal(365);
|
||||||
|
BigDecimal result = releaseCellValueBG.divide(days,5,BigDecimal.ROUND_HALF_UP);
|
||||||
|
|
||||||
|
Sheet releaseDataSheet = outputWorkBook.createSheet(cellValue);
|
||||||
|
Row zeroRow = releaseDataSheet.createRow(0);
|
||||||
|
zeroRow.setHeightInPoints(20);
|
||||||
|
Cell cell0 = zeroRow.createCell(0, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(0, 20*256);
|
||||||
|
cell0.setCellValue("开始时间");
|
||||||
|
cell0.setCellStyle(styles.get("header"));
|
||||||
|
Cell cell1 = zeroRow.createCell(1, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(1, 20*256);
|
||||||
|
cell1.setCellValue("结束时间");
|
||||||
|
cell1.setCellStyle(styles.get("header"));
|
||||||
|
Cell cell2 = zeroRow.createCell(2, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(2, 20*256);
|
||||||
|
cell2.setCellValue("排放量");
|
||||||
|
cell2.setCellStyle(styles.get("header"));
|
||||||
|
|
||||||
|
LocalDateTime startDate = LocalDateTime.of(2014,1,1,0,0,0);
|
||||||
|
LocalDateTime endDate = LocalDateTime.of(2014,1,6,0,0,0);
|
||||||
|
|
||||||
|
int rowNum = 1;
|
||||||
|
while(startDate.isBefore(endDate)) {
|
||||||
|
Row bodyRow = releaseDataSheet.createRow(rowNum);
|
||||||
|
Cell bodyCell0 = bodyRow.createCell(0, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(0, 20*256);
|
||||||
|
bodyCell0.setCellValue(startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
|
bodyCell0.setCellStyle(styles.get("data"));
|
||||||
|
|
||||||
|
startDate = startDate.plusDays(1);
|
||||||
|
Cell bodyCell1 = bodyRow.createCell(1, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(1, 20*256);
|
||||||
|
bodyCell1.setCellValue(startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
|
bodyCell1.setCellStyle(styles.get("data"));
|
||||||
|
|
||||||
|
Cell bodyCell2 = bodyRow.createCell(2, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(2, 20*256);
|
||||||
|
bodyCell2.setCellValue(result.doubleValue());
|
||||||
|
bodyCell2.setCellStyle(styles.get("scientific"));
|
||||||
|
rowNum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理MIPFexcel数据
|
||||||
|
* @param outputWorkBook
|
||||||
|
* @param styles
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private void handleMIPFNRRExcelReleaseData(Workbook outputWorkBook,Map<String, CellStyle> styles,StringBuilder stations) throws Exception {
|
||||||
|
String inputFilePath = "F://工作//五木//放射性核素监测数据综合分析及氙本底源解析系统//其他资料//排放数据//MIPF_NRR_Stackdata//MIPF_NRR_Releases1.xlsx";
|
||||||
|
InputStream inputFileInputStream = new FileInputStream(inputFilePath);
|
||||||
|
Workbook inputWorkBook = new XSSFWorkbook(inputFileInputStream);
|
||||||
|
|
||||||
|
Sheet sheet = inputWorkBook.getSheetAt(0);
|
||||||
|
for(int i=2;i<=11;i++) {
|
||||||
|
Row row = sheet.getRow(i);
|
||||||
|
//设施名称
|
||||||
|
Cell siteCell = row.getCell(1);
|
||||||
|
String cellValue = siteCell.getStringCellValue().toUpperCase();
|
||||||
|
if(cellValue.contains("/")) {
|
||||||
|
cellValue = cellValue.replace("/","");
|
||||||
|
}
|
||||||
|
//站点名称
|
||||||
|
stations.append(cellValue);
|
||||||
|
stations.append(",");
|
||||||
|
//排放数据
|
||||||
|
Cell releaseCell = row.getCell(5);
|
||||||
|
double releaseCellValue = releaseCell.getNumericCellValue();
|
||||||
|
|
||||||
|
Sheet releaseDataSheet = outputWorkBook.createSheet(cellValue);
|
||||||
|
Row zeroRow = releaseDataSheet.createRow(0);
|
||||||
|
zeroRow.setHeightInPoints(20);
|
||||||
|
Cell cell0 = zeroRow.createCell(0, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(0, 20*256);
|
||||||
|
cell0.setCellValue("开始时间");
|
||||||
|
cell0.setCellStyle(styles.get("header"));
|
||||||
|
Cell cell1 = zeroRow.createCell(1, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(1, 20*256);
|
||||||
|
cell1.setCellValue("结束时间");
|
||||||
|
cell1.setCellStyle(styles.get("header"));
|
||||||
|
Cell cell2 = zeroRow.createCell(2, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(2, 20*256);
|
||||||
|
cell2.setCellValue("排放量");
|
||||||
|
cell2.setCellStyle(styles.get("header"));
|
||||||
|
|
||||||
|
LocalDateTime startDate = LocalDateTime.of(2014,1,1,0,0,0);
|
||||||
|
LocalDateTime endDate = LocalDateTime.of(2014,1,6,0,0,0);
|
||||||
|
|
||||||
|
int rowNum = 1;
|
||||||
|
while(startDate.isBefore(endDate)) {
|
||||||
|
Row bodyRow = releaseDataSheet.createRow(rowNum);
|
||||||
|
Cell bodyCell0 = bodyRow.createCell(0, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(0, 20*256);
|
||||||
|
bodyCell0.setCellValue(startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
|
bodyCell0.setCellStyle(styles.get("data"));
|
||||||
|
|
||||||
|
startDate = startDate.plusDays(1);
|
||||||
|
Cell bodyCell1 = bodyRow.createCell(1, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(1, 20*256);
|
||||||
|
bodyCell1.setCellValue(startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
|
bodyCell1.setCellStyle(styles.get("data"));
|
||||||
|
|
||||||
|
Cell bodyCell2 = bodyRow.createCell(2, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(2, 20*256);
|
||||||
|
bodyCell2.setCellValue(releaseCellValue);
|
||||||
|
bodyCell2.setCellStyle(styles.get("scientific"));
|
||||||
|
rowNum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理MIPFexcel数据
|
||||||
|
* @param outputWorkBook
|
||||||
|
* @param styles
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private void handleMIPFExcelReleaseData(Workbook outputWorkBook,Map<String, CellStyle> styles,StringBuilder stations) throws Exception {
|
||||||
|
String inputFilePath = "F://工作//五木//放射性核素监测数据综合分析及氙本底源解析系统//其他资料//排放数据//MIPF_Stackdata//MIPF_Stackdata1.xlsx";
|
||||||
|
InputStream inputFileInputStream = new FileInputStream(inputFilePath);
|
||||||
|
Workbook inputWorkBook = new XSSFWorkbook(inputFileInputStream);
|
||||||
|
|
||||||
|
Iterator<Sheet> sheets = inputWorkBook.sheetIterator();
|
||||||
|
while(sheets.hasNext()) {
|
||||||
|
Sheet sheet = sheets.next();
|
||||||
|
|
||||||
|
stations.append(sheet.getSheetName());
|
||||||
|
stations.append(",");
|
||||||
|
|
||||||
|
Sheet releaseDataSheet = outputWorkBook.createSheet(sheet.getSheetName());
|
||||||
|
Row zeroRow = releaseDataSheet.createRow(0);
|
||||||
|
zeroRow.setHeightInPoints(20);
|
||||||
|
Cell cell0 = zeroRow.createCell(0, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(0, 20*256);
|
||||||
|
cell0.setCellValue("开始时间");
|
||||||
|
cell0.setCellStyle(styles.get("header"));
|
||||||
|
Cell cell1 = zeroRow.createCell(1, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(1, 20*256);
|
||||||
|
cell1.setCellValue("结束时间");
|
||||||
|
cell1.setCellStyle(styles.get("header"));
|
||||||
|
Cell cell2 = zeroRow.createCell(2, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(2, 20*256);
|
||||||
|
cell2.setCellValue("排放量");
|
||||||
|
cell2.setCellStyle(styles.get("header"));
|
||||||
|
|
||||||
|
for (int i = 1; i < sheet.getLastRowNum(); i++) {
|
||||||
|
Row row = sheet.getRow(i);
|
||||||
|
Row bodyRow = releaseDataSheet.createRow(i);
|
||||||
|
Cell bodyCell0 = bodyRow.createCell(0, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(0, 20*256);
|
||||||
|
bodyCell0.setCellValue(row.getCell(0).getStringCellValue());
|
||||||
|
bodyCell0.setCellStyle(styles.get("data"));
|
||||||
|
|
||||||
|
Cell bodyCell1 = bodyRow.createCell(1, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(1, 20*256);
|
||||||
|
bodyCell1.setCellValue(row.getCell(1).getStringCellValue());
|
||||||
|
bodyCell1.setCellStyle(styles.get("data"));
|
||||||
|
|
||||||
|
Cell bodyCell2 = bodyRow.createCell(2, CellType.STRING);
|
||||||
|
releaseDataSheet.setColumnWidth(2, 20*256);
|
||||||
|
bodyCell2.setCellValue(row.getCell(2).getNumericCellValue());
|
||||||
|
bodyCell2.setCellStyle(styles.get("scientific"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String,CellStyle> createStyles(Workbook workBook) {
|
||||||
|
Map<String, CellStyle> styles = new HashMap<>();
|
||||||
|
CellStyle style = workBook.createCellStyle();
|
||||||
|
style.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
style.setBorderRight(BorderStyle.THIN);
|
||||||
|
style.setRightBorderColor(IndexedColors.BLACK.index);
|
||||||
|
style.setBorderLeft(BorderStyle.THIN);
|
||||||
|
style.setLeftBorderColor(IndexedColors.BLACK.index);
|
||||||
|
style.setBorderTop(BorderStyle.THIN);
|
||||||
|
style.setTopBorderColor(IndexedColors.BLACK.index);
|
||||||
|
style.setBorderBottom(BorderStyle.THIN);
|
||||||
|
style.setBottomBorderColor(IndexedColors.BLACK.index);
|
||||||
|
Font titleFont = workBook.createFont();
|
||||||
|
titleFont.setFontName("宋体");
|
||||||
|
titleFont.setFontHeightInPoints((short)16);
|
||||||
|
titleFont.setBold(true);
|
||||||
|
style.setFont(titleFont);
|
||||||
|
styles.put("title", style);
|
||||||
|
|
||||||
|
style = workBook.createCellStyle();
|
||||||
|
style.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
style.setBorderRight(BorderStyle.THIN);
|
||||||
|
style.setRightBorderColor(IndexedColors.BLACK.index);
|
||||||
|
style.setBorderLeft(BorderStyle.THIN);
|
||||||
|
style.setLeftBorderColor(IndexedColors.BLACK.index);
|
||||||
|
style.setBorderTop(BorderStyle.THIN);
|
||||||
|
style.setTopBorderColor(IndexedColors.BLACK.index);
|
||||||
|
style.setBorderBottom(BorderStyle.THIN);
|
||||||
|
style.setBottomBorderColor(IndexedColors.BLACK.index);
|
||||||
|
Font dataFont = workBook.createFont();
|
||||||
|
dataFont.setFontName("宋体");
|
||||||
|
dataFont.setFontHeightInPoints((short)11);
|
||||||
|
style.setFont(dataFont);
|
||||||
|
styles.put("data", style);
|
||||||
|
|
||||||
|
style = workBook.createCellStyle();
|
||||||
|
style.cloneStyleFrom(styles.get("data"));
|
||||||
|
Font headerFont = workBook.createFont();
|
||||||
|
headerFont.setFontName("宋体");
|
||||||
|
headerFont.setFontHeightInPoints((short) 11);
|
||||||
|
headerFont.setBold(true);
|
||||||
|
style.setFont(headerFont);
|
||||||
|
styles.put("header", style);
|
||||||
|
|
||||||
|
style = workBook.createCellStyle();
|
||||||
|
style.cloneStyleFrom(styles.get("data"));
|
||||||
|
Font numericalValueFont = workBook.createFont();
|
||||||
|
numericalValueFont.setFontName("宋体");
|
||||||
|
numericalValueFont.setFontHeightInPoints((short) 11);
|
||||||
|
style.setFont(numericalValueFont);
|
||||||
|
DataFormat format = workBook.createDataFormat();
|
||||||
|
style.setDataFormat(format.getFormat("0.00E+0"));
|
||||||
|
styles.put("scientific", style);
|
||||||
|
|
||||||
|
return styles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入任务
|
||||||
|
* @param file
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<String> importTask(MultipartFile file) throws IOException {
|
||||||
|
List<String> info = new ArrayList<>();
|
||||||
|
if (Objects.isNull(file)) {
|
||||||
|
info.add("上传文件对象为空");
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
if (!file.getOriginalFilename().endsWith(".xlsx")) {
|
||||||
|
info.add("上传文件必须为.xlsx格式的excel文件");
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
Workbook workBook = new XSSFWorkbook(file.getInputStream());
|
||||||
|
//封装任务
|
||||||
|
TransportTask transportTask = new TransportTask();
|
||||||
|
this.handleTaskBaseInfo(transportTask,workBook,info);
|
||||||
|
this.handleSiteReleaseInfo(transportTask,workBook,info);
|
||||||
|
TransactionStatus transaction = transactionManager.getTransaction(transactionDefinition);
|
||||||
|
try{
|
||||||
|
//此处属于内部调用create函数的事务注解不会生效,所以用手动事务
|
||||||
|
this.cteate(transportTask);
|
||||||
|
transactionManager.commit(transaction);
|
||||||
|
}catch (Exception e){
|
||||||
|
transactionManager.rollback(transaction);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理任务基础信息
|
||||||
|
* @param transportTask
|
||||||
|
* @param workBook
|
||||||
|
* @param info
|
||||||
|
*/
|
||||||
|
private void handleTaskBaseInfo(TransportTask transportTask,Workbook workBook,List<String> info){
|
||||||
|
Sheet sheet = workBook.getSheetAt(0);
|
||||||
|
//设置任务名称
|
||||||
|
Cell taskCell = sheet.getRow(1).getCell(1);
|
||||||
|
String taskCellValue = taskCell.getStringCellValue();
|
||||||
|
if (StrUtil.isBlank(taskCellValue)) {
|
||||||
|
info.add("任务名称不能为空");
|
||||||
|
}else {
|
||||||
|
transportTask.setTaskName(taskCell.getStringCellValue());
|
||||||
|
}
|
||||||
|
//设置任务模式
|
||||||
|
Cell taskModeCell = sheet.getRow(1).getCell(3);
|
||||||
|
Integer taskModeCellValue = (int)taskModeCell.getNumericCellValue();
|
||||||
|
if (!TransportTaskModeEnum.FORWARD.getKey().equals(taskModeCellValue) &&
|
||||||
|
!TransportTaskModeEnum.BACK_FORWARD.getKey().equals(taskModeCellValue)) {
|
||||||
|
info.add("任务模式配置错误");
|
||||||
|
}else {
|
||||||
|
transportTask.setTaskMode(taskModeCellValue);
|
||||||
|
}
|
||||||
|
//设置气象数据来源
|
||||||
|
Cell metDataSourceCell = sheet.getRow(1).getCell(5);
|
||||||
|
Integer metDataSourceCellValue = (int)metDataSourceCell.getNumericCellValue();
|
||||||
|
if (!WeatherDataSourceEnum.PANGU.getKey().equals(metDataSourceCellValue) &&
|
||||||
|
!WeatherDataSourceEnum.GRAPHCAST.getKey().equals(metDataSourceCellValue) &&
|
||||||
|
!WeatherDataSourceEnum.T1H.getKey().equals(metDataSourceCellValue) &&
|
||||||
|
!WeatherDataSourceEnum.FNL.getKey().equals(metDataSourceCellValue) &&
|
||||||
|
!WeatherDataSourceEnum.NCEP.getKey().equals(metDataSourceCellValue) &&
|
||||||
|
!WeatherDataSourceEnum.CRA40.getKey().equals(metDataSourceCellValue)) {
|
||||||
|
info.add("气象数据来源配置错误");
|
||||||
|
}else {
|
||||||
|
transportTask.setUseMetType(metDataSourceCellValue);
|
||||||
|
}
|
||||||
|
//设置释放下部高度
|
||||||
|
Cell z1Cell = sheet.getRow(2).getCell(1);
|
||||||
|
transportTask.setZ1(z1Cell.getNumericCellValue());
|
||||||
|
//设置释放上部高度
|
||||||
|
Cell z2Cell = sheet.getRow(2).getCell(3);
|
||||||
|
transportTask.setZ2(z2Cell.getNumericCellValue());
|
||||||
|
//设置粒子数量
|
||||||
|
Cell particleCountCell = sheet.getRow(2).getCell(5);
|
||||||
|
transportTask.setParticleCount((int)particleCountCell.getNumericCellValue());
|
||||||
|
//设置开始时间
|
||||||
|
Cell startTimeCell = sheet.getRow(3).getCell(1);
|
||||||
|
String startTimeCellValue = startTimeCell.getStringCellValue();
|
||||||
|
transportTask.setStartTime(LocalDateTime.parse(startTimeCellValue, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
|
//设置结束时间
|
||||||
|
Cell endTimeCell = sheet.getRow(3).getCell(3);
|
||||||
|
String endTimeCellValue = endTimeCell.getStringCellValue();
|
||||||
|
transportTask.setEndTime(LocalDateTime.parse(endTimeCellValue,DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
|
//设置释放数据来源
|
||||||
|
Cell releaseDataSourceCell = sheet.getRow(3).getCell(5);
|
||||||
|
Integer releaseDataSourceCellValue = (int)releaseDataSourceCell.getNumericCellValue();
|
||||||
|
if (!TransportReleaseDataSource.AUTO_SELECT.getKey().equals(releaseDataSourceCellValue) &&
|
||||||
|
!TransportReleaseDataSource.MANUAL_ENTRY.getKey().equals(releaseDataSourceCellValue)) {
|
||||||
|
info.add("释放数据来源配置错误");
|
||||||
|
}else {
|
||||||
|
transportTask.setReleaseDataSource(releaseDataSourceCellValue);
|
||||||
|
}
|
||||||
|
//设置释放核素
|
||||||
|
Cell releaseNuclideCell = sheet.getRow(4).getCell(1);
|
||||||
|
String releaseNuclideCellValue = "";
|
||||||
|
if (releaseNuclideCell.getCellType() == CellType.NUMERIC) {
|
||||||
|
releaseNuclideCellValue = String.valueOf((int)releaseNuclideCell.getNumericCellValue());
|
||||||
|
}else if (releaseNuclideCell.getCellType() == CellType.STRING) {
|
||||||
|
releaseNuclideCellValue = releaseNuclideCell.getStringCellValue();
|
||||||
|
}
|
||||||
|
String[] nuclides = releaseNuclideCellValue.split(",");
|
||||||
|
if (ArrayUtil.isNotEmpty(nuclides)){
|
||||||
|
List<TransportTaskForwardSpecies> species = new ArrayList<>();
|
||||||
|
for (String nuclidId : nuclides) {
|
||||||
|
if(FlexpartSpeciesType.XE_131m.getValue().toString().equals(nuclidId) ||
|
||||||
|
FlexpartSpeciesType.XE_133.getValue().toString().equals(nuclidId) ||
|
||||||
|
FlexpartSpeciesType.XE_133m.getValue().toString().equals(nuclidId) ||
|
||||||
|
FlexpartSpeciesType.XE_135.getValue().toString().equals(nuclidId)) {
|
||||||
|
TransportTaskForwardSpecies forwardSpecies = new TransportTaskForwardSpecies();
|
||||||
|
forwardSpecies.setSpeciesId(nuclidId);
|
||||||
|
species.add(forwardSpecies);
|
||||||
|
}else {
|
||||||
|
info.add("释放核素信息配置错误,没有:"+nuclidId+"这个选项");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(species)) {
|
||||||
|
transportTask.setSpecies(species);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
info.add("缺失释放核素配置信息");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验设施列表并检查排放数据
|
||||||
|
*/
|
||||||
|
private void handleSiteReleaseInfo(TransportTask transportTask,Workbook workBook,List<String> info){
|
||||||
|
List<Map<String, Object>> facilities = stationDataService.getAllNuclearFacilitiesAndReactors();
|
||||||
|
List<TransportTaskForwardChild> forwardChilds = new ArrayList<>();
|
||||||
|
|
||||||
|
if (TransportReleaseDataSource.AUTO_SELECT.getKey().equals(transportTask.getReleaseDataSource())) {
|
||||||
|
Sheet sheet = workBook.getSheetAt(0);
|
||||||
|
Cell sitesCell = sheet.getRow(5).getCell(1);
|
||||||
|
String sitesCellValue = sitesCell.getStringCellValue();
|
||||||
|
String[] site = sitesCellValue.split(",");
|
||||||
|
if (ArrayUtil.isNotEmpty(site)) {
|
||||||
|
for (String siteName : site) {
|
||||||
|
boolean flag = false;
|
||||||
|
for (Map<String, Object> facilitie : facilities) {
|
||||||
|
if (siteName.equalsIgnoreCase(facilitie.get("facilityName").toString())) {
|
||||||
|
TransportTaskForwardChild forwardChild = new TransportTaskForwardChild();
|
||||||
|
forwardChild.setStationCode(facilitie.get("facilityName").toString());
|
||||||
|
forwardChild.setLon((double)facilitie.get("longitude"));
|
||||||
|
forwardChild.setLat((double)facilitie.get("latitude"));
|
||||||
|
forwardChilds.add(forwardChild);
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!flag) {
|
||||||
|
info.add(siteName+"设施在数据库中未找到");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
info.add("缺失设施列表配置信息");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (TransportReleaseDataSource.MANUAL_ENTRY.getKey().equals(transportTask.getReleaseDataSource())) {
|
||||||
|
int sheetNum = workBook.getNumberOfSheets();
|
||||||
|
System.out.println(sheetNum);
|
||||||
|
if (sheetNum <= 1) {
|
||||||
|
info.add("释放数据来源配置参数为:手动填写,但对应释放信息未配置");
|
||||||
|
}else {
|
||||||
|
for (int i = 1; i < sheetNum; i++) {
|
||||||
|
Sheet sheet = workBook.getSheetAt(i);
|
||||||
|
boolean flag = false;
|
||||||
|
TransportTaskForwardChild forwardChild = new TransportTaskForwardChild();
|
||||||
|
for (Map<String, Object> facilitie : facilities) {
|
||||||
|
String facilityName = facilitie.get("facilityName").toString();
|
||||||
|
if (facilityName.contains("/")) {
|
||||||
|
facilityName = facilityName.replace("/","");
|
||||||
|
}
|
||||||
|
if (sheet.getSheetName().equalsIgnoreCase(facilityName)) {
|
||||||
|
// System.out.println(facilityName);
|
||||||
|
forwardChild.setStationCode(facilitie.get("facilityName").toString());
|
||||||
|
forwardChild.setLon(Double.valueOf(facilitie.get("longitude").toString()));
|
||||||
|
forwardChild.setLat(Double.valueOf(facilitie.get("latitude").toString()));
|
||||||
|
|
||||||
|
List<TransportTaskForwardRelease> releases = new ArrayList<>();
|
||||||
|
for (int j=1;j<sheet.getLastRowNum();j++) {
|
||||||
|
Row row = sheet.getRow(j);
|
||||||
|
//获取开始时间
|
||||||
|
Cell startTimeCell = row.getCell(0);
|
||||||
|
String startTimeCellValue = startTimeCell.getStringCellValue();
|
||||||
|
//获取结束时间
|
||||||
|
Cell endTimeCell = row.getCell(1);
|
||||||
|
String endTimeCellValue = endTimeCell.getStringCellValue();
|
||||||
|
//获取释放数据
|
||||||
|
Cell releaseDataCell = row.getCell(2);
|
||||||
|
String releaseCellValue = "";
|
||||||
|
if (releaseDataCell.getCellType() == CellType.NUMERIC) {
|
||||||
|
releaseCellValue = String.valueOf(releaseDataCell.getNumericCellValue());
|
||||||
|
}else if (releaseDataCell.getCellType() == CellType.STRING) {
|
||||||
|
releaseCellValue = releaseDataCell.getStringCellValue();
|
||||||
|
}
|
||||||
|
if(StrUtil.isBlank(startTimeCellValue) || StrUtil.isBlank(endTimeCellValue)){
|
||||||
|
info.add(sheet.getSheetName()+"设施所在sheet的排放数据有缺失");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
TransportTaskForwardRelease release = new TransportTaskForwardRelease();
|
||||||
|
release.setStartTime(LocalDateTime.parse(startTimeCellValue,DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
|
release.setEndTime(LocalDateTime.parse(endTimeCellValue,DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
|
release.setReleaseAmount(releaseCellValue);
|
||||||
|
releases.add(release);
|
||||||
|
}
|
||||||
|
if(CollUtil.isNotEmpty(releases)){
|
||||||
|
forwardChild.setForwardReleaseChild(releases);
|
||||||
|
}
|
||||||
|
forwardChilds.add(forwardChild);
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!flag) {
|
||||||
|
info.add(sheet.getSheetName()+"设施在数据库中未找到");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
transportTask.setForwardChild(forwardChilds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ public class ForwardTaskExec extends AbstractTaskExec{
|
||||||
//如果此任务已存在历史日志,先清除
|
//如果此任务已存在历史日志,先清除
|
||||||
super.transportTaskService.deleteTaskLog(super.transportTask.getId());
|
super.transportTaskService.deleteTaskLog(super.transportTask.getId());
|
||||||
//检查气象数据
|
//检查气象数据
|
||||||
this.checkMetData();
|
// this.checkMetData();
|
||||||
//执行模拟
|
//执行模拟
|
||||||
this.execSimulation();
|
this.execSimulation();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
|
|
@ -189,11 +189,11 @@ public class ForwardTaskExec extends AbstractTaskExec{
|
||||||
String execScriptMsg = "执行任务脚本,开始模拟,路径为:"+scriptPath;
|
String execScriptMsg = "执行任务脚本,开始模拟,路径为:"+scriptPath;
|
||||||
ProgressQueue.getInstance().offer(new ProgressEvent(super.transportTask.getId(),execScriptMsg));
|
ProgressQueue.getInstance().offer(new ProgressEvent(super.transportTask.getId(),execScriptMsg));
|
||||||
//ssh连接宿主机调用flexpart
|
//ssh连接宿主机调用flexpart
|
||||||
JSchRemoteRunner jschRemoteRunner = new JSchRemoteRunner();
|
// JSchRemoteRunner jschRemoteRunner = new JSchRemoteRunner();
|
||||||
jschRemoteRunner.setCommand(scriptPath);
|
// jschRemoteRunner.setCommand(scriptPath);
|
||||||
jschRemoteRunner.login(super.serverProperties.getHost(),super.serverProperties.getPort(),
|
// jschRemoteRunner.login(super.serverProperties.getHost(),super.serverProperties.getPort(),
|
||||||
super.serverProperties.getUsername(),super.serverProperties.getPassword());
|
// super.serverProperties.getUsername(),super.serverProperties.getPassword());
|
||||||
jschRemoteRunner.execCommand();
|
// jschRemoteRunner.execCommand();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user