Commit d04dcfd6 authored by zhuxiang's avatar zhuxiang
Browse files

增加回退接口

parent 205a5162
...@@ -70,4 +70,9 @@ public class ReportDataInfoController extends BaseController { ...@@ -70,4 +70,9 @@ public class ReportDataInfoController extends BaseController {
return toAjax(reportDataInfoService.submit(id)); return toAjax(reportDataInfoService.submit(id));
} }
@PutMapping("/rollback/{id}")
public Result rollback(@PathVariable String id) {
return toAjax(reportDataInfoService.rollback(id));
}
} }
...@@ -29,4 +29,12 @@ public interface ReportDataInfoService extends IService<ReportDataInfoEntity> { ...@@ -29,4 +29,12 @@ public interface ReportDataInfoService extends IService<ReportDataInfoEntity> {
* @return * @return
*/ */
boolean submit(String id); boolean submit(String id);
/**
* 回退
*
* @param id
* @return
*/
boolean rollback(String id);
} }
...@@ -3,6 +3,7 @@ package com.ruzhoukj.sms.service.impl; ...@@ -3,6 +3,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.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.exception.BusinessException;
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;
...@@ -13,6 +14,7 @@ import com.ruzhoukj.sms.service.*; ...@@ -13,6 +14,7 @@ import com.ruzhoukj.sms.service.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.List; import java.util.List;
/** /**
...@@ -39,6 +41,12 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re ...@@ -39,6 +41,12 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
@Override @Override
public List<ReportDataInfoVO> queryList(ReportDataInfoDTO reportDataInfoDTO) { public List<ReportDataInfoVO> queryList(ReportDataInfoDTO reportDataInfoDTO) {
//获取当前月份
// 获取当前日期
LocalDate now = LocalDate.now();
// 获取当前月份(1 到 12)
int currentMonth = now.getMonthValue();
reportDataInfoDTO.setMonth(currentMonth);
return baseMapper.queryList(reportDataInfoDTO); return baseMapper.queryList(reportDataInfoDTO);
} }
...@@ -46,13 +54,13 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re ...@@ -46,13 +54,13 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
public void countPerformance(ReportDataInfoEntity reportDataInfoEntity) { public void countPerformance(ReportDataInfoEntity reportDataInfoEntity) {
//查看模板信息 //查看模板信息
ReportTemplateEntity reportTemplateEntity = reportTemplateService.getById(reportDataInfoEntity.getTemplateId()); ReportTemplateEntity reportTemplateEntity = reportTemplateService.getById(reportDataInfoEntity.getTemplateId());
if(reportTemplateEntity != null && reportTemplateEntity.getType().equals("绩效")) { if (reportTemplateEntity != null && reportTemplateEntity.getType().equals("绩效")) {
//查看已填写完成,未计算的绩效 //查看已填写完成,未计算的绩效
String content = reportDataInfoEntity.getAllContent(); String content = reportDataInfoEntity.getAllContent();
// 解析JSON字符串为JSONArray // 解析JSON字符串为JSONArray
JSONArray jsonArray = JSONArray.parseArray(content); JSONArray jsonArray = JSONArray.parseArray(content);
// 获取第一个元素(假设第一个元素是Sheet1的数据) // 获取第一个元素(假设第一个元素是Sheet1的数据)
if (jsonArray.size() > 0) { if (!jsonArray.isEmpty()) {
JSONObject jsonObject = jsonArray.getJSONObject(0); JSONObject jsonObject = jsonArray.getJSONObject(0);
// 获取Sheet1中的data数组 // 获取Sheet1中的data数组
JSONArray data = jsonObject.getJSONArray("data"); JSONArray data = jsonObject.getJSONArray("data");
...@@ -97,7 +105,7 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re ...@@ -97,7 +105,7 @@ 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{ } else {
reportDataInfoEntity.setStatus("3"); reportDataInfoEntity.setStatus("3");
} }
reportDataInfoService.updateById(reportDataInfoEntity); reportDataInfoService.updateById(reportDataInfoEntity);
...@@ -147,10 +155,34 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re ...@@ -147,10 +155,34 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
//查看部门负责人Id //查看部门负责人Id
DeptEntity deptEntity = deptService.getById(user.getDeptId()); DeptEntity deptEntity = deptService.getById(user.getDeptId());
reportDataInfoEntity.setActorUser(deptEntity.getDeptAdmin()); reportDataInfoEntity.setActorUser(deptEntity.getDeptAdmin());
} else if (user.getUserRole().equals(Constant.D_ADMIN)) {
reportDataInfoEntity.setActorUser(Constant.OA_ADMIN_ID);
} else if (reportDataInfoEntity.getActorUser().equals(Constant.OA_ADMIN_ID)) { } else if (reportDataInfoEntity.getActorUser().equals(Constant.OA_ADMIN_ID)) {
countPerformance(reportDataInfoEntity); countPerformance(reportDataInfoEntity);
} else {
//不嫩负责人提交
reportDataInfoEntity.setActorUser(Constant.OA_ADMIN_ID);
}
return updateById(reportDataInfoEntity);
}
@Override
public boolean rollback(String id) {
//查看信息
ReportDataInfoEntity reportDataInfoEntity = getById(id);
if (reportDataInfoEntity == null) {
return Boolean.FALSE;
}
//查看被处理人信息
UserEntity user = userService.getById(reportDataInfoEntity.getUserId());
if (reportDataInfoEntity.getActorUser().equals(reportDataInfoEntity.getUserId())) {
throw new BusinessException("当前不可回退");
} else if (reportDataInfoEntity.getActorUser().equals(Constant.OA_ADMIN_ID)) {
//是总经理
DeptEntity deptEntity = deptService.getById(user.getDeptId());
//回退至部门负责人
reportDataInfoEntity.setActorUser(deptEntity.getDeptAdmin());
} else {
//回退至当前绩效被考核人
reportDataInfoEntity.setActorUser(reportDataInfoEntity.getUserId());
} }
return updateById(reportDataInfoEntity); return updateById(reportDataInfoEntity);
} }
......
...@@ -8,6 +8,8 @@ import com.ruzhoukj.sms.model.vo.UserPerformanceVO; ...@@ -8,6 +8,8 @@ import com.ruzhoukj.sms.model.vo.UserPerformanceVO;
import com.ruzhoukj.sms.service.UserPerformanceService; import com.ruzhoukj.sms.service.UserPerformanceService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
/** /**
...@@ -22,6 +24,12 @@ import java.util.List; ...@@ -22,6 +24,12 @@ import java.util.List;
public class UserPerformanceServiceImpl extends ServiceImpl<UserPerformanceDao, UserPerformanceEntity> implements UserPerformanceService { public class UserPerformanceServiceImpl extends ServiceImpl<UserPerformanceDao, UserPerformanceEntity> implements UserPerformanceService {
@Override @Override
public List<UserPerformanceVO> queryList(UserPerformanceDTO userPerformanceDTO) { public List<UserPerformanceVO> queryList(UserPerformanceDTO userPerformanceDTO) {
//获取当前年月
LocalDate now = LocalDate.now();
// 格式化为 "yyyy-MM"
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
String currentYearMonth = now.format(formatter);
userPerformanceDTO.setPerformanceDate(currentYearMonth);
return baseMapper.queryList(userPerformanceDTO); return baseMapper.queryList(userPerformanceDTO);
} }
} }
...@@ -29,6 +29,9 @@ ...@@ -29,6 +29,9 @@
<if test="userId != null and userId != ''"> <if test="userId != null and userId != ''">
r.user_id = #{userId} r.user_id = #{userId}
</if> </if>
<if test="month != null and month != ''">
r.month = #{month}
</if>
</where> </where>
</select> </select>
</mapper> </mapper>
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
<if test="deptId != null and deptId != ''"> <if test="deptId != null and deptId != ''">
and up.dept_id = #{deptId} and up.dept_id = #{deptId}
</if> </if>
<if test="performanceDate != null and performanceDate != ''">
and up.performance_date = #{performanceDate}
</if>
</where> </where>
</select> </select>
</mapper> </mapper>
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