This commit is contained in:
杜建超 2020-11-03 14:36:17 +08:00
parent b455b0c330
commit b136e0cf6e
14 changed files with 91 additions and 27 deletions

View File

@ -42,7 +42,8 @@ public class ChartController extends AbstractController{
public R chartResult(@RequestParam(required = false) @ApiParam(name = "startId",value = "考核周期标识id") Long startId){
List<ChartStatisticalRes> chartStatisticalRes = null;
try {
chartStatisticalRes = chartResultService.chartReport(startId);
Long userId = getUserId();
chartStatisticalRes = chartResultService.chartReport(startId,userId);
} catch (Exception e) {
log.error("获取绩效报表统计异常" ,e);
return R.error();

View File

@ -31,4 +31,6 @@ public class AssessDetailReq extends BasePage{
//状态 确认 执行 结果录入
@ApiModelProperty(value = "状态 确认 执行 结果录入。。。",name = "flowProcess")
private Integer flowProcess;
private List<String> departmentIds;
}

View File

@ -4,6 +4,7 @@ import com.lz.modules.equipment.entity.model.BasePage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @Author: djc
@ -19,4 +20,7 @@ public class AssessListReq extends BasePage {
//组名称
@ApiModelProperty(value = "考核名称",name = "name")
private String name;
private Long staffId;
}

View File

@ -22,4 +22,7 @@ public class ChartResultReq extends BasePage{
@ApiModelProperty(value = "等级",name = "scoreLevel")
private Long scoreLevel;
private Long staffId;
}

View File

@ -15,6 +15,9 @@ import java.util.List;
@Data
@ApiModel("考核详情列表实体")
public class AssessManagerDetailRes {
//头像
@ApiModelProperty(value = "头像", name = "avatar")
private String avatar;
@ApiModelProperty(value = "姓名",name = "staffName")
private String staffName;

View File

@ -17,9 +17,9 @@ public interface AssessService {
/**
*
* @param staffRole
* @param staffId
* @return null 为全部部门 size = 0 为没有部门
*/
List<Long> roleDepartment(StaffRole staffRole);
List<String> roleDepartments(Long staffId);
}

View File

@ -18,7 +18,7 @@ import java.util.List;
*/
public interface ChartResultService {
List<ChartStatisticalRes> chartReport(Long startId);
List<ChartStatisticalRes> chartReport(Long startId,Long staffId);
List<ChartStatistical> countDepartmentAndStaffNum(List<String>staffIds);

View File

@ -1,5 +1,6 @@
package com.lz.modules.performance.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Maps;
import com.lz.common.exception.RRException;
@ -8,6 +9,7 @@ import com.lz.common.utils.R;
import com.lz.common.utils.StringUtil;
import com.lz.modules.app.dto.ApprovalDto;
import com.lz.modules.app.dto.StaffSimpleDto;
import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.service.StaffService;
import com.lz.modules.flow.dao.EvaluationStartStaffMapper;
import com.lz.modules.flow.dao.FlowStartMapper;
@ -27,6 +29,7 @@ import com.lz.modules.performance.req.AssessToScoreReq;
import com.lz.modules.performance.res.AssessManagerDetailRes;
import com.lz.modules.performance.res.AssessManagerListRes;
import com.lz.modules.performance.service.AssessManagerService;
import com.lz.modules.performance.service.AssessService;
import com.lz.modules.sys.dao.app.ResultRecordMapper;
import com.lz.modules.sys.entity.app.ResultRecord;
import com.lz.modules.sys.service.app.ResultRecordService;
@ -71,6 +74,8 @@ public class AssessManagerServiceImpl implements AssessManagerService {
private EvaluationStartStaffMapper evaluationStartStaffMapper;
@Autowired
private FlowStartService flowStartService;
@Autowired
private AssessService assessService;
@Override
public PageUtils assessList(AssessListReq req) {
@ -82,6 +87,7 @@ public class AssessManagerServiceImpl implements AssessManagerService {
if(CollectionUtils.isEmpty(list)){
return pageUtils;
}
List<String> mandepartmentIds = assessService.roleDepartments(req.getStaffId());
list.forEach(flowStart -> {
AssessManagerListRes res = new AssessManagerListRes();
String name = flowStart.getName();
@ -90,7 +96,8 @@ public class AssessManagerServiceImpl implements AssessManagerService {
if(name.contains("绩效考核")){
res.setCycleTime(name.substring(0,name.lastIndexOf("绩效考核")));
}
int i = resultRecordMapper.countStartAndGroupNum(flowStart.getId());
//过滤非自己管理的人员
int i = resultRecordMapper.countStartAndGroupNum(flowStart.getId(),mandepartmentIds);
ResultRecord resultRecord = resultRecordMapper.selectOneByStartId(flowStart.getId());
res.setJoinNum(resultRecord == null? StringUtil.EMPTY : resultRecord.getStaffName() + i + "等人");
data.add(res);
@ -109,6 +116,12 @@ public class AssessManagerServiceImpl implements AssessManagerService {
PageUtils pageUtils = PageUtils.startPage(req.getCurrPage(),req.getPageSize()).doSelect(
page -> resultRecordMapper.selectAssessListByStartId(page,req)
);
List<AssessManagerDetailRes> list = pageUtils.getList();
list.forEach(assessManagerDetailRes -> {
StaffEntity staffEntity = staffService.selectStaffById(assessManagerDetailRes.getStaffId());
assessManagerDetailRes.setAvatar(Optional.ofNullable(staffEntity.getAvatar()).orElse(StringUtil.EMPTY));
});
return pageUtils;
}
@ -236,7 +249,8 @@ public class AssessManagerServiceImpl implements AssessManagerService {
approvalDto.setResultRecordId(aLong);
approvalDto.setMenuName("开始评分");
try {
resultRecordService.newApproval(approvalDto);
R r = resultRecordService.newApproval(approvalDto);
log.info("绩效id aLong :" + aLong + " ,res" + JSON.toJSONString(r));
} catch (Exception e) {
log.error("执行中状态跳过失败 recorId:" + aLong,e);
}

View File

@ -8,10 +8,7 @@ import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.service.StaffService;
import com.lz.modules.flow.entity.StaffRole;
import com.lz.modules.flow.entity.StaffRoleDepartment;
import com.lz.modules.flow.service.FlowChangeService;
import com.lz.modules.flow.service.FlowRecordService;
import com.lz.modules.flow.service.StaffRoleDepartmentService;
import com.lz.modules.flow.service.StaffRoleEvaluationGroupService;
import com.lz.modules.flow.service.*;
import com.lz.modules.performance.dto.TaskListDto;
import com.lz.modules.performance.req.AssessTaskReq;
import com.lz.modules.performance.res.ChartStatisticalRes;
@ -49,6 +46,8 @@ public class AssessServiceImpl implements AssessService {
private StaffRoleDepartmentService staffRoleDepartmentService;
@Autowired
private StaffRoleEvaluationGroupService staffRoleEvaluationGroupService;
@Autowired
private StaffRoleService staffRoleService;
@Override
public PageUtils userTaskList(AssessTaskReq req,Long userId) {
@ -68,7 +67,7 @@ public class AssessServiceImpl implements AssessService {
name = "";
}
//根据状态拼接文案
res.setTitle(name + "" + taskListDto.getMonthTime() + "");
res.setTitle(name + "" + taskListDto.getMonthTime() + "绩效考核 ");
res.setTime(DateUtils.format(taskListDto.getGmtModified(),DateUtils.DATE_TIME_PATTERN));
//跳转绩效详情页
res.setRecordId(taskListDto.getRecordId());
@ -84,7 +83,8 @@ public class AssessServiceImpl implements AssessService {
@Override
public List<Long> roleDepartment(StaffRole staffRole) {
public List<String> roleDepartments(Long staffId) {
StaffRole staffRole = staffRoleService.selectByStaffId(staffId);
if(staffRole == null){
log.info("staffRole 为空");
return Collections.EMPTY_LIST;
@ -103,7 +103,7 @@ public class AssessServiceImpl implements AssessService {
allDepart.addAll(strings);
});
List<Long> collect = allDepart.stream().distinct().map(s -> Long.valueOf(s)).collect(Collectors.toList());
List<String> collect = allDepart.stream().distinct().collect(Collectors.toList());
return collect;
}
log.info("未获取到用户权限对应的部门 roleID: " + staffRole.getId());

View File

@ -1,5 +1,6 @@
package com.lz.modules.performance.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Maps;
import com.lz.common.utils.PageUtils;
@ -24,6 +25,7 @@ import com.lz.modules.performance.req.ChartStartsReq;
import com.lz.modules.performance.res.ChartStartsRes;
import com.lz.modules.performance.res.ChartStatistical;
import com.lz.modules.performance.res.ChartStatisticalRes;
import com.lz.modules.performance.service.AssessService;
import com.lz.modules.performance.service.ChartResultService;
import com.lz.modules.sys.dao.app.ResultRecordMapper;
import com.lz.modules.sys.entity.app.ResultRecord;
@ -62,15 +64,18 @@ public class ChartResultServiceImpl implements ChartResultService {
private DepartmentsService departmentsService;
@Autowired
private FlowChartService flowChartService;
@Autowired
private AssessService assessService;
@Override
public List<ChartStatisticalRes> chartReport(Long startId) {
public List<ChartStatisticalRes> chartReport(Long startId,Long staffId) {
String defaultTime = StringUtil.EMPTY;
Integer defaultCycleType = null;
FlowStart flowStart = null;
if(startId==null){
//取最近一条记录
FlowStart flowStart = flowStartMapper.selectRecentlyLimt();
flowStart = flowStartMapper.selectRecentlyLimt();
if(flowStart!=null){
log.info("首次进入,默认返回最新记录 flowStartId:" + flowStart.getId());
startId = flowStart.getId();
@ -80,10 +85,12 @@ public class ChartResultServiceImpl implements ChartResultService {
return new ArrayList<>();
}
}
//自己管理的部门
List<String> mandepartmentIds = assessService.roleDepartments(staffId);
List<ChartStatisticalRes> data = new ArrayList<>();
ChartStatisticalRes res;
List<ChartStatistical> process = resultRecordService.countNumByFlowProcess(startId,null,null);
List<ChartStatistical> process = resultRecordService.countNumByFlowProcess(startId,null,mandepartmentIds);
res = new ChartStatisticalRes();
res.setType(0);
@ -95,7 +102,7 @@ public class ChartResultServiceImpl implements ChartResultService {
}
data.add(res);
List<ChartStatistical> scoreLevel = resultRecordService.countNumByScoreLevel(startId,null,null);
List<ChartStatistical> scoreLevel = resultRecordService.countNumByScoreLevel(startId,null,mandepartmentIds);
res = new ChartStatisticalRes();
res.setType(1);
res.setStatisticals(scoreLevel);
@ -106,14 +113,24 @@ public class ChartResultServiceImpl implements ChartResultService {
}
data.add(res);
FlowStart flowStart = flowStartMapper.selectFlowStartById(startId);
//如果不是默认获得发起考核信息
if(flowStart == null){
flowStart = flowStartMapper.selectFlowStartById(startId);
}
String[] split = flowStart.getGroupIds().split(",");
Set<String> staffIds = new HashSet<>();
for(String s:split){
List<String> strings = evaluationGroupService.selectAllStaffIdsByGroupId(Long.valueOf(s));
staffIds.addAll(strings);
}
List<String> all = new ArrayList<>(staffIds);
log.info("chartReport 所有人员:" + JSON.toJSONString(staffIds));
//自己管理的和发起的人员交集
List<String> manstaffIds = staffService.staffsByAllDeparmentIds(mandepartmentIds);
log.info("chartReport 管理人员:" + JSON.toJSONString(manstaffIds));
manstaffIds.retainAll(staffIds);
log.info("chartReport 交集人员:" + JSON.toJSONString(manstaffIds));
List<String> all = new ArrayList<>(manstaffIds);
List<ChartStatistical> depstaff = this.countDepartmentAndStaffNum(all);
res = new ChartStatisticalRes();
res.setType(2);
@ -161,7 +178,13 @@ public class ChartResultServiceImpl implements ChartResultService {
@Override
public PageUtils selectChartDetailList(ChartResultReq req) {
List<String> allDeparmentIds = staffService.selectAllDeparmentIdsByDepartmentParentId(req.getDepartmentId());
List<String> ids = staffService.staffsByAllDeparmentIds(allDeparmentIds);
//自己管理的和所有的部门交集
log.info("selectChartDetailList 管理部门:" + JSON.toJSONString(allDeparmentIds));
List<String> mandepartmentIds = assessService.roleDepartments(req.getStaffId());
log.info("selectChartDetailList 管理部门:" + JSON.toJSONString(mandepartmentIds));
mandepartmentIds.retainAll(allDeparmentIds);
log.info("selectChartDetailList 交集部门:" + JSON.toJSONString(mandepartmentIds));
List<String> ids = staffService.staffsByAllDeparmentIds(mandepartmentIds);
PageUtils pageUtils = PageUtils.startPage(req.getCurrPage(), req.getPageSize()).doSelect(
page -> resultRecordMapper.selectChartDetailList(page,ids,req.getStartId(),req.getScoreLevel())
);

View File

@ -73,15 +73,15 @@ public interface ResultRecordMapper extends BaseMapper<ResultRecord> {
List<ResultRecord> selectResultRecordAllByStaffId(@Param("staffId") Long staffId);
List<ChartStatistical> countNumByFlowProcess(@Param("startId") Long startId,@Param("evaluationIds")List<Long> evaluationIds,@Param("departmentIds")List<Long> departmentIds);
List<ChartStatistical> countNumByFlowProcess(@Param("startId") Long startId,@Param("evaluationIds")List<Long> evaluationIds,@Param("departmentIds")List<String> departmentIds);
List<ChartStatistical> countNumByScoreLevel(@Param("startId") Long startId,@Param("evaluationIds")List<Long> evaluationIds,@Param("departmentIds")List<Long> departmentIds);
List<ChartStatistical> countNumByScoreLevel(@Param("startId") Long startId,@Param("evaluationIds")List<Long> evaluationIds,@Param("departmentIds")List<String> departmentIds);
List<ResultRecord> selectChartDetailList(@Param("page") IPage page, @Param("staffIds") List<String> staffIds, @Param("startId")Long startId,@Param("scoreLevel")Long scoreLevel);
int batchDeleteByStartId(@Param("startId")Long startId);
int countStartAndGroupNum(@Param("startId")Long startId);
int countStartAndGroupNum(@Param("startId")Long startId,@Param("departmentIds")List<String> departmentIds);
ResultRecord selectOneByStartId(@Param("startId")Long startId);

View File

@ -103,9 +103,9 @@ public interface ResultRecordService extends IService<ResultRecord> {
List<ResultRecord> selectResultRecordAllByStaffId(Long staffId);
List<ChartStatistical> countNumByFlowProcess(Long startId,List<Long> evaluationIds,List<Long> departmentIds);
List<ChartStatistical> countNumByFlowProcess(Long startId,List<Long> evaluationIds,List<String> departmentIds);
List<ChartStatistical> countNumByScoreLevel(Long startId,List<Long> evaluationIds,List<Long> departmentIds);
List<ChartStatistical> countNumByScoreLevel(Long startId,List<Long> evaluationIds,List<String> departmentIds);
void batchDeleteByStaffIds(List<String> staffIds);

View File

@ -750,12 +750,12 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
}
@Override
public List<ChartStatistical> countNumByFlowProcess(Long startId,List<Long> evaluationIds,List<Long> departmentIds) {
public List<ChartStatistical> countNumByFlowProcess(Long startId,List<Long> evaluationIds,List<String> departmentIds) {
return resultRecordMapper.countNumByFlowProcess(startId,evaluationIds,departmentIds);
}
@Override
public List<ChartStatistical> countNumByScoreLevel(Long startId,List<Long> evaluationIds,List<Long> departmentIds) {
public List<ChartStatistical> countNumByScoreLevel(Long startId,List<Long> evaluationIds,List<String> departmentIds) {
return resultRecordMapper.countNumByScoreLevel(startId,evaluationIds,departmentIds);
}

View File

@ -420,6 +420,13 @@
<select id="countStartAndGroupNum" resultType="int">
select COUNT(1) from lz_result_record where is_delete = 0 and start_id = #{startId}
<if test="departmentIds !=null and departmentIds.size()!=0">
and department_id in (
<foreach collection="departmentIds" item="department_id" separator=",">
#{department_id}
</foreach>
)
</if>
</select>
<select id="selectOneByStartId" resultType="com.lz.modules.sys.entity.app.ResultRecord">
@ -478,6 +485,13 @@
</foreach>
)
</if>
<if test="departmentIds !=null and departmentIds.size()!=0">
and department_id in (
<foreach collection="departmentIds" item="department_id" separator=",">
#{department_id}
</foreach>
)
</if>
GROUP BY flow_process
</select>