diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 40ab6262..3c563aa3 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,14 +2,11 @@ - - - @@ -163,7 +160,7 @@ - + @@ -218,7 +215,7 @@ file://$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java - 82 + 83 @@ -233,14 +230,9 @@ file://$PROJECT_DIR$/src/main/java/com/lz/modules/app/controller/StaffController.java - 176 + 191 - - file://$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java - 118 - diff --git a/src/main/java/com/lz/modules/app/controller/StaffController.java b/src/main/java/com/lz/modules/app/controller/StaffController.java index ffd7860d..b85648e3 100644 --- a/src/main/java/com/lz/modules/app/controller/StaffController.java +++ b/src/main/java/com/lz/modules/app/controller/StaffController.java @@ -169,11 +169,26 @@ public class StaffController { data.put("departmentName", departmentName); List genderRows = staffService.getGenderData(departmentId, beginDate, endDate); - GraphicsDto genderDistribution = new GraphicsDto(); genderDistribution.setRows(genderRows); data.put("genderDistribution", genderDistribution); + List ageRows = staffService.getAgeData(departmentId, beginDate, endDate); + GraphicsDto ageDistribution = new GraphicsDto(); + ageDistribution.setRows(ageRows); + data.put("ageDistribution", ageDistribution); + + List jobSeniorityRows = staffService.getJobSeniorityData(departmentId, beginDate, endDate); + GraphicsDto jobSeniorityDistribution = new GraphicsDto(); + jobSeniorityDistribution.setRows(jobSeniorityRows); + data.put("jobSeniorityDistribution", jobSeniorityDistribution); + + List educationRows = staffService.getEducationData(departmentId, beginDate, endDate); + GraphicsDto educationDistribution = new GraphicsDto(); + educationDistribution.setRows(educationRows); + data.put("educationDistribution", educationDistribution); + + R ret = R.ok(); ret.put("data", data); return ret; diff --git a/src/main/java/com/lz/modules/app/dao/StaffDao.java b/src/main/java/com/lz/modules/app/dao/StaffDao.java index 9d9bbbb6..e3571850 100644 --- a/src/main/java/com/lz/modules/app/dao/StaffDao.java +++ b/src/main/java/com/lz/modules/app/dao/StaffDao.java @@ -37,6 +37,12 @@ public interface StaffDao extends BaseMapper { StaffStatisticalDto getStatisticalData(@Param("departmentId") String departmentId, @Param("beginDate") String beginDate, @Param("endDate") String endDate); - List getGenderData(String departmentId, String beginDate, String endDate); + List getGenderData(@Param("departmentId") String departmentId, @Param("beginDate") String beginDate, @Param("endDate") String endDate); + + List getAgeData(@Param("departmentId") String departmentId, @Param("beginDate") String beginDate, @Param("endDate") String endDate); + + List getJobSeniorityData(@Param("departmentId") String departmentId, @Param("beginDate") String beginDate, @Param("endDate") String endDate); + + List getEducationData(@Param("departmentId") String departmentId, @Param("beginDate") String beginDate, @Param("endDate") String endDate); } diff --git a/src/main/java/com/lz/modules/app/service/StaffService.java b/src/main/java/com/lz/modules/app/service/StaffService.java index 909e083c..5f03d655 100644 --- a/src/main/java/com/lz/modules/app/service/StaffService.java +++ b/src/main/java/com/lz/modules/app/service/StaffService.java @@ -40,5 +40,12 @@ public interface StaffService extends IService { List getGenderData(String departmentId, String beginDate, String endDate); + List getAgeData(String departmentId, String beginDate, String endDate); + + List getJobSeniorityData(String departmentId, String beginDate, String endDate); + + List getEducationData(String departmentId, String beginDate, String endDate); + + } diff --git a/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java b/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java index f0c164c7..eabb0cd2 100644 --- a/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java +++ b/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java @@ -19,6 +19,7 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -111,12 +112,51 @@ public class StaffServiceImpl extends ServiceImpl impleme @Override public List getGenderData(String departmentId, String beginDate, String endDate) { List graphicsStatisticals = staffDao.getGenderData(departmentId, beginDate, endDate); - int totalCount = 0; + BigDecimal totalCount = BigDecimal.ZERO; for (GraphicsStatisticalDto graphicsStatisticalDto : graphicsStatisticals) { - totalCount = totalCount + graphicsStatisticalDto.getNumber(); + totalCount = totalCount.add(new BigDecimal(graphicsStatisticalDto.getNumber())); } for (GraphicsStatisticalDto graphicsStatisticalDto : graphicsStatisticals) { - graphicsStatisticalDto.setRate(NumberUtil.round(graphicsStatisticalDto.getNumber() / totalCount * 100, 2) + "%"); + graphicsStatisticalDto.setRate(new BigDecimal(graphicsStatisticalDto.getNumber() * 100).divide(totalCount, 2, BigDecimal.ROUND_HALF_UP) + "%"); + } + return graphicsStatisticals; + } + + @Override + public List getAgeData(String departmentId, String beginDate, String endDate) { + List graphicsStatisticals = staffDao.getAgeData(departmentId, beginDate, endDate); + BigDecimal totalCount = BigDecimal.ZERO; + for (GraphicsStatisticalDto graphicsStatisticalDto : graphicsStatisticals) { + totalCount = totalCount.add(new BigDecimal(graphicsStatisticalDto.getNumber())); + } + for (GraphicsStatisticalDto graphicsStatisticalDto : graphicsStatisticals) { + graphicsStatisticalDto.setRate(new BigDecimal(graphicsStatisticalDto.getNumber() * 100).divide(totalCount, 2, BigDecimal.ROUND_HALF_UP) + "%"); + } + return graphicsStatisticals; + } + + @Override + public List getJobSeniorityData(String departmentId, String beginDate, String endDate) { + List graphicsStatisticals = staffDao.getJobSeniorityData(departmentId, beginDate, endDate); + BigDecimal totalCount = BigDecimal.ZERO; + for (GraphicsStatisticalDto graphicsStatisticalDto : graphicsStatisticals) { + totalCount = totalCount.add(new BigDecimal(graphicsStatisticalDto.getNumber())); + } + for (GraphicsStatisticalDto graphicsStatisticalDto : graphicsStatisticals) { + graphicsStatisticalDto.setRate(new BigDecimal(graphicsStatisticalDto.getNumber() * 100).divide(totalCount, 2, BigDecimal.ROUND_HALF_UP) + "%"); + } + return graphicsStatisticals; + } + + @Override + public List getEducationData(String departmentId, String beginDate, String endDate) { + List graphicsStatisticals = staffDao.getEducationData(departmentId, beginDate, endDate); + BigDecimal totalCount = BigDecimal.ZERO; + for (GraphicsStatisticalDto graphicsStatisticalDto : graphicsStatisticals) { + totalCount = totalCount.add(new BigDecimal(graphicsStatisticalDto.getNumber())); + } + for (GraphicsStatisticalDto graphicsStatisticalDto : graphicsStatisticals) { + graphicsStatisticalDto.setRate(new BigDecimal(graphicsStatisticalDto.getNumber() * 100).divide(totalCount, 2, BigDecimal.ROUND_HALF_UP) + "%"); } return graphicsStatisticals; } diff --git a/src/main/resources/mapper/generator/StaffDao.xml b/src/main/resources/mapper/generator/StaffDao.xml index 95be5a81..f6b01a2b 100644 --- a/src/main/resources/mapper/generator/StaffDao.xml +++ b/src/main/resources/mapper/generator/StaffDao.xml @@ -110,7 +110,7 @@ and ls.name=#{name} - limit #{startIndex}, #{pageLimit} + limit #{startIndex}, #{pageLimit} select - case gender when 1 then '男' - when 2 then '女' - else '未知' - end category, - count(gender) number - from lz_staff group by gender + case gender when 1 then '男' + when 2 then '女' + else '未知' + end category, + count(gender) number + from lz_staff + where id in (select so.staff_id from lz_staff_occupation so where date(so.resignation_time)>=#{endDate} or + so.resignation_time is null) + + and id in (select dsr.staff_id from lz_departments_staff_relate dsr,lz_departments ld where + dsr.department_id=ld.department_id and find_in_set(ld.department_id, getChildList(#{departmentId}))) + + group by gender + + + + + + + diff --git a/target/classes/com/lz/modules/app/controller/StaffController.class b/target/classes/com/lz/modules/app/controller/StaffController.class index 9a04d1bf..0a35ac0a 100644 Binary files a/target/classes/com/lz/modules/app/controller/StaffController.class and b/target/classes/com/lz/modules/app/controller/StaffController.class differ diff --git a/target/classes/com/lz/modules/app/dao/StaffDao.class b/target/classes/com/lz/modules/app/dao/StaffDao.class index 25eb32e6..527d48f5 100644 Binary files a/target/classes/com/lz/modules/app/dao/StaffDao.class and b/target/classes/com/lz/modules/app/dao/StaffDao.class differ diff --git a/target/classes/com/lz/modules/app/service/StaffService.class b/target/classes/com/lz/modules/app/service/StaffService.class index eb5b3a7c..d18d6988 100644 Binary files a/target/classes/com/lz/modules/app/service/StaffService.class and b/target/classes/com/lz/modules/app/service/StaffService.class differ diff --git a/target/classes/com/lz/modules/app/service/impl/StaffServiceImpl.class b/target/classes/com/lz/modules/app/service/impl/StaffServiceImpl.class index c33eb5f1..e0eabbdb 100644 Binary files a/target/classes/com/lz/modules/app/service/impl/StaffServiceImpl.class and b/target/classes/com/lz/modules/app/service/impl/StaffServiceImpl.class differ diff --git a/target/classes/mapper/generator/StaffDao.xml b/target/classes/mapper/generator/StaffDao.xml index 95be5a81..f6b01a2b 100644 --- a/target/classes/mapper/generator/StaffDao.xml +++ b/target/classes/mapper/generator/StaffDao.xml @@ -110,7 +110,7 @@ and ls.name=#{name} - limit #{startIndex}, #{pageLimit} + limit #{startIndex}, #{pageLimit} select - case gender when 1 then '男' - when 2 then '女' - else '未知' - end category, - count(gender) number - from lz_staff group by gender + case gender when 1 then '男' + when 2 then '女' + else '未知' + end category, + count(gender) number + from lz_staff + where id in (select so.staff_id from lz_staff_occupation so where date(so.resignation_time)>=#{endDate} or + so.resignation_time is null) + + and id in (select dsr.staff_id from lz_departments_staff_relate dsr,lz_departments ld where + dsr.department_id=ld.department_id and find_in_set(ld.department_id, getChildList(#{departmentId}))) + + group by gender + + + + + + +