Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mes
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ximai
mes
Commits
328358c7
Commit
328358c7
authored
Nov 16, 2024
by
温志超
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
2b956ed8
61f71cf7
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
126 additions
and
152 deletions
+126
-152
SysApiLogController.java
...com/ximai/web/controller/monitor/SysApiLogController.java
+9
-1
ApiLogAspect.java
mes/src/main/java/com/ximai/mes/config/ApiLogAspect.java
+13
-5
KanbanAbnormalService.java
...a/com/ximai/mes/kanban/service/KanbanAbnormalService.java
+5
-4
KanbanTaskService.java
.../java/com/ximai/mes/kanban/service/KanbanTaskService.java
+1
-1
SysApiLog.java
system/src/main/java/com/ximai/system/domain/SysApiLog.java
+52
-136
ISysApiLogService.java
...main/java/com/ximai/system/service/ISysApiLogService.java
+7
-0
SysApiLogServiceImpl.java
...a/com/ximai/system/service/impl/SysApiLogServiceImpl.java
+23
-1
SysApiLogMapper.xml
system/src/main/resources/mapper/system/SysApiLogMapper.xml
+14
-4
SysMenuMapper.xml
system/src/main/resources/mapper/system/SysMenuMapper.xml
+2
-0
No files found.
admin/src/main/java/com/ximai/web/controller/monitor/SysApiLogController.java
View file @
328358c7
...
...
@@ -15,7 +15,7 @@ import javax.servlet.http.HttpServletResponse;
import
java.util.List
;
/**
*
操作
日志记录
*
接口
日志记录
*
*/
@RestController
...
...
@@ -50,4 +50,12 @@ public class SysApiLogController extends BaseController
operLogService
.
cleanApiLog
();
return
AjaxResult
.
success
();
}
@Log
(
title
=
"再次执行"
,
businessType
=
BusinessType
.
OTHER
)
@PreAuthorize
(
"@ss.hasPermi('monitor:apilog:remove')"
)
@PostMapping
(
"/execute"
)
public
AjaxResult
execute
(
Long
[]
logIds
)
throws
Exception
{
operLogService
.
executeByIds
(
logIds
);
return
AjaxResult
.
success
();
}
}
mes/src/main/java/com/ximai/mes/config/ApiLogAspect.java
View file @
328358c7
package
com
.
ximai
.
mes
.
config
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.text.StrJoiner
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.google.common.base.Joiner
;
import
com.ximai.common.annotation.ApiLog
;
import
com.ximai.common.annotation.Log
;
import
com.ximai.common.enums.BusinessStatus
;
...
...
@@ -165,26 +168,31 @@ public class ApiLogAspect {
* @param operLog 操作日志
* @throws Exception 异常
*/
private
void
setRequestValue
(
JoinPoint
joinPoint
,
SysApiLog
operLog
)
throws
Exception
{
String
params
=
argsArrayToString
(
joinPoint
.
getArgs
());
operLog
.
setOperParam
(
params
);
private
void
setRequestValue
(
JoinPoint
joinPoint
,
SysApiLog
operLog
)
{
argsArrayToString
(
operLog
,
joinPoint
.
getArgs
());
}
/**
* 参数拼装
*/
private
String
argsArrayToString
(
Object
[]
paramsArray
)
{
private
String
argsArrayToString
(
SysApiLog
operLog
,
Object
[]
paramsArray
)
{
String
params
=
""
;
if
(
paramsArray
!=
null
&&
paramsArray
.
length
>
0
)
{
int
i
=
1
;
StrJoiner
joiner
=
StrJoiner
.
of
(
","
);
for
(
Object
o
:
paramsArray
)
{
joiner
.
append
(
o
.
getClass
().
getName
());
if
(
StringUtils
.
isNotNull
(
o
)
&&
!
isFilterObject
(
o
))
{
try
{
Object
jsonObj
=
JSON
.
toJSON
(
o
);
params
+=
jsonObj
.
toString
()
+
" "
;
BeanUtil
.
setFieldValue
(
operLog
,
"operParam"
+
i
,
jsonObj
)
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
i
++;
}
operLog
.
setParamType
(
joiner
.
toString
());
}
return
params
.
trim
();
}
...
...
mes/src/main/java/com/ximai/mes/kanban/service/KanbanAbnormalService.java
View file @
328358c7
...
...
@@ -101,10 +101,7 @@ public class KanbanAbnormalService {
int
expireCt
=
abnormalList
.
stream
().
filter
(
s
->{
if
(
s
.
getAbnormalStatus
().
equals
(
QcAbnormalReportStatusEnum
.
NOT
.
getStatus
())
||
s
.
getAbnormalStatus
().
equals
(
QcAbnormalReportStatusEnum
.
SUBMIT
.
getStatus
())){
Calendar
createTemp
=
Calendar
.
getInstance
();
createTemp
.
setTime
(
s
.
getCreateTime
());
createTemp
.
add
(
Calendar
.
DATE
,
1
);
if
(
createTemp
.
getTime
().
compareTo
(
curr
.
getTime
())<
0
){
if
(
s
.
getCreateTime
().
compareTo
(
curr
.
getTime
())<
0
){
return
true
;
}
}
...
...
@@ -116,4 +113,8 @@ public class KanbanAbnormalService {
return
abnormal1
;
}
public
static
void
main
(
String
[]
args
)
{
Calendar
curr
=
Calendar
.
getInstance
();
System
.
out
.
println
(
DateUtil
.
format
(
Calendar
.
getInstance
().
getTime
(),
"yyyy-MM-dd HH:mm"
));
}
}
mes/src/main/java/com/ximai/mes/kanban/service/KanbanTaskService.java
View file @
328358c7
...
...
@@ -117,7 +117,7 @@ public class KanbanTaskService {
.
add
(
feedbackDto
.
getQuantityQualify
().
add
(
feedbackDto
.
getQuantityUnqualify
())));
}
}
if
(
s
.
getActualEndDate
()!=
null
&&
s
.
getActualEndDate
().
compareTo
(
s
.
getScheduleEndDate
())
>
0
){
if
(
s
.
getActualEndDate
()!=
null
&&
s
.
getActualEndDate
().
compareTo
(
s
.
getScheduleEndDate
())
<
0
){
endOnTimeRatioNumerator
.
set
(
endOnTimeRatioNumerator
.
get
().
add
(
BigDecimal
.
ONE
));
}
if
(
s
.
getScheduleEndDate
().
compareTo
(
curr
.
getTime
())<
0
){
...
...
system/src/main/java/com/ximai/system/domain/SysApiLog.java
View file @
328358c7
package
com
.
ximai
.
system
.
domain
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.ximai.common.annotation.Excel
;
import
com.ximai.common.annotation.Excel.ColumnType
;
import
com.ximai.common.core.domain.BaseEntity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.ximai.common.exception.ServiceException
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/**
* 操作日志记录表 oper_log
*/
@Data
public
class
SysApiLog
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -84,11 +93,22 @@ public class SysApiLog extends BaseEntity {
@Excel
(
name
=
"操作地点"
)
private
String
operLocation
;
@ApiModelProperty
(
value
=
"方法参数1"
)
private
String
operParam1
;
@ApiModelProperty
(
value
=
"方法参数2"
)
private
String
operParam2
;
@ApiModelProperty
(
value
=
"方法参数3"
)
private
String
operParam3
;
@ApiModelProperty
(
value
=
"方法参数4"
)
private
String
operParam4
;
@ApiModelProperty
(
value
=
"方法参数5"
)
private
String
operParam5
;
/**
* 请求参数
*/
@
Excel
(
name
=
"请求参数
"
)
private
String
operParam
;
@
ApiModelProperty
(
value
=
"参数类型
"
)
private
String
paramType
;
/**
* 返回参数
...
...
@@ -115,139 +135,35 @@ public class SysApiLog extends BaseEntity {
@Excel
(
name
=
"操作时间"
,
width
=
30
,
dateFormat
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
operTime
;
public
Long
getOperId
()
{
return
operId
;
}
public
void
setOperId
(
Long
operId
)
{
this
.
operId
=
operId
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
Integer
getBusinessType
()
{
return
businessType
;
}
public
void
setBusinessType
(
Integer
businessType
)
{
this
.
businessType
=
businessType
;
}
public
Integer
[]
getBusinessTypes
()
{
return
businessTypes
;
}
public
void
setBusinessTypes
(
Integer
[]
businessTypes
)
{
this
.
businessTypes
=
businessTypes
;
}
public
String
getMethod
()
{
return
method
;
}
public
void
setMethod
(
String
method
)
{
this
.
method
=
method
;
}
public
String
getRequestMethod
()
{
return
requestMethod
;
}
public
void
setRequestMethod
(
String
requestMethod
)
{
this
.
requestMethod
=
requestMethod
;
}
public
Integer
getOperatorType
()
{
return
operatorType
;
}
public
void
setOperatorType
(
Integer
operatorType
)
{
this
.
operatorType
=
operatorType
;
}
public
String
getOperName
()
{
return
operName
;
}
public
void
setOperName
(
String
operName
)
{
this
.
operName
=
operName
;
}
public
String
getDeptName
()
{
return
deptName
;
}
public
void
setDeptName
(
String
deptName
)
{
this
.
deptName
=
deptName
;
}
public
String
getOperUrl
()
{
return
operUrl
;
}
public
void
setOperUrl
(
String
operUrl
)
{
this
.
operUrl
=
operUrl
;
}
public
String
getOperIp
()
{
return
operIp
;
}
public
void
setOperIp
(
String
operIp
)
{
this
.
operIp
=
operIp
;
}
public
String
getOperLocation
()
{
return
operLocation
;
}
public
void
setOperLocation
(
String
operLocation
)
{
this
.
operLocation
=
operLocation
;
}
public
String
getOperParam
()
{
return
operParam
;
}
public
void
setOperParam
(
String
operParam
)
{
this
.
operParam
=
operParam
;
}
public
String
getJsonResult
()
{
return
jsonResult
;
}
public
void
setJsonResult
(
String
jsonResult
)
{
this
.
jsonResult
=
jsonResult
;
}
public
Integer
getStatus
()
{
return
status
;
}
public
void
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
}
public
String
getErrorMsg
()
{
return
errorMsg
;
}
public
void
setErrorMsg
(
String
errorMsg
)
{
this
.
errorMsg
=
errorMsg
;
}
public
Date
getOperTime
()
{
return
operTime
;
}
public
void
setOperTime
(
Date
operTime
)
{
this
.
operTime
=
operTime
;
public
Object
[]
parseParamObject
()
throws
ClassNotFoundException
{
List
<
String
>
params
=
new
ArrayList
<
String
>();
if
(
StringUtils
.
isNotEmpty
(
this
.
getOperParam1
())){
params
.
add
(
this
.
getOperParam1
());
}
if
(
StringUtils
.
isNotEmpty
(
this
.
getOperParam2
())){
params
.
add
(
this
.
getOperParam2
());
}
if
(
StringUtils
.
isNotEmpty
(
this
.
getOperParam3
())){
params
.
add
(
this
.
getOperParam3
());
}
if
(
StringUtils
.
isNotEmpty
(
this
.
getOperParam4
())){
params
.
add
(
this
.
getOperParam4
());
}
if
(
StringUtils
.
isNotEmpty
(
this
.
getOperParam5
())){
params
.
add
(
this
.
getOperParam5
());
}
String
[]
paramTypeArr
=
this
.
getParamType
().
split
(
","
);
List
<
Object
>
paramsObj
=
new
ArrayList
<>();
int
i
=
0
;
if
(
paramTypeArr
.
length
!=
params
.
size
()){
throw
new
ServiceException
(
"参数不致,检查方法是否发生变化"
);
}
for
(
String
param
:
params
)
{
Class
clz
=
Class
.
forName
(
paramTypeArr
[
i
]);
Object
obj1
=
JSONUtil
.
toBean
(
param
,
clz
);
paramsObj
.
add
(
obj1
);
i
++;
}
return
paramsObj
.
toArray
();
}
}
system/src/main/java/com/ximai/system/service/ISysApiLogService.java
View file @
328358c7
...
...
@@ -43,4 +43,11 @@ public interface ISysApiLogService {
* 清空操作日志
*/
void
cleanApiLog
();
/**
* 执行日志记录相关操作
* @param logIds
* @throws Exception
*/
void
executeByIds
(
Long
[]
logIds
)
throws
Exception
;
}
system/src/main/java/com/ximai/system/service/impl/SysApiLogServiceImpl.java
View file @
328358c7
...
...
@@ -3,18 +3,24 @@ package com.ximai.system.service.impl;
import
com.ximai.system.domain.SysApiLog
;
import
com.ximai.system.mapper.SysApiLogMapper
;
import
com.ximai.system.service.ISysApiLogService
;
import
org.apache.commons.beanutils.MethodUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.stereotype.Service
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.Date
;
import
java.util.List
;
/**
*
操作
日志 服务层处理
*
接口
日志 服务层处理
*/
@Service
public
class
SysApiLogServiceImpl
implements
ISysApiLogService
{
@Autowired
private
SysApiLogMapper
operApiMapper
;
@Autowired
private
ApplicationContext
applicationContext
;
/**
* 新增操作日志
...
...
@@ -23,6 +29,7 @@ public class SysApiLogServiceImpl implements ISysApiLogService {
*/
@Override
public
void
insertApiLog
(
SysApiLog
operLog
)
{
operLog
.
setCreateTime
(
new
Date
());
operApiMapper
.
insertApiLog
(
operLog
);
}
...
...
@@ -66,4 +73,19 @@ public class SysApiLogServiceImpl implements ISysApiLogService {
public
void
cleanApiLog
()
{
operApiMapper
.
cleanApiLog
();
}
@Override
public
void
executeByIds
(
Long
[]
logIds
)
throws
Exception
{
for
(
Long
logid
:
logIds
){
SysApiLog
log
=
this
.
selectApiLogById
(
logid
);
String
clzStr
=
log
.
getMethod
();
String
clz
=
clzStr
.
substring
(
0
,
clzStr
.
lastIndexOf
(
"."
));
String
methodStr
=
clzStr
.
substring
(
clzStr
.
lastIndexOf
(
"."
)+
1
);
Object
obj
=
applicationContext
.
getBean
(
Class
.
forName
(
clz
));
//参数转换
Object
[]
params
=
log
.
parseParamObject
();
MethodUtils
.
invokeMethod
(
obj
,
methodStr
.
replace
(
"()"
,
""
),
params
);
}
}
}
system/src/main/resources/mapper/system/SysApiLogMapper.xml
View file @
328358c7
...
...
@@ -16,7 +16,12 @@
<result
property=
"operUrl"
column=
"oper_url"
/>
<result
property=
"operIp"
column=
"oper_ip"
/>
<result
property=
"operLocation"
column=
"oper_location"
/>
<result
property=
"operParam"
column=
"oper_param"
/>
<result
property=
"operParam1"
column=
"oper_param1"
/>
<result
property=
"operParam2"
column=
"oper_param2"
/>
<result
property=
"operParam3"
column=
"oper_param3"
/>
<result
property=
"operParam4"
column=
"oper_param4"
/>
<result
property=
"operParam5"
column=
"oper_param5"
/>
<result
property=
"paramType"
column=
"param_type"
/>
<result
property=
"jsonResult"
column=
"json_result"
/>
<result
property=
"status"
column=
"status"
/>
<result
property=
"errorMsg"
column=
"error_msg"
/>
...
...
@@ -35,7 +40,12 @@
oper_url,
oper_ip,
oper_location,
oper_param,
oper_param1,
oper_param2,
oper_param3,
oper_param4,
oper_param5,
param_type,
json_result,
status,
error_msg,
...
...
@@ -45,9 +55,9 @@
<insert
id=
"insertApiLog"
parameterType=
"SysApiLog"
>
insert into sys_api_log(title, business_type, method, request_method, operator_type, oper_name, dept_name,
oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time)
oper_url, oper_ip, oper_location, oper_param
1, oper_param2, oper_param3, oper_param4, oper_param5, param_type
, json_result, status, error_msg, oper_time)
values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName},
#{operUrl}, #{operIp}, #{operLocation}, #{operParam
}, #{jsonResult}, #{status}, #{errorMsg}, sysdate()
)
#{operUrl}, #{operIp}, #{operLocation}, #{operParam
1}, #{operParam2}, #{operParam3}, #{operParam4}, #{operParam5}, #{paramType}, #{jsonResult}, #{status}, #{errorMsg}, #{createTime}
)
</insert>
<select
id=
"selectApiLogList"
parameterType=
"SysApiLog"
resultMap=
"SysApiLogResult"
>
...
...
system/src/main/resources/mapper/system/SysMenuMapper.xml
View file @
328358c7
...
...
@@ -236,6 +236,8 @@
<if
test=
"menuId != null and menuId != 0"
>
#{menuId},
</if>
<if
test=
"parentId != null and parentId != 0"
>
#{parentId},
</if>
<if
test=
"menuName != null and menuName != ''"
>
#{menuName},
</if>
<if
test=
"menuNameEn != null and menuNameEn != ''"
>
#{menuNameEn},
</if>
<if
test=
"menuNameTh != null and menuNameTh != ''"
>
#{menuNameTh},
</if>
<if
test=
"orderNum != null and orderNum != ''"
>
#{orderNum},
</if>
<if
test=
"path != null and path != ''"
>
#{path},
</if>
<if
test=
"component != null and component != ''"
>
#{component},
</if>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment