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
e13b0e06
Commit
e13b0e06
authored
Oct 09, 2025
by
wujipeng
Browse files
Merge branch 'sxx' of
https://gitlab.ruzhoukj.com/wujipeng/ops
into sxx
parents
d6996e16
bf9a50ed
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/ruzhoukj/sms/controller/ReportDataInfoController.java
View file @
e13b0e06
...
...
@@ -70,6 +70,11 @@ public class ReportDataInfoController extends BaseController {
return
toAjax
(
reportDataInfoService
.
submit
(
id
));
}
@GetMapping
(
"/submitTest"
)
public
Result
submitTest
(){
return
toAjax
(
reportDataInfoService
.
submitTest
());
}
@PutMapping
(
"/rollback/{id}"
)
public
Result
rollback
(
@PathVariable
String
id
)
{
return
toAjax
(
reportDataInfoService
.
rollback
(
id
));
...
...
src/main/java/com/ruzhoukj/sms/service/ReportDataInfoService.java
View file @
e13b0e06
...
...
@@ -37,4 +37,6 @@ public interface ReportDataInfoService extends IService<ReportDataInfoEntity> {
* @return
*/
boolean
rollback
(
String
id
);
boolean
submitTest
();
}
src/main/java/com/ruzhoukj/sms/service/impl/ReportDataInfoServiceImpl.java
View file @
e13b0e06
package
com.ruzhoukj.sms.service.impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.platform.exception.BusinessException
;
import
com.platform.utils.StringUtils
;
...
...
@@ -59,7 +61,7 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
//查看已填写完成,未计算的绩效
String
content
=
reportDataInfoEntity
.
getAllContent
();
// 解析JSON字符串为JSONArray
JSONArray
jsonArray
=
JSON
Array
.
parseArray
(
content
);
JSONArray
jsonArray
=
JSON
.
parseArray
(
content
);
// 获取第一个元素(假设第一个元素是Sheet1的数据)
if
(!
jsonArray
.
isEmpty
())
{
JSONObject
jsonObject
=
jsonArray
.
getJSONObject
(
0
);
...
...
@@ -75,15 +77,23 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
if
(
StringUtils
.
isNotEmpty
(
totalStr
)
&&
totalStr
.
contains
(
"合计:"
))
{
//普通员工绩效
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
);
if
(
StringUtils
.
isNotNull
(
score
)
&&
score
.
getString
(
"v"
)
!=
null
)
{
totalScore
=
score
.
getString
(
"v"
);
}
else
{
//财务绩效
score
=
row
.
getJSONObject
(
4
);
totalScore
=
score
.
getString
(
"v"
);
}
}
//财务绩效
if
(
StringUtils
.
isNull
(
score
))
{
s
core
=
row
.
getJSONObject
(
4
);
if
(
StringUtils
.
isEmpty
(
totalScore
))
{
JSONObject
scoreSj
=
row
.
getJSONObject
(
10
);
totalS
core
=
scoreSj
.
getString
(
"m"
);
}
totalScore
=
score
.
getString
(
"v"
);
if
(
StringUtils
.
isEmpty
(
totalScore
))
{
JSONObject
scoreSj
=
row
.
getJSONObject
(
9
);
totalScore
=
scoreSj
.
getString
(
"m"
);
...
...
@@ -111,6 +121,50 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
}
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
());
userPerformanceService
.
save
(
userPerformanceEntity
);
reportDataInfoEntity
.
setStatus
(
"4"
);
}
}
else
{
System
.
out
.
println
(
"No data available in the JSON array."
);
}
}
else
{
reportDataInfoEntity
.
setStatus
(
"3"
);
}
...
...
@@ -192,4 +246,129 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
}
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"
);
}
}
}
src/main/resources/com/ruzhoukj/sms/dao/UserPerformanceDao.xml
View file @
e13b0e06
...
...
@@ -34,5 +34,6 @@
and up.performance_date = #{performanceDate}
</if>
</where>
order by up.performance_date desc
</select>
</mapper>
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