Commit 205a5162 authored by zhuxiang's avatar zhuxiang
Browse files

优化

parent 09ff5406
...@@ -6,16 +6,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -6,16 +6,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.utils.StringUtils; import com.platform.utils.StringUtils;
import com.ruzhoukj.sms.common.Constant; import com.ruzhoukj.sms.common.Constant;
import com.ruzhoukj.sms.dao.ReportDataInfoDao; import com.ruzhoukj.sms.dao.ReportDataInfoDao;
import com.ruzhoukj.sms.entity.DeptEntity; import com.ruzhoukj.sms.entity.*;
import com.ruzhoukj.sms.entity.ReportDataInfoEntity;
import com.ruzhoukj.sms.entity.UserEntity;
import com.ruzhoukj.sms.entity.UserPerformanceEntity;
import com.ruzhoukj.sms.model.dto.ReportDataInfoDTO; import com.ruzhoukj.sms.model.dto.ReportDataInfoDTO;
import com.ruzhoukj.sms.model.vo.ReportDataInfoVO; import com.ruzhoukj.sms.model.vo.ReportDataInfoVO;
import com.ruzhoukj.sms.service.DeptService; import com.ruzhoukj.sms.service.*;
import com.ruzhoukj.sms.service.ReportDataInfoService;
import com.ruzhoukj.sms.service.UserPerformanceService;
import com.ruzhoukj.sms.service.UserService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -40,6 +34,8 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re ...@@ -40,6 +34,8 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
private ReportDataInfoService reportDataInfoService; private ReportDataInfoService reportDataInfoService;
@Resource @Resource
private UserPerformanceService userPerformanceService; private UserPerformanceService userPerformanceService;
@Resource
private ReportTemplateService reportTemplateService;
@Override @Override
public List<ReportDataInfoVO> queryList(ReportDataInfoDTO reportDataInfoDTO) { public List<ReportDataInfoVO> queryList(ReportDataInfoDTO reportDataInfoDTO) {
...@@ -48,58 +44,63 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re ...@@ -48,58 +44,63 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
@Override @Override
public void countPerformance(ReportDataInfoEntity reportDataInfoEntity) { public void countPerformance(ReportDataInfoEntity reportDataInfoEntity) {
//查看已填写完成,未计算的绩效 //查看模板信息
String content = reportDataInfoEntity.getAllContent(); ReportTemplateEntity reportTemplateEntity = reportTemplateService.getById(reportDataInfoEntity.getTemplateId());
// 解析JSON字符串为JSONArray if(reportTemplateEntity != null && reportTemplateEntity.getType().equals("绩效")) {
JSONArray jsonArray = JSONArray.parseArray(content); //查看已填写完成,未计算的绩效
// 获取第一个元素(假设第一个元素是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行开始
if (StringUtils.isNotEmpty(total)) { for (int i = 5; i < data.size(); i++) {
String totalStr = total.getString("v"); JSONArray row = data.getJSONArray(i);
if (StringUtils.isNotEmpty(totalStr) && totalStr.contains("合计:")) { JSONObject total = row.getJSONObject(0);
//普通员工绩效 if (StringUtils.isNotEmpty(total)) {
JSONObject score = row.getJSONObject(11); String totalStr = total.getString("v");
if (StringUtils.isNull(score)) { if (StringUtils.isNotEmpty(totalStr) && totalStr.contains("合计:")) {
//部门管理员绩效 //普通员工绩效
score = row.getJSONObject(10); JSONObject score = row.getJSONObject(11);
} if (StringUtils.isNull(score)) {
//财务绩效 //部门管理员绩效
if (StringUtils.isNull(score)) { score = row.getJSONObject(10);
score = row.getJSONObject(4); }
} //财务绩效
totalScore = score.getString("v"); if (StringUtils.isNull(score)) {
if (StringUtils.isEmpty(totalScore)) { score = row.getJSONObject(4);
JSONObject scoreSj = row.getJSONObject(9); }
totalScore = scoreSj.getString("m"); totalScore = score.getString("v");
if (StringUtils.isEmpty(totalScore)) {
JSONObject scoreSj = row.getJSONObject(9);
totalScore = scoreSj.getString("m");
}
break;
} }
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");
}
} else {
System.out.println("No data available in the JSON array.");
} }
if (!totalScore.equals("0")) { }else{
//更新用户绩效分 reportDataInfoEntity.setStatus("3");
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());
reportDataInfoService.updateById(reportDataInfoEntity);
}
} else {
System.out.println("No data available in the JSON array.");
} }
reportDataInfoService.updateById(reportDataInfoEntity);
} }
/** /**
...@@ -136,7 +137,7 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re ...@@ -136,7 +137,7 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
public boolean submit(String id) { public boolean submit(String id) {
//查看信息 //查看信息
ReportDataInfoEntity reportDataInfoEntity = getById(id); ReportDataInfoEntity reportDataInfoEntity = getById(id);
if (reportDataInfoEntity != null) { if (reportDataInfoEntity == null) {
return Boolean.FALSE; return Boolean.FALSE;
} }
//查看被处理人信息 //查看被处理人信息
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
r.year year, r.year year,
r.month month, r.month month,
r.key_value keyValue, r.key_value keyValue,
r. r.actor_user actorUser,
u.name userName, u.name userName,
r.status status r.status status
from from
......
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