提交 67b1e5a5 authored 作者: 马晨俊's avatar 马晨俊

mcj:

修复导入excel问题
上级 17667656
......@@ -384,8 +384,11 @@ public class InspectController {
@PostMapping("/uploads")
private ServerResponse uploads(@RequestParam(value = "file") MultipartFile multfile) {
try {
HashMap<String, String> map = new HashMap<>();
map.put("unzip","获取压缩文件");
File file = FileUtil.saveToLocal(multfile);
map.put("unzip","压缩文件解压完毕");
asyncTask.sendMessageToAll(map);
String name = file.getName();
String path = file.getCanonicalPath();
return ServerResponse.ok(new com.zjty.inspect.entity.File(name, path));
......
......@@ -155,7 +155,12 @@ public class Inspector {
//初始化成员变量
initData();
//扫描文件,进行文件分类
HashMap<String, String> map = new HashMap<>();
map.put("file","开始扫描文件");
asyncTask.sendMessageToAll(map);
scanFiles();
map.put("file","文件扫描结束");
asyncTask.sendMessageToAll(map);
//配置参数
inspectParameter.setCodeSize((int) codeSize);
report.setFileNum(fileNum);
......@@ -166,7 +171,11 @@ public class Inspector {
//根据扫描结果以及用户配置得出需要使用的规则及技术
ruleTransform(inspectParameter.getRecastMethod());
//扫描源代码文件
map.put("file","开始扫描源代码文件");
asyncTask.sendMessageToAll(map);
forEachFilesMap();
map.put("file","源代码文件扫描结束");
asyncTask.sendMessageToAll(map);
//将得到的告警信息根据技术id进行转换
Set<String> technologyIds = warns.stream().map(Warn::getTechnologyId).collect(Collectors.toSet());
List<Technology> technologies = technologyDao.findAllById(technologyIds);
......
......@@ -69,10 +69,9 @@ public class ExcelUtil {
if (split.length > 1) {
reform.setUnitContent(split[0]);
reform.setUnitPhone(split[1]);
}else if(split.length == 1){
} else if (split.length == 1) {
reform.setUnitContent(split[0]);
}
reform.setUnitName(unitName);
//系统名称
......@@ -102,7 +101,7 @@ public class ExcelUtil {
if (nativeUnit.length > 1) {
reform.setLocalContact(nativeUnit[0]);
reform.setLocalPhone(nativeUnit[1]);
}else if(nativeUnit.length > 0){
} else if (nativeUnit.length > 0) {
reform.setLocalContact(nativeUnit[0]);
}
......@@ -113,7 +112,7 @@ public class ExcelUtil {
reform.setGradeProtection(yesOrNo(gradeProtection));
String construction = getExcelCell(10, 2, sheetAt);
reform.setFramework( getFramework(construction));
reform.setFramework(getFramework(construction));
String disaster = getExcelCell(11, 2, sheetAt);
int i2 = SpecialYesOrNo(disaster);
......@@ -146,11 +145,10 @@ public class ExcelUtil {
BaseDes devFramework = new BaseDes();
FrameWorkEnum frameWorkEnum = FrameWorkEnum.getByName(framework);
if (frameWorkEnum != null) {
if(frameWorkEnum.getCode()==15){
devFramework.setName(remark);
}else{
devFramework.setName(frameWorkEnum.getName());
if (frameWorkEnum.getCode() == -1) {
continue;
}
devFramework.setName(frameWorkEnum.getName());
devFramework.setCode(frameWorkEnum.getCode());
devFramework.setVersion(version);
devFramework.setDes(remark);
......@@ -171,11 +169,7 @@ public class ExcelUtil {
BaseDes font = new BaseDes();
FontTechnologyEnum fontTechnologyEnum = FontTechnologyEnum.getByName(framework);
if (fontTechnologyEnum != null) {
if(fontTechnologyEnum.getCode()==15){
font.setName(remark);
}else{
font.setName(fontTechnologyEnum.getName());
}
font.setCode(fontTechnologyEnum.getCode());
font.setDes(remark);
font.setVersion(version);
......@@ -197,11 +191,7 @@ public class ExcelUtil {
cs.setVersion(version);
CSTechnologyEnum csTechnologyEnum = CSTechnologyEnum.getByName(framework);
if (csTechnologyEnum != null) {
if(csTechnologyEnum.getCode()==10){
cs.setName(remark);
}else{
cs.setName(csTechnologyEnum.getName());
}
cs.setCode(csTechnologyEnum.getCode());
fontDevTechnologies.add(cs);
}
......@@ -220,11 +210,7 @@ public class ExcelUtil {
BaseDes opGA = new BaseDes();
OpgaEnum opgaEnum = OpgaEnum.getByName(framework);
if (opgaEnum != null) {
if(opgaEnum.getCode()==4){
opGA.setName(remark);
}else{
opGA.setName(framework);
}
opGA.setCode(opgaEnum.getCode());
opGA.setVersion(version);
opGA.setDes(remark);
......@@ -248,11 +234,7 @@ public class ExcelUtil {
BaseDes devLanguage = new BaseDes();
LanguageEnum languageEnum = LanguageEnum.getByName(lan);
if (languageEnum != null) {
if(languageEnum.getCode()==12){
devLanguage.setName(languageEnum.getName());
}else{
devLanguage.setName(remark);
}
devLanguage.setCode(languageEnum.getCode());
devLanguage.setVersion(version);
devLanguage.setDes(remark);
......@@ -276,11 +258,7 @@ public class ExcelUtil {
if (middlewareEnum != null) {
BaseDes baseDes = new BaseDes();
baseDes.setDes(remark);
if(middlewareEnum.getCode()==15){
baseDes.setName(remark);
}else{
baseDes.setName(middlewareEnum.name());
}
baseDes.setCode(middlewareEnum.getCode());
baseDes.setVersion(version);
middlewareEnums.add(baseDes);
......@@ -299,11 +277,7 @@ public class ExcelUtil {
String remark = getExcelCell(i, 4, sheetAt);
OtherApi otherApi = new OtherApi();
OtherApiEnum otherApiEnum = OtherApiEnum.getByName(api);
if(otherApiEnum.getOther()==1){
otherApi.setApiName(remark);
}else{
otherApi.setApiName(api);
}
otherApi.setDes(remark);
otherApi.setVersion(version);
otherApi.setCode(String.valueOf(otherApiEnum.getCode()));
......@@ -322,11 +296,7 @@ public class ExcelUtil {
BaseDes microService = new BaseDes();
MicroServiceEnum microServiceEnum = MicroServiceEnum.getByName(name);
if (microServiceEnum != null) {
if(microServiceEnum.getOther()==1){
microService.setName(remark);
}else{
microService.setName(microServiceEnum.getName());
}
microService.setCode(microServiceEnum.getCode());
microService.setDes(remark);
microService.setVersion(version);
......@@ -389,11 +359,7 @@ public class ExcelUtil {
String remark = getExcelCell(i, 4, sheetAt);
CompatibleBrowser compatibleBrowser = CompatibleBrowser.getByName(brows);
BaseDes baseDes = new BaseDes();
if(compatibleBrowser.getCode()==3){
baseDes.setName(remark);
}else{
baseDes.setName(compatibleBrowser.getName());
}
baseDes.setCode(compatibleBrowser.getCode());
baseDes.setVersion(version);
baseDes.setDes(remark);
......@@ -413,11 +379,7 @@ public class ExcelUtil {
browserPlug.setDes(remark);
BrowserPlugEnum browserPlugEnum = BrowserPlugEnum.getByName(plugin);
if(browserPlugEnum.getOther()==1){
browserPlug.setName(remark);
}else{
browserPlug.setName(browserPlugEnum.getName());
}
browserPlug.setCode(browserPlugEnum.getCode());
switch (plugin) {
case "在线文本编辑类:请在备注中填写插件名和版本":
......@@ -442,7 +404,7 @@ public class ExcelUtil {
reform.setBrowser(browser);
String apply = getExcelCell(110, 2, sheetAt);
Apply apply1 = new Apply();
if(!"".equals(apply)){
if (!"".equals(apply)) {
apply1.setCost(Double.valueOf(apply));
}
String remark = getExcelCell(110, 3, sheetAt);
......@@ -484,11 +446,11 @@ public class ExcelUtil {
reform.setRpo(rpoEnum.getCode());
}
int max = Math.max(rpoEnum.getCode(), rtoEnum.getCode());
if(max==1){
if (max == 1) {
reform.setStrategy(3);
}else if(max<=5){
} else if (max <= 5) {
reform.setStrategy(1);
}else {
} else {
reform.setStrategy(2);
}
return reform;
......@@ -496,7 +458,6 @@ public class ExcelUtil {
public static List<ExcelDataTemp> parseExcel2Entity(Evaluation evaluation) {
ArrayList<ExcelDataTemp> excelDataTemps = new ArrayList<>();
ArrayList<String> tables = new ArrayList<>();
String inEva = evaluation.getInEva();
ExcelDataTemp excelDataTemp = new ExcelDataTemp();
excelDataTemp.setName("基本信息");
......@@ -505,14 +466,14 @@ public class ExcelUtil {
Reform reform = JSON.parseObject(evaluation.getInEva(), Reform.class);
arrayList.add(exportEntity("用户名", reform.getUsername()));
if(reform.getAssessmentType()==1){
if (reform.getAssessmentType() == 1) {
arrayList.add(exportEntity("评估类型", "快速评估"));
}else{
} else {
arrayList.add(exportEntity("评估类型", "详细评估"));
}
if(reform.getMode()==1){
if (reform.getMode() == 1) {
arrayList.add(exportEntity("替换方式", "改造"));
}else{
} else {
arrayList.add(exportEntity("替换方式", "适配"));
}
arrayList.add(exportEntity("系统名称", reform.getProjectName()));
......@@ -647,6 +608,7 @@ public class ExcelUtil {
}
return -1;
}
private static String getFilpFramework(int construction) {
switch (construction) {
case 1:
......@@ -672,6 +634,7 @@ public class ExcelUtil {
return -1;
}
}
private static int SpecialYesOrNo(String target) {
if ("是".equals(target)) {
return 4;
......@@ -681,6 +644,7 @@ public class ExcelUtil {
return -1;
}
}
private static String flipYesOrNo(Integer target) {
if (target == 1) {
return "是";
......@@ -690,8 +654,9 @@ public class ExcelUtil {
return "我不清楚";
}
}
private static String flipSafeYesOrNo(Integer target) {
if(target==null){
if (target == null) {
return "否";
}
if (target == 4) {
......@@ -702,6 +667,7 @@ public class ExcelUtil {
return "我不清楚";
}
}
private static String flipSpecialYesOrNo(Integer target) {
if (target == 4) {
return "是";
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论