This commit is contained in:
fumeiai 2020-05-19 18:04:42 +08:00
parent 98ce36f75e
commit 3acef17d49
15 changed files with 114 additions and 11 deletions

17
.idea/workspace.xml generated
View File

@ -2,7 +2,8 @@
<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 afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/Dto/GraphicsDto.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/Dto/GraphicsStatisticalDto.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/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/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/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/dao/StaffDao.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/dao/StaffDao.java" afterDir="false" />
@ -162,7 +163,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="75394000" /> <workItem from="1588936950753" duration="82741000" />
</task> </task>
<servers /> <servers />
</component> </component>
@ -217,7 +218,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>80</line> <line>82</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">
@ -232,13 +233,13 @@
</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/controller/StaffController.java</url> <url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/app/controller/StaffController.java</url>
<line>156</line> <line>176</line>
<option name="timeStamp" value="73" /> <option name="timeStamp" value="75" />
</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/controller/StaffController.java</url> <url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java</url>
<line>157</line> <line>118</line>
<option name="timeStamp" value="74" /> <option name="timeStamp" value="77" />
</line-breakpoint> </line-breakpoint>
</breakpoints> </breakpoints>
</breakpoint-manager> </breakpoint-manager>

View File

@ -0,0 +1,39 @@
package com.lz.modules.app.Dto;
import com.google.common.collect.Lists;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 图形🥱
*
* @author fumeiai
* @email fumeiai@linzikg.com
* @date 2020-05-19 20:59:20
*/
@Data
public class GraphicsDto implements Serializable {
private static final long serialVersionUID = 1L;
public GraphicsDto() {
List columns = Lists.newArrayList();
columns.add("category");
columns.add("number");
columns.add("rate");
this.columns = columns;
}
/**
* 分组
*/
private List columns;
/**
* 数据
*/
private List rows;
}

View File

@ -0,0 +1,17 @@
package com.lz.modules.app.Dto;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class GraphicsStatisticalDto {
//类别
private String category;
//人数
private int number;
//占比
private String rate;
}

View File

@ -135,6 +135,7 @@ public class StaffController {
// @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(); Map data = new HashMap();
String departmentName = "浙江霖梓控股有限公司";
//部门Id //部门Id
String departmentId = ""; String departmentId = "";
//统计时间起 //统计时间起
@ -162,12 +163,16 @@ public class StaffController {
if (departmentId != "") { if (departmentId != "") {
DepartmentsEntity department = departmentsService.getOne(new QueryWrapper<DepartmentsEntity>().eq("department_id", departmentId)); DepartmentsEntity department = departmentsService.getOne(new QueryWrapper<DepartmentsEntity>().eq("department_id", departmentId));
if (department != null) { if (department != null) {
data.put("departmentName", department.getDepartmentName()); departmentName = department.getDepartmentName();
} }
} }
data.put("departmentName", departmentName);
// //总页码 List<GraphicsStatisticalDto> genderRows = staffService.getGenderData(departmentId, beginDate, endDate);
// int maxCount = staffService.getStaffInfoCount(departmentId, name, staffStatus);
GraphicsDto genderDistribution = new GraphicsDto();
genderDistribution.setRows(genderRows);
data.put("genderDistribution", genderDistribution);
R ret = R.ok(); R ret = R.ok();
ret.put("data", data); ret.put("data", data);

View File

@ -1,5 +1,6 @@
package com.lz.modules.app.dao; package com.lz.modules.app.dao;
import com.lz.modules.app.Dto.GraphicsStatisticalDto;
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.Dto.StaffStatisticalDto;
@ -36,5 +37,6 @@ public interface StaffDao extends BaseMapper<StaffEntity> {
StaffStatisticalDto getStatisticalData(@Param("departmentId") String departmentId, @Param("beginDate") String beginDate, @Param("endDate") String endDate); StaffStatisticalDto getStatisticalData(@Param("departmentId") String departmentId, @Param("beginDate") String beginDate, @Param("endDate") String endDate);
List<GraphicsStatisticalDto> getGenderData(String departmentId, String beginDate, String endDate);
} }

View File

@ -2,6 +2,7 @@ package com.lz.modules.app.service;
import com.baomidou.mybatisplus.extension.service.IService; 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.GraphicsStatisticalDto;
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.Dto.StaffStatisticalDto;
@ -36,5 +37,8 @@ public interface StaffService extends IService<StaffEntity> {
StaffStatisticalDto getStatisticalData(String departmentId, String beginDate, String endDate); StaffStatisticalDto getStatisticalData(String departmentId, String beginDate, String endDate);
List<GraphicsStatisticalDto> getGenderData(String departmentId, String beginDate, String endDate);
} }

View File

@ -1,11 +1,13 @@
package com.lz.modules.app.service.impl; package com.lz.modules.app.service.impl;
import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
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.modules.app.Dto.GraphicsStatisticalDto;
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.Dto.StaffStatisticalDto;
@ -106,6 +108,19 @@ public class StaffServiceImpl extends ServiceImpl<StaffDao, StaffEntity> impleme
return staffDao.getStatisticalData(departmentId, beginDate, endDate); return staffDao.getStatisticalData(departmentId, beginDate, endDate);
} }
@Override
public List<GraphicsStatisticalDto> getGenderData(String departmentId, String beginDate, String endDate) {
List<GraphicsStatisticalDto> graphicsStatisticals = staffDao.getGenderData(departmentId, beginDate, endDate);
int totalCount = 0;
for (GraphicsStatisticalDto graphicsStatisticalDto : graphicsStatisticals) {
totalCount = totalCount + graphicsStatisticalDto.getNumber();
}
for (GraphicsStatisticalDto graphicsStatisticalDto : graphicsStatisticals) {
graphicsStatisticalDto.setRate(NumberUtil.round(graphicsStatisticalDto.getNumber() / totalCount * 100, 2) + "%");
}
return graphicsStatisticals;
}
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

@ -157,5 +157,15 @@
and (date(so.resignation_time)>=#{endDate} or so.resignation_time is null ) and (date(so.resignation_time)>=#{endDate} or so.resignation_time is null )
</select> </select>
<select id="getGenderData" resultType="com.lz.modules.app.Dto.GraphicsStatisticalDto">
select
case gender when 1 then '男'
when 2 then '女'
else '未知'
end category,
count(gender) number
from lz_staff group by gender
</select>
</mapper> </mapper>

View File

@ -157,5 +157,15 @@
and (date(so.resignation_time)>=#{endDate} or so.resignation_time is null ) and (date(so.resignation_time)>=#{endDate} or so.resignation_time is null )
</select> </select>
<select id="getGenderData" resultType="com.lz.modules.app.Dto.GraphicsStatisticalDto">
select
case gender when 1 then '男'
when 2 then '女'
else '未知'
end category,
count(gender) number
from lz_staff group by gender
</select>
</mapper> </mapper>