Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
I
inspect
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
912协同工作系统
项目监控管理工具
inspect
Commits
f2da630a
提交
f2da630a
authored
3月 05, 2020
作者:
马晨俊
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mcj:新增评估报告管理
上级
6a1af196
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
228 行增加
和
65 行删除
+228
-65
InspectController.java
...n/java/com/zjty/inspect/controller/InspectController.java
+18
-6
ReportController.java
...in/java/com/zjty/inspect/controller/ReportController.java
+37
-0
ReportDao.java
src/main/java/com/zjty/inspect/dao/ReportDao.java
+7
-0
CoefficientModel.java
src/main/java/com/zjty/inspect/entity/CoefficientModel.java
+1
-1
InspectParameter.java
src/main/java/com/zjty/inspect/entity/InspectParameter.java
+10
-5
Page.java
src/main/java/com/zjty/inspect/entity/Page.java
+37
-0
Report.java
src/main/java/com/zjty/inspect/entity/Report.java
+3
-36
ReportManage.java
src/main/java/com/zjty/inspect/entity/ReportManage.java
+14
-0
ParameterService.java
src/main/java/com/zjty/inspect/service/ParameterService.java
+1
-1
ReportService.java
src/main/java/com/zjty/inspect/service/ReportService.java
+8
-4
InspectServiceImpl.java
...ava/com/zjty/inspect/service/impl/InspectServiceImpl.java
+11
-3
ReportServiceImpl.java
...java/com/zjty/inspect/service/impl/ReportServiceImpl.java
+35
-7
BudgetUitl.java
src/main/java/com/zjty/inspect/utils/BudgetUitl.java
+6
-2
RandomUtil.java
src/main/java/com/zjty/inspect/utils/RandomUtil.java
+40
-0
没有找到文件。
src/main/java/com/zjty/inspect/controller/InspectController.java
浏览文件 @
f2da630a
package
com
.
zjty
.
inspect
.
controller
;
import
com.zjty.inspect.dao.TechnologyDao
;
import
com.zjty.inspect.entity.InspectParameter
;
import
com.zjty.inspect.entity.ReportVo
;
import
com.zjty.inspect.entity.Technology
;
import
com.zjty.inspect.entity.Warn
;
import
com.zjty.inspect.entity.*
;
import
com.zjty.inspect.service.InspectService
;
import
com.zjty.inspect.service.ParameterService
;
import
com.zjty.inspect.service.ReportService
;
import
com.zjty.inspect.service.TechnologyService
;
import
com.zjty.inspect.utils.*
;
import
freemarker.template.TemplateException
;
...
...
@@ -39,6 +38,11 @@ public class InspectController {
@Autowired
private
TechnologyService
technologyService
;
@Autowired
private
ParameterService
parameterService
;
@Autowired
private
ReportService
reportService
;
/**
* 上传代码进行评估
* @param years 系统开发时间
...
...
@@ -82,13 +86,15 @@ public class InspectController {
int
support
=
technologyService
.
findAllTechnologyNotSupport
();
reportVo
.
setTechnologiesRepair
(
support
);
reportVo
.
setId
(
TimeUtil
.
getNowDate
());
reportVo
.
setId
(
RandomUtil
.
getRandom
());
reportVo
.
setUploadType
(
"文件上传"
);
reportVo
.
setFileName
(
file
.
getName
());
reportVo
.
setProjectName
(
projectName
);
reportVo
.
setSourceAddress
(
file
.
getCanonicalPath
());
reportVo
.
setDatabaseType
(
databaseType
);
ReportVo
inspect
=
inspectService
.
inspect
(
reportVo
,
inspectParameter
);
Map
map
=
new
HashMap
();
...
...
@@ -113,7 +119,13 @@ public class InspectController {
}
catch
(
TemplateException
e
)
{
e
.
printStackTrace
();
}
Report
report
=
new
Report
();
String
random
=
RandomUtil
.
getRandom
();
report
.
setId
(
RandomUtil
.
getRandom
());
report
.
setHtmlAddress
(
reportVo
.
getHtmlAddress
());
reportService
.
saveReport
(
report
);
inspectParameter
.
setReportId
(
random
);
parameterService
.
saveParameter
(
inspectParameter
);
return
ResponseEntity
.
ok
(
inspect
);
}
...
...
src/main/java/com/zjty/inspect/controller/ReportController.java
0 → 100644
浏览文件 @
f2da630a
package
com
.
zjty
.
inspect
.
controller
;
import
com.zjty.inspect.service.ReportService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
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.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @author Mcj
* @date 2020-03-05 19:22
*/
@RestController
@RequestMapping
(
"/report"
)
@Api
(
value
=
"报告管理页面接口"
,
description
=
"报告管理页面接口,提供页面的增、删、改、查"
)
public
class
ReportController
{
@Autowired
private
ReportService
reportService
;
@GetMapping
(
"/page/{page}"
)
@ApiOperation
(
"根据页码获取数据"
)
public
ResponseEntity
getReportByPage
(
@PathVariable
int
page
){
return
ResponseEntity
.
ok
(
reportService
.
findReportByPage
(
page
));
}
@GetMapping
(
"/id/{id}"
)
@ApiOperation
(
"根据id获取数据"
)
public
ResponseEntity
getReportById
(
@PathVariable
String
id
){
return
ResponseEntity
.
ok
(
reportService
.
findReportById
(
id
));
}
}
src/main/java/com/zjty/inspect/dao/ReportDao.java
0 → 100644
浏览文件 @
f2da630a
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/entity/CoefficientModel.java
浏览文件 @
f2da630a
...
...
@@ -46,7 +46,7 @@ public class CoefficientModel {
private
Integer
scale
;
public
Double
countCoefficient
(
Integer
data
)
{
if
(
data
==
null
||
data
==
0
){
if
(
data
==
null
){
return
1
D
;
}
if
(
data
<
min
){
...
...
src/main/java/com/zjty/inspect/entity/InspectParameter.java
浏览文件 @
f2da630a
...
...
@@ -56,6 +56,11 @@ public class InspectParameter {
* 代码量
*/
private
Integer
codeSize
;
/**
* 内容
*/
private
Integer
content
;
/**
* 架构
*/
...
...
@@ -97,11 +102,6 @@ public class InspectParameter {
*/
private
String
reportAddress
;
/**
* 预算报告地址
*/
private
String
budgetAddress
;
/**
* git上传地址
*/
...
...
@@ -128,4 +128,9 @@ public class InspectParameter {
* 方式
*/
private
Integer
recastMethod
;
/**
* 报告id
*/
private
String
reportId
;
}
src/main/java/com/zjty/inspect/entity/Page.java
0 → 100644
浏览文件 @
f2da630a
package
com
.
zjty
.
inspect
.
entity
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author Mcj
* @date 2020-03-05 19:24
*/
public
class
Page
<
T
>
{
private
int
totalPage
;
private
int
totalElement
;
private
List
<
T
>
objects
=
new
ArrayList
<
T
>();
public
void
add
(
T
t
){
objects
.
add
(
t
);
}
public
void
addAll
(
List
<
T
>
t
){
objects
.
addAll
(
t
);
}
public
void
setTotalPage
(
int
totalPage
)
{
this
.
totalPage
=
totalPage
;
}
public
void
setTotalElement
(
int
totalElement
)
{
this
.
totalElement
=
totalElement
;
}
public
int
getTotalPage
()
{
return
totalPage
;
}
public
int
getTotalElement
()
{
return
totalElement
;
}
}
src/main/java/com/zjty/inspect/entity/Report.java
浏览文件 @
f2da630a
...
...
@@ -13,45 +13,19 @@ import java.sql.Timestamp;
* 报告
* @author mcj
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public
class
Report
{
/**
* git源代码地址
*/
private
String
gitAddress
;
/**
* 架构,整合型还是分离型,根据jsp数量决定
*/
private
String
framework
;
/**
* 代码管理方式,
*/
private
String
manager
;
/**
* 语言
*/
private
String
language
;
@Id
private
String
id
;
/**
* 生成报告存储地址
*/
private
String
htmlAddress
;
/**
* 适配方式
* 1:适配
* 2:重构
*/
@Column
(
length
=
5
)
private
Integer
recastMethod
;
//前端适配预算
//代码重构预算
//代码修改预算
...
...
@@ -69,11 +43,4 @@ public class Report {
@Column
(
name
=
"update_time"
,
columnDefinition
=
"TIMESTAMP DEFAULT CURRENT_TIMESTAMP"
,
insertable
=
false
)
@Generated
(
GenerationTime
.
ALWAYS
)
private
Timestamp
updateDate
;
public
enum
DependenceManagement
{
MAVEN
,
GRADLE
,
ANT
}
public
enum
Language
{
JAVA
,
PYTHON
,
CPP
,
JSP
,
ASP
,
ONLYVIEW
,
UNKNOW
,
JAVASCRIPT
,
GO
,
VUE
,
HTML
}
}
src/main/java/com/zjty/inspect/entity/ReportManage.java
0 → 100644
浏览文件 @
f2da630a
package
com
.
zjty
.
inspect
.
entity
;
import
lombok.Data
;
/**
* @author Mcj
* @date 2020-03-05 19:49
*/
@Data
public
class
ReportManage
{
Report
report
;
InspectParameter
inspectParameter
;
}
src/main/java/com/zjty/inspect/service/ParameterService.java
浏览文件 @
f2da630a
...
...
@@ -16,7 +16,7 @@ public interface ParameterService {
public
void
saveParameter
(
InspectParameter
inspectParameter
);
/**
*
保存
参数
*
根据id获取
参数
* @param id id
*/
public
InspectParameter
getParameterById
(
String
id
);
...
...
src/main/java/com/zjty/inspect/service/ReportService.java
浏览文件 @
f2da630a
package
com
.
zjty
.
inspect
.
service
;
import
com.zjty.inspect.entity.ReportVo
;
import
org.springframework.data.domain.Page
;
import
java.util.List
;
import
com.zjty.inspect.entity.Page
;
import
com.zjty.inspect.entity.Report
;
import
com.zjty.inspect.entity.ReportManage
;
public
interface
ReportService
{
public
Page
findReportByPage
(
int
page
);
public
ReportManage
findReportById
(
String
id
);
void
saveReport
(
Report
report
);
}
src/main/java/com/zjty/inspect/service/impl/InspectServiceImpl.java
浏览文件 @
f2da630a
package
com
.
zjty
.
inspect
.
service
.
impl
;
import
com.zjty.inspect.dao.ReportDao
;
import
com.zjty.inspect.entity.InspectParameter
;
import
com.zjty.inspect.entity.Report
;
import
com.zjty.inspect.entity.ReportVo
;
import
com.zjty.inspect.enums.Language
;
import
com.zjty.inspect.service.InspectService
;
import
com.zjty.inspect.inspect.Inspector
;
import
com.zjty.inspect.service.ParameterService
;
import
com.zjty.inspect.utils.RandomUtil
;
import
freemarker.cache.StringTemplateLoader
;
import
freemarker.template.Configuration
;
import
freemarker.template.Template
;
...
...
@@ -27,6 +30,12 @@ public class InspectServiceImpl implements InspectService {
@Autowired
Inspector
inspector
;
@Autowired
private
ReportDao
reportDao
;
@Autowired
private
ParameterService
parameterService
;
@Transactional
@Override
public
ReportVo
inspect
(
ReportVo
reportVo
,
InspectParameter
inspectParameter
)
{
...
...
@@ -46,11 +55,10 @@ public class InspectServiceImpl implements InspectService {
inspector
.
setReport
(
reportVo
);
//需要重构
inspector
.
setSuffixLanguageMapping
(
suffixLanguageMapping
);
ReportVo
report
=
inspector
.
inspect
();
ReportVo
reportVoReturn
=
inspector
.
inspect
();
return
report
;
return
report
VoReturn
;
}
//执行静态化
...
...
src/main/java/com/zjty/inspect/service/impl/ReportServiceImpl.java
浏览文件 @
f2da630a
package
com
.
zjty
.
inspect
.
service
.
impl
;
import
com.zjty.inspect.dao.ReportDao
;
import
com.zjty.inspect.dao.TechnologyDao
;
import
com.zjty.inspect.entity.*
;
import
com.zjty.inspect.service.ParameterService
;
import
com.zjty.inspect.service.ReportService
;
import
com.zjty.inspect.utils.RedisUtil
;
import
freemarker.cache.StringTemplateLoader
;
import
freemarker.template.Configuration
;
import
freemarker.template.Template
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.ui.freemarker.FreeMarkerTemplateUtils
;
import
java.util.Map
;
import
java.util.Optional
;
/**
* @author Mcj
...
...
@@ -24,14 +27,12 @@ public class ReportServiceImpl implements ReportService {
@Autowired
private
TechnologyDao
technologyDao
;
@Autowired
private
RedisUtil
redisUtil
;
public
ReportVo
set
(
Report
report
){
@Autowired
private
ParameterService
parameterService
;
return
new
ReportVo
();
}
@Autowired
private
ReportDao
reportDao
;
//执行静态化
private
String
generateHtml
(
String
templateContent
,
Map
model
){
...
...
@@ -56,4 +57,31 @@ public class ReportServiceImpl implements ReportService {
}
@Override
public
Page
findReportByPage
(
int
page
)
{
PageRequest
of
=
PageRequest
.
of
(
page
-
1
,
10
);
org
.
springframework
.
data
.
domain
.
Page
<
Report
>
all
=
reportDao
.
findAll
(
of
);
Page
<
Report
>
reportPage
=
new
Page
<>();
reportPage
.
setTotalElement
((
int
)
all
.
getTotalElements
());
reportPage
.
setTotalPage
(
all
.
getTotalPages
());
reportPage
.
addAll
(
all
.
getContent
());
return
reportPage
;
}
@Override
public
ReportManage
findReportById
(
String
id
)
{
Optional
<
Report
>
report
=
reportDao
.
findById
(
id
);
ReportManage
reportManage
=
new
ReportManage
();
if
(
report
.
isPresent
()){
reportManage
.
setReport
(
report
.
get
());
InspectParameter
inspectParameter
=
parameterService
.
getParameterById
(
report
.
get
().
getId
());
reportManage
.
setInspectParameter
(
inspectParameter
);
}
return
reportManage
;
}
@Override
public
void
saveReport
(
Report
report
)
{
reportDao
.
save
(
report
);
}
}
src/main/java/com/zjty/inspect/utils/BudgetUitl.java
浏览文件 @
f2da630a
...
...
@@ -32,7 +32,7 @@ public class BudgetUitl {
public
BudgetVo
getBudget
(
Integer
fund
,
ReportVo
report
,
InspectParameter
inspectParameter
){
BudgetVo
budgetVo
=
new
BudgetVo
();
// TODO: 2020-03-05 查询年复利率
// TODO: 2020-03-05 查询年复利率
,查询修改,适配和重构占比
inspectParameter
.
setMoneyRate
(
1.04
);
//代码重构比
...
...
@@ -42,7 +42,6 @@ public class BudgetUitl {
if
(
report
.
getRecastMethod
()==
1
){
inspectParameter
.
setProportion
(
0.6
);
}
else
{
// TODO: 2020-03-05 查询config表0.3或者0.15
inspectParameter
.
setProportion
(
0.3
);
}
int
scale
;
...
...
@@ -72,6 +71,7 @@ public class BudgetUitl {
strings
.
add
(
"模块数"
);
strings
.
add
(
"数据库表"
);
strings
.
add
(
"代码量"
);
strings
.
add
(
"内容"
);
double
coefficient
=
1
;
List
<
CoefficientModel
>
nameIn
=
coefficientModelDao
.
findAllByNameIn
(
strings
);
List
<
CoefficientModel
>
collect
=
nameIn
.
stream
().
filter
(
a
->
a
.
getScale
()
==
scale
).
collect
(
Collectors
.
toList
());
...
...
@@ -111,6 +111,10 @@ public class BudgetUitl {
Double
value
=
model
.
countCoefficient
(
inspectParameter
.
getCodeSize
());
coefficientModelVo
.
setValue
(
value
);
coefficient
*=
value
;
}
else
if
(
"内容"
.
equals
(
model
.
getName
())){
Double
value
=
model
.
countCoefficient
(
inspectParameter
.
getContent
());
coefficientModelVo
.
setValue
(
value
);
coefficient
*=
value
;
}
budgetVo
.
getCoefficientModelVos
().
add
(
coefficientModelVo
);
}
...
...
src/main/java/com/zjty/inspect/utils/RandomUtil.java
0 → 100644
浏览文件 @
f2da630a
package
com
.
zjty
.
inspect
.
utils
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
import
java.util.Stack
;
/**
* @author Mcj
* @date 2020-03-05 19:20
*/
public
class
RandomUtil
{
public
synchronized
static
String
getRandom
()
{
String
digths
=
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
;
int
base
=
digths
.
length
();
long
now
=
System
.
currentTimeMillis
();
try
{
Thread
.
sleep
(
1
);}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();}
StringBuffer
str
=
new
StringBuffer
(
""
);
Stack
<
Character
>
s
=
new
Stack
<
Character
>();
while
(
now
!=
0
){
s
.
push
(
digths
.
charAt
((
int
)(
now
%
base
)));
now
/=
base
;
}
while
(!
s
.
isEmpty
()){
str
.
append
(
s
.
pop
());
}
StringBuilder
stringBuilder
=
new
StringBuilder
();
LocalDateTime
date
=
LocalDateTime
.
now
();
String
[]
split
=
UUIDUtil
.
getUUID
().
split
(
"-"
);
stringBuilder
.
append
(
date
.
getYear
())
.
append
(
date
.
getMonth
())
.
append
(
date
.
getDayOfMonth
())
.
append
(
date
.
getHour
()
)
.
append
(
date
.
getMinute
())
.
append
(
date
.
getSecond
())
.
append
(
split
[
0
]);
return
stringBuilder
.
toString
();
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论