Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
I
inspect
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
912协同工作系统
项目监控管理工具
inspect
Commits
a5db92b3
提交
a5db92b3
authored
3月 02, 2020
作者:
马晨俊
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
git update 规则增删改查
上级
fa64da32
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
52 个修改的文件
包含
1662 行增加
和
273 行删除
+1662
-273
hello
hello
+99
-0
pom.xml
pom.xml
+9
-1
RedisConfig.java
src/main/java/com/zjty/inspect/config/RedisConfig.java
+48
-0
InspectController.java
...n/java/com/zjty/inspect/controller/InspectController.java
+19
-7
ReportController.java
...in/java/com/zjty/inspect/controller/ReportController.java
+33
-0
RuleController.java
...main/java/com/zjty/inspect/controller/RuleController.java
+41
-0
TechnologyController.java
...ava/com/zjty/inspect/controller/TechnologyController.java
+40
-0
BudgetDao.java
src/main/java/com/zjty/inspect/dao/BudgetDao.java
+21
-0
CoefficientModelDao.java
src/main/java/com/zjty/inspect/dao/CoefficientModelDao.java
+17
-0
ParameterDao.java
src/main/java/com/zjty/inspect/dao/ParameterDao.java
+7
-0
ReportDao.java
src/main/java/com/zjty/inspect/dao/ReportDao.java
+7
-0
RuleDao.java
src/main/java/com/zjty/inspect/dao/RuleDao.java
+14
-0
TechnologyAndReportDao.java
...ain/java/com/zjty/inspect/dao/TechnologyAndReportDao.java
+20
-0
TechnologyDao.java
src/main/java/com/zjty/inspect/dao/TechnologyDao.java
+14
-0
Budget.java
src/main/java/com/zjty/inspect/entity/Budget.java
+56
-0
CoefficientModel.java
src/main/java/com/zjty/inspect/entity/CoefficientModel.java
+57
-0
DepTreePom.java
src/main/java/com/zjty/inspect/entity/DepTreePom.java
+24
-0
DepTreeVo.java
src/main/java/com/zjty/inspect/entity/DepTreeVo.java
+6
-2
InspectParameter.java
src/main/java/com/zjty/inspect/entity/InspectParameter.java
+32
-2
PomDependency.java
src/main/java/com/zjty/inspect/entity/PomDependency.java
+0
-48
Report.java
src/main/java/com/zjty/inspect/entity/Report.java
+3
-5
ReportVo.java
src/main/java/com/zjty/inspect/entity/ReportVo.java
+77
-0
Rule.java
src/main/java/com/zjty/inspect/entity/Rule.java
+4
-0
RuleAndReportVo.java
src/main/java/com/zjty/inspect/entity/RuleAndReportVo.java
+23
-0
RuleQo.java
src/main/java/com/zjty/inspect/entity/RuleQo.java
+30
-0
RuleVo.java
src/main/java/com/zjty/inspect/entity/RuleVo.java
+28
-0
Technology.java
src/main/java/com/zjty/inspect/entity/Technology.java
+54
-0
TechnologyAndReport.java
...ain/java/com/zjty/inspect/entity/TechnologyAndReport.java
+47
-0
TechnologyQo.java
src/main/java/com/zjty/inspect/entity/TechnologyQo.java
+27
-0
TechnologyVo.java
src/main/java/com/zjty/inspect/entity/TechnologyVo.java
+30
-0
TechnologyVoNoFund.java
...main/java/com/zjty/inspect/entity/TechnologyVoNoFund.java
+22
-0
VueDep.java
src/main/java/com/zjty/inspect/entity/VueDep.java
+1
-1
InspectService.java
src/main/java/com/zjty/inspect/service/InspectService.java
+1
-2
ParameterService.java
src/main/java/com/zjty/inspect/service/ParameterService.java
+17
-0
ReportService.java
src/main/java/com/zjty/inspect/service/ReportService.java
+13
-0
RuleService.java
src/main/java/com/zjty/inspect/service/RuleService.java
+31
-0
TechnologyService.java
...main/java/com/zjty/inspect/service/TechnologyService.java
+23
-0
InspectServiceImpl.java
...ava/com/zjty/inspect/service/impl/InspectServiceImpl.java
+38
-69
ParameterServiceImpl.java
...a/com/zjty/inspect/service/impl/ParameterServiceImpl.java
+20
-0
ReportServiceImpl.java
...java/com/zjty/inspect/service/impl/ReportServiceImpl.java
+98
-0
RuleServiceImpl.java
...n/java/com/zjty/inspect/service/impl/RuleServiceImpl.java
+62
-0
TechnologyServiceImpl.java
.../com/zjty/inspect/service/impl/TechnologyServiceImpl.java
+46
-0
task.java
src/main/java/com/zjty/inspect/task/task.java
+121
-0
AnalysisFile.java
src/main/java/com/zjty/inspect/utils/AnalysisFile.java
+36
-133
BudgetUitl.java
src/main/java/com/zjty/inspect/utils/BudgetUitl.java
+111
-0
FileUtil.java
src/main/java/com/zjty/inspect/utils/FileUtil.java
+4
-2
Inspector.java
src/main/java/com/zjty/inspect/utils/Inspector.java
+0
-0
KmpUtil.java
src/main/java/com/zjty/inspect/utils/KmpUtil.java
+1
-1
MavenUtil.java
src/main/java/com/zjty/inspect/utils/MavenUtil.java
+38
-0
RedisUtil.java
src/main/java/com/zjty/inspect/utils/RedisUtil.java
+66
-0
UUIDUtil.java
src/main/java/com/zjty/inspect/utils/UUIDUtil.java
+16
-0
application.properties
src/main/resources/application.properties
+10
-0
没有找到文件。
hello
0 → 100644
浏览文件 @
a5db92b3
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
pom.xml
浏览文件 @
a5db92b3
...
@@ -27,12 +27,20 @@
...
@@ -27,12 +27,20 @@
<version>
5.2.1.201812262042-r
</version>
<version>
5.2.1.201812262042-r
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
<artifactId>
spring-boot-starter
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.apache.maven.shared
</groupId>
<artifactId>
maven-invoker
</artifactId>
<version>
3.0.1
</version>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
...
...
src/main/java/com/zjty/inspect/config/RedisConfig.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
config
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.cache.RedisCacheManager
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
/**
* @author Mcj
* @date 2020-03-02 11:27
*/
@Configuration
public
class
RedisConfig
{
// @Bean(name = "defaultRedisTpl")
// public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
// RedisTemplate<String, Object> template = new RedisTemplate<>();
// template.setConnectionFactory(factory);
//
// Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
// ObjectMapper om = new ObjectMapper();
// om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
// jackson2JsonRedisSerializer.setObjectMapper(om);
// // value序列化方式采用jackson
// template.setValueSerializer(jackson2JsonRedisSerializer);
//
// template.setKeySerializer(new StringRedisSerializer());
// template.setValueSerializer(jackson2JsonRedisSerializer);
// return template;
// }
//
//
//
// @Bean
// public RedisCacheManager cacheManager(RedisConnectionFactory connectionFactory) {
// //获得redis缓存管理类
// RedisCacheManager redisCacheManager = RedisCacheManager.create(connectionFactory);
// // 开启使用缓存名称做为key前缀(这样所有同名缓存会整理在一起比较容易查找)
//
// return redisCacheManager;
// }
}
src/main/java/com/zjty/inspect/controller/InspectController.java
浏览文件 @
a5db92b3
...
@@ -2,11 +2,16 @@ package com.zjty.inspect.controller;
...
@@ -2,11 +2,16 @@ package com.zjty.inspect.controller;
import
com.zjty.inspect.entity.InspectParameter
;
import
com.zjty.inspect.entity.InspectParameter
;
import
com.zjty.inspect.service.InspectService
;
import
com.zjty.inspect.service.InspectService
;
import
com.zjty.inspect.utils.FileUtil
;
import
com.zjty.inspect.utils.MavenUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
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
java.io.File
;
import
java.io.IOException
;
/**
/**
* 评估接口
* 评估接口
* @author mcj
* @author mcj
...
@@ -20,14 +25,17 @@ public class InspectController {
...
@@ -20,14 +25,17 @@ public class InspectController {
/**
/**
* 上传代码进行评估
* 上传代码进行评估
* @param
path
* @param
inspectParameter
* @return
* @return
*/
*/
@
Ge
tMapping
(
"/path"
)
@
Pos
tMapping
(
"/path"
)
public
ResponseEntity
inspect
(
@RequestBody
InspectParameter
path
,
MultipartFile
file
)
{
public
ResponseEntity
inspect
(
@RequestBody
InspectParameter
inspectParameter
,
MultipartFile
file
)
{
//得到压缩包,进行解压
//得到压缩包,进行解压
//File file1 = file.getResource().getFile();
//inspectService.inspect(inspectParameter),解析
//String path = FileUtil.unZip(file1, "/Users/mcj/IdeaProjects/t5");
File
file2
=
new
File
(
"/Users/mcj/IdeaProjects/inspect"
);
String
path1
=
file2
.
getPath
();
inspectService
.
inspect
(
inspectParameter
,
path1
);
return
ResponseEntity
.
ok
(
200
);
return
ResponseEntity
.
ok
(
200
);
}
}
...
@@ -36,9 +44,13 @@ public class InspectController {
...
@@ -36,9 +44,13 @@ public class InspectController {
* @param path
* @param path
* @return
* @return
*/
*/
@PostMapping
@PostMapping
(
"/git"
)
public
ResponseEntity
inspect1
(
String
path
){
public
ResponseEntity
inspect1
(
@RequestBody
InspectParameter
inspectParameter
,
String
path
){
inspectService
.
inspect
(
inspectParameter
,
path
);
System
.
out
.
println
(
path
);
System
.
out
.
println
(
path
);
return
ResponseEntity
.
ok
(
200
);
return
ResponseEntity
.
ok
(
200
);
}
}
}
}
src/main/java/com/zjty/inspect/controller/ReportController.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
controller
;
import
com.zjty.inspect.entity.ReportVo
;
import
com.zjty.inspect.service.ReportService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
* 报告
* @author Mcj
* @date 2020-02-27 09:58
*/
@RequestMapping
(
"/report"
)
@RestController
public
class
ReportController
{
@Autowired
private
ReportService
reportService
;
/**
* 历史报告查看
* @return 历史报告
*/
@GetMapping
public
ResponseEntity
history
(){
List
<
ReportVo
>
history
=
reportService
.
getHistory
();
return
ResponseEntity
.
ok
(
history
);
}
}
src/main/java/com/zjty/inspect/controller/RuleController.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
controller
;
import
com.zjty.inspect.entity.RuleQo
;
import
com.zjty.inspect.service.RuleService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
/**
* 规则库设置
* @author Mcj
* @date 2020-02-26 14:42
*/
@RestController
@RequestMapping
(
"/rule"
)
public
class
RuleController
{
@Autowired
private
RuleService
ruleService
;
/**
* 新增规则
* @param ruleQo 规则封装
* @return
*/
@PostMapping
public
ResponseEntity
rule
(
@RequestBody
RuleQo
ruleQo
){
ruleService
.
addRule
(
ruleQo
);
return
ResponseEntity
.
ok
(
200
);
}
/**
* 查询所有规则
* @return 规则
*/
@GetMapping
public
ResponseEntity
getRules
(){
return
ResponseEntity
.
ok
(
ruleService
.
findAll
());
}
}
src/main/java/com/zjty/inspect/controller/TechnologyController.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
controller
;
import
com.zjty.inspect.entity.TechnologyQo
;
import
com.zjty.inspect.service.TechnologyService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
/**
* 适配技术
* @author Mcj
* @date 2020-02-29 16:10
*/
@RequestMapping
(
"/technology"
)
@RestController
public
class
TechnologyController
{
@Autowired
private
TechnologyService
technologyService
;
/**
* 获取所有关键技术
* @return List
*/
@GetMapping
public
ResponseEntity
getTechnologies
(){
return
ResponseEntity
.
ok
(
technologyService
.
findAllTechnology
());
}
/**
* 添加关键技术
* @return List
*/
@PostMapping
public
ResponseEntity
addTechnologies
(
@RequestBody
TechnologyQo
technologyQo
){
technologyService
.
addAdvice
(
technologyQo
);
return
ResponseEntity
.
ok
(
200
);
}
}
src/main/java/com/zjty/inspect/dao/BudgetDao.java
0 → 100644
浏览文件 @
a5db92b3
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
);
}
src/main/java/com/zjty/inspect/dao/CoefficientModelDao.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
dao
;
import
com.zjty.inspect.entity.CoefficientModel
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
public
interface
CoefficientModelDao
extends
JpaRepository
<
CoefficientModel
,
String
>
{
/**
* 根据范围查询系数
* @param name 内容名称
* @param scale 规模
* @return
*/
List
<
CoefficientModel
>
findAllByNameInAndScaleEquals
(
List
<
String
>
name
,
Integer
scale
);
}
src/main/java/com/zjty/inspect/dao/ParameterDao.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
dao
;
import
com.zjty.inspect.entity.InspectParameter
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
ParameterDao
extends
JpaRepository
<
InspectParameter
,
String
>
{
}
src/main/java/com/zjty/inspect/dao/ReportDao.java
0 → 100644
浏览文件 @
a5db92b3
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
>
{
}
src/main/java/com/zjty/inspect/dao/RuleDao.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
dao
;
import
com.zjty.inspect.entity.Rule
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
RuleDao
extends
JpaRepository
<
Rule
,
String
>
{
/**
* 根据目标关键字查询规则
* @param target 目标关键字
* @return
*/
Rule
findAllByTargetEquals
(
String
target
);
}
src/main/java/com/zjty/inspect/dao/TechnologyAndReportDao.java
0 → 100644
浏览文件 @
a5db92b3
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
);
}
src/main/java/com/zjty/inspect/dao/TechnologyDao.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
dao
;
import
com.zjty.inspect.entity.Technology
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
TechnologyDao
extends
JpaRepository
<
Technology
,
String
>
{
/**
* 根据名称查询适配技术
* @param name 适配技术名称
* @return Technology
*/
Technology
findAllByTechnologyNameEquals
(
String
name
);
}
src/main/java/com/zjty/inspect/entity/Budget.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
entity
;
import
lombok.Data
;
import
org.hibernate.annotations.Generated
;
import
org.hibernate.annotations.GenerationTime
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
java.sql.Timestamp
;
/**
* 预算
* @author Mcj
* @date 2020-02-27 19:05
*/
@Data
@Entity
public
class
Budget
{
@Id
private
String
id
;
/**
* 代码重构预算、代码修改预算、
*/
private
String
budgetName
;
/**
* 资金
*/
private
String
fund
;
/**
* 资金详情
*/
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
;
}
src/main/java/com/zjty/inspect/entity/CoefficientModel.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
entity
;
import
lombok.Data
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
/**
* 系数计算
*
* @author Mcj
*/
@Entity
@Data
public
class
CoefficientModel
{
@Id
private
String
id
;
/**
* 评定名称
*/
private
String
name
;
/**
* 大规模系数 0.1
*/
private
Double
topCoefficient
;
/**
* 中等规模系数 0
*/
private
Double
mediumCoefficient
;
/**
* 小规模系数 -0.1
*/
private
Double
belowCoefficient
;
/**
* 最小值4
*/
private
Integer
min
;
private
Integer
max
;
private
Integer
scale
;
public
Double
countCoefficient
(
Double
data
)
{
if
(
data
<
min
){
return
1
+
belowCoefficient
;
}
else
if
(
data
>
max
){
return
1
+
topCoefficient
;
}
else
{
return
1
+
mediumCoefficient
;
}
}
}
src/main/java/com/zjty/inspect/entity/DepTreePom.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
entity
;
import
lombok.Data
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
/**
* @author Mcj
* @date 2020-03-01 21:18
*/
@Data
public
class
DepTreePom
{
Set
<
String
>
technologies
=
new
HashSet
<>();
private
String
id
;
private
DepTree
depTree
;
public
void
add
(
String
id
){
technologies
.
add
(
id
);
}
}
src/main/java/com/zjty/inspect/entity/DepTree
AndReport
.java
→
src/main/java/com/zjty/inspect/entity/DepTree
Vo
.java
浏览文件 @
a5db92b3
...
@@ -2,13 +2,17 @@ package com.zjty.inspect.entity;
...
@@ -2,13 +2,17 @@ package com.zjty.inspect.entity;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
/**
* 依赖树封装
* 依赖树封装
* @author Mcj
* @author Mcj
* @date 2020-02-21 20:26
* @date 2020-02-21 20:26
*/
*/
@Data
@Data
public
class
DepTree
AndReport
{
public
class
DepTree
Vo
{
private
String
id
;
private
String
id
;
private
DepTree
depTree
;
private
List
<
DepTree
>
depTreeList
=
new
ArrayList
<>();
private
List
<
DepTree
>
frontend
=
new
ArrayList
<>();
}
}
src/main/java/com/zjty/inspect/entity/InspectParameter.java
浏览文件 @
a5db92b3
...
@@ -27,12 +27,17 @@ public class InspectParameter {
...
@@ -27,12 +27,17 @@ public class InspectParameter {
/**
/**
* 重构占比
* 重构占比
*/
*/
private
String
proportion
;
private
Double
proportion
;
/**
/**
* 年利率
* 年利率
*/
*/
private
String
moneyRate
;
private
Double
moneyRate
;
/**
* 软件开发时间
*/
private
Integer
years
;
/**
/**
* 原系统费用
* 原系统费用
...
@@ -49,5 +54,30 @@ public class InspectParameter {
...
@@ -49,5 +54,30 @@ public class InspectParameter {
*/
*/
private
Integer
pageBudget
;
private
Integer
pageBudget
;
/**
* 数据量
*/
private
Integer
data
;
/**
* 架构
*/
private
Double
framework
;
/**
* 安全能力
* 1:无
* 2:弱
* 3:强
*/
private
Double
safety
;
/**
* 容灾
* 1:无0,有+0.05
* 2:有0,无-0.05
* 3:有0,无-0.1
*/
private
Double
disaster
;
}
}
src/main/java/com/zjty/inspect/entity/PomDependency.java
浏览文件 @
a5db92b3
...
@@ -21,52 +21,4 @@ public class PomDependency {
...
@@ -21,52 +21,4 @@ public class PomDependency {
* 2:后端依赖
* 2:后端依赖
*/
*/
private
Integer
type
;
private
Integer
type
;
/*依赖类型,默认类型是jar。它通常表示依赖的文件的扩展名,但也有例外。一个类型可以被映射成另外一个扩展
名或分类器。类型经常和使用的打包方式对应,尽管这也有例外。一些类型的例子:jar,war,ejb-client和test-jar。
如果设置extensions为 true,就可以在plugin里定义新的类型。所以前面的类型的例子不完整
*/
//private String type;
/*依赖的分类器。分类器可以区分属于同一个POM,但不同构建方式的构件。分类器名被附加到文件名的版本号后面。例如,
如果你想要构建两个单独的构件成JAR,一个使用Java 1.4编译器,另一个使用Java 6编译器,你就可以使用分类器来生
成两个单独的JAR构件
*/
//private String classifier;
/*
依赖范围。在项目发布过程中,帮助决定哪些构件被包括进来。欲知详情请参考依赖机制。
- compile :默认范围,用于编译
- provided:类似于编译,但支持你期待jdk或者容器提供,类似于classpath
- runtime: 在执行时需要使用
- test: 用于test任务时使用
- system: 需要外在提供相应的元素。通过systemPath来取得
- systemPath: 仅用于范围为system。提供相应的路径
- optional: 当项目自身被依赖时,标注依赖是否传递。用于连续依赖时使用
*/
//private String scope;
/*
仅供system范围使用。注意,不鼓励使用这个元素,并且在新的版本中该元素可能被覆盖掉。该元素为依赖规定了文件
系统上的路径。需要绝对路径而不是相对路径。推荐使用属性匹配绝对路径,例如${java.home}
*/
//private String systemPath;
/*
当计算传递依赖时, 从依赖构件列表里,列出被排除的依赖构件集。即告诉maven你只依赖指定的项目,不依赖项目的
依赖。此元素主要用于解决版本冲突问题
*/
//private List<Exclusion> exclusions;
/*
可选依赖,如果你在项目B中把C依赖声明为可选,你就需要在依赖于B的项目(例如项目A)中显式的引用对C的依赖。
可选依赖阻断依赖的传递性
*/
//private String optional;
// private class Exclusion{
// private String artifactId;
// private String groupId;
// }
//private List<PomDependency> parentDependencies;//
//private int reportId;
}
}
src/main/java/com/zjty/inspect/entity/Report.java
浏览文件 @
a5db92b3
...
@@ -63,11 +63,9 @@ public class Report {
...
@@ -63,11 +63,9 @@ public class Report {
@Column
(
length
=
5
)
@Column
(
length
=
5
)
private
Integer
recastMethod
;
private
Integer
recastMethod
;
/**
//前端适配预算
* 总资金(万元)
//代码重构预算
*/
//代码修改预算
@Column
(
length
=
10
)
private
Integer
fund
;
/**
/**
* 数据创建时间
* 数据创建时间
...
...
src/main/java/com/zjty/inspect/entity/ReportVo.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
entity
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
/**
* @author Mcj
*/
@Data
public
class
ReportVo
{
/**
* 主键id uuid
*/
private
String
id
;
/**
* git源代码地址
*/
private
String
gitAddress
;
/**
* 架构,整合型还是分离型,根据jsp数量决定
*/
private
String
framework
;
/**
* 代码管理方式,
*/
private
String
manager
;
/**
* 语言
*/
private
String
language
;
/**
* 生成报告存储地址
*/
private
String
htmlAddress
;
/**
* 适配方式
* 1:适配
* 2:重构
*/
@Column
(
length
=
5
)
private
Integer
recastMethod
;
/**
* 预算详情
*/
private
List
<
Budget
>
budgets
;
/**
* 依赖
*/
private
DepTreeVo
depTreeVo
;
/**
* 匹配技术列表
*/
private
List
<
TechnologyVo
>
technologyVos
;
/**
* 告警点
*/
private
HashMap
<
String
,
ArrayList
<
RuleAndReportVo
>>
warnDetails
;
/**
* 关键技术数量
*/
private
Integer
warnNum
;
}
src/main/java/com/zjty/inspect/entity/Rule.java
浏览文件 @
a5db92b3
...
@@ -38,6 +38,10 @@ public class Rule {
...
@@ -38,6 +38,10 @@ public class Rule {
*/
*/
private
String
suffix
;
private
String
suffix
;
/**
* 适配技术id
*/
private
String
technologyId
;
/**
/**
* 数据创建时间
* 数据创建时间
*/
*/
...
...
src/main/java/com/zjty/inspect/entity/RuleAndReportVo.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
entity
;
import
lombok.Data
;
/**
* @author Mcj
* @date 2020-02-27 14:42
*/
@Data
public
class
RuleAndReportVo
{
/**
* 发现问题的文件地址
*/
private
String
filePath
;
/**
* 匹配行数
*/
private
Integer
lineNum
;
}
src/main/java/com/zjty/inspect/entity/RuleQo.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
entity
;
import
lombok.Data
;
/**
* 规则
* @author Mcj
* @date 2020-02-26 15:08
*/
@Data
public
class
RuleQo
{
/**
* 规则id
*/
private
String
id
;
/**
* 目标关键字
*/
private
String
target
;
/**
* 匹配的文件后缀
*/
private
String
suffix
;
/**
* 适配技术id
*/
private
String
technologyId
;
}
src/main/java/com/zjty/inspect/entity/RuleVo.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
entity
;
import
lombok.Data
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author Mcj
* @date 2020-02-26 23:18
*/
@Data
public
class
RuleVo
{
private
String
id
;
/**
* 目标关键字
*/
private
String
target
;
/**
* 匹配的文件后缀
*/
private
String
suffix
;
/**
* 建议
*/
private
String
technologyId
;
}
src/main/java/com/zjty/inspect/entity/Technology.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
entity
;
import
lombok.Data
;
import
org.hibernate.annotations.Generated
;
import
org.hibernate.annotations.GenerationTime
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
java.sql.Timestamp
;
/**
* 建议
* @author Mcj
* @date 2020-02-26 14:18
*/
@Entity
@Data
public
class
Technology
{
@Id
@Column
(
length
=
48
)
private
String
id
;
/**
* 技术名称
*/
private
String
technologyName
;
/**
* 技术建议
*/
private
String
advice
;
/**
* 金额(万元)
*/
private
Integer
fund
;
/**
* 数据创建时间
*/
@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
;
}
src/main/java/com/zjty/inspect/entity/TechnologyAndReport.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
entity
;
import
lombok.Data
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
/**
* 规则与报告中间表
* @author Mcj
* @date 2020-02-26 14:57
*/
@Data
@Entity
public
class
TechnologyAndReport
{
/**
* 主键id
*/
@Id
private
String
id
;
/**
* 报告id
*/
private
String
reportId
;
/**
* 发现问题的文件地址
*/
private
String
filePath
;
/**
* 匹配行数
*/
private
Integer
lineNum
;
/**
* 适配技术id
*/
private
String
technologyId
;
/**
* 关键字id
*/
private
String
ruleId
;
}
src/main/java/com/zjty/inspect/entity/TechnologyQo.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
entity
;
import
lombok.Data
;
/**
* 关键技术qo
* @author Mcj
* @date 2020-02-27 12:01
*/
@Data
public
class
TechnologyQo
{
/**
* 技术名称
*/
private
String
technologyQoName
;
/**
* 适配建议
*/
private
String
advice
;
/**
* 金额
*/
private
Integer
fund
;
}
src/main/java/com/zjty/inspect/entity/TechnologyVo.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
entity
;
import
lombok.Data
;
import
java.util.List
;
/**
* 建议
* @author Mcj
* @date 2020-02-27 10:31
*/
@Data
public
class
TechnologyVo
{
/**
* 技术名称
*/
private
String
technologyName
;
/**
* 建议
*/
private
String
advice
;
/**
* 资金
*/
private
Integer
fund
;
}
src/main/java/com/zjty/inspect/entity/TechnologyVoNoFund.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
entity
;
import
lombok.Data
;
import
java.util.List
;
/**
* @author Mcj
* @date 2020-02-27 14:56
*/
@Data
public
class
TechnologyVoNoFund
{
/**
* 建议
*/
private
String
advice
;
/**
* 绑定的规则
*/
private
List
<
RuleVo
>
ruleVos
;
}
src/main/java/com/zjty/inspect/entity/VueDep.java
浏览文件 @
a5db92b3
...
@@ -23,6 +23,6 @@ public class VueDep {
...
@@ -23,6 +23,6 @@ public class VueDep {
Map
<
String
,
String
>
dependencies
=
new
HashMap
<>();
Map
<
String
,
String
>
dependencies
=
new
HashMap
<>();
Map
<
String
,
String
>
scripts
=
new
HashMap
<>();
Map
<
String
,
String
>
scripts
=
new
HashMap
<>();
Map
<
String
,
String
>
eslintConfig
=
new
HashMap
<>();
Map
<
String
,
String
>
eslintConfig
=
new
HashMap
<>();
VueBrowserslist
browserslist
;
VueBrowserslist
browserslist
=
new
VueBrowserslist
()
;
}
}
src/main/java/com/zjty/inspect/service/InspectService.java
浏览文件 @
a5db92b3
...
@@ -4,7 +4,6 @@ import com.zjty.inspect.entity.InspectParameter;
...
@@ -4,7 +4,6 @@ import com.zjty.inspect.entity.InspectParameter;
import
com.zjty.inspect.entity.Report
;
import
com.zjty.inspect.entity.Report
;
public
interface
InspectService
{
public
interface
InspectService
{
Report
inspect
(
InspectParameter
inspectParameter
);
Report
inspect
(
InspectParameter
inspectParameter
,
String
path
);
}
}
src/main/java/com/zjty/inspect/service/ParameterService.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
service
;
import
com.zjty.inspect.entity.InspectParameter
;
/**
*
* 评估参数
* @author mcj
*/
public
interface
ParameterService
{
/**
* 保存参数
* @param inspectParameter 评估封装参数。
*/
public
void
saveParameter
(
InspectParameter
inspectParameter
);
}
src/main/java/com/zjty/inspect/service/ReportService.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
service
;
import
com.zjty.inspect.entity.ReportVo
;
import
java.util.List
;
public
interface
ReportService
{
/**
* 获取所有历史报告
* @return 历史报告
*/
public
List
<
ReportVo
>
getHistory
();
}
src/main/java/com/zjty/inspect/service/RuleService.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
service
;
import
com.zjty.inspect.entity.Rule
;
import
com.zjty.inspect.entity.RuleQo
;
import
com.zjty.inspect.entity.RuleVo
;
import
java.util.List
;
/**
* 规则接口
*/
public
interface
RuleService
{
/**
* 新增规则
* @param ruleQo 规则封装类
*/
public
void
addRule
(
RuleQo
ruleQo
);
/**
* 删除规则
* @param ruleQo 规则封装类
*/
public
void
deleteRule
(
RuleQo
ruleQo
);
/**
* 查询所有规则
* @return 规则
*/
List
<
Rule
>
findAll
();
}
src/main/java/com/zjty/inspect/service/TechnologyService.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
service
;
import
com.zjty.inspect.entity.Technology
;
import
com.zjty.inspect.entity.TechnologyQo
;
import
java.util.List
;
/**
* 关键技术
* @author mcj
*/
public
interface
TechnologyService
{
/**
* 新增关键技术点
*/
public
void
addAdvice
(
TechnologyQo
technologyQo
);
/**
* 查询所有技术
* @return List
*/
public
List
<
Technology
>
findAllTechnology
();
}
src/main/java/com/zjty/inspect/service/impl/InspectServiceImpl.java
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
service
.
impl
;
package
com
.
zjty
.
inspect
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
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.PomDependency
;
import
com.zjty.inspect.entity.Report
;
import
com.zjty.inspect.entity.Report
;
import
com.zjty.inspect.entity.Rule
;
import
com.zjty.inspect.entity.Rule
;
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.File
;
import
java.io.FileOutputStream
;
import
java.io.FileWriter
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* 解析
* 解析
...
@@ -26,10 +29,21 @@ import java.util.*;
...
@@ -26,10 +29,21 @@ import java.util.*;
@Service
@Service
public
class
InspectServiceImpl
implements
InspectService
{
public
class
InspectServiceImpl
implements
InspectService
{
@Autowired
Inspector
inspector
;
@Autowired
private
ParameterService
parameterService
;
@Autowired
private
RuleDao
ruleDao
;
@Autowired
private
ReportDao
reportDao
;
@Transactional
@Transactional
@Override
@Override
public
Report
inspect
(
InspectParameter
inspectParameter
)
{
public
Report
inspect
(
InspectParameter
inspectParameter
,
String
path
)
{
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
);
...
@@ -39,45 +53,16 @@ public class InspectServiceImpl implements InspectService {
...
@@ -39,45 +53,16 @@ public class InspectServiceImpl implements InspectService {
suffixLanguageMapping
.
put
(
"html"
,
Report
.
Language
.
ONLYVIEW
);
suffixLanguageMapping
.
put
(
"html"
,
Report
.
Language
.
ONLYVIEW
);
suffixLanguageMapping
.
put
(
"js"
,
Report
.
Language
.
JAVASCRIPT
);
suffixLanguageMapping
.
put
(
"js"
,
Report
.
Language
.
JAVASCRIPT
);
suffixLanguageMapping
.
put
(
"go"
,
Report
.
Language
.
GO
);
suffixLanguageMapping
.
put
(
"go"
,
Report
.
Language
.
GO
);
List
<
Rule
>
ruleList
=
inspectParameter
.
getRuleList
();
Path
path1
=
Paths
.
get
(
path
);
//com.mysql.cj.jdbc.Driver//com.mysql.jdbc.Driver
File
file
=
path1
.
toFile
();
// ruleList.add(new Rule("com.mysql.cj.jdbc.Driver", "建议修改为postgresql数据库驱动"));
Report
report1
=
new
Report
();
// ruleList.add(new Rule("com.mysql.jdbc.Driver", "建议修改为postgresql数据库驱动"));
report1
.
setGitAddress
(
path
);
// //net.sourceforge.jtds.jdbc.Driver//sqlserver
inspector
.
setReport
(
report1
);
// ruleList.add(new Rule("net.sourceforge.jtds.jdbc.Driver", "建议修改为postgresql数据库驱动"));
inspector
.
setSuffixLanguageMapping
(
suffixLanguageMapping
);
// //COM.ibm.db2.jdbc.app.DB2Driver//com.ibm.db2.jcc.DB2Driver//COM.ibm.db2.jdbc.net.DB2Driver//com.ibm.db2.jcc.DB2Driver
inspector
.
setPath
(
path
);
// ruleList.add(new Rule("DB2Driver", "建议修改为postgresql数据库驱动"));
Report
report
=
inspector
.
inspect
();
// //oracle.jdbc.OracleDriver//oracle.jdbc.driver.OracleDriver
reportDao
.
save
(
report
);
// ruleList.add(new Rule("OracleDriver", "建议修改为postgresql数据库驱动"));
return
null
;
//
// ruleList.add(new Rule("mysql-connector-java", "建议修改为postgresql依赖声明"));
// ruleList.add(new Rule("com.microsoft.sqlserver", "建议修改为postgresql依赖声明"));
// ruleList.add(new Rule("com.oracle", "建议修改为postgresql依赖声明"));
// ruleList.add(new Rule("org.mariadb.jdbc", "建议修改为postgresql依赖声明"));
// ruleList.add(new Rule("com.sap.cloud.db.jdbc", "建议修改为postgresql依赖声明"));
// ruleList.add(new Rule("com.ibm.informix", "建议修改为postgresql依赖声明"));
// ruleList.add(new Rule("org.firebirdsql.jdbc", "建议修改为postgresql依赖声明"));
// ruleList.add(new Rule("org.hsqldb", "建议修改为postgresql依赖声明"));
// ruleList.add(new Rule("com.h2database", "建议修改为postgresql依赖声明"));
// ruleList.add(new Rule("org.apache.derby", "建议修改为postgresql依赖声明"));
// ruleList.add(new Rule("org.mongodb", "建议修改为postgresql依赖声明"));
// ruleList.add(new Rule("package.json", "需要nodejs环境"));
// ruleList.add(new Rule("public native", "这里用到了JNI"));
// ruleList.add(new Rule("<packaging>jar</packaging>", "建议修改打包方式为war包并排除掉springboot内置的tomcat,以部署到国产化中间件上"));
// ruleList.add(new Rule("WebOffice", "这里用到了weboffice文档展示编辑插件"));
// ruleList.add(new Rule("webOffice", "这里用到了weboffice文档展示编辑插件"));
// ruleList.add(new Rule("weboffice", "这里用到了weboffice文档展示编辑插件"));
// ruleList.add(new Rule("Weboffice", "这里用到了weboffice文档展示编辑插件"));
// ruleList.add(new Rule("pdfobject.min.js", "这里用到了pdf文档展示插件"));
// ruleList.add(new Rule("pdfobject.js", "这里用到了pdf文档展示插件"));
// ruleList.add(new Rule(".swf", "这里用到了flash流媒体播放插件"));
String
path
=
inspectParameter
.
getPath
();
//调用下载服务下载源代码
Report
report
=
notList
(
path
,
suffixLanguageMapping
,
ruleList
);
return
report
;
}
}
public
void
listfile
(
String
path
,
Map
<
String
,
Report
.
Language
>
suffixLanguageMapping
,
List
<
Rule
>
ruleList
){
public
void
listfile
(
String
path
,
Map
<
String
,
Report
.
Language
>
suffixLanguageMapping
,
List
<
Rule
>
ruleList
){
Path
path1
=
Paths
.
get
(
path
);
Path
path1
=
Paths
.
get
(
path
);
...
@@ -85,38 +70,22 @@ public class InspectServiceImpl implements InspectService {
...
@@ -85,38 +70,22 @@ public class InspectServiceImpl implements InspectService {
File
[]
files
=
file
.
listFiles
();
File
[]
files
=
file
.
listFiles
();
System
.
out
.
println
(
file
.
isDirectory
());
System
.
out
.
println
(
file
.
isDirectory
());
for
(
File
file1
:
files
)
{
for
(
File
file1
:
files
)
{
Report
report
=
new
Inspector
(
file1
.
getPath
(),
suffixLanguageMapping
,
ruleList
).
inspect
();
// Report report = new Inspector(file1.getPath(), suffixLanguageMapping, ruleList).inspect();
File
file2
=
new
File
(
file1
.
getPath
()
+
"/评估报告"
+
file1
.
getName
()
+
".txt"
);
try
{
FileWriter
writer
=
new
FileWriter
(
file2
);
writer
.
write
(
"系统名称:"
+
file1
.
getName
()
+
"\n"
);
writer
.
write
(
"评估时间:"
+
new
Date
()
+
"\n\n"
);
writer
.
close
();
}
catch
(
IOException
e
)
{
}
}
}
}
}
public
Report
notList
(
String
path
,
Map
<
String
,
Report
.
Language
>
suffixLanguageMapping
,
List
<
Rule
>
ruleList
){
public
Report
notList
(
String
path
,
Map
<
String
,
Report
.
Language
>
suffixLanguageMapping
,
List
<
Rule
>
ruleList
){
Path
path1
=
Paths
.
get
(
path
);
Path
path1
=
Paths
.
get
(
path
);
File
file
=
path1
.
toFile
();
File
file
=
path1
.
toFile
();
File
file2
=
new
File
(
file
.
getPath
()
+
"/评估报告"
+
file
.
getName
()
+
".txt"
);
//File file2 = new File(file.getPath() + "/评估报告" + file.getName() + ".txt");
if
(
file2
.
exists
()){
// if (file2.exists()){
file2
.
delete
();
// file2.delete();
//
// }
// Report report = new Inspector(file.getPath(), suffixLanguageMapping, ruleList).inspect();
}
Report
report
=
new
Inspector
(
file
.
getPath
(),
suffixLanguageMapping
,
ruleList
).
inspect
();
try
{
return
new
Report
();
FileWriter
writer
=
new
FileWriter
(
file2
);
writer
.
write
(
"系统名称:"
+
file
.
getName
()
+
"\n"
);
writer
.
write
(
"评估时间:"
+
new
Date
()
+
"\n\n"
);
writer
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
report
;
}
}
}
}
src/main/java/com/zjty/inspect/service/impl/ParameterServiceImpl.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
service
.
impl
;
import
com.zjty.inspect.entity.InspectParameter
;
import
com.zjty.inspect.service.ParameterService
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
/**
* @author Mcj
* @date 2020-02-27 21:36
*/
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
ParameterServiceImpl
implements
ParameterService
{
@Override
public
void
saveParameter
(
InspectParameter
inspectParameter
)
{
}
}
src/main/java/com/zjty/inspect/service/impl/ReportServiceImpl.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
service
.
impl
;
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.entity.*
;
import
com.zjty.inspect.service.ReportService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.*
;
/**
* @author Mcj
* @date 2020-02-27 10:35
*/
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
ReportServiceImpl
implements
ReportService
{
@Autowired
private
ReportDao
reportDao
;
@Autowired
private
TechnologyDao
technologyDao
;
@Autowired
private
TechnologyAndReportDao
technologyAndReportDao
;
@Autowired
private
BudgetDao
budgetDao
;
@Override
public
List
<
ReportVo
>
getHistory
()
{
ArrayList
<
ReportVo
>
reportVos
=
new
ArrayList
<>();
List
<
Report
>
all
=
reportDao
.
findAll
();
for
(
Report
report
:
all
)
{
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中查询依赖树
HashSet
<
String
>
num
=
new
HashSet
<>();
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
());
reportVos
.
add
(
reportVo
);
}
return
reportVos
;
}
}
src/main/java/com/zjty/inspect/service/impl/RuleServiceImpl.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
service
.
impl
;
import
com.zjty.inspect.dao.TechnologyDao
;
import
com.zjty.inspect.dao.RuleDao
;
import
com.zjty.inspect.entity.Technology
;
import
com.zjty.inspect.entity.Rule
;
import
com.zjty.inspect.entity.RuleQo
;
import
com.zjty.inspect.service.RuleService
;
import
com.zjty.inspect.utils.UUIDUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
/**
* 规则库
* @author Mcj
* @date 2020-02-26 15:05
*/
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
RuleServiceImpl
implements
RuleService
{
/**
* 规则库dao
*/
@Autowired
private
RuleDao
ruleDao
;
/**
* 新增规则
* @param ruleQo 规则封装类
*/
@Override
public
void
addRule
(
RuleQo
ruleQo
)
{
// TODO: 2020-02-27 适配技术与扫描关键字关联
Rule
rule
=
new
Rule
();
rule
.
setTarget
(
ruleQo
.
getTarget
());
rule
.
setSuffix
(
ruleQo
.
getSuffix
());
rule
.
setTechnologyId
(
ruleQo
.
getTechnologyId
());
rule
.
setId
(
UUIDUtil
.
getUUID
());
ruleDao
.
save
(
rule
);
}
@Override
@Modifying
public
void
deleteRule
(
RuleQo
ruleQo
)
{
ruleDao
.
deleteById
(
ruleQo
.
getId
());
}
/**
* 查询所有规则
* @return RuleVoList
*/
@Override
public
List
<
Rule
>
findAll
()
{
return
ruleDao
.
findAll
();
}
}
src/main/java/com/zjty/inspect/service/impl/TechnologyServiceImpl.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
service
.
impl
;
import
com.zjty.inspect.dao.TechnologyDao
;
import
com.zjty.inspect.entity.TechnologyQo
;
import
com.zjty.inspect.entity.Technology
;
import
com.zjty.inspect.service.TechnologyService
;
import
com.zjty.inspect.utils.UUIDUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
/**
* 适配技术
* @author Mcj
* @date 2020-02-27 12:00
*/
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
TechnologyServiceImpl
implements
TechnologyService
{
@Autowired
private
TechnologyDao
technologyDao
;
/**
* 新增适配技术
* @param technologyQo 前端数据封装类
*/
@Override
public
void
addAdvice
(
TechnologyQo
technologyQo
)
{
if
(
technologyDao
.
findAllByTechnologyNameEquals
(
technologyQo
.
getTechnologyQoName
())==
null
){
Technology
technology
=
new
Technology
();
technology
.
setFund
(
technologyQo
.
getFund
());
technology
.
setAdvice
(
technologyQo
.
getAdvice
());
technology
.
setTechnologyName
(
technologyQo
.
getTechnologyQoName
());
technology
.
setId
(
UUIDUtil
.
getUUID
());
technologyDao
.
save
(
technology
);
}
}
@Override
public
List
<
Technology
>
findAllTechnology
()
{
return
technologyDao
.
findAll
();
}
}
src/main/java/com/zjty/inspect/task/task.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
task
;
import
com.zjty.inspect.dao.CoefficientModelDao
;
import
com.zjty.inspect.dao.RuleDao
;
import
com.zjty.inspect.dao.TechnologyDao
;
import
com.zjty.inspect.entity.CoefficientModel
;
import
com.zjty.inspect.entity.Rule
;
import
com.zjty.inspect.entity.Technology
;
import
com.zjty.inspect.utils.UUIDUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
/**
* @author Mcj
* @date 2020-03-02 14:35
*/
@Component
public
class
task
implements
CommandLineRunner
{
@Autowired
private
CoefficientModelDao
coefficientModelDao
;
@Autowired
private
RuleDao
ruleDao
;
@Autowired
private
TechnologyDao
technologyDao
;
@Override
public
void
run
(
String
...
args
)
{
ArrayList
<
CoefficientModel
>
coefficientModels
=
new
ArrayList
<>();
//无,弱,强
CoefficientModel
coefficientModel
=
new
CoefficientModel
();
coefficientModel
.
setScale
(
1
);
coefficientModel
.
setId
(
UUIDUtil
.
getUUID
());
coefficientModel
.
setName
(
"安全能力"
);
coefficientModel
.
setMin
(
0
);
coefficientModel
.
setMax
(
2
);
coefficientModel
.
setBelowCoefficient
(
0
D
);
coefficientModel
.
setMediumCoefficient
(
0.1
);
coefficientModel
.
setTopCoefficient
(
0.2
);
CoefficientModel
coefficientMode2
=
new
CoefficientModel
();
coefficientMode2
.
setScale
(
2
);
coefficientMode2
.
setId
(
UUIDUtil
.
getUUID
());
coefficientMode2
.
setName
(
"安全能力"
);
coefficientMode2
.
setMin
(
0
);
coefficientMode2
.
setMax
(
2
);
coefficientMode2
.
setBelowCoefficient
(-
0.1
);
coefficientMode2
.
setMediumCoefficient
(
0
D
);
coefficientMode2
.
setTopCoefficient
(
0.1
);
CoefficientModel
coefficientMode3
=
new
CoefficientModel
();
coefficientMode3
.
setScale
(
3
);
coefficientMode3
.
setId
(
UUIDUtil
.
getUUID
());
coefficientMode3
.
setName
(
"安全能力"
);
coefficientMode3
.
setMin
(
0
);
coefficientMode3
.
setMax
(
2
);
coefficientMode3
.
setBelowCoefficient
(-
0.2
);
coefficientMode3
.
setMediumCoefficient
(-
0.1
);
coefficientMode3
.
setTopCoefficient
(
0
D
);
CoefficientModel
coefficientMode4
=
new
CoefficientModel
();
coefficientMode4
.
setScale
(
1
);
coefficientMode4
.
setId
(
UUIDUtil
.
getUUID
());
coefficientMode4
.
setName
(
"模块"
);
coefficientMode4
.
setMin
(
4
);
coefficientMode4
.
setMax
(
10
);
coefficientMode4
.
setBelowCoefficient
(-
0.3
);
coefficientMode4
.
setMediumCoefficient
(
0
D
);
coefficientMode4
.
setTopCoefficient
(
0.3
);
CoefficientModel
coefficientMode5
=
new
CoefficientModel
();
coefficientMode5
.
setScale
(
1
);
coefficientMode5
.
setId
(
UUIDUtil
.
getUUID
());
coefficientMode5
.
setName
(
"数据量"
);
coefficientMode5
.
setMin
(
1
);
coefficientMode5
.
setMax
(
100
);
coefficientMode5
.
setBelowCoefficient
(-
0.05
);
coefficientMode5
.
setMediumCoefficient
(
0
D
);
coefficientMode5
.
setTopCoefficient
(
0.05
);
CoefficientModel
coefficientMode6
=
new
CoefficientModel
();
coefficientMode6
.
setScale
(
1
);
coefficientMode6
.
setId
(
UUIDUtil
.
getUUID
());
coefficientMode6
.
setName
(
"页面数"
);
coefficientMode6
.
setMin
(
10
);
coefficientMode6
.
setMax
(
100
);
coefficientMode6
.
setBelowCoefficient
(-
0.05
);
coefficientMode6
.
setMediumCoefficient
(
0
D
);
coefficientMode6
.
setTopCoefficient
(
0.05
);
coefficientModels
.
add
(
coefficientMode6
);
coefficientModels
.
add
(
coefficientMode5
);
coefficientModels
.
add
(
coefficientMode4
);
coefficientModels
.
add
(
coefficientMode3
);
coefficientModels
.
add
(
coefficientMode2
);
coefficientModels
.
add
(
coefficientModel
);
coefficientModelDao
.
saveAll
(
coefficientModels
);
Technology
technology
=
new
Technology
();
technology
.
setTechnologyName
(
"spring技术"
);
technology
.
setAdvice
(
"建议替换成国产化技术"
);
technology
.
setFund
(
200
);
technology
.
setId
(
UUIDUtil
.
getUUID
());
Rule
rule
=
new
Rule
();
rule
.
setId
(
UUIDUtil
.
getUUID
());
rule
.
setSuffix
(
"java"
);
rule
.
setTarget
(
"ruleService"
);
rule
.
setTechnologyId
(
technology
.
getId
());
technologyDao
.
save
(
technology
);
ruleDao
.
save
(
rule
);
}
}
src/main/java/com/zjty/inspect/utils/AnalysisFile.java
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
utils
;
package
com
.
zjty
.
inspect
.
utils
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zjty.inspect.dao.TechnologyAndReportDao
;
import
com.zjty.inspect.entity.*
;
import
com.zjty.inspect.entity.*
;
import
com.zjty.inspect.entity.Properties
;
import
com.zjty.inspect.entity.Properties
;
import
org.dom4j.Document
;
import
org.dom4j.Document
;
import
org.dom4j.DocumentException
;
import
org.dom4j.DocumentException
;
import
org.dom4j.DocumentHelper
;
import
org.dom4j.DocumentHelper
;
import
org.dom4j.Element
;
import
org.dom4j.Element
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.util.*
;
import
java.util.*
;
@Component
public
class
AnalysisFile
{
public
class
AnalysisFile
{
public
static
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
();
if
(
rootElement
.
element
(
"properties"
)!=
null
){
Element
dependencies1
=
rootElement
.
element
(
"properties"
);
for
(
Element
element:
dependencies1
.
elements
()){
Properties
properties
=
new
Properties
();
String
name
=
element
.
getName
();
String
stringValue
=
element
.
getStringValue
();
properties
.
setValue
(
stringValue
);
properties
.
setName
(
name
);
projectPom
.
getProperties
().
add
(
properties
);
}
}
projectPom
.
setModelVersion
(
rootElement
.
elementText
(
"modelVersion"
));
projectPom
.
setGroupId
(
rootElement
.
elementText
(
"groupId"
));
projectPom
.
setArtifactId
(
rootElement
.
elementText
(
"artifactId"
));
projectPom
.
setPackaging
(
rootElement
.
elementText
(
"packing"
));
projectPom
.
setVersion
(
rootElement
.
elementText
(
"version"
));
if
(
rootElement
.
elementText
(
"version"
)!=
null
){
projectPom
.
setVersion
(
rootElement
.
elementText
(
"version"
));
}
projectPom
.
setName
(
rootElement
.
elementText
(
"name"
));
projectPom
.
setDescription
(
rootElement
.
elementText
(
"description"
));
if
(
rootElement
.
element
(
"dependencies"
)!=
null
){
@Autowired
Element
dependencies1
=
rootElement
.
element
(
"dependencies"
);
private
TechnologyAndReportDao
technologyAndReportDao
;
List
<
Element
>
dependency
=
dependencies1
.
elements
(
"dependency"
);
for
(
Element
element:
dependency
){
PomDependency
pomDependency
=
new
PomDependency
();
pomDependency
.
setGroupId
(
element
.
elementText
(
"groupId"
));
pomDependency
.
setArtifactId
(
element
.
elementText
(
"artifactId"
));
if
(
element
.
elementText
(
"version"
)!=
null
){
pomDependency
.
setVersion
(
element
.
elementText
(
"version"
));
}
dependencies
.
add
(
pomDependency
);
}
}
if
(
rootElement
.
elements
(
"parent"
)!=
null
){
List
<
Element
>
parent
=
rootElement
.
elements
(
"parent"
);
for
(
Element
p:
parent
){
PomDependency
pomDependency
=
new
PomDependency
();
pomDependency
.
setGroupId
(
p
.
elementText
(
"groupId"
));
pomDependency
.
setArtifactId
(
p
.
elementText
(
"artifactId"
));
if
(
p
.
elementText
(
"version"
)!=
null
){
pomDependency
.
setVersion
(
p
.
elementText
(
"version"
));
}
dependencies
.
add
(
pomDependency
);
}
}
if
(
rootElement
.
element
(
"dependencyManagement"
)!=
null
){
Element
dependencies1
=
rootElement
.
element
(
"dependencyManagement"
);
Element
dependencies2
=
dependencies1
.
element
(
"dependencies"
);
List
<
Element
>
dependency
=
dependencies2
.
elements
(
"dependency"
);
for
(
Element
element:
dependency
){
PomDependency
pomDependency
=
new
PomDependency
();
pomDependency
.
setGroupId
(
element
.
elementText
(
"groupId"
));
pomDependency
.
setArtifactId
(
element
.
elementText
(
"artifactId"
));
if
(
element
.
elementText
(
"version"
)!=
null
){
pomDependency
.
setVersion
(
element
.
elementText
(
"version"
));
}
dependencies
.
add
(
pomDependency
);
}
}
projectPom
.
setDependencies
(
dependencies
);
return
projectPom
;
}
public
static
List
<
PomDependency
>
analysisGradle
(
Path
pomPath
)
{
public
static
List
<
PomDependency
>
analysisGradle
(
Path
pomPath
)
{
List
<
String
>
strings
=
null
;
List
<
String
>
strings
=
null
;
try
{
try
{
...
@@ -113,25 +44,40 @@ public class AnalysisFile {
...
@@ -113,25 +44,40 @@ public class AnalysisFile {
return
dependencies
;
return
dependencies
;
}
}
public
static
void
main
(
String
[]
args
)
{
public
DepTreePom
parseTreeFile
(
String
reportId
,
String
filePath
,
List
<
Rule
>
ruleList
)
{
Path
path
=
Paths
.
get
(
"/Users/mcj/IdeaProjects/inspect/tree.txt"
);
ArrayList
<
TechnologyAndReport
>
technologyAndReports
=
new
ArrayList
<>();
int
is
=
0
;
Path
path
=
Paths
.
get
(
filePath
);
boolean
b1
=
path
.
toString
().
endsWith
(
""
);
DepTreePom
depTreePom
=
new
DepTreePom
();
HashMap
<
Integer
,
DepTree
>
map
=
new
HashMap
<>();
HashMap
<
Integer
,
DepTree
>
map
=
new
HashMap
<>();
int
one
=
1
;
int
one
=
1
;
DepTree
depTree
=
new
DepTree
();
DepTree
depTree
=
new
DepTree
();
depTreePom
.
setDepTree
(
depTree
);
try
{
try
{
List
<
String
>
strings
=
Files
.
readAllLines
(
path
);
List
<
String
>
strings
=
Files
.
readAllLines
(
path
);
String
s1
=
strings
.
get
(
7
);
String
s1
=
strings
.
get
(
0
);
String
s2
=
s1
.
replaceAll
(
"\\[INFO] "
,
""
);
depTree
.
setDepName
(
s1
);
depTree
.
setDepName
(
s2
);
map
.
put
(
0
,
depTree
);
map
.
put
(
1
,
depTree
);
System
.
out
.
println
(
strings
.
size
()
);
int
now
=
0
;
int
now
=
0
;
for
(
int
i
=
8
;
i
<=
strings
.
size
()-
7
;
i
++)
{
for
(
int
i
=
1
;
i
<=
strings
.
size
()-
1
;
i
++)
{
DepTree
depTree1
=
new
DepTree
();
DepTree
depTree1
=
new
DepTree
();
String
s
=
strings
.
get
(
i
).
replaceAll
(
"\\[INFO] "
,
""
);
System
.
out
.
println
(
i
);
String
s
=
strings
.
get
(
i
);
for
(
Rule
rule
:
ruleList
)
{
if
(
KmpUtil
.
kmpMatch
(
s
,
rule
.
getTarget
())>
0
){
depTree1
.
setViolation
(
1
);
depTreePom
.
add
(
rule
.
getTechnologyId
());
//rule匹配上了
TechnologyAndReport
technologyAndReport
=
new
TechnologyAndReport
();
technologyAndReport
.
setFilePath
(
filePath
);
technologyAndReport
.
setLineNum
(
i
);
technologyAndReport
.
setTechnologyId
(
rule
.
getTechnologyId
());
technologyAndReport
.
setReportId
(
reportId
);
technologyAndReport
.
setRuleId
(
rule
.
getId
());
technologyAndReport
.
setId
(
UUIDUtil
.
getUUID
());
technologyAndReports
.
add
(
technologyAndReport
);
}
}
int
i1
=
s
.
indexOf
(
"-"
);
int
i1
=
s
.
indexOf
(
"-"
);
if
(
i1
==
one
){
if
(
i1
==
one
){
depTree1
.
setDepName
(
s
);
depTree1
.
setDepName
(
s
);
...
@@ -148,54 +94,11 @@ public class AnalysisFile {
...
@@ -148,54 +94,11 @@ public class AnalysisFile {
map
.
put
(
i1
+
3
,
depTree1
);
map
.
put
(
i1
+
3
,
depTree1
);
now
=
i1
;
now
=
i1
;
}
}
DepTreeAndReport
depTreeAndReport
=
new
DepTreeAndReport
();
depTreeAndReport
.
setId
(
"报告id"
);
depTreeAndReport
.
setDepTree
(
depTree
);
Object
o
=
JSONObject
.
toJSON
(
depTreeAndReport
);
System
.
out
.
println
(
o
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
technologyAndReportDao
.
saveAll
(
technologyAndReports
);
return
depTreePom
;
String
a
=
"AAbaaa"
;
String
b
=
"cccccaaB"
;
boolean
aaB
=
a
.
equalsIgnoreCase
(
"aaB"
);
int
aaB1
=
b
.
indexOf
(
"aaB"
);
int
i
=
AnalysisFile
.
EditDistance
(
a
,
b
);
System
.
out
.
println
(
i
);
}
public
static
int
EditDistance
(
String
source
,
String
target
)
{
char
[]
sources
=
source
.
toCharArray
();
char
[]
targets
=
target
.
toCharArray
();
int
sourceLen
=
sources
.
length
;
int
targetLen
=
targets
.
length
;
int
[][]
d
=
new
int
[
sourceLen
+
1
][
targetLen
+
1
];
for
(
int
i
=
0
;
i
<=
sourceLen
;
i
++)
{
d
[
i
][
0
]
=
i
;
}
for
(
int
i
=
0
;
i
<=
targetLen
;
i
++)
{
d
[
0
][
i
]
=
i
;
}
for
(
int
i
=
1
;
i
<=
sourceLen
;
i
++)
{
for
(
int
j
=
1
;
j
<=
targetLen
;
j
++)
{
if
(
sources
[
i
-
1
]
==
targets
[
j
-
1
])
{
d
[
i
][
j
]
=
d
[
i
-
1
][
j
-
1
];
}
else
{
//插入
int
insert
=
d
[
i
][
j
-
1
]
+
1
;
//删除
int
delete
=
d
[
i
-
1
][
j
]
+
1
;
//替换
int
replace
=
d
[
i
-
1
][
j
-
1
]
+
1
;
d
[
i
][
j
]
=
Math
.
min
(
insert
,
delete
)
>
Math
.
min
(
delete
,
replace
)
?
Math
.
min
(
delete
,
replace
)
:
Math
.
min
(
insert
,
delete
);
}
}
}
return
d
[
sourceLen
][
targetLen
];
}
}
...
...
src/main/java/com/zjty/inspect/utils/BudgetUitl.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
utils
;
import
com.zjty.inspect.dao.BudgetDao
;
import
com.zjty.inspect.dao.CoefficientModelDao
;
import
com.zjty.inspect.dao.TechnologyDao
;
import
com.zjty.inspect.entity.Budget
;
import
com.zjty.inspect.entity.CoefficientModel
;
import
com.zjty.inspect.entity.InspectParameter
;
import
com.zjty.inspect.entity.TechnologyAndReport
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 获取预算
* @author Mcj
* @date 2020-02-26 15:14
*/
@Component
public
class
BudgetUitl
{
@Autowired
private
CoefficientModelDao
coefficientModelDao
;
@Autowired
private
BudgetDao
budgetDao
;
/**
* 获取预算数据
* @param reportId 报告id
* @param fund 技术费用
* @param inspectParameter2 计算所需数据
* @return
*/
public
List
<
Budget
>
getBudget
(
String
reportId
,
Integer
fund
,
InspectParameter
inspectParameter2
){
InspectParameter
inspectParameter
=
new
InspectParameter
();
inspectParameter
.
setMoneyRate
(
1.42
);
inspectParameter
.
setYears
(
2015
);
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
();
if
(
systemFund
==
0
){
double
v
=
inspectParameter
.
getModules
()
*
7.5
;
systemFund
=
(
int
)
v
;
}
if
(
systemFund
<
30
){
scale
=
1
;
}
else
if
(
systemFund
<
200
){
scale
=
2
;
}
else
{
scale
=
3
;
}
Budget
budget
=
new
Budget
();
budget
.
setId
(
UUIDUtil
.
getUUID
());
budget
.
setBudgetName
(
"代码重构预算"
);
budget
.
setReportId
(
reportId
);
Double
moneyRate
=
inspectParameter
.
getMoneyRate
();
int
i
=
2020
-
inspectParameter
.
getYears
();
double
pow
=
Math
.
pow
(
moneyRate
,
i
);
//不带修正系数资金
double
v
=
inspectParameter
.
getProportion
()
*
pow
*
systemFund
+
fund
;
//带修正系数资金
ArrayList
<
String
>
strings
=
new
ArrayList
<>();
Double
v1
=
v
;
strings
.
add
(
"安全能力"
);
strings
.
add
(
"容灾能力"
);
strings
.
add
(
"架构"
);
List
<
CoefficientModel
>
nameIn
=
coefficientModelDao
.
findAllByNameInAndScaleEquals
(
strings
,
scale
);
for
(
CoefficientModel
model
:
nameIn
)
{
if
(
"架构"
.
equals
(
model
.
getName
())){
Double
aDouble
=
model
.
countCoefficient
(
inspectParameter
.
getFramework
());
v1
*=
aDouble
;
}
else
if
(
"容灾能力"
.
equals
(
model
.
getName
())){
Double
aDouble
=
model
.
countCoefficient
(
inspectParameter
.
getDisaster
());
v1
*=
aDouble
;
}
else
if
(
"安全能力"
.
equals
(
model
.
getName
())){
Double
aDouble
=
model
.
countCoefficient
(
inspectParameter
.
getSafety
());
v1
*=
aDouble
;
}
}
if
(
v
<
v1
){
budget
.
setFund
(
v
+
"--"
+
v1
);
}
else
if
(
v
>
v1
){
budget
.
setFund
(
v1
+
"--"
+
v
);
}
else
{
budget
.
setFund
(
v1
+
"--"
+
v
);
}
budget
.
setFundDetail
(
"普通业务开发费用:"
+
v
);
budget
.
setFundDetail
(
"普通业务开发费用(修正):"
+
v1
);
budget
.
setFundDetail
(
"关键适配技术成本:"
+
fund
);
Budget
budget1
=
new
Budget
();
//budget.setBudgetName("代码修改预算");
ArrayList
<
Budget
>
budgets
=
new
ArrayList
<>();
budgets
.
add
(
budget
);
budgetDao
.
saveAll
(
budgets
);
return
budgets
;
}
}
src/main/java/com/zjty/inspect/utils/FileUtil.java
浏览文件 @
a5db92b3
...
@@ -28,7 +28,7 @@ public class FileUtil {
...
@@ -28,7 +28,7 @@ public class FileUtil {
* @param destDirPath 解压后的目标文件夹
* @param destDirPath 解压后的目标文件夹
* @throws RuntimeException 解压失败会抛出运行时异常
* @throws RuntimeException 解压失败会抛出运行时异常
*/
*/
public
static
void
unZip
(
File
srcFile
,
String
destDirPath
)
throws
RuntimeException
{
public
static
String
unZip
(
File
srcFile
,
String
destDirPath
)
throws
RuntimeException
{
long
start
=
System
.
currentTimeMillis
();
long
start
=
System
.
currentTimeMillis
();
// 判断源文件是否存在
// 判断源文件是否存在
if
(!
srcFile
.
exists
())
{
if
(!
srcFile
.
exists
())
{
...
@@ -66,6 +66,7 @@ public class FileUtil {
...
@@ -66,6 +66,7 @@ public class FileUtil {
// 关流顺序,先打开的后关闭
// 关流顺序,先打开的后关闭
fos
.
close
();
fos
.
close
();
is
.
close
();
is
.
close
();
return
targetFile
.
getPath
();
}
}
}
}
long
end
=
System
.
currentTimeMillis
();
long
end
=
System
.
currentTimeMillis
();
...
@@ -81,6 +82,7 @@ public class FileUtil {
...
@@ -81,6 +82,7 @@ public class FileUtil {
}
}
}
}
}
}
return
""
;
}
}
private
static
void
recursiveFiles
(
String
path
)
{
private
static
void
recursiveFiles
(
String
path
)
{
...
@@ -118,7 +120,7 @@ public class FileUtil {
...
@@ -118,7 +120,7 @@ public class FileUtil {
vueDep
=
new
ObjectMapper
().
readValue
(
file
,
VueDep
.
class
);
vueDep
=
new
ObjectMapper
().
readValue
(
file
,
VueDep
.
class
);
return
vueDep
;
return
vueDep
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
return
n
ull
;
return
n
ew
VueDep
()
;
}
}
}
}
...
...
src/main/java/com/zjty/inspect/utils/Inspector.java
浏览文件 @
a5db92b3
差异被折叠。
点击展开。
src/main/java/com/zjty/inspect/utils/KmpUtil.java
浏览文件 @
a5db92b3
...
@@ -11,7 +11,7 @@ public class KmpUtil {
...
@@ -11,7 +11,7 @@ public class KmpUtil {
* @param t 字符数组
* @param t 字符数组
* @return next数组
* @return next数组
*/
*/
p
ublic
static
int
[]
getNextArray
(
char
[]
t
)
{
p
rivate
static
int
[]
getNextArray
(
char
[]
t
)
{
int
[]
next
=
new
int
[
t
.
length
];
int
[]
next
=
new
int
[
t
.
length
];
next
[
0
]
=
-
1
;
next
[
0
]
=
-
1
;
next
[
1
]
=
0
;
next
[
1
]
=
0
;
...
...
src/main/java/com/zjty/inspect/utils/MavenUtil.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
utils
;
import
org.apache.maven.shared.invoker.*
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.io.File
;
import
java.util.Collections
;
/**
* @author Mcj
* @date 2020-03-01 17:11
*/
@Component
public
class
MavenUtil
{
@Value
(
"${maven.command}"
)
private
String
mavenCommand
;
@Value
(
"${maven.home}"
)
private
String
mavenHome
;
@Value
(
"${maven.treefile}"
)
private
String
treeFile
;
public
File
genTreeFile
(
String
path
){
InvocationRequest
request
=
new
DefaultInvocationRequest
();
request
.
setPomFile
(
new
File
(
path
));
request
.
setGoals
(
Collections
.
singletonList
(
mavenCommand
+
treeFile
));
Invoker
invoker
=
new
DefaultInvoker
();
invoker
.
setMavenHome
(
new
File
(
mavenHome
));
try
{
invoker
.
execute
(
request
);
}
catch
(
MavenInvocationException
e
)
{
e
.
printStackTrace
();
}
return
new
File
(
treeFile
);
}
}
src/main/java/com/zjty/inspect/utils/RedisUtil.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
utils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.ValueOperations
;
import
org.springframework.stereotype.Service
;
import
java.io.Serializable
;
/**
* @author Mcj
* @date 2020-03-02 11:30
*/
@Service
public
class
RedisUtil
{
@Autowired
private
RedisTemplate
redisTemplate
;
/**
* 写入缓存
* @param key
* @param value
* @return
*/
public
boolean
set
(
final
String
key
,
Object
value
)
{
boolean
result
=
false
;
try
{
ValueOperations
<
Serializable
,
Object
>
operations
=
redisTemplate
.
opsForValue
();
operations
.
set
(
key
,
value
);
result
=
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
result
;
}
/**
* 批量删除对应的value
* @param keys
*/
public
void
remove
(
final
String
...
keys
)
{
for
(
String
key
:
keys
)
{
remove
(
key
);
}
}
/**
* 删除对应的value
* @param key
*/
public
void
remove
(
final
String
key
)
{
if
(
exists
(
key
))
{
redisTemplate
.
delete
(
key
);
}
}
/**
* 判断缓存中是否有对应的value
* @param key
* @return
*/
public
boolean
exists
(
final
String
key
)
{
return
redisTemplate
.
hasKey
(
key
);
}
}
src/main/java/com/zjty/inspect/utils/UUIDUtil.java
0 → 100644
浏览文件 @
a5db92b3
package
com
.
zjty
.
inspect
.
utils
;
import
java.util.UUID
;
/**
* @author Mcj
* @date 2019-09-20 10:57
*/
public
class
UUIDUtil
{
public
static
String
getUUID
(){
//转化为String对象
return
UUID
.
randomUUID
().
toString
();
}
}
src/main/resources/application.properties
浏览文件 @
a5db92b3
...
@@ -54,3 +54,12 @@ spring.datasource.url=jdbc:mysql://localhost:3306/adaptation?useSSL=false&server
...
@@ -54,3 +54,12 @@ spring.datasource.url=jdbc:mysql://localhost:3306/adaptation?useSSL=false&server
spring.datasource.username
=
root
spring.datasource.username
=
root
spring.datasource.password
=
root
spring.datasource.password
=
root
maven.home
=
/Users/mcj/apache-maven-3.6.1
maven.command
=
dependency:tree -DoutputType=txt -DoutputFile=
maven.treefile
=
/Users/mcj/IdeaProjects/inspect/hello
spring.redis.host
=
127.0.0.1
#Redis服务器连接端口
spring.redis.port
=
6379
#Redis服务器连接密码(默认为空)
spring.redis.password
=
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论