提交修改

This commit is contained in:
quyixiao 2020-09-19 15:15:57 +08:00
commit 7ae003d594
16 changed files with 200 additions and 57 deletions

View File

@ -1,9 +1,10 @@
package com.lz.modules.app.controller; package com.lz.modules.app.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Maps;
import com.lz.common.utils.R; import com.lz.common.utils.R;
import com.lz.modules.app.dto.DepartmentsDto; import com.lz.common.utils.StringUtil;
import com.lz.modules.app.dto.ResultProgressDto; import com.lz.modules.app.dto.*;
import com.lz.modules.app.entity.DepartmentsStaffRelateEntity; import com.lz.modules.app.entity.DepartmentsStaffRelateEntity;
import com.lz.modules.app.entity.StaffEntity; import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.enums.ResultRecordStatusEnum; import com.lz.modules.app.enums.ResultRecordStatusEnum;
@ -22,10 +23,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.time.LocalDate;
import java.util.Calendar; import java.util.*;
import java.util.Date;
import java.util.List;
/** /**
* @Author: djc * @Author: djc
@ -46,26 +45,55 @@ public class ReportResultController extends AbstractController{
@Autowired @Autowired
private ChartService chartService; private ChartService chartService;
static final String[] levels = new String[]{"3.25","3.5-","3.5","3.5+","3.75-","3.75","3.75+","4"};
@RequestMapping("chart") @RequestMapping("chart")
public R reportChart(String monthTime){ public R reportChart(String monthTime){
if(StringUtil.isBlank(monthTime)){
String time = LocalDate.now().toString();
monthTime = time.substring(0,time.length()-3);
}
ReportChartResp data = new ReportChartResp(); ReportChartResp data = new ReportChartResp();
ResultProgressDto target = chartService.resultProgress(ResultRecordTypeEnum.TARGET.getType(),monthTime); //月初目标
ResultProgressDto result = chartService.resultProgress(ResultRecordTypeEnum.RESULT.getType(),monthTime); List<GraphicsStatisticalDto> start = chartService.resultProgressDistribution(ResultRecordTypeEnum.TARGET.getType(),monthTime);
//月末结果
List<GraphicsStatisticalDto> end = chartService.resultProgressDistribution(ResultRecordTypeEnum.RESULT.getType(),monthTime);
//人员等级分布 //人员等级分布
List<GraphicsStatisticalDto> staffLevels = resultRecordService.staffDistribution(monthTime);
List<GraphicsStatisticalDto> sortStaffLevels = new ArrayList<>();
// 0人是否需要展示
Map<String,Integer> map = Maps.newHashMap();
for (GraphicsStatisticalDto staffLevel : staffLevels) {
map.put(staffLevel.getCategory(),staffLevel.getNumber());
}
// 默认等级赋予默认值并排序
for (String level : levels) {
GraphicsStatisticalDto dto = new GraphicsStatisticalDto();
dto.setCategory(level);
if(!map.containsKey(level)){
dto.setNumber(0);
}else {
dto.setNumber(map.get(level));
}
sortStaffLevels.add(dto);
}
//部门等级占比 //部门等级占比
GraphicsDto dto = new GraphicsDto();
dto.setRows(start);
data.setTarget(target); data.setTargetDistribution(dto);
data.setResult(result); dto = new GraphicsDto();
dto.setRows(end);
data.setResultDistribution(dto);
dto = new GraphicsDto();
dto.setRows(sortStaffLevels);
data.setStaffDistribution(dto);
return R.ok().put("data",data); return R.ok().put("data",data);
} }
@RequestMapping("/own/result") @RequestMapping("/own/result")
public R ownResult(Long userId){ public R ownResult(Long userId){
if(userId == null){ if(userId == null){
@ -101,14 +129,6 @@ public class ReportResultController extends AbstractController{
} }
public static void main(String[] args) {
List<String> list = getMonthBetween("2018-01","2018-07");
for(String s : list){
System.out.println("日期:"+s);
}
}
//获取日期之内的月份 //获取日期之内的月份
private static List<String> getMonthBetween(String minDate, String maxDate){ private static List<String> getMonthBetween(String minDate, String maxDate){
@ -135,4 +155,5 @@ public class ReportResultController extends AbstractController{
return result; return result;
} }
} }

View File

@ -42,4 +42,7 @@ public interface DepartmentsDao extends BaseMapper<DepartmentsEntity> {
int addDepartment(@Param("departments") DepartmentsEntity departments); int addDepartment(@Param("departments") DepartmentsEntity departments);
DepartmentInfos selectUserAllDepartmentIds(@Param("departmentId") String departmentId); DepartmentInfos selectUserAllDepartmentIds(@Param("departmentId") String departmentId);
List<String> selectDepartmentIdsByparentIds(@Param("parentIds") List parentIds);
} }

View File

@ -0,0 +1,16 @@
package com.lz.modules.app.dto;
import lombok.Data;
/**
* @Author: djc
* @Desc:
* @Date: 2020/9/16 16:39
*/
@Data
public class ChartDto {
//属性名
private String name;
//属性值
private String value;
}

