提交修改
This commit is contained in:
commit
52e7520506
@ -69,7 +69,6 @@ public class ShiroConfig {
|
||||
filterMap.put("/dtlg/jump", "anon");
|
||||
filterMap.put("/luck/getLuckById", "anon");
|
||||
filterMap.put("/luck/updateLuck", "anon");
|
||||
filterMap.put("/result/**","anon");
|
||||
filterMap.put("/**", "oauth2");
|
||||
shiroFilter.setFilterChainDefinitionMap(filterMap);
|
||||
|
||||
|
||||
@ -2,7 +2,9 @@ package com.lz.modules.app.controller;
|
||||
|
||||
import com.lz.common.utils.PageUtils;
|
||||
import com.lz.common.utils.R;
|
||||
import com.lz.common.utils.StringUtil;
|
||||
import com.lz.modules.app.dto.DepartmentsDto;
|
||||
import com.lz.modules.app.entity.DepartmentsStaffRelateEntity;
|
||||
import com.lz.modules.app.enums.ResultRecordStatusEnum;
|
||||
import com.lz.modules.app.req.ReportListReq;
|
||||
import com.lz.modules.app.req.ResultDistributionReq;
|
||||
@ -42,9 +44,13 @@ public class ReportResultController extends AbstractController{
|
||||
|
||||
@RequestMapping("chart")
|
||||
public R reportChart(ResultDistributionReq req){
|
||||
if(!chartService.hrOrBoss(getUserId())){
|
||||
Long userId = getUserId();
|
||||
if(!chartService.hrOrBoss(userId)){
|
||||
return R.ok();
|
||||
}
|
||||
if(StringUtil.isBlank(req.getDepartmentId())){
|
||||
req.setDepartmentId("1");
|
||||
}
|
||||
ReportChartResp reportChartResp = chartService.reportChart(req.getSelectMonthTime(), req.getDepartmentId());
|
||||
return R.ok().put("data",reportChartResp);
|
||||
}
|
||||
@ -54,8 +60,18 @@ public class ReportResultController extends AbstractController{
|
||||
|
||||
@RequestMapping("/report")
|
||||
public R list(ReportListReq req){
|
||||
if(!chartService.leader(getUserId())){
|
||||
return R.ok();
|
||||
Long userId = getUserId();
|
||||
if(!chartService.hrOrBoss(userId)){
|
||||
if(!chartService.leader(userId)){
|
||||
return R.ok();
|
||||
}
|
||||
if(StringUtil.isBlank(req.getDepartmentId())){
|
||||
DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectByStaffId(userId);
|
||||
req.setDepartmentId(departmentsStaffRelateEntity.getDepartmentId());
|
||||
}
|
||||
}
|
||||
if(StringUtil.isBlank(req.getDepartmentId())){
|
||||
req.setDepartmentId("1");
|
||||
}
|
||||
PageUtils pageUtils = chartService.resultReportList(req);
|
||||
return R.ok().put("page",pageUtils);
|
||||
@ -67,6 +83,9 @@ public class ReportResultController extends AbstractController{
|
||||
if(!chartService.hrOrBoss(getUserId())){
|
||||
return R.ok();
|
||||
}
|
||||
if(StringUtil.isBlank(req.getDepartmentId())){
|
||||
req.setDepartmentId("1");
|
||||
}
|
||||
PageUtils pageUtils = chartService.reportDistribution(req);
|
||||
return R.ok().put("page",pageUtils);
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ public class ReportProgressListDto {
|
||||
//价值观得分
|
||||
private String valueScore;
|
||||
//得分
|
||||
private String score;
|
||||
private String allScore;
|
||||
//等级
|
||||
private String scoreLevel;
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ import java.time.YearMonth;
|
||||
*/
|
||||
@Data
|
||||
public class ResultDistributionReq extends BasePage {
|
||||
private String departmentId = "1";
|
||||
private String departmentId;
|
||||
|
||||
private String selectMonthTime = YearMonth.now().toString();
|
||||
}
|
||||
|
||||
@ -8,10 +8,12 @@ package com.lz.modules.sys.dao.app;
|
||||
* @since 2020-08-10
|
||||
*/
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.lz.common.utils.BigDecimalUtil;
|
||||
import com.lz.modules.sys.entity.app.ResultDetail;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@ -36,4 +38,7 @@ public interface ResultDetailMapper extends BaseMapper<ResultDetail> {
|
||||
List<ResultDetail> selectByRecordId(@Param("recordResultId") Long recordResultId);
|
||||
|
||||
List<ResultDetail> selectByRecordIdType(@Param("recordResultId") Long recordResultId, @Param("type") Integer type);
|
||||
|
||||
//计算业务/价值观得分
|
||||
BigDecimal calculateScore(@Param("recordId") Long recordId, @Param("staffId") Long staffId,@Param("type") Integer type);
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.lz.modules.sys.service.app;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.lz.common.utils.PageUtils;
|
||||
import com.lz.modules.app.dto.DepartmentsDto;
|
||||
import com.lz.modules.app.dto.GraphicsStatisticalDto;
|
||||
@ -8,6 +9,7 @@ import com.lz.modules.app.dto.ReportProgressListDto;
|
||||
import com.lz.modules.app.req.ReportListReq;
|
||||
import com.lz.modules.app.req.ResultDistributionReq;
|
||||
import com.lz.modules.app.resp.ReportChartResp;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -39,7 +41,6 @@ public interface ChartService {
|
||||
|
||||
boolean leader(Long staffId);
|
||||
|
||||
|
||||
|
||||
List<ReportProgressListDto> targetReportList(ReportListReq req, List<String> staffIds, IPage page);
|
||||
|
||||
}
|
||||
|
||||
@ -3,12 +3,10 @@ package com.lz.modules.sys.service.app.impl;
|
||||
import cn.hutool.core.util.PageUtil;
|
||||
import com.alibaba.druid.sql.PagerUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.lz.common.utils.BigDecimalUtil;
|
||||
import com.lz.common.utils.ListUtils;
|
||||
import com.lz.common.utils.PageUtils;
|
||||
import com.lz.common.utils.StringUtil;
|
||||
import com.lz.common.utils.*;
|
||||
import com.lz.modules.app.dao.DepartmentsDao;
|
||||
import com.lz.modules.app.dao.DepartmentsStaffRelateDao;
|
||||
import com.lz.modules.app.dao.StaffDao;
|
||||
@ -24,6 +22,7 @@ import com.lz.modules.app.resp.ReportChartResp;
|
||||
import com.lz.modules.app.service.StaffService;
|
||||
import com.lz.modules.flow.dao.StaffRoleMapper;
|
||||
import com.lz.modules.flow.entity.StaffRole;
|
||||
import com.lz.modules.sys.dao.app.ResultDetailMapper;
|
||||
import com.lz.modules.sys.dao.app.ResultRecordMapper;
|
||||
import com.lz.modules.sys.entity.app.ResultRecord;
|
||||
import com.lz.modules.sys.service.app.ChartService;
|
||||
@ -34,6 +33,7 @@ import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -42,6 +42,7 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @Author: djc
|
||||
@ -65,6 +66,8 @@ public class ChartServiceImpl implements ChartService {
|
||||
private DepartmentsDao departmentsDao;
|
||||
@Autowired
|
||||
private StaffRoleMapper staffRoleMapper;
|
||||
@Autowired
|
||||
private ResultDetailMapper resultDetailMapper;
|
||||
|
||||
static final String[] levels = new String[]{"3.25","3.5-","3.5","3.5+","3.75-","3.75","3.75+","4"};
|
||||
|
||||
@ -163,7 +166,19 @@ public class ChartServiceImpl implements ChartService {
|
||||
copyStaffIds.addAll(staffIds);
|
||||
|
||||
if(req.getStatus()!=null){
|
||||
if(req.getStatus() == ResultRecordStatusEnum.CREATE.getStatus()){ // 状态为0的数据存在两张表,单独处理
|
||||
|
||||
if(req.getStatus() != ResultRecordStatusEnum.CREATE.getStatus()){
|
||||
//获取真实状态
|
||||
List<Integer> groupStatus = ResultRecordStatusEnum.getGroupStatus(req.getStatus());
|
||||
req.setRealStatus(groupStatus);
|
||||
//获取处理过业绩目标的人员
|
||||
PageUtils pageUtils = PageUtils.startPage(req.getCurrPage(),req.getPageSize()).doSelect(
|
||||
page -> this.targetReportList(req, staffIds, page)
|
||||
);
|
||||
return pageUtils;
|
||||
|
||||
}else { // 状态为0的数据存在两张表,单独处理
|
||||
|
||||
//获取已提交人员
|
||||
List<String> commitStaffIds = new ArrayList<>();
|
||||
List<Object> collect=resultRecordService.listObjs(new QueryWrapper<ResultRecord>()
|
||||
@ -181,23 +196,20 @@ public class ChartServiceImpl implements ChartService {
|
||||
staffIds.removeAll(commitStaffIds);
|
||||
return buildPageByStaffIds(req,staffIds);
|
||||
|
||||
}else {
|
||||
//获取真实状态
|
||||
List<Integer> groupStatus = ResultRecordStatusEnum.getGroupStatus(req.getStatus());
|
||||
req.setRealStatus(groupStatus);
|
||||
//获取处理过业绩目标的人员
|
||||
PageUtils pageUtils = PageUtils.startPage(req.getCurrPage(),req.getPageSize()).doSelect(
|
||||
page -> resultRecordMapper.targetReportList(req, staffIds, page)
|
||||
);
|
||||
return pageUtils;
|
||||
}
|
||||
|
||||
}else{ // 查询所有,需要拼装数据 ,先查询已提交得剩余得 用未提交缺多少补多少
|
||||
|
||||
//查询全部 思路 result record 全部查完,记录的用户id 取出, 部门下所有的用户剔除掉这些 就是剩下未提交的用户
|
||||
|
||||
PageUtils pageUtils = PageUtils.startPage(req.getCurrPage(),req.getPageSize()).doSelect(
|
||||
page -> resultRecordMapper.targetReportList(req, staffIds, page)
|
||||
page -> this.targetReportList(req, staffIds, page)
|
||||
);
|
||||
List<ReportProgressListDto> list = pageUtils.getList();
|
||||
|
||||
|
||||
List<ReportProgressListDto> copyList = new ArrayList<>();
|
||||
copyList.addAll(list);
|
||||
int totalPage = pageUtils.getTotalPage();
|
||||
|
||||
/*************************************数据拼接逻辑****************************************/
|
||||
@ -213,7 +225,14 @@ public class ChartServiceImpl implements ChartService {
|
||||
if(CollectionUtils.isNotEmpty(objects)){
|
||||
commitStaffIds = objects.stream().map(o -> o.toString()).collect(Collectors.toList());
|
||||
}
|
||||
//去除已提交的
|
||||
staffIds.removeAll(commitStaffIds);
|
||||
//防止真实状态为未提交的 又重新拼接
|
||||
if(CollectionUtils.isNotEmpty(list)){
|
||||
List<String> collect = list.stream().map(reportProgressListDto -> reportProgressListDto.getStaffId()).collect(Collectors.toList());
|
||||
staffIds.removeAll(collect);
|
||||
}
|
||||
|
||||
if(CollectionUtils.isEmpty(staffIds)){
|
||||
return pageUtils;
|
||||
}
|
||||
@ -225,27 +244,27 @@ public class ChartServiceImpl implements ChartService {
|
||||
copyReq.setCurrPage(pageUtils.getTotalPage());
|
||||
copyReq.setPageSize(req.getPageSize());
|
||||
PageUtils ps = PageUtils.startPage(copyReq.getCurrPage(),copyReq.getPageSize()).doSelect(
|
||||
page -> resultRecordMapper.targetReportList(copyReq, copyStaffIds, page)
|
||||
page -> this.targetReportList(copyReq, copyStaffIds, page)
|
||||
);
|
||||
int sub = ps.getList().size();
|
||||
addStart = (addStart-1) * req.getPageSize() + (copyReq.getPageSize()-sub);
|
||||
}
|
||||
int addEnd = addSize + addStart;
|
||||
addEnd = addEnd>staffIds.size()?staffIds.size():addEnd;
|
||||
addStart = addStart>staffIds.size()?0:addStart;
|
||||
List<String> addList = staffIds.subList(addStart,addEnd);
|
||||
copyReq.setCurrPage(0);
|
||||
copyReq.setPageSize(addSize);
|
||||
PageUtils addResult = buildPageByStaffIds(copyReq, addList);
|
||||
staffIds.addAll(commitStaffIds);
|
||||
PageUtils data = new PageUtils();
|
||||
list.addAll(addResult.getList());
|
||||
data.setList(list);
|
||||
copyList.addAll(addResult.getList());
|
||||
data.setList(copyList);
|
||||
data.setPageSize(req.getPageSize());
|
||||
data.setCurrPage(req.getCurrPage());
|
||||
data.setTotalCount(copyStaffIds.size());
|
||||
data.setTotalPage(PageUtil.totalPage(copyStaffIds.size(),req.getPageSize()));
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
PageUtils data = new PageUtils();
|
||||
@ -307,7 +326,7 @@ public class ChartServiceImpl implements ChartService {
|
||||
public boolean hrOrBoss(Long staffId) {
|
||||
log.info("hrOrBoss判断 : " + staffId);
|
||||
//超级管理员
|
||||
if(1==staffId){
|
||||
if(Constant.SUPER_ADMIN==staffId){
|
||||
return true;
|
||||
}
|
||||
StaffRole staffRole = staffRoleMapper.selectByStaffId(staffId);
|
||||
@ -321,16 +340,45 @@ public class ChartServiceImpl implements ChartService {
|
||||
public boolean leader(Long staffId) {
|
||||
log.info("leader判断 : " + staffId);
|
||||
//超级管理员
|
||||
if(1==staffId){
|
||||
if(Constant.SUPER_ADMIN==staffId){
|
||||
return true;
|
||||
}
|
||||
DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateDao.selectByStaffId(staffId);
|
||||
if(departmentsStaffRelateEntity!=null && "1".equals(departmentsStaffRelateEntity.getIsLeader())){
|
||||
if(departmentsStaffRelateEntity!=null && 1 == departmentsStaffRelateEntity.getIsLeader()){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ReportProgressListDto> targetReportList(ReportListReq req, List<String> staffIds, IPage page) {
|
||||
List<ReportProgressListDto> reportProgressListDtos = resultRecordMapper.targetReportList(req, staffIds, page);
|
||||
//由于使用了 maxId 需要拿到id 获取最新数据
|
||||
if(CollectionUtils.isNotEmpty(reportProgressListDtos)){
|
||||
reportProgressListDtos.forEach(reportProgressListDto -> {
|
||||
Long id = reportProgressListDto.getId();
|
||||
String staffId = reportProgressListDto.getStaffId();
|
||||
ResultRecord resultRecord = resultRecordMapper.selectById(id);
|
||||
reportProgressListDto.setAllScore(resultRecord.getAllScore() + "");
|
||||
reportProgressListDto.setStatus(resultRecord.getStatus());
|
||||
reportProgressListDto.setScoreLevel(resultRecord.getScoreLevel());
|
||||
|
||||
//获取业务 ,价值观得分
|
||||
BigDecimal businessScore = resultDetailMapper.calculateScore(id, Long.valueOf(staffId), 1);
|
||||
BigDecimal valueScore = resultDetailMapper.calculateScore(id, Long.valueOf(staffId), 2);
|
||||
if(businessScore!=null && !businessScore.equals(new BigDecimal("0.0"))){
|
||||
reportProgressListDto.setBusinessScore(businessScore + "");
|
||||
}
|
||||
if(valueScore!=null && !valueScore.equals(new BigDecimal("0.0"))){
|
||||
reportProgressListDto.setValueScore(valueScore + "");
|
||||
}
|
||||
});
|
||||
return reportProgressListDtos;
|
||||
}
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
|
||||
private String getBussinessLine(String departmentId){
|
||||
DepartmentsEntity departmentsEntity = departmentsDao.selectByDepartmentId(departmentId);
|
||||
if("1".equals(departmentsEntity.getDepartmentParentId())){
|
||||
@ -395,8 +443,14 @@ public class ChartServiceImpl implements ChartService {
|
||||
List<String> selectStaffIds = dataList.stream().map(reportProgressListDto -> reportProgressListDto.getStaffId()).collect(Collectors.toList());
|
||||
List<ReportProgressListDto> departmentNameByStaffIds = departmentsStaffRelateDao.getDepartmentNameByStaffIds(selectStaffIds);
|
||||
Map<String,String> map = Maps.newHashMap();
|
||||
departmentNameByStaffIds.forEach(reportProgressListDto -> map.put(reportProgressListDto.getStaffId(),reportProgressListDto.getDepartmentName()));
|
||||
dataList.forEach(reportProgressListDto -> reportProgressListDto.setDepartmentName(map.get(reportProgressListDto.getStaffId())));
|
||||
departmentNameByStaffIds.forEach(reportProgressListDto -> {
|
||||
map.put(reportProgressListDto.getStaffId(), reportProgressListDto.getDepartmentName());
|
||||
});
|
||||
dataList.forEach(reportProgressListDto -> {
|
||||
reportProgressListDto.setDepartmentName(map.get(reportProgressListDto.getStaffId()));
|
||||
reportProgressListDto.setAllScore("0.0");
|
||||
reportProgressListDto.setScoreLevel("0");
|
||||
});
|
||||
return pageUtils;
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,6 +140,10 @@
|
||||
</select>
|
||||
|
||||
|
||||
<select id="calculateScore" resultType="BigDecimal">
|
||||
SELECT sum(check_weight * acquire_score) from lz_result_detail where is_delete = 0
|
||||
and record_id = #{recordId} and staff_id = #{staffId} and type = #{type}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
||||
@ -290,12 +290,17 @@
|
||||
|
||||
|
||||
<select id="targetReportList" resultType="com.lz.modules.app.dto.ReportProgressListDto">
|
||||
|
||||
SELECT max(r.id) id,r.staff_id ,staff_name,status,position,department_name from lz_result_record r
|
||||
SELECT max(r.id) id,r.staff_id ,staff_name,position,department_name from lz_result_record r
|
||||
LEFT JOIN lz_staff_occupation o
|
||||
on r.staff_id = o.staff_id
|
||||
where r.is_delete=0 and o.is_delete=0
|
||||
where o.is_delete=0
|
||||
<if test="req.type !=null ">
|
||||
<if test="req.type == 1">
|
||||
and r.is_delete=2
|
||||
</if>
|
||||
<if test="req.type == 2">
|
||||
and r.is_delete=0
|
||||
</if>
|
||||
and type = #{req.type}
|
||||
</if>
|
||||
<if test="staffIds !=null and staffIds.size() !=0">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user