Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
ops
Commits
84f466dc
"...service/git@gitlab.ruzhoukj.com:wujipeng/relation.git" did not exist on "46fcc05a15514afd088686f655a2b557358433b5"
Commit
84f466dc
authored
Mar 07, 2025
by
zhuxiang
Browse files
优化
parent
263d9ef7
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/ruzhoukj/sms/controller/ReportDataInfoController.java
View file @
84f466dc
...
@@ -65,9 +65,4 @@ public class ReportDataInfoController extends BaseController {
...
@@ -65,9 +65,4 @@ public class ReportDataInfoController extends BaseController {
return
toAjax
(
reportDataInfoService
.
removeById
(
id
));
return
toAjax
(
reportDataInfoService
.
removeById
(
id
));
}
}
@GetMapping
(
"/test"
)
public
void
test
()
{
reportDataInfoService
.
countPerformance
();
}
}
}
src/main/java/com/ruzhoukj/sms/entity/ReportDataInfoEntity.java
View file @
84f466dc
...
@@ -46,5 +46,5 @@ public class ReportDataInfoEntity {
...
@@ -46,5 +46,5 @@ public class ReportDataInfoEntity {
private
String
deptId
;
private
String
deptId
;
@TableField
(
"status"
)
@TableField
(
"status"
)
private
String
status
;
private
String
status
=
"1"
;
}
}
src/main/java/com/ruzhoukj/sms/service/ReportDataInfoService.java
View file @
84f466dc
...
@@ -18,7 +18,7 @@ import java.util.List;
...
@@ -18,7 +18,7 @@ import java.util.List;
public
interface
ReportDataInfoService
extends
IService
<
ReportDataInfoEntity
>
{
public
interface
ReportDataInfoService
extends
IService
<
ReportDataInfoEntity
>
{
List
<
ReportDataInfoVO
>
queryList
(
ReportDataInfoDTO
reportDataInfoDTO
);
List
<
ReportDataInfoVO
>
queryList
(
ReportDataInfoDTO
reportDataInfoDTO
);
void
countPerformance
();
void
countPerformance
(
String
reportDataInfoId
);
boolean
saveOrUpdateReportData
(
ReportDataInfoDTO
reportDataInfoDTO
);
boolean
saveOrUpdateReportData
(
ReportDataInfoDTO
reportDataInfoDTO
);
}
}
src/main/java/com/ruzhoukj/sms/service/impl/ReportDataInfoServiceImpl.java
View file @
84f466dc
...
@@ -2,7 +2,6 @@ package com.ruzhoukj.sms.service.impl;
...
@@ -2,7 +2,6 @@ package com.ruzhoukj.sms.service.impl;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.platform.utils.StringUtils
;
import
com.platform.utils.StringUtils
;
import
com.ruzhoukj.sms.dao.ReportDataInfoDao
;
import
com.ruzhoukj.sms.dao.ReportDataInfoDao
;
...
@@ -41,47 +40,48 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
...
@@ -41,47 +40,48 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
}
}
@Override
@Override
public
void
countPerformance
()
{
public
void
countPerformance
(
String
reportDataInfoId
)
{
//查看已填写完成,未计算的绩效
//查看已填写完成,未计算的绩效
List
<
ReportDataInfoEntity
>
reportDataInfoEntity
List
=
baseMapper
.
selectList
(
new
LambdaQueryWrapper
<
R
eportDataInfo
Entity
>()
ReportDataInfoEntity
reportDataInfoEntity
=
getById
(
r
eportDataInfo
Id
);
.
eq
(
R
eportDataInfoEntity
:
:
get
Status
,
3
)
);
String
content
=
r
eportDataInfoEntity
.
get
AllContent
(
);
reportDataInfoEntityList
.
forEach
(
reportDataInfoEntity
->
{
// 解析JSON字符串为JSONArray
String
content
=
reportDataInfoEntity
.
getAllC
ontent
(
);
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
c
ontent
);
// 解析JSON字符串为JSONArray
// 获取第一个元素(假设第一个元素是Sheet1的数据)
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
content
);
if
(
jsonArray
.
size
()
>
0
)
{
// 获取第一个元素(假设第一个元素是Sheet1的数据)
JSONObject
jsonObject
=
jsonArray
.
getJSONObject
(
0
);
if
(
jsonArray
.
size
()
>
0
)
{
// 获取Sheet1中的data数组
JSONObject
jsonObject
=
jsonArray
.
getJSONObject
(
0
);
JSONArray
data
=
jsonObject
.
getJSONArray
(
"data"
);
// 获取Sheet1中的data数组
String
totalScore
=
"0"
;
JSONArray
data
=
jsonObject
.
getJSONArray
(
"data"
);
// 遍历data数组,从第6行开始
String
totalScore
=
"0"
;
for
(
int
i
=
5
;
i
<
data
.
size
();
i
++)
{
// 遍历data数组,从第6行开始
JSONArray
row
=
data
.
getJSONArray
(
i
);
for
(
int
i
=
5
;
i
<
data
.
size
();
i
++)
{
JSONObject
total
=
row
.
getJSONObject
(
0
);
JSONArray
row
=
da
ta
.
get
JSONArray
(
i
);
String
totalStr
=
to
ta
l
.
get
String
(
"v"
);
JSONObject
total
=
row
.
getJSONObject
(
0
);
if
(
StringUtils
.
isNotEmpty
(
totalStr
)
&&
totalStr
.
contains
(
"合计:"
))
{
String
totalStr
=
total
.
getString
(
"v"
);
JSONObject
score
=
row
.
getJSONObject
(
11
);
if
(
StringUtils
.
isNotEmpty
(
totalStr
)
&&
totalStr
.
conta
in
s
(
"
合计:"
))
{
totalScore
=
score
.
getStr
in
g
(
"
v"
);
JSONObject
score
=
row
.
getJSONObject
(
11
);
if
(
StringUtils
.
isEmpty
(
totalScore
))
{
totalS
core
=
score
.
getString
(
"v"
);
JSONObject
s
core
Sj
=
row
.
getJSONObject
(
9
);
break
;
totalScore
=
scoreSj
.
getString
(
"m"
)
;
}
}
break
;
}
}
if
(!
totalScore
.
equals
(
"0"
))
{
//更新用户绩效分
UserPerformanceEntity
userPerformanceEntity
=
new
UserPerformanceEntity
();
userPerformanceEntity
.
setUserId
(
reportDataInfoEntity
.
getUserId
());
userPerformanceEntity
.
setPerformanceDate
(
reportDataInfoEntity
.
getYear
(),
reportDataInfoEntity
.
getMonth
());
userPerformanceEntity
.
setPerformanceScore
(
totalScore
);
userPerformanceEntity
.
setDeptId
(
reportDataInfoEntity
.
getDeptId
());
userPerformanceEntity
.
setReportDataId
(
reportDataInfoEntity
.
getId
());
userPerformanceService
.
save
(
userPerformanceEntity
);
reportDataInfoEntity
.
setStatus
(
"4"
);
reportDataInfoEntity
.
setId
(
reportDataInfoEntity
.
getId
());
}
}
else
{
System
.
out
.
println
(
"No data available in the JSON array."
);
}
}
});
if
(!
totalScore
.
equals
(
"0"
))
{
//更新用户绩效分
UserPerformanceEntity
userPerformanceEntity
=
new
UserPerformanceEntity
();
userPerformanceEntity
.
setUserId
(
reportDataInfoEntity
.
getUserId
());
userPerformanceEntity
.
setPerformanceDate
(
reportDataInfoEntity
.
getYear
(),
reportDataInfoEntity
.
getMonth
());
userPerformanceEntity
.
setPerformanceScore
(
totalScore
);
userPerformanceEntity
.
setDeptId
(
reportDataInfoEntity
.
getDeptId
());
userPerformanceEntity
.
setReportDataId
(
reportDataInfoEntity
.
getId
());
userPerformanceService
.
save
(
userPerformanceEntity
);
reportDataInfoEntity
.
setStatus
(
"4"
);
reportDataInfoEntity
.
setId
(
reportDataInfoEntity
.
getId
());
}
}
else
{
System
.
out
.
println
(
"No data available in the JSON array."
);
}
}
}
/**
/**
...
@@ -99,10 +99,21 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
...
@@ -99,10 +99,21 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
@Override
@Override
public
boolean
saveOrUpdateReportData
(
ReportDataInfoDTO
reportDataInfoDTO
)
{
public
boolean
saveOrUpdateReportData
(
ReportDataInfoDTO
reportDataInfoDTO
)
{
//查看当前用户所属部门
UserEntity
user
=
userService
.
getById
(
reportDataInfoDTO
.
getLoginUserId
());
if
(
StringUtils
.
isNotEmpty
(
reportDataInfoDTO
.
getId
()))
{
reportDataInfoDTO
.
setDeptId
(
user
.
getDeptId
());
//是编辑
reportDataInfoDTO
.
setUserId
(
user
.
getId
());
updateById
(
reportDataInfoDTO
);
return
saveOrUpdate
(
reportDataInfoDTO
);
}
else
{
//查看当前用户所属部门
UserEntity
user
=
userService
.
getById
(
reportDataInfoDTO
.
getUserId
());
reportDataInfoDTO
.
setDeptId
(
user
.
getDeptId
());
reportDataInfoDTO
.
setUserId
(
user
.
getId
());
save
(
reportDataInfoDTO
);
}
//处理绩效提交
if
(
StringUtils
.
isNotEmpty
(
reportDataInfoDTO
.
getId
())
&&
reportDataInfoDTO
.
getStatus
().
equals
(
"3"
))
{
countPerformance
(
reportDataInfoDTO
.
getId
());
}
return
Boolean
.
TRUE
;
}
}
}
}
src/main/java/com/ruzhoukj/sms/task/PerformanceTask.java
deleted
100644 → 0
View file @
263d9ef7
package
com.ruzhoukj.sms.task
;
import
com.ruzhoukj.sms.service.ReportDataInfoService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
@Component
@Slf4j
public
class
PerformanceTask
{
@Resource
private
ReportDataInfoService
reportDataInfoService
;
//每天八点查询一次绩效
@Scheduled
(
cron
=
"0 0 20 * * ?"
)
private
void
performanceTask
()
{
reportDataInfoService
.
countPerformance
();
}
}
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