View File

@ -1,18 +0,0 @@
package com.lz.modules.app.dto;
import lombok.Data;
/**
* @Author: djc
* @Desc:
* @Date: 2020/9/14 16:34
*/
@Data
public class ResultProgressDto {
//未提交
private int noCommit;
//完成
private int finished;
//审核中
private int review;
}

View File

@ -1,8 +1,12 @@
package com.lz.modules.app.resp; package com.lz.modules.app.resp;
import com.lz.modules.app.dto.ResultProgressDto; import com.lz.modules.app.dto.ChartDto;
import com.lz.modules.app.dto.GraphicsDto;
import com.lz.modules.app.dto.GraphicsStatisticalDto;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* @Author: djc * @Author: djc
* @Desc: * @Desc:
@ -11,8 +15,12 @@ import lombok.Data;
@Data @Data
public class ReportChartResp { public class ReportChartResp {
//月初目标 //月初目标
private ResultProgressDto target; private GraphicsDto targetDistribution;
//月末结果 //月末结果
private ResultProgressDto result; private GraphicsDto resultDistribution;
//个人等级占比
private GraphicsDto staffDistribution;
//部门等级占比
private GraphicsDto departmentDistribution;
} }

View File

@ -44,5 +44,6 @@ public interface DepartmentsService extends IService<DepartmentsEntity> {
Map<String,String> selectUserAllDepartmentInFo(String departmentId); Map<String,String> selectUserAllDepartmentInFo(String departmentId);
} }

View File

@ -77,5 +77,8 @@ public interface StaffService extends IService<StaffEntity> {
List<StaffEntity> selectBySearchName(IPage page, FindByNameModel nameModel); List<StaffEntity> selectBySearchName(IPage page, FindByNameModel nameModel);
SysUserEntity getUser(String userName); SysUserEntity getUser(String userName);
//查询部门下的所有人员 包括子部门下人员
List<Long> selectAllStaffByDepartmentId(String departmentId);
} }

View File

@ -200,5 +200,4 @@ public class DepartmentsServiceImpl extends ServiceImpl<DepartmentsDao, Departme
return map; return map;
} }
} }

View File

@ -10,10 +10,8 @@ import com.lz.common.utils.DateUtils;
import com.lz.common.utils.PageUtils; import com.lz.common.utils.PageUtils;
import com.lz.common.utils.Query; import com.lz.common.utils.Query;
import com.lz.common.utils.R; import com.lz.common.utils.R;
import com.lz.modules.app.dto.GraphicsStatisticalDto; import com.lz.modules.app.dao.DepartmentsDao;
import com.lz.modules.app.dto.StaffBaseInfoDto; import com.lz.modules.app.dto.*;
import com.lz.modules.app.dto.StaffDto;
import com.lz.modules.app.dto.StaffStatisticalDto;
import com.lz.modules.app.dao.StaffDao; import com.lz.modules.app.dao.StaffDao;
import com.lz.modules.app.entity.*; import com.lz.modules.app.entity.*;
import com.lz.modules.app.service.*; import com.lz.modules.app.service.*;
@ -21,10 +19,12 @@ import com.lz.modules.equipment.entity.model.FindByNameModel;
import com.lz.modules.job.model.responseBo.DepartmentStaffBo; import com.lz.modules.job.model.responseBo.DepartmentStaffBo;
import com.lz.modules.sys.entity.SysUserEntity; import com.lz.modules.sys.entity.SysUserEntity;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -48,6 +48,8 @@ public class StaffServiceImpl extends ServiceImpl<StaffDao, StaffEntity> impleme
DepartmentsService departmentsService; DepartmentsService departmentsService;
@Resource @Resource
DepartmentsStaffRelateService departmentsStaffRelateService; DepartmentsStaffRelateService departmentsStaffRelateService;
@Autowired
private DepartmentsDao departmentsDao;
@ -379,4 +381,32 @@ public class StaffServiceImpl extends ServiceImpl<StaffDao, StaffEntity> impleme
return staffEntity; return staffEntity;
} }
@Override
public List<Long> selectAllStaffByDepartmentId(String departmentId) {
//154344269,154322459,154274609,154254673
List<String> parentsIds = Lists.newArrayList("154344269","154322459","154274609","154254673");
List<String> departmentsList = new ArrayList<>();
return null;
}
/**
*
* @param departmentsList 最终的存储集合
* @param parentIds 本次查询的父id集合
* @return
*/
private List<String> getAllChilds(List<String> departmentsList,List<String> parentIds){
List<String> childs = departmentsDao.selectDepartmentIdsByparentIds(parentIds);
/* while (childs!=null){
}*/
return null;
}
} }

