Commit 1cdf589a authored by zhuxiang's avatar zhuxiang
Browse files

联调优化

parent d1690f64
......@@ -33,6 +33,9 @@ public class UserPerformanceEntity {
@TableField("dept_id")
private String deptId;
@TableField("report_data_id")
private String reportDataId;
public void setPerformanceDate(int year, int month) {
if (month < 10) {
this.performanceDate = year + "-0" + month;
......
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.extension.service.impl.ServiceImpl;
......@@ -17,7 +16,6 @@ import com.ruzhoukj.sms.service.UserService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
/**
......@@ -43,48 +41,39 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
@Override
public void test() {
ReportDataInfoEntity reportDataInfoEntity = getById("1893947910320414721");
ReportDataInfoEntity reportDataInfoEntity = getById("1894302342735548417");
String content = reportDataInfoEntity.getAllContent();
// 解析JSON字符串为JSONArray
JSONArray jsonArray = JSONArray.parseArray(content);
// 获取第一个元素(假设第一个元素是Sheet1的数据)
if (jsonArray.size() > 0) {
JSONObject jsonObject = jsonArray.getJSONObject(0);
// 获取Sheet1中的data数组
JSONArray data = jsonObject.getJSONArray("data");
double totalScore = 0;
String totalScore = "0";
// 遍历data数组,从第6行开始
for (int i = 5; i < data.size(); i++) {
JSONArray row = data.getJSONArray(i);
//权重
if (row.getJSONObject(6).containsKey("v")) {
double weight = row.getJSONObject(6).getDouble("v");
int selfScore = row.getJSONObject(8).getIntValue("v");
int leaderScore = row.getJSONObject(9).getIntValue("v");
int adminScore = row.getJSONObject(10).getIntValue("v");
//计算每行的分数
double rowScore = countRowScore(weight, selfScore, leaderScore, adminScore);
totalScore = totalScore + rowScore;
}
JSONObject subjoin = row.getJSONObject(0);
String subjoinStr = subjoin.getString("v");
if (StringUtils.isNotEmpty(subjoinStr) && subjoinStr.contains("附加考核")) {
JSONObject total = row.getJSONObject(0);
String totalStr = total.getString("v");
if (StringUtils.isNotEmpty(totalStr) && totalStr.contains("合计:")) {
JSONObject score = row.getJSONObject(11);
totalScore = score.getString("v");
break;
}
}
//更新用户绩效分
UserPerformanceEntity userPerformanceEntity = new UserPerformanceEntity();
userPerformanceEntity.setUserId(reportDataInfoEntity.getUserId());
userPerformanceEntity.setPerformanceDate(reportDataInfoEntity.getYear(), reportDataInfoEntity.getMonth());
String formattedScore = String.format("%.2f", totalScore);
userPerformanceEntity.setPerformanceScore(formattedScore);
userPerformanceEntity.setDeptId(reportDataInfoEntity.getDeptId());
userPerformanceService.save(userPerformanceEntity);
reportDataInfoEntity.setStatus("4");
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.");
}
......
......@@ -30,5 +30,5 @@ pagehelper:
oss:
key: LTAI5tENboKK5bcuqHfPvEdr
secret: Q006EvMzC63i1ozDiVNxEAxo8eH9zA
endPoint: oss-cn-beijing.aliyuncs.com
endPoint: https://oss-cn-beijing.aliyuncs.com
bucket: manj
\ No newline at end of file
......@@ -28,6 +28,7 @@
name,
second_dept as secondDept,
third_dept as thirdDept,
user_role userRole,
create_time as createTime
FROM user
WHERE name = #{name}
......
......@@ -5,6 +5,7 @@
<select id="queryList" resultType="com.ruzhoukj.sms.model.vo.UserPerformanceVO">
select
up.report_data_id id,
u.name userName,
up.user_id userId,
u.dept_id deptId,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment