"...service/git@gitlab.ruzhoukj.com:wujipeng/relation.git" did not exist on "fbf5742e3e5f432b805b3135f71ab77b4d966ac6"
Commit 452c13ee authored by zhuxiang's avatar zhuxiang
Browse files

增加绩效计算定时任务,每日八点执行

parent 1cdf589a
...@@ -67,7 +67,7 @@ public class ReportDataInfoController extends BaseController { ...@@ -67,7 +67,7 @@ public class ReportDataInfoController extends BaseController {
@GetMapping("/test") @GetMapping("/test")
public void test() { public void test() {
reportDataInfoService.test(); reportDataInfoService.countPerformance();
} }
} }
...@@ -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 test(); void countPerformance();
boolean saveOrUpdateReportData(ReportDataInfoDTO reportDataInfoDTO); boolean saveOrUpdateReportData(ReportDataInfoDTO reportDataInfoDTO);
} }
...@@ -2,6 +2,7 @@ package com.ruzhoukj.sms.service.impl; ...@@ -2,6 +2,7 @@ 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;
...@@ -40,43 +41,47 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re ...@@ -40,43 +41,47 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
} }
@Override @Override
public void test() { public void countPerformance() {
ReportDataInfoEntity reportDataInfoEntity = getById("1894302342735548417"); //查看已填写完成,未计算的绩效
String content = reportDataInfoEntity.getAllContent(); List<ReportDataInfoEntity> reportDataInfoEntityList = baseMapper.selectList(new LambdaQueryWrapper<ReportDataInfoEntity>()
// 解析JSON字符串为JSONArray .eq(ReportDataInfoEntity::getStatus, 3));
JSONArray jsonArray = JSONArray.parseArray(content); reportDataInfoEntityList.forEach(reportDataInfoEntity -> {
// 获取第一个元素(假设第一个元素是Sheet1的数据) String content = reportDataInfoEntity.getAllContent();
if (jsonArray.size() > 0) { // 解析JSON字符串为JSONArray
JSONObject jsonObject = jsonArray.getJSONObject(0); JSONArray jsonArray = JSONArray.parseArray(content);
// 获取Sheet1中的data数组 // 获取第一个元素(假设第一个元素是Sheet1的数据)
JSONArray data = jsonObject.getJSONArray("data"); if (jsonArray.size() > 0) {
String totalScore = "0"; JSONObject jsonObject = jsonArray.getJSONObject(0);
// 遍历data数组,从第6行开始 // 获取Sheet1中的data数组
for (int i = 5; i < data.size(); i++) { JSONArray data = jsonObject.getJSONArray("data");
JSONArray row = data.getJSONArray(i); String totalScore = "0";
JSONObject total = row.getJSONObject(0); // 遍历data数组,从第6行开始
String totalStr = total.getString("v"); for (int i = 5; i < data.size(); i++) {
if (StringUtils.isNotEmpty(totalStr) && totalStr.contains("合计:")) { JSONArray row = data.getJSONArray(i);
JSONObject score = row.getJSONObject(11); JSONObject total = row.getJSONObject(0);
totalScore = score.getString("v"); String totalStr = total.getString("v");
break; if (StringUtils.isNotEmpty(totalStr) && totalStr.contains("合计:")) {
JSONObject score = row.getJSONObject(11);
totalScore = score.getString("v");
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.");
}
} }
/** /**
......
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();
}
}
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