add statistical

This commit is contained in:
fumeiai 2020-05-19 14:17:42 +08:00
parent f75bc6c30e
commit 98ce36f75e
13 changed files with 138 additions and 28 deletions

43
.idea/workspace.xml generated
View File

@ -2,26 +2,19 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="e4baaf01-a2c2-445d-98a1-9f4c50c148cf" name="Default Changelist" comment=""> <list default="true" id="e4baaf01-a2c2-445d-98a1-9f4c50c148cf" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/Dto/StaffStatisticalDto.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/dao/DepartmentsStaffRelateDao.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/dao/DepartmentsStaffRelateDao.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/controller/StaffController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/controller/StaffController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/dao/StaffOccupationDao.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/dao/StaffOccupationDao.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/dao/StaffDao.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/dao/StaffDao.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/DepartmentsStaffRelateService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/DepartmentsStaffRelateService.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/StaffService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/StaffService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/StaffOccupationService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/StaffOccupationService.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/DepartmentsStaffRelateServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/DepartmentsStaffRelateServiceImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffOccupationServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffOccupationServiceImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/job/business/FeishuBusiness.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/job/business/FeishuBusiness.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/oauth2/OAuth2Filter.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/oauth2/OAuth2Filter.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/oauth2/OAuth2Filter.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/oauth2/OAuth2Filter.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/mapper/generator/DepartmentsStaffRelateDao.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mapper/generator/DepartmentsStaffRelateDao.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/resources/mapper/generator/StaffDao.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mapper/generator/StaffDao.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/mapper/generator/StaffOccupationDao.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mapper/generator/StaffOccupationDao.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/controller/StaffController.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/controller/StaffController.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/dao/DepartmentsStaffRelateDao.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/dao/DepartmentsStaffRelateDao.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/dao/StaffDao.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/dao/StaffDao.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/dao/StaffOccupationDao.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/dao/StaffOccupationDao.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/StaffService.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/StaffService.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/DepartmentsStaffRelateService.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/DepartmentsStaffRelateService.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/impl/StaffServiceImpl.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/impl/StaffServiceImpl.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/StaffOccupationService.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/StaffOccupationService.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/target/classes/mapper/generator/StaffDao.xml" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/mapper/generator/StaffDao.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/impl/DepartmentsStaffRelateServiceImpl.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/impl/DepartmentsStaffRelateServiceImpl.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/impl/StaffOccupationServiceImpl.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/impl/StaffOccupationServiceImpl.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/job/business/FeishuBusiness.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/job/business/FeishuBusiness.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/mapper/generator/DepartmentsStaffRelateDao.xml" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/mapper/generator/DepartmentsStaffRelateDao.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/mapper/generator/StaffOccupationDao.xml" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/mapper/generator/StaffOccupationDao.xml" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -169,7 +162,7 @@
<workItem from="1588159936850" duration="1226000" /> <workItem from="1588159936850" duration="1226000" />
<workItem from="1588161274115" duration="1691000" /> <workItem from="1588161274115" duration="1691000" />
<workItem from="1588163384182" duration="74761000" /> <workItem from="1588163384182" duration="74761000" />
<workItem from="1588936950753" duration="69525000" /> <workItem from="1588936950753" duration="75394000" />
</task> </task>
<servers /> <servers />
</component> </component>
@ -224,7 +217,7 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="java-line"> <line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java</url> <url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java</url>
<line>79</line> <line>80</line>
<option name="timeStamp" value="62" /> <option name="timeStamp" value="62" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="java-line"> <line-breakpoint enabled="true" type="java-line">
@ -237,6 +230,16 @@
<line>80</line> <line>80</line>
<option name="timeStamp" value="67" /> <option name="timeStamp" value="67" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/app/controller/StaffController.java</url>
<line>156</line>
<option name="timeStamp" value="73" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/app/controller/StaffController.java</url>
<line>157</line>
<option name="timeStamp" value="74" />
</line-breakpoint>
</breakpoints> </breakpoints>
</breakpoint-manager> </breakpoint-manager>
</component> </component>

View File

@ -0,0 +1,24 @@
package com.lz.modules.app.Dto;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class StaffStatisticalDto {
//总人数
private int totalStaffCount;
//管理人员人数
private int managementCount;
//管理人员占比
private BigDecimal managementRate;
//新入职员工人数
private int newStaffCount;
//离职人员人数
private int leaveStaffCount;
//离职率
private BigDecimal leaveRate;
}

View File