View File

@ -10,6 +10,8 @@ package com.lz.modules.sys.dao.app;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lz.modules.app.dto.ChartDto;
import com.lz.modules.app.dto.GraphicsStatisticalDto;
import com.lz.modules.app.req.ResultRecordReq; import com.lz.modules.app.req.ResultRecordReq;
import com.lz.modules.app.resp.OwnResultResp; import com.lz.modules.app.resp.OwnResultResp;
import com.lz.modules.flow.model.ResultRecordDto; import com.lz.modules.flow.model.ResultRecordDto;
@ -52,4 +54,12 @@ public interface ResultRecordMapper extends BaseMapper<ResultRecord> {
List<ResultRecord> selectResultRecordByIds(@Param("recordIds") List<Long> recordIds); List<ResultRecord> selectResultRecordByIds(@Param("recordIds") List<Long> recordIds);
List<OwnResultResp> ownResult(@Param("userId") Long userId, @Param("status") int status); List<OwnResultResp> ownResult(@Param("userId") Long userId, @Param("status") int status);
List<GraphicsStatisticalDto> staffDistribution(@Param("monthTime") String monthTime);
List<ChartDto> departmentDistribution(@Param("monthTime") String monthTime);
} }

View File

@ -1,6 +1,7 @@
package com.lz.modules.sys.service.app; package com.lz.modules.sys.service.app;
import com.lz.modules.app.dto.ResultProgressDto; import com.lz.modules.app.dto.ChartDto;
import com.lz.modules.app.dto.GraphicsStatisticalDto;
import java.util.List; import java.util.List;
@ -11,7 +12,14 @@ import java.util.List;
*/ */
public interface ChartService { public interface ChartService {
ResultProgressDto resultProgress(int type,String monthTime); /**
* 查询当月绩效提交情况
* @param type
* @param monthTime
* @return
*/
List<GraphicsStatisticalDto> resultProgressDistribution(int type, String monthTime);
} }

View File

@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.lz.common.emun.WorkMsgTypeEnum; import com.lz.common.emun.WorkMsgTypeEnum;
import com.lz.common.utils.PageUtils; import com.lz.common.utils.PageUtils;
import com.lz.common.utils.R; import com.lz.common.utils.R;
import com.lz.modules.app.dto.ChartDto;
import com.lz.modules.app.dto.GraphicsStatisticalDto;
import com.lz.modules.app.entity.StaffEntity; import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.req.ResultRecordReq; import com.lz.modules.app.req.ResultRecordReq;
import com.lz.modules.app.resp.OwnResultResp; import com.lz.modules.app.resp.OwnResultResp;
@ -70,5 +72,18 @@ public interface ResultRecordService extends IService<ResultRecord> {
List<OwnResultResp> ownResult(Long userId, int status); List<OwnResultResp> ownResult(Long userId, int status);
/**
* 人员等级排布
* @param monthTime
* @return
*/
List<GraphicsStatisticalDto> staffDistribution(String monthTime);
/**
* 部门等级占比
* @param monthTime
* @return
*/
List<ChartDto> departmentDistribution(String monthTime);
} }

View File

