|
|
@@ -29,7 +29,6 @@ import java.time.Year;
|
|
|
import java.time.YearMonth;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.format.TextStyle;
|
|
|
-import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
@@ -77,7 +76,7 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
dashBoardDTO.setPlanDto(getPlanRate(dept));
|
|
|
|
|
|
// 近一周发布计划
|
|
|
- dashBoardDTO.setWeekDtoList(getCurrWeek(dept));
|
|
|
+ dashBoardDTO.setWeekDtoList(getLastSeven(dept));
|
|
|
|
|
|
// type value
|
|
|
// 周 week 本周 nowWeek 上周 lastWeek 下周 nextWeek
|
|
|
@@ -120,23 +119,28 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
// }
|
|
|
// 年 year 去年 lastYear 今年 nowYear
|
|
|
|
|
|
+
|
|
|
+ String dateCondition = "";
|
|
|
+
|
|
|
// 在岗培训人员统计情况
|
|
|
if (dates.contains("-")){
|
|
|
// 月
|
|
|
dashBoardDTO.setPxrytjqkDtoList(getYmdData(getAllDatesOfMonth(dates),dept,"month",""));
|
|
|
+ dateCondition = String.format(" AND DATE_FORMAT(pei_xun_shi_jian_, '%%Y-%%m') = '%s'", dates);
|
|
|
}else {
|
|
|
// 年
|
|
|
dashBoardDTO.setPxrytjqkDtoList(getYmdData(getYearMonth(),dept,"year",dates));
|
|
|
+ dateCondition = String.format(" AND DATE_FORMAT(pei_xun_shi_jian_, '%%Y') = '%s'", dates);
|
|
|
}
|
|
|
|
|
|
// 在岗个人培训次数排名
|
|
|
- dashBoardDTO.setUserRankList(getUserTrainRank(dept));
|
|
|
+ dashBoardDTO.setUserRankList(getUserTrainRank(dept,dateCondition));
|
|
|
|
|
|
// 在岗培训类别占比
|
|
|
- dashBoardDTO.setTypeDto(getTypeRate(dept));
|
|
|
+ dashBoardDTO.setTypeDto(getTypeRate(dept,dateCondition));
|
|
|
|
|
|
// 在岗培训对象占比
|
|
|
- dashBoardDTO.setObjectDto(getObjectRate(dept));
|
|
|
+ dashBoardDTO.setObjectDto(getObjectRate(dept,dateCondition));
|
|
|
|
|
|
// 本年度岗前培训计划
|
|
|
dashBoardDTO.setNdgqpxList(getCurrentYearData(getYearMonth(),dept));
|
|
|
@@ -339,12 +343,14 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
|
|
|
public TrainGuardAutoPlanDto getPlanRate(String dept){
|
|
|
TrainGuardAutoPlanDto planDto = new TrainGuardAutoPlanDto();
|
|
|
- String zdSql = "select count(*) as auto from t_rypxcjb where ji_hua_wai_jian_ in(select id_ from t_ndrypxjhzb) and ji_hua_lei_xing_='在岗培训' and di_dian_='"+getDiDian()+"'";
|
|
|
- String zsSql = "select count(*) as total from t_rypxcjb where ji_hua_lei_xing_='在岗培训' and di_dian_='"+getDiDian()+"' ";
|
|
|
+ String zdSql = "select count(*) as auto from t_rypxcjb where ji_hua_wai_jian_ in(select id_ from t_ndrypxjhzb) and ji_hua_lei_xing_='在岗培训' %s";
|
|
|
+ String zsSql = "select count(*) as total from t_rypxcjb where ji_hua_lei_xing_='在岗培训' %s ";
|
|
|
+ String dateCondition = String.format(" AND di_dian_ = '%s' ", getDiDian());
|
|
|
if (BeanUtils.isNotEmpty(dept)){
|
|
|
- zdSql = zdSql + " and bian_zhi_bu_men_ = '"+dept+"'";
|
|
|
- zsSql = zsSql + " and bian_zhi_bu_men_ = '"+dept+"'";
|
|
|
+ dateCondition += String.format(" AND bian_zhi_bu_men_ = '%s' ", dept);
|
|
|
}
|
|
|
+ zdSql = String.format(zdSql,dateCondition);
|
|
|
+ zsSql = String.format(zsSql,dateCondition);
|
|
|
int autoNum = Integer.parseInt(commonDao.queryOne(zdSql).get("auto").toString());
|
|
|
int total = Integer.parseInt(commonDao.queryOne(zsSql).get("total").toString());
|
|
|
int manual = total - autoNum;
|
|
|
@@ -352,55 +358,57 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
planDto.setAutoNum(autoNum);
|
|
|
planDto.setManual(manual);
|
|
|
planDto.setRemark("自动创建培训计划占比");
|
|
|
-
|
|
|
- BigDecimal sum = new BigDecimal(total);
|
|
|
- BigDecimal sign = new BigDecimal(autoNum);
|
|
|
- if (sum.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
- BigDecimal percentage = sign.divide(sum, 10, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
|
|
|
- percentage = percentage.setScale(2, RoundingMode.HALF_UP);
|
|
|
- planDto.setRate(percentage.toString());
|
|
|
- }else {
|
|
|
- planDto.setRate("0.00");
|
|
|
- }
|
|
|
+ planDto.setRate(getRate(total,autoNum));
|
|
|
return planDto;
|
|
|
}
|
|
|
|
|
|
- public List<TrainWeekDto> getCurrWeek(String dept){
|
|
|
- LocalDate startOfWeek = LocalDate.now().with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
|
|
+ public List<TrainWeekDto> getLastSeven(String dept){
|
|
|
List<TrainWeekDto> weekDtoList = new ArrayList<>();
|
|
|
- List<String> weekDates = getWeeks(startOfWeek);
|
|
|
- for (String dateStr : weekDates) {
|
|
|
+ List<String> lastWeek = getLastSevenDaysDates();
|
|
|
+ for (String dateStr : lastWeek) {
|
|
|
TrainWeekDto weekDto = new TrainWeekDto();
|
|
|
weekDto.setDate(dateStr);
|
|
|
weekDto.setDayName(getDayName(dateStr));
|
|
|
String sql = "select count(*) value from t_rypxcjb where ji_hua_lei_xing_='在岗培训' and shi_fou_guo_shen_='未发布' " +
|
|
|
- " and di_dian_='"+getDiDian()+"' and date_format(pei_xun_shi_jian_,'%Y-%m-%d')='"+dateStr+"'";
|
|
|
+ " and di_dian_='%s' and date_format(pei_xun_shi_jian_,'%%Y-%%m-%%d')='%s' ";
|
|
|
+ sql = String.format(sql,getDiDian(),dateStr);
|
|
|
if (BeanUtils.isNotEmpty(dept)){
|
|
|
- sql = sql + " and bian_zhi_bu_men_ = '"+dept+"'";
|
|
|
+ sql = String.format(sql+" and bian_zhi_bu_men_ = '%s'",dept);
|
|
|
}
|
|
|
Map<String,Object> map = commonDao.queryOne(sql);
|
|
|
weekDto.setValue(map.get("value"));
|
|
|
weekDtoList.add(weekDto);
|
|
|
}
|
|
|
+ weekDtoList.sort(Comparator.comparing(TrainWeekDto::getDate));
|
|
|
return weekDtoList;
|
|
|
}
|
|
|
|
|
|
+ public List<String> getLastSevenDaysDates() {
|
|
|
+ List<String> datesStrings = new ArrayList<>();
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ for (int i = 0; i < 7; i++) {
|
|
|
+ LocalDate date = today.minusDays(i);
|
|
|
+ datesStrings.add(date.format(formatter));
|
|
|
+ }
|
|
|
+ return datesStrings;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- public TrainObjectDto getObjectRate(String dept){
|
|
|
+ public TrainObjectDto getObjectRate(String dept,String dateCondition){
|
|
|
TrainObjectDto objectDto = new TrainObjectDto();
|
|
|
objectDto.setRemark("在岗培训对象占比");
|
|
|
List<TrainRateDto> rateDtoList = new ArrayList<>();
|
|
|
String sql = "select pei_xun_lei_xing_,count(pei_xun_lei_xing_)as nums from t_rypxcjb where ji_hua_lei_xing_='在岗培训' " +
|
|
|
- "and shi_fou_guo_shen_='已结束' and di_dian_='"+getDiDian()+"' group by pei_xun_lei_xing_";
|
|
|
+ "and shi_fou_guo_shen_='已结束' %s group by pei_xun_lei_xing_";
|
|
|
String talSql = "SELECT COALESCE(SUM(nums), 0) AS total_num from (select pei_xun_lei_xing_,COUNT(pei_xun_lei_xing_)as nums " +
|
|
|
- "from t_rypxcjb where ji_hua_lei_xing_='在岗培训' and shi_fou_guo_shen_='已结束' and di_dian_='"+getDiDian()+"' GROUP BY pei_xun_lei_xing_) as qw";
|
|
|
+ "from t_rypxcjb where ji_hua_lei_xing_='在岗培训' and shi_fou_guo_shen_='已结束' %s GROUP BY pei_xun_lei_xing_) as qw";
|
|
|
+ dateCondition += String.format(" AND di_dian_ = '%s' ", getDiDian());
|
|
|
if (BeanUtils.isNotEmpty(dept)){
|
|
|
- sql = "select pei_xun_lei_xing_,count(pei_xun_lei_xing_)as nums from t_rypxcjb where ji_hua_lei_xing_='在岗培训' " +
|
|
|
- "and shi_fou_guo_shen_='已结束' and di_dian_='"+getDiDian()+"' and bian_zhi_bu_men_='"+dept+"' group by pei_xun_lei_xing_";
|
|
|
- talSql = "SELECT COALESCE(SUM(nums), 0) AS total_num from (select pei_xun_lei_xing_,COUNT(pei_xun_lei_xing_)as nums " +
|
|
|
- " from t_rypxcjb where ji_hua_lei_xing_='在岗培训' and shi_fou_guo_shen_='已结束' and di_dian_='"+getDiDian()+"' " +
|
|
|
- " and bian_zhi_bu_men_='"+dept+"' GROUP BY pei_xun_lei_xing_) as qw";
|
|
|
+ dateCondition += String.format(" AND bian_zhi_bu_men_ = '%s' ", dept);
|
|
|
}
|
|
|
+ sql = String.format(sql,dateCondition);
|
|
|
+ talSql = String.format(talSql,dateCondition);
|
|
|
List<Map<String,Object>> list = (List<Map<String, Object>>) commonDao.query(sql);
|
|
|
int total = Integer.parseInt(commonDao.queryOne(talSql).get("total_num").toString());
|
|
|
objectDto.setObjectTotal(total);
|
|
|
@@ -410,15 +418,7 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
String nums = map.get("nums").toString();
|
|
|
rateDto.setTypeName(map.get("pei_xun_lei_xing_").toString());
|
|
|
rateDto.setTypeNum(nums);
|
|
|
- BigDecimal sum = new BigDecimal(total);
|
|
|
- BigDecimal sign = new BigDecimal(nums);
|
|
|
- if (sum.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
- BigDecimal percentage = sign.divide(sum, 10, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
|
|
|
- percentage = percentage.setScale(2, RoundingMode.HALF_UP);
|
|
|
- rateDto.setRate(percentage.toString());
|
|
|
- }else {
|
|
|
- rateDto.setRate("0.00");
|
|
|
- }
|
|
|
+ rateDto.setRate(getRate(total,Integer.parseInt(nums)));
|
|
|
rateDtoList.add(rateDto);
|
|
|
}
|
|
|
objectDto.setObjectDtoList(rateDtoList);
|
|
|
@@ -426,21 +426,20 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
return objectDto;
|
|
|
}
|
|
|
|
|
|
- public TrainTypeDto getTypeRate(String dept){
|
|
|
+ public TrainTypeDto getTypeRate(String dept,String dateCondition){
|
|
|
TrainTypeDto typeDto = new TrainTypeDto();
|
|
|
typeDto.setRemark("在岗培训类别占比");
|
|
|
List<TrainRateDto> rateDtoList = new ArrayList<>();
|
|
|
String sql = "select pei_xun_lei_bie_,count(pei_xun_lei_bie_)as nums from t_rypxcjb where ji_hua_lei_xing_='在岗培训' " +
|
|
|
- " and shi_fou_guo_shen_='已结束' and di_dian_='"+getDiDian()+"' group by pei_xun_lei_bie_";
|
|
|
+ " and shi_fou_guo_shen_='已结束' %s group by pei_xun_lei_bie_";
|
|
|
String talSql = "SELECT COALESCE(SUM(nums), 0) AS total_num from (select pei_xun_lei_bie_,COUNT(pei_xun_lei_bie_)as nums " +
|
|
|
- "from t_rypxcjb where ji_hua_lei_xing_='在岗培训' and shi_fou_guo_shen_='已结束' and di_dian_='"+getDiDian()+"' GROUP BY pei_xun_lei_bie_) as qw";
|
|
|
+ "from t_rypxcjb where ji_hua_lei_xing_='在岗培训' and shi_fou_guo_shen_='已结束' %s GROUP BY pei_xun_lei_bie_) as qw";
|
|
|
+ dateCondition += String.format(" AND di_dian_ = '%s' ", getDiDian());
|
|
|
if (BeanUtils.isNotEmpty(dept)){
|
|
|
- sql = "select pei_xun_lei_bie_,count(pei_xun_lei_bie_)as nums from t_rypxcjb where ji_hua_lei_xing_='在岗培训' " +
|
|
|
- "and shi_fou_guo_shen_='已结束' and di_dian_='"+getDiDian()+"' and bian_zhi_bu_men_='"+dept+"' group by pei_xun_lei_bie_";
|
|
|
- talSql = "SELECT COALESCE(SUM(nums), 0) AS total_num from (select pei_xun_lei_bie_,COUNT(pei_xun_lei_bie_)as nums " +
|
|
|
- "from t_rypxcjb where ji_hua_lei_xing_='在岗培训' and shi_fou_guo_shen_='已结束' and di_dian_='"+getDiDian()+"'" +
|
|
|
- " and bian_zhi_bu_men_='"+dept+"' GROUP BY pei_xun_lei_bie_) as qw";
|
|
|
+ dateCondition += String.format(" AND bian_zhi_bu_men_ = '%s' ", dept);
|
|
|
}
|
|
|
+ sql = String.format(sql,dateCondition);
|
|
|
+ talSql = String.format(talSql,dateCondition);
|
|
|
int total = Integer.parseInt(commonDao.queryOne(talSql).get("total_num").toString());
|
|
|
List<Map<String,Object>> list = (List<Map<String, Object>>) commonDao.query(sql);
|
|
|
typeDto.setTypeTotal(total);
|
|
|
@@ -450,15 +449,7 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
String nums = map.get("nums").toString();
|
|
|
rateDto.setTypeName(map.get("pei_xun_lei_bie_").toString());
|
|
|
rateDto.setTypeNum(nums);
|
|
|
- BigDecimal sum = new BigDecimal(total);
|
|
|
- BigDecimal sign = new BigDecimal(nums);
|
|
|
- if (sum.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
- BigDecimal percentage = sign.divide(sum, 10, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
|
|
|
- percentage = percentage.setScale(2, RoundingMode.HALF_UP);
|
|
|
- rateDto.setRate(percentage.toString());
|
|
|
- }else {
|
|
|
- rateDto.setRate("0.00");
|
|
|
- }
|
|
|
+ rateDto.setRate(getRate(total,Integer.parseInt(nums)));
|
|
|
rateDtoList.add(rateDto);
|
|
|
}
|
|
|
typeDto.setTypeDtoList(rateDtoList);
|
|
|
@@ -471,17 +462,15 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
preWorkDto.setRemark("本年度岗前培训类别占比");
|
|
|
List<TrainRateDto> rateDtoList = new ArrayList<>();
|
|
|
String sql = "select pei_xun_lei_bie_,count(pei_xun_lei_bie_)as nums from t_rypxcjb where ji_hua_lei_xing_='岗前培训' " +
|
|
|
- "and shi_fou_guo_shen_='已结束' and di_dian_='"+getDiDian()+"' group by pei_xun_lei_bie_";
|
|
|
+ "and shi_fou_guo_shen_='已结束' %s group by pei_xun_lei_bie_";
|
|
|
String talSql = "SELECT COALESCE(SUM(nums), 0) AS total_num from (select pei_xun_lei_bie_,COUNT(pei_xun_lei_bie_)as nums " +
|
|
|
- "from t_rypxcjb where ji_hua_lei_xing_='岗前培训' and shi_fou_guo_shen_='已结束' and di_dian_='"+getDiDian()+"' GROUP BY pei_xun_lei_bie_) as qw";
|
|
|
+ "from t_rypxcjb where ji_hua_lei_xing_='岗前培训' and shi_fou_guo_shen_='已结束' %s GROUP BY pei_xun_lei_bie_) as qw";
|
|
|
+ String dateCondition = String.format(" AND di_dian_ = '%s' ", getDiDian());
|
|
|
if (BeanUtils.isNotEmpty(dept)){
|
|
|
- sql = "select pei_xun_lei_bie_,count(pei_xun_lei_bie_)as nums from t_rypxcjb where ji_hua_lei_xing_='岗前培训' " +
|
|
|
- "and shi_fou_guo_shen_='已结束' and di_dian_='"+getDiDian()+"' and bian_zhi_bu_men_='"+dept+"' group by pei_xun_lei_bie_";
|
|
|
- talSql = "SELECT COALESCE(SUM(nums), 0) AS total_num from (select pei_xun_lei_bie_,COUNT(pei_xun_lei_bie_)as nums " +
|
|
|
- "from t_rypxcjb where ji_hua_lei_xing_='岗前培训' and shi_fou_guo_shen_='已结束' and di_dian_='"+getDiDian()+"' " +
|
|
|
- " and bian_zhi_bu_men_='"+dept+"' GROUP BY pei_xun_lei_bie_) as qw";
|
|
|
+ dateCondition += String.format(" AND bian_zhi_bu_men_ = '%s' ", dept);
|
|
|
}
|
|
|
-
|
|
|
+ sql = String.format(sql,dateCondition);
|
|
|
+ talSql = String.format(talSql,dateCondition);
|
|
|
List<Map<String,Object>> list = (List<Map<String, Object>>) commonDao.query(sql);
|
|
|
int total = Integer.parseInt(commonDao.queryOne(talSql).get("total_num").toString());
|
|
|
preWorkDto.setYearPreWorkTotal(total);
|
|
|
@@ -491,15 +480,7 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
String nums = map.get("nums").toString();
|
|
|
rateDto.setTypeName(map.get("pei_xun_lei_bie_").toString());
|
|
|
rateDto.setTypeNum(nums);
|
|
|
- BigDecimal sum = new BigDecimal(total);
|
|
|
- BigDecimal sign = new BigDecimal(nums);
|
|
|
- if (sum.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
- BigDecimal percentage = sign.divide(sum, 10, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
|
|
|
- percentage = percentage.setScale(2, RoundingMode.HALF_UP);
|
|
|
- rateDto.setRate(percentage.toString());
|
|
|
- }else {
|
|
|
- rateDto.setRate("0.00");
|
|
|
- }
|
|
|
+ rateDto.setRate(getRate(total,Integer.parseInt(nums)));
|
|
|
rateDtoList.add(rateDto);
|
|
|
}
|
|
|
preWorkDto.setYearProWorkDtoList(rateDtoList);
|
|
|
@@ -508,7 +489,8 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> getCurrentYearData(List<String> dateStr, String dept) {
|
|
|
- String baseSql = "SELECT count(*) AS total FROM t_rypxcjb WHERE ji_hua_lei_xing_ = '岗前培训' AND shi_fou_guo_shen_ = '已结束' and di_dian_='"+getDiDian()+"'";
|
|
|
+ String baseSql = "SELECT count(*) AS total FROM t_rypxcjb WHERE ji_hua_lei_xing_ = '岗前培训' AND shi_fou_guo_shen_ = '已结束' and di_dian_='%s'";
|
|
|
+ baseSql = String.format(baseSql,getDiDian());
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
int year = Year.now().getValue();
|
|
|
for (String date : dateStr) {
|
|
|
@@ -528,15 +510,16 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- public List<TrainRankDto> getUserTrainRank(String dept){
|
|
|
+ public List<TrainRankDto> getUserTrainRank(String dept,String dateCondition){
|
|
|
String sql = "SELECT a.ren_yuan_id_ userId,e.NAME_ userName,a.rank as count from (select ren_yuan_id_,COUNT(ren_yuan_id_)as rank from t_qdxxb " +
|
|
|
- "where guan_lian_id_ in(select id_ from t_rypxcjb where ji_hua_lei_xing_='在岗培训' and shi_fou_guo_shen_='已结束' " +
|
|
|
- "and di_dian_='%s') GROUP BY guan_lian_id_,ren_yuan_id_) a ,ibps_party_employee e WHERE e.id_=a.ren_yuan_id_ ";
|
|
|
+ "where guan_lian_id_ in(select id_ from t_rypxcjb where ji_hua_lei_xing_='在岗培训' and shi_fou_guo_shen_='已结束' %s) " +
|
|
|
+ "GROUP BY guan_lian_id_,ren_yuan_id_) a ,ibps_party_employee e WHERE e.id_=a.ren_yuan_id_ ";
|
|
|
+ dateCondition += String.format(" AND di_dian_ = '%s' ", getDiDian());
|
|
|
if (BeanUtils.isNotEmpty(dept)){
|
|
|
sql = sql + " and POSITIONS_ like '%%%s%%' ";
|
|
|
}
|
|
|
sql = sql + " ORDER BY a.rank desc ";
|
|
|
- sql = String.format(sql,getDiDian(),dept);
|
|
|
+ sql = String.format(sql,dateCondition,dept);
|
|
|
List<Map<String,Object>> list = (List<Map<String, Object>>) commonDao.query(sql);
|
|
|
List<TrainRankDto> rankedResults = new ArrayList<>();
|
|
|
int rank = 1;
|