@ -6,8 +6,12 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lz.common.utils.DateUtils;
import com.lz.modules.app.Dto.*; import com.lz.modules.app.Dto.*;
import com.lz.modules.app.entity.DepartmentsEntity;
import com.lz.modules.app.service.*; import com.lz.modules.app.service.*;
import com.lz.modules.sys.entity.SysCaptchaEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@ -34,6 +38,9 @@ public class StaffController {
@Autowired @Autowired
private StaffService staffService; private StaffService staffService;
@Autowired
private DepartmentsService departmentsService;
@Autowired @Autowired
private StaffEducationService staffEducationService; private StaffEducationService staffEducationService;
@ -127,13 +134,13 @@ public class StaffController {
@RequestMapping("/statistical") @RequestMapping("/statistical")
// @RequiresPermissions("staff:info:statistical") // @RequiresPermissions("staff:info:statistical")
public R statistical(@RequestParam Map<String, Object> params) { public R statistical(@RequestParam Map<String, Object> params) {
Map data = new HashMap();
//部门Id //部门Id
String departmentId = ""; String departmentId = "";
//统计时间起 //统计时间起
String beginDate = ""; String beginDate = "2017-01-01";
//统计时间止 //统计时间止
String endDate = ""; String endDate = DateUtils.format(DateUtils.getCurrentDate(), DateUtils.DATE_PATTERN);
if (params.containsKey("departmentId")) { if (params.containsKey("departmentId")) {
departmentId = params.get("departmentId").toString(); departmentId = params.get("departmentId").toString();
@ -146,14 +153,24 @@ public class StaffController {
if (params.containsKey("endDate")) { if (params.containsKey("endDate")) {
endDate = params.get("endDate").toString(); endDate = params.get("endDate").toString();
} }
//
// List<StaffDto> staffInfos = staffService.getStaffInfos(currentPage, limit, departmentId, name, staffStatus); StaffStatisticalDto staffStatisticals = staffService.getStatisticalData(departmentId, beginDate, endDate);
data = JSON.parseObject(JSON.toJSONString(staffStatisticals), Map.class);
data.put("beginDate", beginDate);
data.put("endDate", endDate);
if (departmentId != "") {
DepartmentsEntity department = departmentsService.getOne(new QueryWrapper<DepartmentsEntity>().eq("department_id", departmentId));
if (department != null) {
data.put("departmentName", department.getDepartmentName());
}
}
// //总页码 // //总页码
// int maxCount = staffService.getStaffInfoCount(departmentId, name, staffStatus); // int maxCount = staffService.getStaffInfoCount(departmentId, name, staffStatus);
//
R ret = R.ok(); R ret = R.ok();
// PageUtils pageInfo = new PageUtils(staffInfos, maxCount, limit, currentPage); ret.put("data", data);
// ret.put("page", pageInfo);
return ret; return ret;
} }

View File

@ -2,6 +2,7 @@ package com.lz.modules.app.dao;
import com.lz.modules.app.Dto.StaffBaseInfoDto; import com.lz.modules.app.Dto.StaffBaseInfoDto;
import com.lz.modules.app.Dto.StaffDto; import com.lz.modules.app.Dto.StaffDto;
import com.lz.modules.app.Dto.StaffStatisticalDto;
import com.lz.modules.app.entity.StaffEntity; import com.lz.modules.app.entity.StaffEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -33,5 +34,7 @@ public interface StaffDao extends BaseMapper<StaffEntity> {
StaffBaseInfoDto getBaseInfo(@Param("staffId") Long staffId); StaffBaseInfoDto getBaseInfo(@Param("staffId") Long staffId);
StaffStatisticalDto getStatisticalData(@Param("departmentId") String departmentId, @Param("beginDate") String beginDate, @Param("endDate") String endDate);
} }

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.lz.common.utils.PageUtils; import com.lz.common.utils.PageUtils;
import com.lz.modules.app.Dto.StaffBaseInfoDto; import com.lz.modules.app.Dto.StaffBaseInfoDto;
import com.lz.modules.app.Dto.StaffDto; import com.lz.modules.app.Dto.StaffDto;
import com.lz.modules.app.Dto.StaffStatisticalDto;
import com.lz.modules.app.entity.StaffEntity; import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.job.model.responseBo.DepartmentStaffBo; import com.lz.modules.job.model.responseBo.DepartmentStaffBo;
@ -33,5 +34,7 @@ public interface StaffService extends IService<StaffEntity> {
StaffBaseInfoDto getBaseInfo(Long staffId); StaffBaseInfoDto getBaseInfo(Long staffId);
StaffStatisticalDto getStatisticalData(String departmentId, String beginDate, String endDate);
} }

View File

@ -8,6 +8,7 @@ import com.lz.common.utils.PageUtils;
import com.lz.common.utils.Query; import com.lz.common.utils.Query;
import com.lz.modules.app.Dto.StaffBaseInfoDto; import com.lz.modules.app.Dto.StaffBaseInfoDto;
import com.lz.modules.app.Dto.StaffDto; 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.StaffEntity; import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.service.StaffService; import com.lz.modules.app.service.StaffService;
@ -100,6 +101,11 @@ public class StaffServiceImpl extends ServiceImpl<StaffDao, StaffEntity> impleme
return staffDao.getBaseInfo(staffId); return staffDao.getBaseInfo(staffId);
} }
@Override
public StaffStatisticalDto getStatisticalData(String departmentId, String beginDate, String endDate) {
return staffDao.getStatisticalData(departmentId, beginDate, endDate);
}
private StaffEntity convertStaffEntity(DepartmentStaffBo staffBo) { private StaffEntity convertStaffEntity(DepartmentStaffBo staffBo) {
StaffEntity staffEntity = new StaffEntity(); StaffEntity staffEntity = new StaffEntity();
staffEntity.setName(staffBo.getName());//员工姓名 staffEntity.setName(staffBo.getName());//员工姓名

View File

@ -130,5 +130,32 @@
select name staffName,gender,birthday,marital_status,national,political_landscape,mobile,current_address from lz_staff where id=#{staffId} select name staffName,gender,birthday,marital_status,national,political_landscape,mobile,current_address from lz_staff where id=#{staffId}
</select> </select>
<select id="getStatisticalData" resultType="com.lz.modules.app.Dto.StaffStatisticalDto">
select
count(DISTINCT(ls.id)) totalStaffCount,
count(DISTINCT(td.leader_employee_id)) managementCount,
ifnull(round(count(DISTINCT(td.leader_employee_id))/count(DISTINCT(ls.id))*100,2),0) managementRate,
count(DISTINCT(ls.new_staff)) newStaffCount,
count(DISTINCT(ls.leave_staff)) leaveStaffCount,
ifnull(round(count(DISTINCT(ls.leave_staff))/(count(DISTINCT(ls.leave_staff))+count(DISTINCT(ls.id)))*100,2),0) leaveRate
from
(select * from lz_staff ll
left join
(select staff_id as new_staff from lz_staff_occupation where date(entry_time) between #{beginDate} and #{endDate}) so1
on so1.new_staff=ll.id
left join
(select staff_id as leave_staff from lz_staff_occupation where date(resignation_time) between #{beginDate} and #{endDate}) so2
on so2.leave_staff=ll.id) ls,
lz_departments_staff_relate dsr,lz_staff_occupation so,
(select * from lz_departments
<if test="departmentId != null and departmentId != ''">
where find_in_set(department_id, getChildList(#{departmentId}))
</if>
) td
where ls.is_delete=0 and ls.id=dsr.staff_id and so.staff_id=ls.id
and dsr.department_id=td.department_id
and (date(so.resignation_time)>=#{endDate} or so.resignation_time is null )
</select>
</mapper> </mapper>

View File

@ -130,5 +130,32 @@
select name staffName,gender,birthday,marital_status,national,political_landscape,mobile,current_address from lz_staff where id=#{staffId} select name staffName,gender,birthday,marital_status,national,political_landscape,mobile,current_address from lz_staff where id=#{staffId}
</select> </select>
<select id="getStatisticalData" resultType="com.lz.modules.app.Dto.StaffStatisticalDto">
select
count(DISTINCT(ls.id)) totalStaffCount,
count(DISTINCT(td.leader_employee_id)) managementCount,
ifnull(round(count(DISTINCT(td.leader_employee_id))/count(DISTINCT(ls.id))*100,2),0) managementRate,
count(DISTINCT(ls.new_staff)) newStaffCount,
count(DISTINCT(ls.leave_staff)) leaveStaffCount,
ifnull(round(count(DISTINCT(ls.leave_staff))/(count(DISTINCT(ls.leave_staff))+count(DISTINCT(ls.id)))*100,2),0) leaveRate
from
(select * from lz_staff ll
left join
(select staff_id as new_staff from lz_staff_occupation where date(entry_time) between #{beginDate} and #{endDate}) so1
on so1.new_staff=ll.id
left join
(select staff_id as leave_staff from lz_staff_occupation where date(resignation_time) between #{beginDate} and #{endDate}) so2
on so2.leave_staff=ll.id) ls,
lz_departments_staff_relate dsr,lz_staff_occupation so,
(select * from lz_departments
<if test="departmentId != null and departmentId != ''">
where find_in_set(department_id, getChildList(#{departmentId}))
</if>
) td
where ls.is_delete=0 and ls.id=dsr.staff_id and so.staff_id=ls.id
and dsr.department_id=td.department_id
and (date(so.resignation_time)>=#{endDate} or so.resignation_time is null )
</select>
</mapper> </mapper>