|
|
|
@ -34,6 +34,7 @@ import java.io.IOException;
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.math.RoundingMode; |
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Optional; |
|
|
|
@ -58,10 +59,10 @@ public class TrainPlanServiceImpl extends ServiceImpl<TrainPlanMapper, TrainPlan
|
|
|
|
|
* 月度培训数据 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public IPage<TrainMonthVO> dataByMonth(String month, Query query) { |
|
|
|
|
public IPage<TrainMonthVO> dataByMonth(String month, String unit, Query query) { |
|
|
|
|
// 查询当月各单位的培训计划总数
|
|
|
|
|
IPage<TrainMonthVO> page = new Page<>(query.getCurrent(), query.getSize()); |
|
|
|
|
IPage<TrainMonthVO> unitPage = baseMapper.selectByMonth(page, month); |
|
|
|
|
IPage<TrainMonthVO> unitPage = baseMapper.selectByMonth(page, unit, month); |
|
|
|
|
List<TrainMonthVO> unitList = unitPage.getRecords(); |
|
|
|
|
// 若无数据,返回空页面
|
|
|
|
|
if (CollectionUtils.isEmpty(unitList)) { |
|
|
|
@ -69,18 +70,18 @@ public class TrainPlanServiceImpl extends ServiceImpl<TrainPlanMapper, TrainPlan
|
|
|
|
|
} |
|
|
|
|
// 查询当月各单位已完成的培训数据
|
|
|
|
|
IPage<TrainMonthVO> page1 = new Page<>(query.getCurrent(), query.getSize()); |
|
|
|
|
IPage<TrainMonthVO> finishedPage = baseMapper.selectFinishedDataByMonth(page1, month); |
|
|
|
|
IPage<TrainMonthVO> finishedPage = baseMapper.selectFinishedDataByMonth(page1, unit, month); |
|
|
|
|
List<TrainMonthVO> finishedList = finishedPage.getRecords(); |
|
|
|
|
// 处理统计数据
|
|
|
|
|
for (TrainMonthVO unit : unitList) { |
|
|
|
|
Long taskNum = unit.getScheduledTrainNum(); |
|
|
|
|
Optional<TrainMonthVO> finishedRehearsal = finishedList.stream().filter(x -> x.getUnit().equals(unit.getUnit())).findFirst(); |
|
|
|
|
for (TrainMonthVO u : unitList) { |
|
|
|
|
Long taskNum = u.getScheduledTrainNum(); |
|
|
|
|
Optional<TrainMonthVO> finishedRehearsal = finishedList.stream().filter(x -> x.getUnit().equals(u.getUnit())).findFirst(); |
|
|
|
|
Long finishedTaskNum = finishedRehearsal.isPresent() ? finishedRehearsal.get().getFinishedTrainNum() : 0L; |
|
|
|
|
unit.setFinishedTrainNum(finishedTaskNum); |
|
|
|
|
unit.setUnfinishedTrainNum(taskNum - finishedTaskNum); |
|
|
|
|
u.setFinishedTrainNum(finishedTaskNum); |
|
|
|
|
u.setUnfinishedTrainNum(taskNum - finishedTaskNum); |
|
|
|
|
BigDecimal taskDecimal = new BigDecimal(taskNum); |
|
|
|
|
BigDecimal finishedDecimal = new BigDecimal(finishedTaskNum); |
|
|
|
|
unit.setCompletionRate(finishedDecimal.divide(taskDecimal, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")) |
|
|
|
|
u.setCompletionRate(finishedDecimal.divide(taskDecimal, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")) |
|
|
|
|
.setScale(2, RoundingMode.HALF_UP)); |
|
|
|
|
} |
|
|
|
|
unitPage.setRecords(unitList); |
|
|
|
@ -91,10 +92,10 @@ public class TrainPlanServiceImpl extends ServiceImpl<TrainPlanMapper, TrainPlan
|
|
|
|
|
* 年度培训数据 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public IPage<TrainYearVO> dataByYear(String year, Query query) { |
|
|
|
|
public IPage<TrainYearVO> dataByYear(String year, String unit, Query query) { |
|
|
|
|
IPage<TrainYearVO> page = new Page<>(query.getCurrent(), query.getSize()); |
|
|
|
|
// 查询当年的所有单位
|
|
|
|
|
IPage<TrainYearVO> unitPage = baseMapper.selectUnitByYear(page, year); |
|
|
|
|
IPage<TrainYearVO> unitPage = baseMapper.selectUnitByYear(page, unit, year); |
|
|
|
|
List<TrainYearVO> records = unitPage.getRecords(); |
|
|
|
|
// 若无数据,返回空页面
|
|
|
|
|
if (CollectionUtils.isEmpty(records)) { |
|
|
|
@ -104,49 +105,66 @@ public class TrainPlanServiceImpl extends ServiceImpl<TrainPlanMapper, TrainPlan
|
|
|
|
|
// 查询各单位全年已完成的培训计划数
|
|
|
|
|
List<AnalysisYearDTO> unitMonthDataList = baseMapper.selectFinishedDataByUnit(unitList, year); |
|
|
|
|
// 将各单位每个月的培训计划数据写入统计列表
|
|
|
|
|
List<TrainYearVO> res = new ArrayList<>(); |
|
|
|
|
unitMonthDataList.forEach(data -> { |
|
|
|
|
TrainYearVO trainYearVO = records.stream().filter(x -> x.getUnit().equals(data.getUnit())) |
|
|
|
|
.collect(Collectors.toList()).get(0); |
|
|
|
|
long sum = trainYearVO.getSum() == null ? 0 : trainYearVO.getSum(); |
|
|
|
|
// 根据月份匹配写入对应字段
|
|
|
|
|
switch (data.getDateTime()) { |
|
|
|
|
case "01": |
|
|
|
|
trainYearVO.setJanuaryNum(data.getFinishedNum()); |
|
|
|
|
trainYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
|
break; |
|
|
|
|
case "02": |
|
|
|
|
trainYearVO.setFebruaryNum(data.getFinishedNum()); |
|
|
|
|
trainYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
|
break; |
|
|
|
|
case "03": |
|
|
|
|
trainYearVO.setMarchNum(data.getFinishedNum()); |
|
|
|
|
trainYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
|
break; |
|
|
|
|
case "04": |
|
|
|
|
trainYearVO.setAprilNum(data.getFinishedNum()); |
|
|
|
|
trainYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
|
break; |
|
|
|
|
case "05": |
|
|
|
|
trainYearVO.setMayNum(data.getFinishedNum()); |
|
|
|
|
trainYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
|
break; |
|
|
|
|
case "06": |
|
|
|
|
trainYearVO.setJuneNum(data.getFinishedNum()); |
|
|
|
|
trainYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
|
break; |
|
|
|
|
case "07": |
|
|
|
|
trainYearVO.setJulyNum(data.getFinishedNum()); |
|
|
|
|
trainYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
|
break; |
|
|
|
|
case "08": |
|
|
|
|
trainYearVO.setAugustNum(data.getFinishedNum()); |
|
|
|
|
trainYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
|
break; |
|
|
|
|
case "09": |
|
|
|
|
trainYearVO.setSeptemberNum(data.getFinishedNum()); |
|
|
|
|
trainYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
|
break; |
|
|
|
|
case "10": |
|
|
|
|
trainYearVO.setOctoberNum(data.getFinishedNum()); |
|
|
|
|
trainYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
|
break; |
|
|
|
|
case "11": |
|
|
|
|
trainYearVO.setNovemberNum(data.getFinishedNum()); |
|
|
|
|
trainYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
|
break; |
|
|
|
|
case "12": |
|
|
|
|
trainYearVO.setDecemberNum(data.getFinishedNum()); |
|
|
|
|
trainYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
|
} |
|
|
|
|
if (trainYearVO.getSum() != 0) { |
|
|
|
|
res.add(trainYearVO); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
unitPage.setRecords(records); |
|
|
|
|
unitPage.setRecords(res); |
|
|
|
|
return unitPage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -256,6 +274,7 @@ public class TrainPlanServiceImpl extends ServiceImpl<TrainPlanMapper, TrainPlan
|
|
|
|
|
if (!endTime.equals("null") && !endTime.equals("")) { |
|
|
|
|
queryWrapper.lambda().le(TrainPlanEntity::getScheduledEndTime, endTime); |
|
|
|
|
} |
|
|
|
|
queryWrapper.lambda().orderByDesc(TrainPlanEntity::getCreateTime); |
|
|
|
|
return this.page(Condition.getPage(query), queryWrapper); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -277,7 +296,7 @@ public class TrainPlanServiceImpl extends ServiceImpl<TrainPlanMapper, TrainPlan
|
|
|
|
|
if (!endTime.equals("null")) { |
|
|
|
|
queryWrapper.lt(TrainPlanEntity::getScheduledEndTime, endTime); |
|
|
|
|
} |
|
|
|
|
queryWrapper.orderByDesc(TrainPlanEntity::getScheduledEndTime); |
|
|
|
|
queryWrapper.orderByDesc(TrainPlanEntity::getCreateTime); |
|
|
|
|
return this.list(queryWrapper); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|