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
580a8793
Commit
580a8793
authored
Aug 11, 2025
by
zhuxiang
Browse files
绩效提交优化
parent
afada94c
Changes
3
Show whitespace changes
Inline
Side-by-side
src/main/java/com/ruzhoukj/sms/controller/ReportDataInfoController.java
View file @
580a8793
...
@@ -70,6 +70,11 @@ public class ReportDataInfoController extends BaseController {
...
@@ -70,6 +70,11 @@ public class ReportDataInfoController extends BaseController {
return
toAjax
(
reportDataInfoService
.
submit
(
id
));
return
toAjax
(
reportDataInfoService
.
submit
(
id
));
}
}
@GetMapping
(
"/submitTest"
)
public
Result
submitTest
(){
return
toAjax
(
reportDataInfoService
.
submitTest
());
}
@PutMapping
(
"/rollback/{id}"
)
@PutMapping
(
"/rollback/{id}"
)
public
Result
rollback
(
@PathVariable
String
id
)
{
public
Result
rollback
(
@PathVariable
String
id
)
{
return
toAjax
(
reportDataInfoService
.
rollback
(
id
));
return
toAjax
(
reportDataInfoService
.
rollback
(
id
));
...
...
src/main/java/com/ruzhoukj/sms/service/ReportDataInfoService.java
View file @
580a8793
...
@@ -37,4 +37,6 @@ public interface ReportDataInfoService extends IService<ReportDataInfoEntity> {
...
@@ -37,4 +37,6 @@ public interface ReportDataInfoService extends IService<ReportDataInfoEntity> {
* @return
* @return
*/
*/
boolean
rollback
(
String
id
);
boolean
rollback
(
String
id
);
boolean
submitTest
();
}
}
src/main/java/com/ruzhoukj/sms/service/impl/ReportDataInfoServiceImpl.java
View file @
580a8793
package
com.ruzhoukj.sms.service.impl
;
package
com.ruzhoukj.sms.service.impl
;
import
com.alibaba.fastjson.JSON
;
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.exception.BusinessException
;
import
com.platform.exception.BusinessException
;
import
com.platform.utils.StringUtils
;
import
com.platform.utils.StringUtils
;
...
@@ -59,7 +61,7 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
...
@@ -59,7 +61,7 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
//查看已填写完成,未计算的绩效
//查看已填写完成,未计算的绩效
String
content
=
reportDataInfoEntity
.
getAllContent
();
String
content
=
reportDataInfoEntity
.
getAllContent
();
// 解析JSON字符串为JSONArray
// 解析JSON字符串为JSONArray
JSONArray
jsonArray
=
JSON
Array
.
parseArray
(
content
);
JSONArray
jsonArray
=
JSON
.
parseArray
(
content
);
// 获取第一个元素(假设第一个元素是Sheet1的数据)
// 获取第一个元素(假设第一个元素是Sheet1的数据)
if
(!
jsonArray
.
isEmpty
())
{
if
(!
jsonArray
.
isEmpty
())
{
JSONObject
jsonObject
=
jsonArray
.
getJSONObject
(
0
);
JSONObject
jsonObject
=
jsonArray
.
getJSONObject
(
0
);
...
@@ -75,15 +77,23 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
...
@@ -75,15 +77,23 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
if
(
StringUtils
.
isNotEmpty
(
totalStr
)
&&
totalStr
.
contains
(
"合计:"
))
{
if
(
StringUtils
.
isNotEmpty
(
totalStr
)
&&
totalStr
.
contains
(
"合计:"
))
{
//普通员工绩效
//普通员工绩效
JSONObject
score
=
row
.
getJSONObject
(
11
);
JSONObject
score
=
row
.
getJSONObject
(
11
);
if
(
StringUtils
.
isNull
(
score
))
{
if
(
StringUtils
.
isNotNull
(
score
)
&&
score
.
getString
(
"v"
)
!=
null
)
{
totalScore
=
score
.
getString
(
"v"
);
}
else
{
//部门管理员绩效
//部门管理员绩效
score
=
row
.
getJSONObject
(
10
);
score
=
row
.
getJSONObject
(
10
);
}
if
(
StringUtils
.
isNotNull
(
score
)
&&
score
.
getString
(
"v"
)
!=
null
)
{
totalScore
=
score
.
getString
(
"v"
);
}
else
{
//财务绩效
//财务绩效
if
(
StringUtils
.
isNull
(
score
))
{
score
=
row
.
getJSONObject
(
4
);
score
=
row
.
getJSONObject
(
4
);
}
totalScore
=
score
.
getString
(
"v"
);
totalScore
=
score
.
getString
(
"v"
);
}
}
if
(
StringUtils
.
isEmpty
(
totalScore
))
{
JSONObject
scoreSj
=
row
.
getJSONObject
(
10
);
totalScore
=
scoreSj
.
getString
(
"m"
);
}
if
(
StringUtils
.
isEmpty
(
totalScore
))
{
if
(
StringUtils
.
isEmpty
(
totalScore
))
{
JSONObject
scoreSj
=
row
.
getJSONObject
(
9
);
JSONObject
scoreSj
=
row
.
getJSONObject
(
9
);
totalScore
=
scoreSj
.
getString
(
"m"
);
totalScore
=
scoreSj
.
getString
(
"m"
);
...
@@ -111,6 +121,50 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
...
@@ -111,6 +121,50 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
}
else
{
}
else
{
System
.
out
.
println
(
"No data available in the JSON array."
);
System
.
out
.
println
(
"No data available in the JSON array."
);
}
}
}
else
if
(
reportTemplateEntity
.
getType
().
equals
(
"试用期考核"
))
{
//查看已填写完成,未计算的绩效
String
content
=
reportDataInfoEntity
.
getAllContent
();
// 解析JSON字符串为JSONArray
JSONArray
jsonArray
=
JSON
.
parseArray
(
content
);
// 获取第一个元素(假设第一个元素是Sheet1的数据)
if
(!
jsonArray
.
isEmpty
())
{
JSONObject
jsonObject
=
jsonArray
.
getJSONObject
(
0
);
// 获取Sheet1中的data数组
JSONArray
data
=
jsonObject
.
getJSONArray
(
"data"
);
String
totalScore
=
"0"
;
// 遍历data数组,从第6行开始
for
(
int
i
=
12
;
i
<
data
.
size
();
i
++)
{
JSONArray
row
=
data
.
getJSONArray
(
i
);
JSONObject
total
=
row
.
getJSONObject
(
0
);
if
(
StringUtils
.
isNotEmpty
(
total
))
{
String
totalStr
=
total
.
getString
(
"v"
);
if
(
StringUtils
.
isNotEmpty
(
totalStr
)
&&
totalStr
.
contains
(
"总分"
))
{
//普通员工绩效
JSONObject
score
=
row
.
getJSONObject
(
6
);
totalScore
=
score
.
getString
(
"v"
);
break
;
}
}
}
if
(!
totalScore
.
equals
(
"0"
))
{
// 将字符串转换为数值
double
value
=
Double
.
parseDouble
(
totalScore
);
// 使用 DecimalFormat 保留两位小数
DecimalFormat
df
=
new
DecimalFormat
(
"#.##"
);
String
formattedValue
=
df
.
format
(
value
);
//更新用户绩效分
UserPerformanceEntity
userPerformanceEntity
=
new
UserPerformanceEntity
();
userPerformanceEntity
.
setUserId
(
reportDataInfoEntity
.
getUserId
());
userPerformanceEntity
.
setPerformanceDate
(
reportDataInfoEntity
.
getYear
(),
reportDataInfoEntity
.
getMonth
());
userPerformanceEntity
.
setPerformanceScore
(
formattedValue
);
userPerformanceEntity
.
setDeptId
(
reportDataInfoEntity
.
getDeptId
());
userPerformanceEntity
.
setReportDataId
(
reportDataInfoEntity
.
getId
());
userPerformanceService
.
save
(
userPerformanceEntity
);
reportDataInfoEntity
.
setStatus
(
"4"
);
}
}
else
{
System
.
out
.
println
(
"No data available in the JSON array."
);
}
}
else
{
}
else
{
reportDataInfoEntity
.
setStatus
(
"3"
);
reportDataInfoEntity
.
setStatus
(
"3"
);
}
}
...
@@ -192,4 +246,129 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
...
@@ -192,4 +246,129 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
}
}
return
updateById
(
reportDataInfoEntity
);
return
updateById
(
reportDataInfoEntity
);
}
}
@Override
public
boolean
submitTest
()
{
//查看待处理的绩效
List
<
ReportDataInfoEntity
>
reportDataInfoEntityList
=
baseMapper
.
selectList
(
new
LambdaQueryWrapper
<
ReportDataInfoEntity
>()
.
eq
(
ReportDataInfoEntity:
:
getStatus
,
1
));
reportDataInfoEntityList
.
forEach
(
this
::
countPerformanceTest
);
return
true
;
}
public
void
countPerformanceTest
(
ReportDataInfoEntity
reportDataInfoEntity
)
{
System
.
out
.
println
(
"绩效数据id"
+
reportDataInfoEntity
.
getId
());
//查看模板信息
ReportTemplateEntity
reportTemplateEntity
=
reportTemplateService
.
getById
(
reportDataInfoEntity
.
getTemplateId
());
if
(
reportTemplateEntity
!=
null
&&
reportTemplateEntity
.
getType
().
equals
(
"绩效"
))
{
//查看已填写完成,未计算的绩效
String
content
=
reportDataInfoEntity
.
getAllContent
();
// 解析JSON字符串为JSONArray
JSONArray
jsonArray
=
JSON
.
parseArray
(
content
);
// 获取第一个元素(假设第一个元素是Sheet1的数据)
if
(!
jsonArray
.
isEmpty
())
{
JSONObject
jsonObject
=
jsonArray
.
getJSONObject
(
0
);
// 获取Sheet1中的data数组
JSONArray
data
=
jsonObject
.
getJSONArray
(
"data"
);
String
totalScore
=
"0"
;
// 遍历data数组,从第6行开始
for
(
int
i
=
5
;
i
<
data
.
size
();
i
++)
{
JSONArray
row
=
data
.
getJSONArray
(
i
);
JSONObject
total
=
row
.
getJSONObject
(
0
);
if
(
StringUtils
.
isNotEmpty
(
total
))
{
String
totalStr
=
total
.
getString
(
"v"
);
if
(
StringUtils
.
isNotEmpty
(
totalStr
)
&&
totalStr
.
contains
(
"合计:"
))
{
//普通员工绩效
JSONObject
score
=
row
.
getJSONObject
(
11
);
if
(
StringUtils
.
isNotNull
(
score
)
&&
score
.
getString
(
"v"
)
!=
null
)
{
totalScore
=
score
.
getString
(
"v"
);
}
else
{
//部门管理员绩效
score
=
row
.
getJSONObject
(
10
);
if
(
StringUtils
.
isNotNull
(
score
)
&&
score
.
getString
(
"v"
)
!=
null
)
{
totalScore
=
score
.
getString
(
"v"
);
}
else
{
//财务绩效
score
=
row
.
getJSONObject
(
4
);
totalScore
=
score
.
getString
(
"v"
);
}
}
if
(
StringUtils
.
isEmpty
(
totalScore
))
{
JSONObject
scoreSj
=
row
.
getJSONObject
(
10
);
totalScore
=
scoreSj
.
getString
(
"m"
);
}
if
(
StringUtils
.
isEmpty
(
totalScore
))
{
JSONObject
scoreSj
=
row
.
getJSONObject
(
9
);
totalScore
=
scoreSj
.
getString
(
"m"
);
}
break
;
}
}
}
System
.
out
.
println
(
"分数"
+
totalScore
);
if
(!
totalScore
.
equals
(
"0"
))
{
// 将字符串转换为数值
double
value
=
Double
.
parseDouble
(
totalScore
);
// 使用 DecimalFormat 保留两位小数
DecimalFormat
df
=
new
DecimalFormat
(
"#.##"
);
String
formattedValue
=
df
.
format
(
value
);
//更新用户绩效分
UserPerformanceEntity
userPerformanceEntity
=
new
UserPerformanceEntity
();
userPerformanceEntity
.
setUserId
(
reportDataInfoEntity
.
getUserId
());
userPerformanceEntity
.
setPerformanceDate
(
reportDataInfoEntity
.
getYear
(),
reportDataInfoEntity
.
getMonth
());
userPerformanceEntity
.
setPerformanceScore
(
formattedValue
);
userPerformanceEntity
.
setDeptId
(
reportDataInfoEntity
.
getDeptId
());
userPerformanceEntity
.
setReportDataId
(
reportDataInfoEntity
.
getId
());
reportDataInfoEntity
.
setStatus
(
"4"
);
}
}
else
{
System
.
out
.
println
(
"No data available in the JSON array."
);
}
}
else
if
(
reportTemplateEntity
.
getType
().
equals
(
"试用期考核"
))
{
//查看已填写完成,未计算的绩效
String
content
=
reportDataInfoEntity
.
getAllContent
();
// 解析JSON字符串为JSONArray
JSONArray
jsonArray
=
JSON
.
parseArray
(
content
);
// 获取第一个元素(假设第一个元素是Sheet1的数据)
if
(!
jsonArray
.
isEmpty
())
{
JSONObject
jsonObject
=
jsonArray
.
getJSONObject
(
0
);
// 获取Sheet1中的data数组
JSONArray
data
=
jsonObject
.
getJSONArray
(
"data"
);
String
totalScore
=
"0"
;
// 遍历data数组,从第6行开始
for
(
int
i
=
12
;
i
<
data
.
size
();
i
++)
{
JSONArray
row
=
data
.
getJSONArray
(
i
);
JSONObject
total
=
row
.
getJSONObject
(
0
);
if
(
StringUtils
.
isNotEmpty
(
total
))
{
String
totalStr
=
total
.
getString
(
"v"
);
if
(
StringUtils
.
isNotEmpty
(
totalStr
)
&&
totalStr
.
contains
(
"总分"
))
{
//普通员工绩效
JSONObject
score
=
row
.
getJSONObject
(
6
);
totalScore
=
score
.
getString
(
"v"
);
break
;
}
}
}
if
(!
totalScore
.
equals
(
"0"
))
{
// 将字符串转换为数值
double
value
=
Double
.
parseDouble
(
totalScore
);
// 使用 DecimalFormat 保留两位小数
DecimalFormat
df
=
new
DecimalFormat
(
"#.##"
);
String
formattedValue
=
df
.
format
(
value
);
//更新用户绩效分
UserPerformanceEntity
userPerformanceEntity
=
new
UserPerformanceEntity
();
userPerformanceEntity
.
setUserId
(
reportDataInfoEntity
.
getUserId
());
userPerformanceEntity
.
setPerformanceDate
(
reportDataInfoEntity
.
getYear
(),
reportDataInfoEntity
.
getMonth
());
userPerformanceEntity
.
setPerformanceScore
(
formattedValue
);
userPerformanceEntity
.
setDeptId
(
reportDataInfoEntity
.
getDeptId
());
userPerformanceEntity
.
setReportDataId
(
reportDataInfoEntity
.
getId
());
reportDataInfoEntity
.
setStatus
(
"4"
);
}
}
else
{
System
.
out
.
println
(
"No data available in the JSON array."
);
}
}
else
{
reportDataInfoEntity
.
setStatus
(
"3"
);
}
}
}
}
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