提交 f7e9e969 authored 作者: czq's avatar czq

Merge branch 'master' of git.yfzx.zjtys.com.cn:912-system/monitor/inspect into czq

......@@ -27,6 +27,16 @@
</properties>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
......
......@@ -366,6 +366,7 @@ public class InspectController {
String in = JSON.toJSONString(reform);
//输出参数
String out = JSON.toJSONString(assessmentReport);
evaluation.setInEva(in);
evaluation.setOutEva(out);
evaluation.setUsername(reform.getUsername());
......
package com.zjty.inspect.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ExcelDataVo {
private String name;
}
......@@ -46,6 +46,8 @@ public class Technology {
* 1:支持
* 2:不支持
* 3:未知
* 4:不完全支持
* 5:优化
*/
@ApiModelProperty(value = "是否支持",example = "1")
private Integer support;
......
......@@ -15,7 +15,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import springfox.documentation.spring.web.json.Json;
import java.io.IOException;
import java.nio.charset.MalformedInputException;
......@@ -32,7 +31,7 @@ import java.util.stream.Collectors;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Service("property")
@Service
@Slf4j
@Transactional()
public class Inspector {
......@@ -503,12 +502,12 @@ public class Inspector {
HashMap<String, List<Warn>> warnMap = new HashMap<>();
for (Warn warn : warns) {
if(!warnMap.containsKey(techMap.get(warn.getTechnologyId()).getId())){
if(!warnMap.containsKey(warn.getTechnologyName())){
ArrayList<Warn> warns1 = new ArrayList<>();
warns1.add(warn);
warnMap.put(techMap.get(warn.getTechnologyId()).getTechnologyName(), warns1);
}else{
warnMap.get(techMap.get(warn.getTechnologyId()).getTechnologyName()).add(warn);
warnMap.get(warn.getTechnologyName()).add(warn);
}
}
for (Technology technology : technologies) {
......
......@@ -29,14 +29,18 @@ public class EvaluationServiceImpl implements EvaluationService {
private EvaluationDao evaluationDao;
@Override
public void save(Evaluation evaluation) {
String uuid = UUIDUtil.getUUID();
evaluation.setId(uuid);
Evaluation evaluation1 = evaluationDao.findByUsernameAndIdNot(evaluation.getUsername(),evaluation.getId());
if(evaluation1!=null){
return;
Evaluation evaluation2 = evaluationDao.findByUsername(evaluation.getUsername());
if(evaluation2==null){
String uuid = UUIDUtil.getUUID();
evaluation.setId(uuid);
evaluationDao.save(evaluation);
}else{
evaluation2.setId(evaluation2.getId());
evaluation2.setInEva(evaluation.getInEva());
evaluation2.setOutEva(evaluation.getOutEva());
evaluationDao.save(evaluation2);
}
evaluationDao.save(evaluation);
}
@Override
......
package com.zjty.inspect.utils;
import com.zjty.inspect.entity.ExcelDataVo;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
public class ExcelReader {
private static final String XLS = "xls";
private static final String XLSX = "xlsx";
/**
* 根据文件后缀名类型获取对应的工作簿对象
* @param inputStream 读取文件的输入流
* @param fileType 文件后缀名类型(xls或xlsx)
* @return 包含文件数据的工作簿对象
* @throws IOException
*/
public static Workbook getWorkbook(InputStream inputStream, String fileType) throws IOException {
Workbook workbook = null;
if (fileType.equalsIgnoreCase(XLS)) {
workbook = new HSSFWorkbook(inputStream);
} else if (fileType.equalsIgnoreCase(XLSX)) {
workbook = new XSSFWorkbook(inputStream);
}
return workbook;
}
/**
* 读取Excel文件内容
* @param fileName 要读取的Excel文件所在路径
* @return 读取结果列表,读取失败时返回null
*/
public static List<ExcelDataVo> readExcel(String fileName) {
Workbook workbook = null;
FileInputStream inputStream = null;
try {
// 获取Excel后缀名
String fileType = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
// 获取Excel文件
File excelFile = new File(fileName);
if (!excelFile.exists()) {
System.out.println("指定的Excel文件不存在!");
return null;
}
// 获取Excel工作簿
inputStream = new FileInputStream(excelFile);
workbook = getWorkbook(inputStream, fileType);
// 读取excel中的数据
List<ExcelDataVo> resultDataList = parseExcel(workbook);
return resultDataList;
} catch (Exception e) {
System.out.println("解析Excel失败,文件名:" + fileName + " 错误信息:" + e.getMessage());
return null;
} finally {
try {
if (null != workbook) {
workbook.close();
}
if (null != inputStream) {
inputStream.close();
}
} catch (Exception e) {
System.out.println("关闭数据流出错!错误信息:" + e.getMessage());
return null;
}
}
}
/**
* 解析Excel数据
* @param workbook Excel工作簿对象
* @return 解析结果
*/
private static List<ExcelDataVo> parseExcel(Workbook workbook) {
List<ExcelDataVo> resultDataList = new ArrayList<>();
// 解析sheet
for (int sheetNum = 0; sheetNum < workbook.getNumberOfSheets(); sheetNum++) {
Sheet sheet = workbook.getSheetAt(sheetNum);
// 校验sheet是否合法
if (sheet == null) {
continue;
}
// 获取第一行数据
int firstRowNum = sheet.getFirstRowNum();
Row firstRow = sheet.getRow(firstRowNum);
if (null == firstRow) {
System.out.println("解析Excel失败,在第一行没有读取到任何数据!");
}
// 解析每一行的数据,构造数据对象
int rowStart = firstRowNum + 1;
int rowEnd = sheet.getPhysicalNumberOfRows();
for (int rowNum = rowStart; rowNum < rowEnd; rowNum++) {
Row row = sheet.getRow(rowNum);
if (null == row) {
continue;
}
ExcelDataVo resultData = convertRowToData(row);
if (null == resultData) {
System.out.println("第 " + row.getRowNum() + "行数据不合法,已忽略!");
continue;
}
resultDataList.add(resultData);
}
}
return resultDataList;
}
/**
* 将单元格内容转换为字符串
* @param cell
* @return
*/
private static String convertCellValueToString(Cell cell) {
if(cell==null){
return null;
}
String returnValue = null;
switch (cell.getCellType()) {
case NUMERIC: //数字
Double doubleValue = cell.getNumericCellValue();
// 格式化科学计数法,取一位整数
DecimalFormat df = new DecimalFormat("0");
returnValue = df.format(doubleValue);
break;
case STRING: //字符串
returnValue = cell.getStringCellValue();
break;
case BOOLEAN: //布尔
Boolean booleanValue = cell.getBooleanCellValue();
returnValue = booleanValue.toString();
break;
case BLANK: // 空值
break;
case FORMULA: // 公式
returnValue = cell.getCellFormula();
break;
case ERROR: // 故障
break;
default:
break;
}
return returnValue;
}
/**
* 提取每一行中需要的数据,构造成为一个结果数据对象
*
* 当该行中有单元格的数据为空或不合法时,忽略该行的数据
*
* @param row 行数据
* @return 解析后的行数据对象,行数据错误时返回null
*/
private static ExcelDataVo convertRowToData(Row row) {
ExcelDataVo resultData = new ExcelDataVo();
Cell cell;
int cellNum = 0;
// 获取姓名
cell = row.getCell(cellNum++);
String name = convertCellValueToString(cell);
resultData.setName(name);
return resultData;
}
}
......@@ -48,7 +48,7 @@ public class FileUtil {
FileUtil.unPackRar(excelFile, "./"+name+"/"+split1[0]);
}
String[] split = fileName.split("\\.");
File file3 = new File("./"+name+"/"+split1[0]+"/"+split[0]);
File file3 = new File("./"+name+"/"+split1[0]);
excelFile.delete();
log.info("end unpack file");
return file3;
......
......@@ -396,22 +396,25 @@ public class WorkLoadUtil {
/*
建议:
*/
StringBuilder string = new StringBuilder("本系统通过源代码评估适配关键技术"+report.getTechnologyList().getTechnologyReports().size()+"项,"
+"其中");
StringBuilder string = new StringBuilder("本系统通过源代码评估适配关键技术"+report.getTechnologyList().getTechnologyReports().size()+"项,");
if(report.getTechnologyList().getTechnologyReports().size()>0){
string.append("其中");
}
for(TechnologyReport technologyReport:report.getTechnologyList().getTechnologyReports()){
string .append( technologyReport.getTechnology()+"修改项"+technologyReport.getTechnologyContents().size()+"个,");
}
report.getTechnologyList().setDes(string.substring(0,string.length()-1)+"。");
String type = "";
if(report.getType()==1){
if(report.getType()==2){
type = "改造";
}else if(report.getType()==2){
}else if(report.getType()==1){
type = "适配";
}
String workloadDes = "本系统通过选择"+type+"方式部署到国产化安全自主可控环境上。代码层面的关键工作量包含{开发量}*修正系数人工月(包含对不可预见的估算)";
String workloadDes = "本系统通过选择"+type+"方式部署到国产化安全自主可控环境上。代码层面的关键工作量包含"+nf.format(totalWorkload)+"人工月(包含对不可预见的估算)";
report.getWorkload().setDes(workloadDes);
double multipleHardrage = totalWorkload*r/f;
report.getDifficultyAssessment().setDes("本系统通过源代码评估,及用户额外信息提供,认为综合难度系数:"+Double.valueOf(nf.format(multipleHardrage)));
report.setDifficulty(Double.valueOf(nf.format(multipleHardrage)));
/**
* 人工单价、基础工作量(人月)、难度系数、额外申请(万元)、预算费用 的计算值
*/
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论