|
@@ -13,7 +13,9 @@ import com.lc.ibps.cloud.entity.APIResult;
|
|
|
import com.lc.ibps.common.api.IDictionaryService;
|
|
import com.lc.ibps.common.api.IDictionaryService;
|
|
|
import com.lc.ibps.common.cat.persistence.entity.DictionaryPo;
|
|
import com.lc.ibps.common.cat.persistence.entity.DictionaryPo;
|
|
|
import com.lc.ibps.org.api.IPartyPositionService;
|
|
import com.lc.ibps.org.api.IPartyPositionService;
|
|
|
|
|
+import com.lc.ibps.org.party.persistence.entity.PartyEmployeePo;
|
|
|
import com.lc.ibps.org.party.persistence.entity.PartyPositionPo;
|
|
import com.lc.ibps.org.party.persistence.entity.PartyPositionPo;
|
|
|
|
|
+import com.lc.ibps.wx.entity.Employee;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -23,10 +25,13 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
|
import java.time.DayOfWeek;
|
|
import java.time.DayOfWeek;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
|
|
+import java.time.Year;
|
|
|
|
|
+import java.time.YearMonth;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.format.TextStyle;
|
|
import java.time.format.TextStyle;
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.stream.IntStream;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
public class StatisticServiceImpl implements StatisticService {
|
|
public class StatisticServiceImpl implements StatisticService {
|
|
@@ -64,7 +69,7 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public List<TrainingDashBoardDTO> getTrainingDashBoard(String dept, String type, String value) {
|
|
|
|
|
|
|
+ public List<TrainingDashBoardDTO> getTrainingDashBoard(String dept, String types, String dates) {
|
|
|
|
|
|
|
|
List<TrainingDashBoardDTO> list = new ArrayList<>();
|
|
List<TrainingDashBoardDTO> list = new ArrayList<>();
|
|
|
TrainingDashBoardDTO dashBoardDTO = new TrainingDashBoardDTO();
|
|
TrainingDashBoardDTO dashBoardDTO = new TrainingDashBoardDTO();
|
|
@@ -74,7 +79,7 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
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_='在岗培训' ";
|
|
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_='在岗培训' ";
|
|
|
String zsSql = "select count(*) as total from t_rypxcjb where ji_hua_lei_xing_='在岗培训'";
|
|
String zsSql = "select count(*) as total from t_rypxcjb where ji_hua_lei_xing_='在岗培训'";
|
|
|
if (BeanUtils.isNotEmpty(dept)){
|
|
if (BeanUtils.isNotEmpty(dept)){
|
|
|
- zdSql = zsSql + " and bian_zhi_bu_men_ = '"+dept+"'";
|
|
|
|
|
|
|
+ zdSql = zdSql + " and bian_zhi_bu_men_ = '"+dept+"'";
|
|
|
zsSql = zsSql + " and bian_zhi_bu_men_ = '"+dept+"'";
|
|
zsSql = zsSql + " and bian_zhi_bu_men_ = '"+dept+"'";
|
|
|
}
|
|
}
|
|
|
int autoNum = Integer.parseInt(commonDao.queryOne(zdSql).get("auto").toString());
|
|
int autoNum = Integer.parseInt(commonDao.queryOne(zdSql).get("auto").toString());
|
|
@@ -93,108 +98,275 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
}else {
|
|
}else {
|
|
|
planDto.setRate("0.00");
|
|
planDto.setRate("0.00");
|
|
|
}
|
|
}
|
|
|
|
|
+ dashBoardDTO.setPlanDto(planDto);
|
|
|
|
|
|
|
|
// 获取本周的第一天(星期一)
|
|
// 获取本周的第一天(星期一)
|
|
|
LocalDate startOfWeek = LocalDate.now().with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
|
LocalDate startOfWeek = LocalDate.now().with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
|
|
// 近一周发布计划
|
|
// 近一周发布计划
|
|
|
- //if ("week".equals(type)){
|
|
|
|
|
- List<TrainWeekDto> weekDtoList = new ArrayList<>();
|
|
|
|
|
- List<String> weekDates = getWeeks(startOfWeek);
|
|
|
|
|
- for (String date : weekDates) {
|
|
|
|
|
- TrainWeekDto weekDto = new TrainWeekDto();
|
|
|
|
|
- weekDto.setDate(date);
|
|
|
|
|
- weekDto.setDayName(getDayName(date));
|
|
|
|
|
- String sql = "select count(*) value from t_rypxcjb where ji_hua_lei_xing_='在岗培训' and shi_fou_guo_shen_='未发布' " +
|
|
|
|
|
- " and date_format(pei_xun_shi_jian_,'%Y-%m-%d')='"+date+"'";
|
|
|
|
|
- if (BeanUtils.isNotEmpty(dept)){
|
|
|
|
|
- sql = sql + " and bian_zhi_bu_men_ = '"+dept+"'";
|
|
|
|
|
- }
|
|
|
|
|
- Map<String,Object> map = commonDao.queryOne(sql);
|
|
|
|
|
- weekDto.setValue(map.get("value"));
|
|
|
|
|
- weekDtoList.add(weekDto);
|
|
|
|
|
|
|
+ List<TrainWeekDto> weekDtoList = new ArrayList<>();
|
|
|
|
|
+ List<String> weekDates = getWeeks(startOfWeek);
|
|
|
|
|
+ for (String dateStr : weekDates) {
|
|
|
|
|
+ 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 date_format(pei_xun_shi_jian_,'%Y-%m-%d')='"+dateStr+"'";
|
|
|
|
|
+ if (BeanUtils.isNotEmpty(dept)){
|
|
|
|
|
+ sql = sql + " and bian_zhi_bu_men_ = '"+dept+"'";
|
|
|
}
|
|
}
|
|
|
- dashBoardDTO.setWeekDtoList(weekDtoList);
|
|
|
|
|
- //}
|
|
|
|
|
- dashBoardDTO.setPlanDto(planDto);
|
|
|
|
|
|
|
+ Map<String,Object> map = commonDao.queryOne(sql);
|
|
|
|
|
+ weekDto.setValue(map.get("value"));
|
|
|
|
|
+ weekDtoList.add(weekDto);
|
|
|
|
|
+ }
|
|
|
|
|
+ dashBoardDTO.setWeekDtoList(weekDtoList);
|
|
|
|
|
|
|
|
- // 培训人员统计情况
|
|
|
|
|
// type value
|
|
// type value
|
|
|
// 周 week 本周 nowWeek 上周 lastWeek 下周 nextWeek
|
|
// 周 week 本周 nowWeek 上周 lastWeek 下周 nextWeek
|
|
|
- if ("week".equals(type)){
|
|
|
|
|
- switch (value){
|
|
|
|
|
- case "nowWeek":
|
|
|
|
|
- List<String> nowWeek = getWeeks(startOfWeek);
|
|
|
|
|
- dashBoardDTO.setPxrytjqkDtoList(getYmdData(nowWeek,dept));
|
|
|
|
|
- break;
|
|
|
|
|
- case "lastWeek":
|
|
|
|
|
- List<String> lastWeek = getWeeks(startOfWeek.minusWeeks(1));
|
|
|
|
|
- dashBoardDTO.setPxrytjqkDtoList(getYmdData(lastWeek,dept));
|
|
|
|
|
- break;
|
|
|
|
|
- case "nextWeek":
|
|
|
|
|
- List<String> nextWeek = getWeeks(startOfWeek.plusWeeks(1));
|
|
|
|
|
- dashBoardDTO.setPxrytjqkDtoList(getYmdData(nextWeek,dept));
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- //
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// if ("week".equals(type)){
|
|
|
|
|
+// switch (value){
|
|
|
|
|
+// case "nowWeek":
|
|
|
|
|
+// List<String> nowWeek = getWeeks(startOfWeek);
|
|
|
|
|
+// dashBoardDTO.setPxrytjqkDtoList(getYmdData(nowWeek,dept));
|
|
|
|
|
+// break;
|
|
|
|
|
+// case "lastWeek":
|
|
|
|
|
+// List<String> lastWeek = getWeeks(startOfWeek.minusWeeks(1));
|
|
|
|
|
+// dashBoardDTO.setPxrytjqkDtoList(getYmdData(lastWeek,dept));
|
|
|
|
|
+// break;
|
|
|
|
|
+// case "nextWeek":
|
|
|
|
|
+// List<String> nextWeek = getWeeks(startOfWeek.plusWeeks(1));
|
|
|
|
|
+// dashBoardDTO.setPxrytjqkDtoList(getYmdData(nextWeek,dept));
|
|
|
|
|
+// break;
|
|
|
|
|
+// default:
|
|
|
|
|
+// //
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
// 月 month 本月 nowMonth 上月 lastMonth 下月 nextMonth
|
|
// 月 month 本月 nowMonth 上月 lastMonth 下月 nextMonth
|
|
|
- if ("month".equals(type)){
|
|
|
|
|
- switch (value){
|
|
|
|
|
- case "nowMonth":
|
|
|
|
|
- List<String> nowMonth = getMonths(LocalDate.now().withDayOfMonth(1));
|
|
|
|
|
- dashBoardDTO.setPxrytjqkDtoList(getYmdData(nowMonth,dept));
|
|
|
|
|
- break;
|
|
|
|
|
- case "lastMonth":
|
|
|
|
|
- List<String> lastMonth = getMonths(LocalDate.now().minusMonths(1).withDayOfMonth(1));
|
|
|
|
|
- dashBoardDTO.setPxrytjqkDtoList(getYmdData(lastMonth,dept));
|
|
|
|
|
- break;
|
|
|
|
|
- case "nextMonth":
|
|
|
|
|
- List<String> nextMonth = getMonths(LocalDate.now().plusMonths(1).withDayOfMonth(1));
|
|
|
|
|
- dashBoardDTO.setPxrytjqkDtoList(getYmdData(nextMonth,dept));
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- //
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// if ("month".equals(type)){
|
|
|
|
|
+// switch (value){
|
|
|
|
|
+// case "nowMonth":
|
|
|
|
|
+// List<String> nowMonth = getMonths(LocalDate.now().withDayOfMonth(1));
|
|
|
|
|
+// dashBoardDTO.setPxrytjqkDtoList(getYmdData(nowMonth,dept));
|
|
|
|
|
+// break;
|
|
|
|
|
+// case "lastMonth":
|
|
|
|
|
+// List<String> lastMonth = getMonths(LocalDate.now().minusMonths(1).withDayOfMonth(1));
|
|
|
|
|
+// dashBoardDTO.setPxrytjqkDtoList(getYmdData(lastMonth,dept));
|
|
|
|
|
+// break;
|
|
|
|
|
+// case "nextMonth":
|
|
|
|
|
+// List<String> nextMonth = getMonths(LocalDate.now().plusMonths(1).withDayOfMonth(1));
|
|
|
|
|
+// dashBoardDTO.setPxrytjqkDtoList(getYmdData(nextMonth,dept));
|
|
|
|
|
+// break;
|
|
|
|
|
+// default:
|
|
|
|
|
+// //
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
// 年 year 去年 lastYear 今年 nowYear
|
|
// 年 year 去年 lastYear 今年 nowYear
|
|
|
- if ("year".equals(type)){
|
|
|
|
|
|
|
|
|
|
|
|
+ // 培训人员统计情况
|
|
|
|
|
+ if (dates.contains("-")){
|
|
|
|
|
+ // 月
|
|
|
|
|
+ List<String> months = getAllDatesOfMonth(dates);
|
|
|
|
|
+ dashBoardDTO.setPxrytjqkDtoList(getYmdData(months,dept,"month",""));
|
|
|
|
|
+ }else {
|
|
|
|
|
+ // 年
|
|
|
|
|
+ List<String> years = getYearMonth();
|
|
|
|
|
+ dashBoardDTO.setPxrytjqkDtoList(getYmdData(years,dept,"year",dates));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 个人培训次数排名
|
|
|
|
|
+ dashBoardDTO.setUserRankList(getUserTrainRank(dept));
|
|
|
|
|
+
|
|
|
|
|
+ // 在岗培训类别占比
|
|
|
|
|
+ getTypeRate(dashBoardDTO,dept);
|
|
|
|
|
+
|
|
|
|
|
+ // 在岗培训对象占比
|
|
|
|
|
+ getObjectRate(dashBoardDTO);
|
|
|
|
|
+
|
|
|
// 本年度岗前培训计划
|
|
// 本年度岗前培训计划
|
|
|
|
|
+ List<String> years = getYearMonth();
|
|
|
|
|
+ dashBoardDTO.setNdgqpxList(getCurrentYearData(years,dept));
|
|
|
|
|
+
|
|
|
|
|
+ // 本年度岗前培训类别占比
|
|
|
|
|
+ getYearPre(dashBoardDTO);
|
|
|
|
|
+
|
|
|
list.add(dashBoardDTO);
|
|
list.add(dashBoardDTO);
|
|
|
return list;
|
|
return list;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public List<TraineeStatisticsDto> getYmdData(List<String> dateStr,String dept){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public void getObjectRate(TrainingDashBoardDTO dashBoardDTO){
|
|
|
|
|
+ List<TrainObjectDto> objectDtoList = 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_='已结束' group by pei_xun_lei_xing_";
|
|
|
|
|
+ List<Map<String,Object>> list = (List<Map<String, Object>>) commonDao.query(sql);
|
|
|
|
|
+ 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_='已结束' GROUP BY pei_xun_lei_xing_) as qw";
|
|
|
|
|
+ int total = Integer.parseInt(commonDao.queryOne(talSql).get("total_num").toString());
|
|
|
|
|
+ dashBoardDTO.setTypeTotal(total);
|
|
|
|
|
+ if (BeanUtils.isNotEmpty(list)){
|
|
|
|
|
+ for (Map<String,Object> map : list){
|
|
|
|
|
+ TrainObjectDto objectDto = new TrainObjectDto();
|
|
|
|
|
+ String nums = map.get("nums").toString();
|
|
|
|
|
+ objectDto.setTypeName(map.get("pei_xun_lei_xing_").toString());
|
|
|
|
|
+ objectDto.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);
|
|
|
|
|
+ objectDto.setRate(percentage.toString());
|
|
|
|
|
+ }else {
|
|
|
|
|
+ objectDto.setRate("0.00");
|
|
|
|
|
+ }
|
|
|
|
|
+ objectDtoList.add(objectDto);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ dashBoardDTO.setObjectDtoList(objectDtoList);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void getTypeRate(TrainingDashBoardDTO dashBoardDTO,String dept){
|
|
|
|
|
+ List<TrainTypeDto> typeDtoList = 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_='已结束' 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_='已结束' GROUP BY pei_xun_lei_bie_) as qw";
|
|
|
|
|
+ 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 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 bian_zhi_bu_men_='"+dept+"' GROUP BY pei_xun_lei_bie_) as qw";
|
|
|
|
|
+ }
|
|
|
|
|
+ int total = Integer.parseInt(commonDao.queryOne(talSql).get("total_num").toString());
|
|
|
|
|
+ List<Map<String,Object>> list = (List<Map<String, Object>>) commonDao.query(sql);
|
|
|
|
|
+ dashBoardDTO.setTypeTotal(total);
|
|
|
|
|
+ if (BeanUtils.isNotEmpty(list)){
|
|
|
|
|
+ for (Map<String,Object> map : list){
|
|
|
|
|
+ TrainTypeDto typeDto = new TrainTypeDto();
|
|
|
|
|
+ String nums = map.get("nums").toString();
|
|
|
|
|
+ typeDto.setTypeName(map.get("pei_xun_lei_bie_").toString());
|
|
|
|
|
+ typeDto.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);
|
|
|
|
|
+ typeDto.setRate(percentage.toString());
|
|
|
|
|
+ }else {
|
|
|
|
|
+ typeDto.setRate("0.00");
|
|
|
|
|
+ }
|
|
|
|
|
+ typeDtoList.add(typeDto);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ dashBoardDTO.setTypeDtoList(typeDtoList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void getYearPre(TrainingDashBoardDTO dashBoardDTO){
|
|
|
|
|
+ List<TrainYearPreWorkDto> preWorkDtoList = 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_='已结束' group by pei_xun_lei_bie_";
|
|
|
|
|
+ List<Map<String,Object>> list = (List<Map<String, Object>>) commonDao.query(sql);
|
|
|
|
|
+ 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_='已结束' GROUP BY pei_xun_lei_bie_) as qw";
|
|
|
|
|
+ int total = Integer.parseInt(commonDao.queryOne(talSql).get("total_num").toString());
|
|
|
|
|
+ dashBoardDTO.setYearPreWorkTotal(total);
|
|
|
|
|
+ if (BeanUtils.isNotEmpty(list)){
|
|
|
|
|
+ for (Map<String,Object> map : list){
|
|
|
|
|
+ TrainYearPreWorkDto preWorkDto = new TrainYearPreWorkDto();
|
|
|
|
|
+ String nums = map.get("nums").toString();
|
|
|
|
|
+ preWorkDto.setTypeName(map.get("pei_xun_lei_bie_").toString());
|
|
|
|
|
+ preWorkDto.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);
|
|
|
|
|
+ preWorkDto.setRate(percentage.toString());
|
|
|
|
|
+ }else {
|
|
|
|
|
+ preWorkDto.setRate("0.00");
|
|
|
|
|
+ }
|
|
|
|
|
+ preWorkDtoList.add(preWorkDto);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ dashBoardDTO.setYearPreWorkDtoList(preWorkDtoList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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_ = '已结束' ";
|
|
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
|
|
+ int year = Year.now().getValue();
|
|
|
|
|
+ for (String date : dateStr) {
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
|
+ map.put("date", date + "月");
|
|
|
|
|
+ String formattedDate = year + "-" + (Integer.parseInt(date) < 10 ? "0" + date : date);
|
|
|
|
|
+ StringBuilder queryBuilder = new StringBuilder(baseSql)
|
|
|
|
|
+ .append("AND DATE_FORMAT(pei_xun_shi_jian_, '%Y-%m') = '").append(formattedDate).append("' ");
|
|
|
|
|
+ if (BeanUtils.isNotEmpty(dept)) {
|
|
|
|
|
+ queryBuilder.append("AND bian_zhi_bu_men_ = '").append(dept).append("' ");
|
|
|
|
|
+ }
|
|
|
|
|
+ String countSql = queryBuilder.toString();
|
|
|
|
|
+ Map<String, Object> countResult = commonDao.queryOne(countSql);
|
|
|
|
|
+ map.put("num", Integer.parseInt(countResult.get("total").toString()));
|
|
|
|
|
+ list.add(map);
|
|
|
|
|
+ }
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public List<TrainRankDto> getUserTrainRank(String dept){
|
|
|
|
|
+ String sql = "SELECT a.ren_yuan_id_ userId,e.NAME_ userName,a.rank 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_ ";
|
|
|
|
|
+ if (BeanUtils.isNotEmpty(dept)){
|
|
|
|
|
+ sql = sql + " and POSITIONS_ like '%%%s%%' ";
|
|
|
|
|
+ }
|
|
|
|
|
+ sql = sql + " ORDER BY a.rank desc ";
|
|
|
|
|
+ sql = String.format(sql,getDiDian(),dept);
|
|
|
|
|
+ return (List<TrainRankDto>) commonDao.query(sql);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public List<TraineeStatisticsDto> getYmdData(List<String> dateStr, String dept, String type, String year) {
|
|
|
List<TraineeStatisticsDto> statisticsDtoList = new ArrayList<>();
|
|
List<TraineeStatisticsDto> statisticsDtoList = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 定义SQL模板
|
|
|
|
|
+ String countSqlTemplate = "SELECT COALESCE(SUM(num), 0) AS total_num FROM (" +
|
|
|
|
|
+ "SELECT LENGTH(pei_xun_ren_yuan_) - LENGTH(REPLACE(pei_xun_ren_yuan_, ',', '')) + 1 AS num " +
|
|
|
|
|
+ "FROM t_rypxcjb " +
|
|
|
|
|
+ "WHERE ji_hua_lei_xing_ = '在岗培训' AND shi_fou_guo_shen_ = '已结束' %s) AS subquery";
|
|
|
|
|
+
|
|
|
|
|
+ String realSqlTemplate = "SELECT COUNT(*) AS realNum FROM (" +
|
|
|
|
|
+ "SELECT id_ FROM t_qdxxb " +
|
|
|
|
|
+ "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_) AS re";
|
|
|
|
|
+
|
|
|
for (String date : dateStr) {
|
|
for (String date : dateStr) {
|
|
|
TraineeStatisticsDto traineeDto = new TraineeStatisticsDto();
|
|
TraineeStatisticsDto traineeDto = new TraineeStatisticsDto();
|
|
|
- traineeDto.setDate(date);
|
|
|
|
|
- traineeDto.setDayName(getDayName(date));
|
|
|
|
|
- // 总人数
|
|
|
|
|
- String countSql = "select coalesce(sum(num),0)as total_num from (select length(pei_xun_ren_yuan_)-length(replace(pei_xun_ren_yuan_,',',''))+1 as num " +
|
|
|
|
|
- "from t_rypxcjb where ji_hua_lei_xing_='在岗培训' and shi_fou_guo_shen_='已结束' and date_format(pei_xun_shi_jian_,'%Y-%m-%d')='"+date+"' ";
|
|
|
|
|
- if (BeanUtils.isNotEmpty(dept)){
|
|
|
|
|
- countSql = countSql + " and bian_zhi_bu_men_='"+dept+"'";
|
|
|
|
|
|
|
+
|
|
|
|
|
+ String dateCondition = "";
|
|
|
|
|
+ if ("year".equals(type)) {
|
|
|
|
|
+ traineeDto.setDayName(date + "月");
|
|
|
|
|
+ date = Integer.parseInt(date)<10?year + "-0" + date : year + "-" + date;
|
|
|
|
|
+ traineeDto.setDate(date);
|
|
|
|
|
+ dateCondition = String.format("AND DATE_FORMAT(pei_xun_shi_jian_, '%%Y-%%m') = '%s'", date);
|
|
|
|
|
+ } else if ("month".equals(type)) {
|
|
|
|
|
+ traineeDto.setDate(date);
|
|
|
|
|
+ dateCondition = String.format("AND DATE_FORMAT(pei_xun_shi_jian_, '%%Y-%%m-%%d') = '%s'", date);
|
|
|
|
|
+ traineeDto.setDayName(getDayName(date));
|
|
|
}
|
|
}
|
|
|
- countSql = countSql + " )as subquery";
|
|
|
|
|
- Map<String,Object> map = commonDao.queryOne(countSql);
|
|
|
|
|
- int numAll = Integer.parseInt( BeanUtils.isEmpty(map.get("total_num"))?"0":map.get("total_num").toString());
|
|
|
|
|
- traineeDto.setNumAll(numAll);
|
|
|
|
|
|
|
|
|
|
- // 实际签到人数
|
|
|
|
|
- String realSql = "select count(*)as realNum from (select id_ from t_qdxxb where guan_lian_id_ in(select id_ from t_rypxcjb where " +
|
|
|
|
|
- "ji_hua_lei_xing_='在岗培训' and shi_fou_guo_shen_='已结束' and date_format(pei_xun_shi_jian_,'%Y-%m-%d')='"+date+"' ";
|
|
|
|
|
- if (BeanUtils.isNotEmpty(dept)){
|
|
|
|
|
- realSql = realSql + " and bian_zhi_bu_men_='"+dept+"'";
|
|
|
|
|
|
|
+ if (BeanUtils.isNotEmpty(dept)) {
|
|
|
|
|
+ dateCondition += String.format(" AND bian_zhi_bu_men_ = '%s'", dept);
|
|
|
}
|
|
}
|
|
|
- realSql = realSql + " ) group by guan_lian_id_,ren_yuan_id_)as re";
|
|
|
|
|
- int numReal = Integer.parseInt(commonDao.queryOne(realSql).get("realNum").toString());
|
|
|
|
|
|
|
+
|
|
|
|
|
+ String countSql = String.format(countSqlTemplate, dateCondition);
|
|
|
|
|
+ String realSql = String.format(realSqlTemplate, dateCondition);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> countResult = commonDao.queryOne(countSql);
|
|
|
|
|
+ int numAll = Integer.parseInt(countResult.get("total_num").toString());
|
|
|
|
|
+ traineeDto.setNumAll(numAll);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> realResult = commonDao.queryOne(realSql);
|
|
|
|
|
+ int numReal = Integer.parseInt(realResult.get("realNum").toString());
|
|
|
traineeDto.setNumReal(numReal);
|
|
traineeDto.setNumReal(numReal);
|
|
|
|
|
|
|
|
// 未签到人数
|
|
// 未签到人数
|
|
|
- traineeDto.setNumUn(numAll==0?0:numAll-numReal);
|
|
|
|
|
|
|
+ traineeDto.setNumUn(numAll == 0 ? 0 : numAll - numReal);
|
|
|
|
|
|
|
|
statisticsDtoList.add(traineeDto);
|
|
statisticsDtoList.add(traineeDto);
|
|
|
}
|
|
}
|
|
@@ -203,7 +375,24 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
|
|
|
|
|
public String getDayName(String dateString){
|
|
public String getDayName(String dateString){
|
|
|
LocalDate date = LocalDate.parse(dateString, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
LocalDate date = LocalDate.parse(dateString, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
- return date.getDayOfWeek().getDisplayName(TextStyle.FULL, java.util.Locale.getDefault());
|
|
|
|
|
|
|
+ return date.getDayOfWeek().getDisplayName(TextStyle.FULL,Locale.getDefault());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public List<String> getYearMonth(){
|
|
|
|
|
+ List<String> years = new ArrayList<>();
|
|
|
|
|
+ for (int day = 1; day <=12; day++) {
|
|
|
|
|
+ years.add("" + day);
|
|
|
|
|
+ }
|
|
|
|
|
+ return years;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public List<String> getAllDatesOfMonth(String yearMonthStr) {
|
|
|
|
|
+ YearMonth yearMonth = YearMonth.parse(yearMonthStr, DateTimeFormatter.ofPattern("yyyy-MM"));
|
|
|
|
|
+ List<String> dates = new ArrayList<>();
|
|
|
|
|
+ for (int day = 1; day <= yearMonth.lengthOfMonth(); day++) {
|
|
|
|
|
+ dates.add(yearMonth.atDay(day).toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ return dates;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public List<String> getMonths(LocalDate startDate){
|
|
public List<String> getMonths(LocalDate startDate){
|