Commit 84f466dc authored by zhuxiang's avatar zhuxiang
Browse files

优化

parent 263d9ef7
......@@ -65,9 +65,4 @@ public class ReportDataInfoController extends BaseController {
return toAjax(reportDataInfoService.removeById(id));
}
@GetMapping("/test")
public void test() {
reportDataInfoService.countPerformance();
}
}
......@@ -46,5 +46,5 @@ public class ReportDataInfoEntity {
private String deptId;
@TableField("status")
private String status;
private String status = "1";
}
......@@ -18,7 +18,7 @@ import java.util.List;
public interface ReportDataInfoService extends IService<ReportDataInfoEntity> {
List<ReportDataInfoVO> queryList(ReportDataInfoDTO reportDataInfoDTO);
void countPerformance();
void countPerformance(String reportDataInfoId);
boolean saveOrUpdateReportData(ReportDataInfoDTO reportDataInfoDTO);
}
......@@ -2,7 +2,6 @@ package com.ruzhoukj.sms.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.utils.StringUtils;
import com.ruzhoukj.sms.dao.ReportDataInfoDao;
......@@ -41,11 +40,9 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
}
@Override
public void countPerformance() {
public void countPerformance(String reportDataInfoId) {
//查看已填写完成,未计算的绩效
List<ReportDataInfoEntity> reportDataInfoEntityList = baseMapper.selectList(new LambdaQueryWrapper<ReportDataInfoEntity>()
.eq(ReportDataInfoEntity::getStatus, 3));
reportDataInfoEntityList.forEach(reportDataInfoEntity -> {
ReportDataInfoEntity reportDataInfoEntity = getById(reportDataInfoId);
String content = reportDataInfoEntity.getAllContent();
// 解析JSON字符串为JSONArray
JSONArray jsonArray = JSONArray.parseArray(content);
......@@ -63,6 +60,10 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
if (StringUtils.isNotEmpty(totalStr) && totalStr.contains("合计:")) {
JSONObject score = row.getJSONObject(11);
totalScore = score.getString("v");
if (StringUtils.isEmpty(totalScore)) {
JSONObject scoreSj = row.getJSONObject(9);
totalScore = scoreSj.getString("m");
}
break;
}
}
......@@ -81,7 +82,6 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
} else {
System.out.println("No data available in the JSON array.");
}
});
}
/**
......@@ -99,10 +99,21 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
@Override
public boolean saveOrUpdateReportData(ReportDataInfoDTO reportDataInfoDTO) {
if (StringUtils.isNotEmpty(reportDataInfoDTO.getId())) {
//是编辑
updateById(reportDataInfoDTO);
} else {
//查看当前用户所属部门
UserEntity user = userService.getById(reportDataInfoDTO.getLoginUserId());
UserEntity user = userService.getById(reportDataInfoDTO.getUserId());
reportDataInfoDTO.setDeptId(user.getDeptId());
reportDataInfoDTO.setUserId(user.getId());
return saveOrUpdate(reportDataInfoDTO);
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