提交 4b753e73 authored 作者: 马晨俊's avatar 马晨俊

mcj:更新项目结构

上级 c5fff57b
com.zjty:inspect:jar:0.0.1-SNAPSHOT
+- org.eclipse.jgit:org.eclipse.jgit:jar:5.2.1.201812262042-r:compile
+- org.springframework.boot:spring-boot-starter-data-redis:jar:2.1.6.RELEASE:compile
| +- org.springframework.data:spring-data-redis:jar:2.1.9.RELEASE:compile
| | +- org.springframework.data:spring-data-keyvalue:jar:2.1.9.RELEASE:compile
| | +- org.springframework:spring-tx:jar:5.1.8.RELEASE:compile
| | +- org.springframework:spring-oxm:jar:5.1.8.RELEASE:compile
| | +- org.springframework:spring-aop:jar:5.1.8.RELEASE:compile
| | +- org.springframework:spring-context-support:jar:5.1.8.RELEASE:compile
| | \- org.slf4j:slf4j-api:jar:1.7.26:compile
| \- io.lettuce:lettuce-core:jar:5.1.7.RELEASE:compile
| +- io.netty:netty-common:jar:4.1.36.Final:compile
| +- io.netty:netty-handler:jar:4.1.36.Final:compile
| | +- io.netty:netty-buffer:jar:4.1.36.Final:compile
| | \- io.netty:netty-codec:jar:4.1.36.Final:compile
| +- io.netty:netty-transport:jar:4.1.36.Final:compile
| | \- io.netty:netty-resolver:jar:4.1.36.Final:compile
| \- io.projectreactor:reactor-core:jar:3.2.10.RELEASE:compile
| \- org.reactivestreams:reactive-streams:jar:1.0.2:compile
+- org.springframework.boot:spring-boot-starter:jar:2.1.6.RELEASE:compile
| +- org.springframework.boot:spring-boot:jar:2.1.6.RELEASE:compile
| | \- org.springframework:spring-context:jar:5.1.8.RELEASE:compile
| +- org.springframework.boot:spring-boot-autoconfigure:jar:2.1.6.RELEASE:compile
| +- org.springframework.boot:spring-boot-starter-logging:jar:2.1.6.RELEASE:compile
| | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
| | | \- ch.qos.logback:logback-core:jar:1.2.3:compile
| | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.11.2:compile
| | | \- org.apache.logging.log4j:log4j-api:jar:2.11.2:compile
| | \- org.slf4j:jul-to-slf4j:jar:1.7.26:compile
| +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
| \- org.springframework:spring-core:jar:5.1.8.RELEASE:compile
| \- org.springframework:spring-jcl:jar:5.1.8.RELEASE:compile
+- org.apache.maven.shared:maven-invoker:jar:3.0.1:compile
| +- org.apache.maven.shared:maven-shared-utils:jar:3.2.1:compile
| | \- commons-io:commons-io:jar:2.5:compile
| \- org.codehaus.plexus:plexus-component-annotations:jar:1.7.1:compile
+- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.1.6.RELEASE:compile
| +- org.springframework.boot:spring-boot-starter-aop:jar:2.1.6.RELEASE:compile
| | \- org.aspectj:aspectjweaver:jar:1.9.4:compile
| +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.1.6.RELEASE:compile
| | +- com.zaxxer:HikariCP:jar:3.2.0:compile
| | \- org.springframework:spring-jdbc:jar:5.1.8.RELEASE:compile
| +- javax.transaction:javax.transaction-api:jar:1.3:compile
| +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
| | \- javax.activation:javax.activation-api:jar:1.2.0:compile
| +- org.hibernate:hibernate-core:jar:5.3.10.Final:compile
| | +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
| | +- javax.persistence:javax.persistence-api:jar:2.2:compile
| | +- org.javassist:javassist:jar:3.23.2-GA:compile
| | +- net.bytebuddy:byte-buddy:jar:1.9.13:compile
| | +- antlr:antlr:jar:2.7.7:compile
| | +- org.jboss:jandex:jar:2.0.5.Final:compile
| | +- com.fasterxml:classmate:jar:1.4.0:compile
| | +- org.dom4j:dom4j:jar:2.1.1:compile
| | \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.4.Final:compile
| +- org.springframework.data:spring-data-jpa:jar:2.1.9.RELEASE:compile
| | +- org.springframework.data:spring-data-commons:jar:2.1.9.RELEASE:compile
| | +- org.springframework:spring-orm:jar:5.1.8.RELEASE:compile
| | \- org.springframework:spring-beans:jar:5.1.8.RELEASE:compile
| \- org.springframework:spring-aspects:jar:5.1.8.RELEASE:compile
+- org.springframework.boot:spring-boot-starter-web:jar:2.1.6.RELEASE:compile
| +- org.springframework.boot:spring-boot-starter-json:jar:2.1.6.RELEASE:compile
| | +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.9:compile
| | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
| | | \- com.fasterxml.jackson.core:jackson-core:jar:2.9.9:compile
| | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.9:compile
| | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.9:compile
| | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.9:compile
| +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.1.6.RELEASE:compile
| | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.21:compile
| | +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.21:compile
| | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.21:compile
| +- org.hibernate.validator:hibernate-validator:jar:6.0.17.Final:compile
| | \- javax.validation:validation-api:jar:2.0.1.Final:compile
| +- org.springframework:spring-web:jar:5.1.8.RELEASE:compile
| \- org.springframework:spring-webmvc:jar:5.1.8.RELEASE:compile
| \- org.springframework:spring-expression:jar:5.1.8.RELEASE:compile
+- com.alibaba:fastjson:jar:1.2.61:compile
+- mysql:mysql-connector-java:jar:8.0.16:compile
+- org.projectlombok:lombok:jar:1.18.8:compile
+- org.springframework.boot:spring-boot-starter-test:jar:2.1.6.RELEASE:test
| +- org.springframework.boot:spring-boot-test:jar:2.1.6.RELEASE:test
| +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.1.6.RELEASE:test
| +- com.jayway.jsonpath:json-path:jar:2.4.0:test
| | \- net.minidev:json-smart:jar:2.3:test
| | \- net.minidev:accessors-smart:jar:1.2:test
| | \- org.ow2.asm:asm:jar:5.0.4:test
| +- junit:junit:jar:4.12:test
| +- org.assertj:assertj-core:jar:3.11.1:test
| +- org.mockito:mockito-core:jar:2.23.4:test
| | +- net.bytebuddy:byte-buddy-agent:jar:1.9.13:test
| | \- org.objenesis:objenesis:jar:2.6:test
| +- org.hamcrest:hamcrest-core:jar:1.3:test
| +- org.hamcrest:hamcrest-library:jar:1.3:test
| +- org.skyscreamer:jsonassert:jar:1.5.0:test
| | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
| +- org.springframework:spring-test:jar:5.1.8.RELEASE:test
| \- org.xmlunit:xmlunit-core:jar:2.6.2:test
\- org.yaml:snakeyaml:jar:1.25:compile
package com.zjty.inspect.controller; package com.zjty.inspect.controller;
import com.zjty.inspect.entity.InspectParameter; import com.zjty.inspect.entity.InspectParameter;
import com.zjty.inspect.entity.ReportVo;
import com.zjty.inspect.service.InspectService; import com.zjty.inspect.service.InspectService;
import com.zjty.inspect.utils.FileUtil; import com.zjty.inspect.utils.FileUtil;
import com.zjty.inspect.utils.GitLabUtil;
import com.zjty.inspect.utils.MavenUtil; import com.zjty.inspect.utils.MavenUtil;
import com.zjty.inspect.utils.UUIDUtil;
import org.apache.commons.io.FileUtils;
import org.apache.tomcat.util.http.fileupload.disk.DiskFileItem;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import java.io.File; import java.io.*;
import java.io.IOException;
/** /**
* 评估接口 * 评估接口
...@@ -25,25 +31,36 @@ public class InspectController { ...@@ -25,25 +31,36 @@ public class InspectController {
/** /**
* 上传代码进行评估 * 上传代码进行评估
* @param inspectParameter * @param years
* @param systemFund
* @param modules
* @param multfile
* @return * @return
* @throws IOException
*/ */
@PostMapping("/path") @PostMapping("/path")
public ResponseEntity inspect(@RequestBody InspectParameter inspectParameter, MultipartFile file) throws IOException { public ResponseEntity inspect(Integer years,Integer systemFund,Integer modules
File file1 = file.getResource().getFile(); ,String valid,Double framework,Double safety,Double disaster,Integer data
if(file1.getName().endsWith("zip")){ ,Integer admin, MultipartFile multfile) throws IOException {
FileUtil.unPackZip(file1,"", "./");
}else{ File file = FileUtil.saveToLocal(multfile);
FileUtil.unPackRar(file1, "./"); InspectParameter inspectParameter = new InspectParameter();
} inspectParameter.setSourceAddress(file.getPath());
String[] split = file1.getName().split("\\."); inspectParameter.setSystemFund(systemFund);
File file2 = new File("./"+split[0]); inspectParameter.setAdmin(admin);
String path1 = file2.getPath(); inspectParameter.setModules(modules);
// File file1 = new File("/Users/mcj/IdeaProjects/inspect"); inspectParameter.setSafety(safety);
// String path1 = file1.getPath(); inspectParameter.setValid(valid);
inspectParameter.setPath(path1); inspectParameter.setYears(years);
inspectService.inspect(inspectParameter); inspectParameter.setDisaster(disaster);
return ResponseEntity.ok(200); inspectParameter.setData(data);
inspectParameter.setFramework(framework);
inspectParameter.setPath(file.getPath());
inspectParameter.setId(UUIDUtil.getUUID());
ReportVo reportVo = new ReportVo();
reportVo.setSourceAddress(file.getPath());
ReportVo inspect = inspectService.inspect(reportVo,inspectParameter);
return ResponseEntity.ok(inspect);
} }
/** /**
...@@ -53,7 +70,11 @@ public class InspectController { ...@@ -53,7 +70,11 @@ public class InspectController {
*/ */
@PostMapping("/git") @PostMapping("/git")
public ResponseEntity inspect1(@RequestBody InspectParameter inspectParameter){ public ResponseEntity inspect1(@RequestBody InspectParameter inspectParameter){
inspectService.inspect(inspectParameter); String path = GitLabUtil.downLoadProject(inspectParameter.getGitAddress());
inspectParameter.setId(UUIDUtil.getUUID());
ReportVo report1 = new ReportVo();
report1.setSourceAddress(path);
inspectService.inspect(report1,inspectParameter);
return ResponseEntity.ok(200); return ResponseEntity.ok(200);
} }
......
package com.zjty.inspect.controller;
import com.zjty.inspect.entity.Pages;
import com.zjty.inspect.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
/**
* 报告
*
* @author Mcj
* @date 2020-02-27 09:58
*/
@RequestMapping("/report")
@RestController
public class ReportController {
@Autowired
private ReportService reportService;
/**
* 历史报告查看
*
* @return 历史报告
*/
@GetMapping
public ResponseEntity history() {
return ResponseEntity.ok(reportService.getHistory());
}
/**
* 历史报告查看
*
* @return 历史报告
*/
@PostMapping
public ResponseEntity history(@RequestBody Pages pages) {
return ResponseEntity.ok(reportService.getHistory(pages.getPage()));
}
/**
* 历史报告查看
*
* @return 历史报告
*/
@GetMapping("/{id}")
public ResponseEntity getHistory(@PathVariable String id) {
return ResponseEntity.ok(reportService.getHistory(id));
}
/**
* 历史报告删除
*
* @return 历史报告
*/
@DeleteMapping
public ResponseEntity remove(String id) {
reportService.remove(id);
return ResponseEntity.ok(200);
}
}
package com.zjty.inspect.dao;
import com.zjty.inspect.entity.Budget;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
/**
*
* 预算
* @author mcj
*/
public interface BudgetDao extends JpaRepository<Budget,String> {
/**
* 根据报告id查询预算
* @param id 报告id
* @return
*/
List<Budget> findAllByReportIdEquals(String id);
/**
* 根据报告id删除
* @param id 报告id
*/
void deleteByReportIdEquals(String id);
}
...@@ -10,8 +10,7 @@ public interface CoefficientModelDao extends JpaRepository<CoefficientModel,Stri ...@@ -10,8 +10,7 @@ public interface CoefficientModelDao extends JpaRepository<CoefficientModel,Stri
/** /**
* 根据范围查询系数 * 根据范围查询系数
* @param name 内容名称 * @param name 内容名称
* @param scale 规模
* @return * @return
*/ */
List<CoefficientModel> findAllByNameInAndScaleEquals(List<String> name,Integer scale); List<CoefficientModel> findAllByNameIn(List<String> name);
} }
package com.zjty.inspect.dao;
import com.zjty.inspect.entity.Report;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ReportDao extends JpaRepository<Report,String> {
}
package com.zjty.inspect.dao;
import com.zjty.inspect.entity.TechnologyAndReport;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
/**
* 报告与适配技术中间表
* @author mcj
*/
public interface TechnologyAndReportDao extends JpaRepository<TechnologyAndReport,String> {
/**
* 根据报告id查询规则
* @param id 报告id
* @return list
*/
List<TechnologyAndReport> findAllByReportIdEquals(String id);
/**
* 根据报告id删除
* @param id 报告id
*/
void deleteByReportIdEquals(String id);
}
...@@ -16,11 +16,7 @@ import java.sql.Timestamp; ...@@ -16,11 +16,7 @@ import java.sql.Timestamp;
*/ */
@Data @Data
@Entity
public class Budget { public class Budget {
@Id
private String id;
/** /**
* 代码重构预算、代码修改预算、 * 代码重构预算、代码修改预算、
*/ */
...@@ -35,22 +31,4 @@ public class Budget { ...@@ -35,22 +31,4 @@ public class Budget {
*/ */
private String fundDetail; private String fundDetail;
/**
* 关键报告id
*/
private String reportId;
/**
* 数据创建时间
*/
@Column(name="create_time",columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP",insertable = false,updatable = false)
@Generated(GenerationTime.INSERT)
private Timestamp createDate;
/**
* 数据更新时间
*/
@Column(name="update_time",columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP",insertable = false)
@Generated(GenerationTime.ALWAYS)
private Timestamp updateDate;
} }
...@@ -13,7 +13,13 @@ import java.util.List; ...@@ -13,7 +13,13 @@ import java.util.List;
*/ */
@Data @Data
public class DepTreeVo implements Serializable { public class DepTreeVo implements Serializable {
private String id; private List<ProjectPom> depTreeList = new ArrayList<>();
private List<DepTree> depTreeList = new ArrayList<>(); private List<ProjectPom> frontend = new ArrayList<>();
private List<DepTree> frontend = new ArrayList<>();
public void add(ProjectPom projectPom){
depTreeList.add(projectPom);
}
public void addAll(List<ProjectPom> projectPoms){
depTreeList.addAll(projectPoms);
}
} }
...@@ -10,7 +10,7 @@ import java.util.ArrayList; ...@@ -10,7 +10,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* 传入参数,需要保存 * 传入参数
* @author Mcj * @author Mcj
* @date 2020-02-12 12:35 * @date 2020-02-12 12:35
*/ */
...@@ -49,16 +49,10 @@ public class InspectParameter { ...@@ -49,16 +49,10 @@ public class InspectParameter {
*/ */
private Integer modules; private Integer modules;
/**
* 每页预算
*/
private Integer pageBudget;
/** /**
* 数据量 * 数据量
*/ */
private Integer data; private Integer data;
/** /**
* 架构 * 架构
*/ */
...@@ -84,4 +78,36 @@ public class InspectParameter { ...@@ -84,4 +78,36 @@ public class InspectParameter {
* git地址 * git地址
*/ */
private String path; private String path;
/**
* null:无效
*/
private String valid;
/**
* 评估报告地址
*/
private String reportAddress;
/**
* 预算报告地址
*/
private String budgetAddress;
/**
* git上传地址
*/
private String gitAddress;
/**
* 源代码存储地址
*/
private String sourceAddress;
/**
* 是否管理员
* 1:是
* 0:否
*/
private Integer admin;
} }
...@@ -3,22 +3,28 @@ package com.zjty.inspect.entity; ...@@ -3,22 +3,28 @@ package com.zjty.inspect.entity;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.io.Serializable;
/** /**
* 依赖 * 依赖
* 入库
*/ */
@NoArgsConstructor @NoArgsConstructor
@Data @Data
public class PomDependency { public class PomDependency implements Serializable {
private String groupId = ""; private String groupId = "";
private String artifactId = ""; private String artifactId = "";
private String version = "";
private String gradle = ""; private String gradle = "";
/** /**
* 1:前端依赖 * 1:前端依赖
* 2:后端依赖 * 2:后端依赖
*/ */
private Integer type; private Integer type = 2;
/**
* 1:支持
* 2:不支持
*/
private Integer support;
} }
...@@ -3,41 +3,17 @@ package com.zjty.inspect.entity; ...@@ -3,41 +3,17 @@ package com.zjty.inspect.entity;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
*
* @author mcj
*/
@NoArgsConstructor @NoArgsConstructor
@Data @Data
public class ProjectPom { public class ProjectPom implements Serializable {
private List<Properties> properties = new ArrayList<>();
private Parent parent;
private String modelVersion;
private String groupId;
private String artifactId;
private String packaging;
private String version;
private String name;
private String description;
//private List<Prerequisite> prerequisites;//描述了这个项目构建环境中的前提条件。 -->
//private IssueManagement issueManagement;//项目的问题管理系统(Bugzilla, Jira, Scarab,或任何你喜欢的问题管理系统)的名称和URL
//private CiManagement ciManagement;//项目持续集成信息
//private String inceptionYear;//项目创建年份,4位数字。当产生版权信息时需要使用这个值
//private MailingLists mailingLists;//项目相关邮件列表信息
//private Developers developers;//项目开发者列表
//private Contributors contributors;//项目的其他贡献者列表
//private List<License> licenses;//该元素描述了项目所有License列表。 应该只列出该项目的license列表,不要列出依赖项目的 license列表。如果列出多个license,用户可以选择它们中的一个而不是接受所有license
//private Scm scm;//SCM(Source Control Management)标签允许你配置你的代码库,供Maven web站点和其它插件使用
//private Organization organization;//描述项目所属组织的各种属性。Maven产生的文档用
//private Build build;//构建项目需要的信息
//private List<Profile> profiles;//在列的项目构建profile,如果被激活,会修改构建处理
//private List<Module> modules;//模块(有时称作子项目) 被构建成项目的一部分。列出的每个模块元素是指向该模块的目录的相对路径
//private List<Repository> repositories;//发现依赖和扩展的远程仓库列表
//private List<PluginRepository> pluginRepositiries;//发现插件的远程仓库列表,这些插件用于构建和报表
private List<PomDependency> dependencies;
//private Repoting repoting;//该元素描述使用报表插件产生报表的规范。当用户执行“mvn site”,这些报表就会运行。 在页面导航栏能看到所有报表的链接
//private DependencyManagement dependencyManagement;//继承自该项目的所有子项目的默认依赖信息。这部分的依赖信息不会被立即解析,而是当子项目声明一个依赖(必须描述group ID和artifact ID信息),如果group ID和artifact ID以外的一些信息没有描述,则通过group ID和artifact ID匹配到这里的依赖,并使用这里的依赖信息
//private DistributionManagement distributionManagement;//项目分发信息,在执行mvn deploy后表示要发布的位置。有了这些信息就可以把网站部署到远程服务器或者把构件部署到远程仓库
//private Properties properties;//以值替代名称,Properties可以在整个POM中使用,也可以作为触发条件(见settings.xml配置文件里activation元素的说明)。格式是<name>value</name>
private List<PomDependency> dependencies = new ArrayList<>();
} }
...@@ -17,19 +17,11 @@ import java.util.List; ...@@ -17,19 +17,11 @@ import java.util.List;
* 报告 * 报告
* @author mcj * @author mcj
*/ */
@Entity
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class Report { public class Report {
/**
* 主键id uuid
*/
@Id
@Column(length = 48)
private String id;
/** /**
* git源代码地址 * git源代码地址
*/ */
...@@ -63,6 +55,7 @@ public class Report { ...@@ -63,6 +55,7 @@ public class Report {
@Column(length = 5) @Column(length = 5)
private Integer recastMethod; private Integer recastMethod;
//前端适配预算 //前端适配预算
//代码重构预算 //代码重构预算
//代码修改预算 //代码修改预算
......
...@@ -12,10 +12,6 @@ import java.util.List; ...@@ -12,10 +12,6 @@ import java.util.List;
*/ */
@Data @Data
public class ReportVo { public class ReportVo {
/**
* 主键id uuid
*/
private String id;
/** /**
* git源代码地址 * git源代码地址
...@@ -50,6 +46,11 @@ public class ReportVo { ...@@ -50,6 +46,11 @@ public class ReportVo {
@Column(length = 5) @Column(length = 5)
private Integer recastMethod; private Integer recastMethod;
/**
* 源代码地址
*/
private String sourceAddress;
/** /**
* 预算详情 * 预算详情
*/ */
...@@ -63,15 +64,10 @@ public class ReportVo { ...@@ -63,15 +64,10 @@ public class ReportVo {
/** /**
* 匹配技术列表 * 匹配技术列表
*/ */
private List<TechnologyVo> technologyVos; private List<Technology> technologies;
/** /**
* 告警点 * 告警点
*/ */
private HashMap<String, ArrayList<RuleAndReportVo>> warnDetails; private HashMap<String, List<Warn>> warnDetails;
/**
* 关键技术数量
*/
private Integer warnNum;
} }
package com.zjty.inspect.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.List;
/**
* @author Mcj
* @date 2020-01-15 13:18
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class VueBrowserslist {
List<String> production = new ArrayList<>();
List<String> development = new ArrayList<>();
}
package com.zjty.inspect.entity;
import com.fasterxml.jackson.annotation.JsonSetter;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.HashMap;
import java.util.Map;
/**
* @author Mcj
* @date 2020-01-15 11:18
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class VueDep {
String name;
String version;
@JsonSetter("private")
String vuePrivate;
Map<String,String> dependencies = new HashMap<>();
Map<String,String> scripts = new HashMap<>();
Map<String,String> eslintConfig = new HashMap<>();
VueBrowserslist browserslist = new VueBrowserslist();
}
...@@ -13,18 +13,13 @@ import javax.persistence.Id; ...@@ -13,18 +13,13 @@ import javax.persistence.Id;
@Data @Data
@Entity @Entity
public class TechnologyAndReport { public class Warn {
/** /**
* 主键id * 主键id
*/ */
@Id @Id
private String id; private String id;
/**
* 报告id
*/
private String reportId;
/** /**
* 发现问题的文件地址 * 发现问题的文件地址
*/ */
...@@ -44,4 +39,9 @@ public class TechnologyAndReport { ...@@ -44,4 +39,9 @@ public class TechnologyAndReport {
* 关键字id * 关键字id
*/ */
private String ruleId; private String ruleId;
/**
* 关键字
*/
private String rule;
} }
...@@ -2,9 +2,13 @@ package com.zjty.inspect.service; ...@@ -2,9 +2,13 @@ package com.zjty.inspect.service;
import com.zjty.inspect.entity.InspectParameter; import com.zjty.inspect.entity.InspectParameter;
import com.zjty.inspect.entity.Report; import com.zjty.inspect.entity.Report;
import com.zjty.inspect.entity.ReportVo;
public interface InspectService { public interface InspectService {
Report inspect(InspectParameter inspectParameter); /**
* 评估
void setTechId(String id); * @param inspectParameter
* @return
*/
ReportVo inspect(ReportVo reportVo,InspectParameter inspectParameter);
} }
...@@ -6,29 +6,5 @@ import org.springframework.data.domain.Page; ...@@ -6,29 +6,5 @@ import org.springframework.data.domain.Page;
import java.util.List; import java.util.List;
public interface ReportService { public interface ReportService {
/**
* 获取历史报告数量。页码等
* @param page 页码
* @return 历史报告
*/
public List<ReportVo> getHistory(int page);
/**
* 获取所有历史报告
* @return 历史报告
*/
public Page getHistory();
/**
* 根据报告id查询
* @param id 报告id
* @return 历史报告
*/
public ReportVo getHistory(String id);
/**
* 根据id删除数据
* @param id 报告id
*/
void remove(String id);
} }
package com.zjty.inspect.service.impl; package com.zjty.inspect.service.impl;
import com.zjty.inspect.dao.ReportDao;
import com.zjty.inspect.dao.RuleDao;
import com.zjty.inspect.entity.InspectParameter; import com.zjty.inspect.entity.InspectParameter;
import com.zjty.inspect.entity.Report; import com.zjty.inspect.entity.Report;
import com.zjty.inspect.entity.Rule; import com.zjty.inspect.entity.ReportVo;
import com.zjty.inspect.service.InspectService; import com.zjty.inspect.service.InspectService;
import com.zjty.inspect.service.ParameterService;
import com.zjty.inspect.utils.Inspector; import com.zjty.inspect.utils.Inspector;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -32,62 +22,22 @@ public class InspectServiceImpl implements InspectService { ...@@ -32,62 +22,22 @@ public class InspectServiceImpl implements InspectService {
@Autowired @Autowired
Inspector inspector; Inspector inspector;
private String techId;
@Autowired
private ReportDao reportDao;
@Transactional @Transactional
@Override @Override
public Report inspect(InspectParameter inspectParameter) { public ReportVo inspect(ReportVo reportVo,InspectParameter inspectParameter) {
Map<String, Report.Language> suffixLanguageMapping = new HashMap<>(); Map<String, Report.Language> suffixLanguageMapping = new HashMap<>();
suffixLanguageMapping.put("java", Report.Language.JAVA); suffixLanguageMapping.put("java", Report.Language.JAVA);
suffixLanguageMapping.put("vue", Report.Language.VUE); suffixLanguageMapping.put("vue", Report.Language.VUE);
suffixLanguageMapping.put("cpp", Report.Language.CPP); suffixLanguageMapping.put("cpp", Report.Language.CPP);
suffixLanguageMapping.put("py", Report.Language.PYTHON); suffixLanguageMapping.put("py", Report.Language.PYTHON);
suffixLanguageMapping.put("jsp", Report.Language.JSP); suffixLanguageMapping.put("jsp", Report.Language.JSP);
suffixLanguageMapping.put("html", Report.Language.ONLYVIEW);
suffixLanguageMapping.put("js", Report.Language.JAVASCRIPT);
suffixLanguageMapping.put("go", Report.Language.GO); suffixLanguageMapping.put("go", Report.Language.GO);
Report report1 = new Report();
report1.setGitAddress(inspectParameter.getPath());
inspector.setTechId(techId);
inspector.setInspectParameter(inspectParameter); inspector.setInspectParameter(inspectParameter);
inspector.setReport(report1); inspector.setReport(reportVo);
inspector.setSuffixLanguageMapping(suffixLanguageMapping); inspector.setSuffixLanguageMapping(suffixLanguageMapping);
inspector.setPath(inspectParameter.getPath()); inspector.setPath(inspectParameter.getPath());
Report report = inspector.inspect(); ReportVo report = inspector.inspect();
reportDao.save(report);
return report; return report;
} }
@Override
public void setTechId(String id) {
techId=id;
}
public void listfile(String path,Map<String, Report.Language> suffixLanguageMapping,List<Rule> ruleList){
Path path1 = Paths.get(path);
File file = path1.toFile();
File[] files = file.listFiles();
System.out.println(file.isDirectory());
for (File file1 : files) {
// Report report = new Inspector(file1.getPath(), suffixLanguageMapping, ruleList).inspect();
}
}
public Report notList(String path,Map<String, Report.Language> suffixLanguageMapping,List<Rule> ruleList){
Path path1 = Paths.get(path);
File file = path1.toFile();
//File file2 = new File(file.getPath() + "/评估报告" + file.getName() + ".txt");
// if (file2.exists()){
// file2.delete();
//
// }
// Report report = new Inspector(file.getPath(), suffixLanguageMapping, ruleList).inspect();
return new Report();
}
} }
package com.zjty.inspect.service.impl; package com.zjty.inspect.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.zjty.inspect.dao.BudgetDao;
import com.zjty.inspect.dao.ReportDao;
import com.zjty.inspect.dao.TechnologyAndReportDao;
import com.zjty.inspect.dao.TechnologyDao; import com.zjty.inspect.dao.TechnologyDao;
import com.zjty.inspect.entity.*; import com.zjty.inspect.entity.*;
import com.zjty.inspect.service.ReportService; import com.zjty.inspect.service.ReportService;
import com.zjty.inspect.utils.RedisUtil; import com.zjty.inspect.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/** /**
* @author Mcj * @author Mcj
* @date 2020-02-27 10:35 * @date 2020-02-27 10:35
...@@ -25,113 +16,14 @@ import java.util.*; ...@@ -25,113 +16,14 @@ import java.util.*;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class ReportServiceImpl implements ReportService { public class ReportServiceImpl implements ReportService {
@Autowired
private ReportDao reportDao;
@Autowired @Autowired
private TechnologyDao technologyDao; private TechnologyDao technologyDao;
@Autowired
private TechnologyAndReportDao technologyAndReportDao;
@Autowired
private BudgetDao budgetDao;
@Autowired @Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Override
public List<ReportVo> getHistory(int page) {
ArrayList<ReportVo> reportVos = new ArrayList<>();
PageRequest pageRequest = PageRequest.of(page - 1,10);
Page<Report> all = reportDao.findAll(pageRequest);
for (Report report : all.getContent()) {
ReportVo reportVo = set(report);
reportVos.add(reportVo);
}
return reportVos;
}
@Override
public Page getHistory() {
PageRequest pageRequest = PageRequest.of(1,10);
Page<Report> all = reportDao.findAll(pageRequest);
return all;
}
@Override
public ReportVo getHistory(String id) {
Optional<Report> byId = reportDao.findById(id);
if(byId.isPresent()){
return set(byId.get());
}
return new ReportVo();
}
@Override
@Modifying
public void remove(String id) {
reportDao.deleteById(id);
budgetDao.deleteByReportIdEquals(id);
technologyAndReportDao.deleteByReportIdEquals(id);
}
public ReportVo set(Report report){ public ReportVo set(Report report){
ReportVo reportVo = new ReportVo();
reportVo.setId(report.getId());
reportVo.setManager(report.getManager());
reportVo.setLanguage(report.getLanguage());
reportVo.setFramework(report.getFramework());
reportVo.setRecastMethod(report.getRecastMethod());
reportVo.setHtmlAddress(report.getHtmlAddress());
// TODO: 2020-02-27 从redis中查询依赖树
Object o = redisUtil.get(report.getId());
if(o!=null){
reportVo.setDepTreeVo((DepTreeVo) o);
}
HashSet<String> num = new HashSet<>(); return new ReportVo();
List<TechnologyAndReport> rar = technologyAndReportDao.findAllByReportIdEquals(report.getId());
ArrayList<TechnologyVo> technologyVos = new ArrayList<>();
HashMap<String, ArrayList<RuleAndReportVo>> map = new HashMap<>();
for (TechnologyAndReport technologyAndReport : rar) {
num.add(technologyAndReport.getTechnologyId());
if (map.containsKey(technologyAndReport.getTechnologyId())) {
RuleAndReportVo ruleAndReportVo = new RuleAndReportVo();
ruleAndReportVo.setFilePath(technologyAndReport.getFilePath());
ruleAndReportVo.setLineNum(technologyAndReport.getLineNum());
map.get(technologyAndReport.getTechnologyId()).add(ruleAndReportVo);
} else {
RuleAndReportVo ruleAndReportVo = new RuleAndReportVo();
ruleAndReportVo.setFilePath(technologyAndReport.getFilePath());
ruleAndReportVo.setLineNum(technologyAndReport.getLineNum());
map.put(technologyAndReport.getTechnologyId(), new ArrayList<>());
map.get(technologyAndReport.getTechnologyId()).add(ruleAndReportVo);
}
}
Set<String> strings = map.keySet();
ArrayList<String> strings1 = new ArrayList<>(strings);
for (String id : strings) {
Optional<Technology> byId = technologyDao.findById(id);
if (byId.isPresent()) {
Technology technology = byId.get();
String technologyName = technology.getTechnologyName();
map.put(technologyName, map.get(id));
TechnologyVo technologyVo = new TechnologyVo();
technologyVo.setAdvice(technology.getAdvice());
technologyVo.setTechnologyName(technology.getTechnologyName());
technologyVo.setFund(technology.getFund());
technologyVos.add(technologyVo);
}
}
List<Budget> budgetList = budgetDao.findAllByReportIdEquals(report.getId());
for (String s : strings1) {
map.remove(s);
}
reportVo.setBudgets(budgetList);
reportVo.setWarnDetails(map);
reportVo.setTechnologyVos(technologyVos);
reportVo.setWarnNum(num.size());
return reportVo;
} }
} }
...@@ -59,7 +59,7 @@ public class task implements CommandLineRunner { ...@@ -59,7 +59,7 @@ public class task implements CommandLineRunner {
coefficientMode2.setId(UUIDUtil.getUUID()); coefficientMode2.setId(UUIDUtil.getUUID());
coefficientMode2.setName("安全能力"); coefficientMode2.setName("安全能力");
coefficientMode2.setMin(0); coefficientMode2.setMin(0);
coefficientMode2.setMax(3); coefficientMode2.setMax(2);
coefficientMode2.setBelowCoefficient(-0.1); coefficientMode2.setBelowCoefficient(-0.1);
coefficientMode2.setMediumCoefficient(0D); coefficientMode2.setMediumCoefficient(0D);
coefficientMode2.setTopCoefficient(0.1); coefficientMode2.setTopCoefficient(0.1);
...@@ -69,7 +69,7 @@ public class task implements CommandLineRunner { ...@@ -69,7 +69,7 @@ public class task implements CommandLineRunner {
coefficientMode3.setId(UUIDUtil.getUUID()); coefficientMode3.setId(UUIDUtil.getUUID());
coefficientMode3.setName("安全能力"); coefficientMode3.setName("安全能力");
coefficientMode3.setMin(0); coefficientMode3.setMin(0);
coefficientMode3.setMax(3); coefficientMode3.setMax(2);
coefficientMode3.setBelowCoefficient(-0.2); coefficientMode3.setBelowCoefficient(-0.2);
coefficientMode3.setMediumCoefficient(-0.1); coefficientMode3.setMediumCoefficient(-0.1);
coefficientMode3.setTopCoefficient(0D); coefficientMode3.setTopCoefficient(0D);
...@@ -77,69 +77,103 @@ public class task implements CommandLineRunner { ...@@ -77,69 +77,103 @@ public class task implements CommandLineRunner {
CoefficientModel coefficientMode4 = new CoefficientModel(); CoefficientModel coefficientMode4 = new CoefficientModel();
coefficientMode4.setScale(1); coefficientMode4.setScale(1);
coefficientMode4.setId(UUIDUtil.getUUID()); coefficientMode4.setId(UUIDUtil.getUUID());
coefficientMode4.setName("模块"); coefficientMode4.setName("容灾能力");
coefficientMode4.setMin(4); coefficientMode4.setMin(0);
coefficientMode4.setMax(10); coefficientMode4.setMax(2);
coefficientMode4.setBelowCoefficient(-0.3); coefficientMode4.setBelowCoefficient(0D);
coefficientMode4.setMediumCoefficient(0D); coefficientMode4.setMediumCoefficient(0D);
coefficientMode4.setTopCoefficient(0.3); coefficientMode4.setTopCoefficient(0.05);
CoefficientModel coefficientMode5 = new CoefficientModel(); CoefficientModel coefficientMode5 = new CoefficientModel();
coefficientMode5.setScale(1); coefficientMode5.setScale(2);
coefficientMode5.setId(UUIDUtil.getUUID()); coefficientMode5.setId(UUIDUtil.getUUID());
coefficientMode5.setName("数据量"); coefficientMode5.setName("容灾能力");
coefficientMode5.setMin(1); coefficientMode5.setMin(0);
coefficientMode5.setMax(100); coefficientMode5.setMax(2);
coefficientMode5.setBelowCoefficient(-0.05); coefficientMode5.setBelowCoefficient(0.05);
coefficientMode5.setMediumCoefficient(0D); coefficientMode5.setMediumCoefficient(0D);
coefficientMode5.setTopCoefficient(0.05); coefficientMode5.setTopCoefficient(0D);
CoefficientModel coefficientMode6 = new CoefficientModel(); CoefficientModel coefficientMode6 = new CoefficientModel();
coefficientMode6.setScale(1); coefficientMode6.setScale(3);
coefficientMode6.setId(UUIDUtil.getUUID()); coefficientMode6.setId(UUIDUtil.getUUID());
coefficientMode6.setName("页面数"); coefficientMode6.setName("模块");
coefficientMode6.setMin(10); coefficientMode6.setMin(4);
coefficientMode6.setMax(100); coefficientMode6.setMax(10);
coefficientMode6.setBelowCoefficient(-0.05); coefficientMode6.setBelowCoefficient(-0.3);
coefficientMode6.setMediumCoefficient(0D); coefficientMode6.setMediumCoefficient(0D);
coefficientMode6.setTopCoefficient(0.05); coefficientMode6.setTopCoefficient(0.3);
CoefficientModel coefficientMode8 = new CoefficientModel();
coefficientMode8.setScale(2);
coefficientMode8.setId(UUIDUtil.getUUID());
coefficientMode8.setName("模块");
coefficientMode8.setMin(4);
coefficientMode8.setMax(10);
coefficientMode8.setBelowCoefficient(-0.3);
coefficientMode8.setMediumCoefficient(0D);
coefficientMode8.setTopCoefficient(0.3);
CoefficientModel coefficientMode9 = new CoefficientModel();
coefficientMode9.setScale(1);
coefficientMode9.setId(UUIDUtil.getUUID());
coefficientMode9.setName("模块");
coefficientMode9.setMin(4);
coefficientMode9.setMax(10);
coefficientMode9.setBelowCoefficient(-0.3);
coefficientMode9.setMediumCoefficient(0D);
coefficientMode9.setTopCoefficient(0.3);
CoefficientModel coefficientMode7 = new CoefficientModel();
coefficientMode7.setScale(3);
coefficientMode7.setId(UUIDUtil.getUUID());
coefficientMode7.setName("容灾能力");
coefficientMode7.setMin(0);
coefficientMode7.setMax(2);
coefficientMode7.setBelowCoefficient(-0.1);
coefficientMode7.setMediumCoefficient(0D);
coefficientMode7.setTopCoefficient(0D);
coefficientModels.add(coefficientMode6); coefficientModels.add(coefficientMode6);
coefficientModels.add(coefficientMode5); coefficientModels.add(coefficientMode5);
coefficientModels.add(coefficientMode4); coefficientModels.add(coefficientMode4);
coefficientModels.add(coefficientMode3); coefficientModels.add(coefficientMode3);
coefficientModels.add(coefficientMode2); coefficientModels.add(coefficientMode2);
coefficientModels.add(coefficientModel); coefficientModels.add(coefficientModel);
coefficientModels.add(coefficientMode7);
coefficientModels.add(coefficientMode8);
coefficientModels.add(coefficientMode9);
coefficientModelDao.saveAll(coefficientModels); coefficientModelDao.saveAll(coefficientModels);
Technology technology = new Technology(); Technology technology = new Technology();
technology.setTechnologyName("Java依赖"); technology.setTechnologyName("Java依赖");
technology.setAdvice("spring技术"); technology.setAdvice("国产化支持的依赖");
technology.setFund(5); technology.setFund(5);
technology.setId(UUIDUtil.getUUID()); technology.setId(UUIDUtil.getUUID());
technology.setSupport(1);
inspectService.setTechId(technology.getId());
Technology technology1 = new Technology(); Technology technology1 = new Technology();
technology1.setTechnologyName("非国产化依赖"); technology1.setTechnologyName("非国产化依赖");
technology1.setAdvice("建议替换成国产化技术"); technology1.setAdvice("国产化不支持的依赖");
technology1.setFund(5); technology1.setFund(5);
technology1.setId(UUIDUtil.getUUID()); technology1.setId(UUIDUtil.getUUID());
Rule rule = new Rule(); Rule rule = new Rule();
rule.setId(UUIDUtil.getUUID()); rule.setId(UUIDUtil.getUUID());
rule.setSuffix("*"); rule.setSuffix("*");
rule.setTarget("ruleService"); rule.setTarget("ruleService");
rule.setTechnologyId(technology.getId()); rule.setTechnologyId(technology.getId());
Rule rule1 = new Rule();
rule1.setId(UUIDUtil.getUUID());
rule1.setSuffix("*");
rule1.setTarget("mysql-connect");
rule1.setTechnologyId(technology1.getId());
technologyDao.save(technology); technologyDao.save(technology);
technologyDao.save(technology1);
ruleDao.save(rule); ruleDao.save(rule);
ruleDao.save(rule1);
List<Rule> all = ruleDao.findAll();
HashMap<String, Rule> stringRuleHashMap = new HashMap<>();
for (Rule rule1 : all) {
stringRuleHashMap.put(rule1+":"+rule1.getTechnologyId(),rule1);
}
analysisFile.setMap(stringRuleHashMap);
} }
} }
package com.zjty.inspect.utils; package com.zjty.inspect.utils;
import com.zjty.inspect.dao.RuleDao; import com.zjty.inspect.dao.RuleDao;
import com.zjty.inspect.dao.TechnologyAndReportDao;
import com.zjty.inspect.entity.*; import com.zjty.inspect.entity.*;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -20,9 +23,6 @@ public class AnalysisFile { ...@@ -20,9 +23,6 @@ public class AnalysisFile {
private HashMap<String,Rule> ruleMap = new HashMap<String,Rule>(); private HashMap<String,Rule> ruleMap = new HashMap<String,Rule>();
@Autowired
private TechnologyAndReportDao technologyAndReportDao;
@Autowired @Autowired
private RuleDao ruleDao; private RuleDao ruleDao;
...@@ -50,7 +50,7 @@ public class AnalysisFile { ...@@ -50,7 +50,7 @@ public class AnalysisFile {
public DepTreePom parseTreeFile(String reportId,String filePath, List<Rule> ruleList,String techId) { public DepTreePom parseTreeFile(String reportId,String filePath, List<Rule> ruleList,String techId) {
ArrayList<Rule> rules = new ArrayList<>(); ArrayList<Rule> rules = new ArrayList<>();
HashMap<String, String> map1 = new HashMap<>(); HashMap<String, String> map1 = new HashMap<>();
ArrayList<TechnologyAndReport> technologyAndReports = new ArrayList<>(); ArrayList<Warn> warns = new ArrayList<>();
Path path = Paths.get(filePath); Path path = Paths.get(filePath);
DepTreePom depTreePom = new DepTreePom(); DepTreePom depTreePom = new DepTreePom();
HashMap<Integer, DepTree> map = new HashMap<>(); HashMap<Integer, DepTree> map = new HashMap<>();
...@@ -90,14 +90,13 @@ public class AnalysisFile { ...@@ -90,14 +90,13 @@ public class AnalysisFile {
depTree1.setViolation(1); depTree1.setViolation(1);
depTreePom.add(rule.getTechnologyId()); depTreePom.add(rule.getTechnologyId());
//rule匹配上了 //rule匹配上了
TechnologyAndReport technologyAndReport = new TechnologyAndReport(); Warn warn = new Warn();
technologyAndReport.setFilePath(filePath); warn.setFilePath(filePath);
technologyAndReport.setLineNum(i); warn.setLineNum(i);
technologyAndReport.setTechnologyId(rule.getTechnologyId()); warn.setTechnologyId(rule.getTechnologyId());
technologyAndReport.setReportId(reportId); warn.setRuleId(rule.getId());
technologyAndReport.setRuleId(rule.getId()); warn.setId(UUIDUtil.getUUID());
technologyAndReport.setId(UUIDUtil.getUUID()); warns.add(warn);
technologyAndReports.add(technologyAndReport);
} }
} }
map.put(i1+3,depTree1); map.put(i1+3,depTree1);
...@@ -140,11 +139,38 @@ public class AnalysisFile { ...@@ -140,11 +139,38 @@ public class AnalysisFile {
append.delete(0,append.length()); append.delete(0,append.length());
} }
ruleDao.saveAll(rules); ruleDao.saveAll(rules);
technologyAndReportDao.saveAll(technologyAndReports);
return depTreePom; return depTreePom;
} }
public void setMap(HashMap<String,Rule> map){ public void setMap(HashMap<String,Rule> map){
this.ruleMap=map; this.ruleMap=map;
} }
public ProjectPom analysisPom(Path pomPath){
ProjectPom projectPom = new ProjectPom();
List<PomDependency> dependencies = new ArrayList<>();
Document document = null;
try {
document = DocumentHelper.parseText(new String(Files.readAllBytes(pomPath)));
} catch (DocumentException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Element rootElement = document.getRootElement();
Element dependencies1 = rootElement.element("dependencies");
if(dependencies1!=null){
List<Element> dependency = dependencies1.elements("dependency");
for(Element element:dependency){
PomDependency pomDependency = new PomDependency();
pomDependency.setGroupId(element.elementText("groupId"));
pomDependency.setArtifactId(element.elementText("artifactId"));
dependencies.add(pomDependency);
}
}
projectPom.setDependencies(dependencies);
return projectPom;
}
} }
package com.zjty.inspect.utils; package com.zjty.inspect.utils;
import com.zjty.inspect.dao.BudgetDao;
import com.zjty.inspect.dao.CoefficientModelDao; import com.zjty.inspect.dao.CoefficientModelDao;
import com.zjty.inspect.dao.TechnologyDao;
import com.zjty.inspect.entity.Budget; import com.zjty.inspect.entity.Budget;
import com.zjty.inspect.entity.CoefficientModel; import com.zjty.inspect.entity.CoefficientModel;
import com.zjty.inspect.entity.InspectParameter; import com.zjty.inspect.entity.InspectParameter;
import com.zjty.inspect.entity.TechnologyAndReport;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 获取预算 * 获取预算
...@@ -26,27 +24,16 @@ public class BudgetUitl { ...@@ -26,27 +24,16 @@ public class BudgetUitl {
@Autowired @Autowired
private CoefficientModelDao coefficientModelDao; private CoefficientModelDao coefficientModelDao;
@Autowired
private BudgetDao budgetDao;
/** /**
* 获取预算数据 * 获取预算数据
* @param reportId 报告id
* @param fund 技术费用 * @param fund 技术费用
* @param inspectParameter2 计算所需数据 * @param inspectParameter 计算所需数据
* @return * @return
*/ */
public List<Budget> getBudget(String reportId,Integer fund, InspectParameter inspectParameter2){ public List<Budget> getBudget(Integer fund, InspectParameter inspectParameter){
InspectParameter inspectParameter = new InspectParameter(); inspectParameter.setMoneyRate(1.04);
inspectParameter.setMoneyRate(1.42); inspectParameter.setProportion(0.6);
inspectParameter.setYears(2015); int scale;
inspectParameter.setModules(5);
inspectParameter.setProportion(1.1);
inspectParameter.setFramework(0.5);
inspectParameter.setDisaster(0.5);
inspectParameter.setSafety(2.5);
inspectParameter.setSystemFund(200);
Integer scale;
Integer systemFund = inspectParameter.getSystemFund(); Integer systemFund = inspectParameter.getSystemFund();
if(systemFund==0){ if(systemFund==0){
double v = inspectParameter.getModules() * 7.5; double v = inspectParameter.getModules() * 7.5;
...@@ -60,9 +47,7 @@ public class BudgetUitl { ...@@ -60,9 +47,7 @@ public class BudgetUitl {
scale=3; scale=3;
} }
Budget budget = new Budget(); Budget budget = new Budget();
budget.setId(UUIDUtil.getUUID());
budget.setBudgetName("代码重构预算"); budget.setBudgetName("代码重构预算");
budget.setReportId(reportId);
Double moneyRate = inspectParameter.getMoneyRate(); Double moneyRate = inspectParameter.getMoneyRate();
int i = 2020 - inspectParameter.getYears(); int i = 2020 - inspectParameter.getYears();
double pow = Math.pow(moneyRate, i); double pow = Math.pow(moneyRate, i);
...@@ -71,11 +56,14 @@ public class BudgetUitl { ...@@ -71,11 +56,14 @@ public class BudgetUitl {
//带修正系数资金 //带修正系数资金
ArrayList<String> strings = new ArrayList<>(); ArrayList<String> strings = new ArrayList<>();
Double v1 = v; Double v1 = v;
//strings.add("安全能力"); strings.add("安全能力");
//strings.add("容灾能力"); strings.add("容灾能力");
strings.add("架构"); strings.add("架构");
List<CoefficientModel> nameIn = coefficientModelDao.findAllByNameInAndScaleEquals(strings,scale); List<CoefficientModel> nameIn = coefficientModelDao.findAllByNameIn(strings);
for (CoefficientModel model : nameIn) { List<CoefficientModel> collect = nameIn.stream().filter(a -> {
return a.getScale() == scale;
}).collect(Collectors.toList());
for (CoefficientModel model : collect) {
if("架构".equals(model.getName())){ if("架构".equals(model.getName())){
Double aDouble = model.countCoefficient(inspectParameter.getFramework()); Double aDouble = model.countCoefficient(inspectParameter.getFramework());
v1*=aDouble; v1*=aDouble;
...@@ -100,12 +88,8 @@ public class BudgetUitl { ...@@ -100,12 +88,8 @@ public class BudgetUitl {
budget.setFundDetail("普通业务开发费用(修正):"+v1); budget.setFundDetail("普通业务开发费用(修正):"+v1);
budget.setFundDetail("关键适配技术成本:"+fund); budget.setFundDetail("关键适配技术成本:"+fund);
Budget budget1 = new Budget();
//budget.setBudgetName("代码修改预算");
ArrayList<Budget> budgets = new ArrayList<>(); ArrayList<Budget> budgets = new ArrayList<>();
budgets.add(budget); budgets.add(budget);
budgetDao.saveAll(budgets);
return budgets; return budgets;
} }
} }
...@@ -3,22 +3,52 @@ package com.zjty.inspect.utils; ...@@ -3,22 +3,52 @@ package com.zjty.inspect.utils;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.junrar.Archive; import com.github.junrar.Archive;
import com.github.junrar.rarfile.FileHeader; import com.github.junrar.rarfile.FileHeader;
import com.zjty.inspect.entity.VueDep;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.lingala.zip4j.core.ZipFile; import net.lingala.zip4j.core.ZipFile;
import org.apache.commons.io.FileUtils;
import org.dom4j.Document; import org.dom4j.Document;
import org.dom4j.io.SAXReader; import org.dom4j.io.SAXReader;
import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Slf4j @Slf4j
public class FileUtil { public class FileUtil {
static int BUFFER_SIZE = 1024; static int BUFFER_SIZE = 1024;
/**
* 保存文件到本地
* @param multipartFile
* @return
* @throws IOException
*/
public static File saveToLocal(MultipartFile multipartFile) throws IOException {
// 获取文件名
String fileName = multipartFile.getOriginalFilename();
// 获取文件后缀
String prefix=fileName.substring(fileName.lastIndexOf("."));
// 用uuid作为文件名,防止生成的临时文件重复
final File excelFile = File.createTempFile(LocalDateTime.now()+fileName, prefix);
// MultipartFile to File
multipartFile.transferTo(excelFile);
if(prefix.equals(".zip")){
FileUtil.unPackZip(excelFile,"", "./");
}else{
FileUtil.unPackRar(excelFile, "./");
}
String[] split = fileName.split("\\.");
File file3 = new File("./"+split[0]);
excelFile.delete();
log.info("end unpack file");
return file3;
}
/** /**
* zip文件解压 * zip文件解压
* *
...@@ -82,16 +112,6 @@ public class FileUtil { ...@@ -82,16 +112,6 @@ public class FileUtil {
} }
} }
static VueDep parseJsonFile(String path) {
try {
File file = new File(path);
VueDep vueDep;
vueDep = new ObjectMapper().readValue(file,VueDep.class);
return vueDep;
} catch (Exception e) {
return new VueDep();
}
}
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
File file = new File("/Users/mcj/Downloads/acq-server.zip"); File file = new File("/Users/mcj/Downloads/acq-server.zip");
......
...@@ -3,6 +3,7 @@ package com.zjty.inspect.utils; ...@@ -3,6 +3,7 @@ package com.zjty.inspect.utils;
import org.eclipse.jgit.api.CloneCommand; import org.eclipse.jgit.api.CloneCommand;
import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
import org.springframework.stereotype.Component;
import java.io.File; import java.io.File;
...@@ -10,46 +11,22 @@ import java.io.File; ...@@ -10,46 +11,22 @@ import java.io.File;
* @author Mcj * @author Mcj
* @date 2020-02-13 16:01 * @date 2020-02-13 16:01
*/ */
@Component
public class GitLabUtil { public class GitLabUtil {
String downLoadProject(String path) { public static String downLoadProject(String path) {
//String REMOTE_URL = "https://git.yfzx.zjtys.com.cn:8888/912-system/monitor/adaptation-master.git"; //String REMOTE_URL = "https://git.yfzx.zjtys.com.cn:8888/912-system/monitor/adaptation-master.git";
CloneCommand cloneCommand = Git.cloneRepository(); CloneCommand cloneCommand = Git.cloneRepository();
cloneCommand.setURI(path); cloneCommand.setURI(path);
// cloneCommand.setCredentialsProvider(mcj); // cloneCommand.setCredentialsProvider(mcj);
cloneCommand.setDirectory(new File("/Users/mcj/IdeaProjects/test5")); File file = new File("./");
cloneCommand.setDirectory(file);
try { try {
cloneCommand.call(); cloneCommand.call();
} catch (GitAPIException e) { } catch (GitAPIException e) {
e.printStackTrace(); e.printStackTrace();
} }
// try { return file.getPath();
// cloneCommand.setTransportConfigCallback(new TransportConfigCallback() {
// @Override
// public void configure(Transport transport) {
// }
// }).call();
// } catch (GitAPIException e) {
// e.printStackTrace();
// }
// System.out.println("Listing remote repository " + REMOTE_URL);
// try {
// refs = Git.lsRemoteRepository()
// .setHeads(true)
// .setTags(true)
// .setRemote(REMOTE_URL)
// .call();
// } catch (GitAPIException ex) {
// ex.printStackTrace();
// }
return "";
} }
} }
......
...@@ -40,6 +40,9 @@ public class KmpUtil { ...@@ -40,6 +40,9 @@ public class KmpUtil {
*/ */
public static int kmpMatch(String s, String t){ public static int kmpMatch(String s, String t){
char[] s_arr = s.toCharArray(); char[] s_arr = s.toCharArray();
if(t.isEmpty()){
return -1;
}
char[] t_arr = t.toCharArray(); char[] t_arr = t.toCharArray();
int[] next = getNextArray(t_arr); int[] next = getNextArray(t_arr);
int i = 0, j = 0; int i = 0, j = 0;
...@@ -59,7 +62,6 @@ public class KmpUtil { ...@@ -59,7 +62,6 @@ public class KmpUtil {
return -1; return -1;
} }
} }
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(kmpMatch("abcabaabaabcacb", "abaabcac")); System.out.println(kmpMatch("abcabaabaabcacb", "abaabcac"));
} }
......
...@@ -21,6 +21,7 @@ public class MavenUtil { ...@@ -21,6 +21,7 @@ public class MavenUtil {
@Value("${maven.treefile}") @Value("${maven.treefile}")
private String treeFile; private String treeFile;
public File genTreeFile(String path){ public File genTreeFile(String path){
InvocationRequest request = new DefaultInvocationRequest(); InvocationRequest request = new DefaultInvocationRequest();
request.setPomFile(new File(path)); request.setPomFile(new File(path));
......
# 配置文件使用 默认使用 dev 环境 # 配置文件使用 默认使用 dev 环境
spring.profiles.active=dev #spring.profiles.active=dev
#spring.profiles.active=doc #spring.profiles.active=doc
#spring.profiles.active=prod #spring.profiles.active=prod
# 服务器相关配置 # 服务器相关配置
......
com.zjty:inspect:jar:0.0.1-SNAPSHOT
+- org.eclipse.jgit:org.eclipse.jgit:jar:5.2.1.201812262042-r:compile
+- org.springframework.boot:spring-boot-starter-data-redis:jar:2.1.6.RELEASE:compile
| +- org.springframework.data:spring-data-redis:jar:2.1.9.RELEASE:compile
| | +- org.springframework.data:spring-data-keyvalue:jar:2.1.9.RELEASE:compile
| | +- org.springframework:spring-tx:jar:5.1.8.RELEASE:compile
| | +- org.springframework:spring-oxm:jar:5.1.8.RELEASE:compile
| | +- org.springframework:spring-aop:jar:5.1.8.RELEASE:compile
| | +- org.springframework:spring-context-support:jar:5.1.8.RELEASE:compile
| | \- org.slf4j:slf4j-api:jar:1.7.26:compile
| \- io.lettuce:lettuce-core:jar:5.1.7.RELEASE:compile
| +- io.netty:netty-common:jar:4.1.36.Final:compile
| +- io.netty:netty-handler:jar:4.1.36.Final:compile
| | +- io.netty:netty-buffer:jar:4.1.36.Final:compile
| | \- io.netty:netty-codec:jar:4.1.36.Final:compile
| +- io.netty:netty-transport:jar:4.1.36.Final:compile
| | \- io.netty:netty-resolver:jar:4.1.36.Final:compile
| \- io.projectreactor:reactor-core:jar:3.2.10.RELEASE:compile
| \- org.reactivestreams:reactive-streams:jar:1.0.2:compile
+- org.springframework.boot:spring-boot-starter:jar:2.1.6.RELEASE:compile
| +- org.springframework.boot:spring-boot:jar:2.1.6.RELEASE:compile
| | \- org.springframework:spring-context:jar:5.1.8.RELEASE:compile
| +- org.springframework.boot:spring-boot-autoconfigure:jar:2.1.6.RELEASE:compile
| +- org.springframework.boot:spring-boot-starter-logging:jar:2.1.6.RELEASE:compile
| | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
| | | \- ch.qos.logback:logback-core:jar:1.2.3:compile
| | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.11.2:compile
| | | \- org.apache.logging.log4j:log4j-api:jar:2.11.2:compile
| | \- org.slf4j:jul-to-slf4j:jar:1.7.26:compile
| +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
| \- org.springframework:spring-core:jar:5.1.8.RELEASE:compile
| \- org.springframework:spring-jcl:jar:5.1.8.RELEASE:compile
+- org.apache.maven.shared:maven-invoker:jar:3.0.1:compile
| +- org.apache.maven.shared:maven-shared-utils:jar:3.2.1:compile
| | \- commons-io:commons-io:jar:2.5:compile
| \- org.codehaus.plexus:plexus-component-annotations:jar:1.7.1:compile
+- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.1.6.RELEASE:compile
| +- org.springframework.boot:spring-boot-starter-aop:jar:2.1.6.RELEASE:compile
| | \- org.aspectj:aspectjweaver:jar:1.9.4:compile
| +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.1.6.RELEASE:compile
| | +- com.zaxxer:HikariCP:jar:3.2.0:compile
| | \- org.springframework:spring-jdbc:jar:5.1.8.RELEASE:compile
| +- javax.transaction:javax.transaction-api:jar:1.3:compile
| +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
| | \- javax.activation:javax.activation-api:jar:1.2.0:compile
| +- org.hibernate:hibernate-core:jar:5.3.10.Final:compile
| | +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
| | +- javax.persistence:javax.persistence-api:jar:2.2:compile
| | +- org.javassist:javassist:jar:3.23.2-GA:compile
| | +- net.bytebuddy:byte-buddy:jar:1.9.13:compile
| | +- antlr:antlr:jar:2.7.7:compile
| | +- org.jboss:jandex:jar:2.0.5.Final:compile
| | +- com.fasterxml:classmate:jar:1.4.0:compile
| | +- org.dom4j:dom4j:jar:2.1.1:compile
| | \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.4.Final:compile
| +- org.springframework.data:spring-data-jpa:jar:2.1.9.RELEASE:compile
| | +- org.springframework.data:spring-data-commons:jar:2.1.9.RELEASE:compile
| | +- org.springframework:spring-orm:jar:5.1.8.RELEASE:compile
| | \- org.springframework:spring-beans:jar:5.1.8.RELEASE:compile
| \- org.springframework:spring-aspects:jar:5.1.8.RELEASE:compile
+- org.springframework.boot:spring-boot-starter-web:jar:2.1.6.RELEASE:compile
| +- org.springframework.boot:spring-boot-starter-json:jar:2.1.6.RELEASE:compile
| | +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.9:compile
| | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
| | | \- com.fasterxml.jackson.core:jackson-core:jar:2.9.9:compile
| | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.9:compile
| | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.9:compile
| | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.9:compile
| +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.1.6.RELEASE:compile
| | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.21:compile
| | +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.21:compile
| | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.21:compile
| +- org.hibernate.validator:hibernate-validator:jar:6.0.17.Final:compile
| | \- javax.validation:validation-api:jar:2.0.1.Final:compile
| +- org.springframework:spring-web:jar:5.1.8.RELEASE:compile
| \- org.springframework:spring-webmvc:jar:5.1.8.RELEASE:compile
| \- org.springframework:spring-expression:jar:5.1.8.RELEASE:compile
+- com.alibaba:fastjson:jar:1.2.61:compile
+- mysql:mysql-connector-java:jar:8.0.16:compile
+- org.projectlombok:lombok:jar:1.18.8:compile
+- org.springframework.boot:spring-boot-starter-test:jar:2.1.6.RELEASE:test
| +- org.springframework.boot:spring-boot-test:jar:2.1.6.RELEASE:test
| +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.1.6.RELEASE:test
| +- com.jayway.jsonpath:json-path:jar:2.4.0:test
| | \- net.minidev:json-smart:jar:2.3:test
| | \- net.minidev:accessors-smart:jar:1.2:test
| | \- org.ow2.asm:asm:jar:5.0.4:test
| +- junit:junit:jar:4.12:test
| +- org.assertj:assertj-core:jar:3.11.1:test
| +- org.mockito:mockito-core:jar:2.23.4:test
| | +- net.bytebuddy:byte-buddy-agent:jar:1.9.13:test
| | \- org.objenesis:objenesis:jar:2.6:test
| +- org.hamcrest:hamcrest-core:jar:1.3:test
| +- org.hamcrest:hamcrest-library:jar:1.3:test
| +- org.skyscreamer:jsonassert:jar:1.5.0:test
| | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
| +- org.springframework:spring-test:jar:5.1.8.RELEASE:test
| \- org.xmlunit:xmlunit-core:jar:2.6.2:test
+- org.yaml:snakeyaml:jar:1.25:compile
+- net.lingala.zip4j:zip4j:jar:1.3.2:compile
\- com.github.junrar:junrar:jar:0.7:compile
+- commons-logging:commons-logging-api:jar:1.1:compile
\- org.apache.commons:commons-vfs2:jar:2.0:compile
+- commons-logging:commons-logging:jar:1.1.1:compile
+- org.apache.maven.scm:maven-scm-api:jar:1.4:compile
| \- org.codehaus.plexus:plexus-utils:jar:1.5.6:compile
\- org.apache.maven.scm:maven-scm-provider-svnexe:jar:1.4:compile
+- org.apache.maven.scm:maven-scm-provider-svn-commons:jar:1.4:compile
\- regexp:regexp:jar:1.3:compile
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论