"...service/git@gitlab.ruzhoukj.com:wujipeng/relation.git" did not exist on "46fcc05a15514afd088686f655a2b557358433b5"
Commit 84f466dc authored by zhuxiang's avatar zhuxiang
Browse files

优化

parent 263d9ef7
...@@ -65,9 +65,4 @@ public class ReportDataInfoController extends BaseController { ...@@ -65,9 +65,4 @@ public class ReportDataInfoController extends BaseController {
return toAjax(reportDataInfoService.removeById(id)); return toAjax(reportDataInfoService.removeById(id));
} }
@GetMapping("/test")
public void test() {
reportDataInfoService.countPerformance();
}
} }
...@@ -46,5 +46,5 @@ public class ReportDataInfoEntity { ...@@ -46,5 +46,5 @@ public class ReportDataInfoEntity {
private String deptId; private String deptId;
@TableField("status") @TableField("status")
private String status; private String status = "1";
} }
...@@ -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 countPerformance(); void countPerformance(String reportDataInfoId);
boolean saveOrUpdateReportData(ReportDataInfoDTO reportDataInfoDTO); boolean saveOrUpdateReportData(ReportDataInfoDTO reportDataInfoDTO);
} }
...@@ -2,7 +2,6 @@ package com.ruzhoukj.sms.service.impl; ...@@ -2,7 +2,6 @@ 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;
...@@ -41,47 +40,48 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re ...@@ -41,47 +40,48 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
} }
@Override @Override
public void countPerformance() { public void countPerformance(String reportDataInfoId) {
//查看已填写完成,未计算的绩效 //查看已填写完成,未计算的绩效
List<ReportDataInfoEntity> reportDataInfoEntityList = baseMapper.selectList(new LambdaQueryWrapper<ReportDataInfoEntity>() ReportDataInfoEntity reportDataInfoEntity = getById(reportDataInfoId);
.eq(ReportDataInfoEntity::getStatus, 3)); String content = reportDataInfoEntity.getAllContent();
reportDataInfoEntityList.forEach(reportDataInfoEntity -> { // 解析JSON字符串为JSONArray
String content = reportDataInfoEntity.getAllContent(); JSONArray jsonArray = JSONArray.parseArray(content);
// 解析JSON字符串为JSONArray // 获取第一个元素(假设第一个元素是Sheet1的数据)
JSONArray jsonArray = JSONArray.parseArray(content); if (jsonArray.size() > 0) {
// 获取第一个元素(假设第一个元素是Sheet1的数据) JSONObject jsonObject = jsonArray.getJSONObject(0);
if (jsonArray.size() > 0) { // 获取Sheet1中的data数组
JSONObject jsonObject = jsonArray.getJSONObject(0); JSONArray data = jsonObject.getJSONArray("data");
// 获取Sheet1中的data数组 String totalScore = "0";
JSONArray data = jsonObject.getJSONArray("data"); // 遍历data数组,从第6行开始
String totalScore = "0"; for (int i = 5; i < data.size(); i++) {
// 遍历data数组,从第6行开始 JSONArray row = data.getJSONArray(i);
for (int i = 5; i < data.size(); i++) { JSONObject total = row.getJSONObject(0);
JSONArray row = data.getJSONArray(i); String totalStr = total.getString("v");
JSONObject total = row.getJSONObject(0); if (StringUtils.isNotEmpty(totalStr) && totalStr.contains("合计:")) {
String totalStr = total.getString("v"); JSONObject score = row.getJSONObject(11);
if (StringUtils.isNotEmpty(totalStr) && totalStr.contains("合计:")) { totalScore = score.getString("v");
JSONObject score = row.getJSONObject(11); if (StringUtils.isEmpty(totalScore)) {
totalScore = score.getString("v"); JSONObject scoreSj = row.getJSONObject(9);
break; totalScore = scoreSj.getString("m");
} }
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.");
}
} }
/** /**
...@@ -99,10 +99,21 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re ...@@ -99,10 +99,21 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
@Override @Override
public boolean saveOrUpdateReportData(ReportDataInfoDTO reportDataInfoDTO) { public boolean saveOrUpdateReportData(ReportDataInfoDTO reportDataInfoDTO) {
//查看当前用户所属部门
UserEntity user = userService.getById(reportDataInfoDTO.getLoginUserId()); if (StringUtils.isNotEmpty(reportDataInfoDTO.getId())) {
reportDataInfoDTO.setDeptId(user.getDeptId()); //是编辑
reportDataInfoDTO.setUserId(user.getId()); updateById(reportDataInfoDTO);
return saveOrUpdate(reportDataInfoDTO); } else {
//查看当前用户所属部门
UserEntity user = userService.getById(reportDataInfoDTO.getUserId());
reportDataInfoDTO.setDeptId(user.getDeptId());
reportDataInfoDTO.setUserId(user.getId());
save(reportDataInfoDTO);
}
//处理绩效提交
if (StringUtils.isNotEmpty(reportDataInfoDTO.getId()) && reportDataInfoDTO.getStatus().equals("3")) {
countPerformance(reportDataInfoDTO.getId());
}
return Boolean.TRUE;
} }
} }
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