@ -1,16 +1,22 @@
package com.lz.modules.sys.service.app.impl; package com.lz.modules.sys.service.app.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lz.modules.app.dto.ResultProgressDto; import com.lz.common.utils.StringUtil;
import com.lz.modules.app.dto.ChartDto;
import com.lz.modules.app.dto.GraphicsStatisticalDto;
import com.lz.modules.app.entity.StaffEntity; import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.enums.ResultRecordStatusEnum; import com.lz.modules.app.enums.ResultRecordStatusEnum;
import com.lz.modules.app.service.StaffService; import com.lz.modules.app.service.StaffService;
import com.lz.modules.sys.entity.app.ResultRecord; import com.lz.modules.sys.entity.app.ResultRecord;
import com.lz.modules.sys.service.app.ChartService; import com.lz.modules.sys.service.app.ChartService;
import com.lz.modules.sys.service.app.ResultRecordService; import com.lz.modules.sys.service.app.ResultRecordService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/** /**
* @Author: djc * @Author: djc
* @Desc: * @Desc:
@ -23,8 +29,8 @@ public class ChartServiceImpl implements ChartService {
@Autowired @Autowired
private StaffService staffService; private StaffService staffService;
@Override @Override
public ResultProgressDto resultProgress(int type, String monthTime) { public List<GraphicsStatisticalDto> resultProgressDistribution(int type, String monthTime) {
ResultProgressDto resultProgressDto = new ResultProgressDto(); List<GraphicsStatisticalDto> dtos = new ArrayList<>();
int total = staffService.count(new QueryWrapper<StaffEntity>().eq("is_delete", 0)); int total = staffService.count(new QueryWrapper<StaffEntity>().eq("is_delete", 0));
int commit = resultRecordService.count(new QueryWrapper<ResultRecord>() int commit = resultRecordService.count(new QueryWrapper<ResultRecord>()
@ -38,9 +44,19 @@ public class ChartServiceImpl implements ChartService {
.like("month_time",monthTime) .like("month_time",monthTime)
.in("status", ResultRecordStatusEnum.REFUSE.getStatus(),ResultRecordStatusEnum.AGREE.getStatus())); .in("status", ResultRecordStatusEnum.REFUSE.getStatus(),ResultRecordStatusEnum.AGREE.getStatus()));
resultProgressDto.setNoCommit(total-commit); GraphicsStatisticalDto dto = new GraphicsStatisticalDto();
resultProgressDto.setFinished(finished); dto.setCategory("未提交");
resultProgressDto.setReview(commit-finished); dto.setNumber(total-commit);
return resultProgressDto; dtos.add(dto);
dto = new GraphicsStatisticalDto();
dto.setCategory("已完成");
dto.setNumber(finished);
dtos.add(dto);
dto = new GraphicsStatisticalDto();
dto.setCategory("审核中");
dto.setNumber(commit-finished);
dtos.add(dto);
return dtos;
} }
} }

View File

@ -7,7 +7,9 @@ import com.lz.common.emun.WorkMsgTypeEnum;
import com.lz.common.utils.*; import com.lz.common.utils.*;
import com.lz.modules.app.dao.DepartmentsDao; import com.lz.modules.app.dao.DepartmentsDao;
import com.lz.modules.app.dao.DepartmentsStaffRelateDao; import com.lz.modules.app.dao.DepartmentsStaffRelateDao;
import com.lz.modules.app.dto.ChartDto;
import com.lz.modules.app.dto.EmployeesDto; import com.lz.modules.app.dto.EmployeesDto;
import com.lz.modules.app.dto.GraphicsStatisticalDto;
import com.lz.modules.app.entity.DepartmentsEntity; import com.lz.modules.app.entity.DepartmentsEntity;
import com.lz.modules.app.entity.DepartmentsStaffRelateEntity; import com.lz.modules.app.entity.DepartmentsStaffRelateEntity;
import com.lz.modules.app.entity.StaffEntity; import com.lz.modules.app.entity.StaffEntity;
@ -615,4 +617,14 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
public List<OwnResultResp> ownResult(Long userId, int status) { public List<OwnResultResp> ownResult(Long userId, int status) {
return resultRecordMapper.ownResult(userId,status); return resultRecordMapper.ownResult(userId,status);
} }
@Override
public List<GraphicsStatisticalDto> staffDistribution(String monthTime) {
return resultRecordMapper.staffDistribution(monthTime);
}
@Override
public List<ChartDto> departmentDistribution(String monthTime) {
return resultRecordMapper.departmentDistribution(monthTime);
}
} }

View File

@ -257,5 +257,15 @@
<select id="ownResult" resultType="com.lz.modules.app.resp.OwnResultResp"> <select id="ownResult" resultType="com.lz.modules.app.resp.OwnResultResp">
SELECT last_score,DATE_FORMAT(month_time, '%Y-%m') month_time from lz_result_record where is_delete=0 and status = #{status} and type=2 and staff_id = #{userId} ORDER BY month_time limit 6 SELECT last_score,DATE_FORMAT(month_time, '%Y-%m') month_time from lz_result_record where is_delete=0 and status = #{status} and type=2 and staff_id = #{userId} ORDER BY month_time limit 6
</select> </select>
<select id="staffDistribution" resultType="com.lz.modules.app.dto.GraphicsStatisticalDto">
SELECT count(score_level) number ,CASE score_level when 0 THEN '未知' ELSE score_level END category from lz_result_record where is_delete = 0 and status =4 and type =2 and DATE_FORMAT(month_time,'%Y-%m') = #{monthTime} GROUP BY score_level
</select>
<select id="departmentDistribution" resultType="com.lz.modules.app.dto.ChartDto">
SELECT count(score_level) value,score_level name from lz_result_record where is_delete = 0 and status =4 and type =2 and DATE_FORMAT(month_time,'%Y-%m') = #{monthTime} GROUP BY score_level
</select>
</mapper> </mapper>

View File

@ -116,4 +116,13 @@
where d1.department_id = #{departmentId} where d1.department_id = #{departmentId}
</select> </select>
<select id="selectDepartmentIdsByparentIds" resultType="String">
select department_id from lz_departments where is_delete=0 and department_parent_id IN
<foreach collection="parentIds" item="id" open="(" close=")"
separator=",">
#{id}
</foreach>
</select>
</mapper> </mapper>