Commit 580a8793 authored by zhuxiang's avatar zhuxiang
Browse files

绩效提交优化

parent afada94c
...@@ -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));
......
...@@ -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();
} }
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 = JSONArray.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{
//财务绩效
score = row.getJSONObject(4);
totalScore = score.getString("v");
}
} }
//财务绩效 if (StringUtils.isEmpty(totalScore)) {
if (StringUtils.isNull(score)) { JSONObject scoreSj = row.getJSONObject(10);
score = row.getJSONObject(4); totalScore = scoreSj.getString("m");
} }
totalScore = score.getString("v");
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");
}
}
} }
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