|
|
@ -32,6 +32,7 @@ import java.io.IOException; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.net.URLEncoder; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Optional; |
|
|
@ -68,10 +69,10 @@ public class RehearsalPlanServiceImpl extends ServiceImpl<RehearsalPlanMapper, R |
|
|
|
* 演练月度数据 |
|
|
|
* 演练月度数据 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public IPage<RehearsalMonthVO> dataByMonth(String month, Query query) { |
|
|
|
public IPage<RehearsalMonthVO> dataByMonth(String month, String unit, Query query) { |
|
|
|
// 查询当月各单位的演练总数
|
|
|
|
// 查询当月各单位的演练总数
|
|
|
|
IPage<RehearsalMonthVO> page = new Page<>(query.getCurrent(), query.getSize()); |
|
|
|
IPage<RehearsalMonthVO> page = new Page<>(query.getCurrent(), query.getSize()); |
|
|
|
IPage<RehearsalMonthVO> unitPage = baseMapper.selectByMonth(page, month); |
|
|
|
IPage<RehearsalMonthVO> unitPage = baseMapper.selectByMonth(page, unit, month); |
|
|
|
List<RehearsalMonthVO> unitList = unitPage.getRecords(); |
|
|
|
List<RehearsalMonthVO> unitList = unitPage.getRecords(); |
|
|
|
// 若无数据,返回空页面
|
|
|
|
// 若无数据,返回空页面
|
|
|
|
if (CollectionUtils.isEmpty(unitList)) { |
|
|
|
if (CollectionUtils.isEmpty(unitList)) { |
|
|
@ -79,18 +80,18 @@ public class RehearsalPlanServiceImpl extends ServiceImpl<RehearsalPlanMapper, R |
|
|
|
} |
|
|
|
} |
|
|
|
// 查询当月各单位已完成的演练数据
|
|
|
|
// 查询当月各单位已完成的演练数据
|
|
|
|
IPage<RehearsalMonthVO> page1 = new Page<>(query.getCurrent(), query.getSize()); |
|
|
|
IPage<RehearsalMonthVO> page1 = new Page<>(query.getCurrent(), query.getSize()); |
|
|
|
IPage<RehearsalMonthVO> finishedPage = baseMapper.selectFinishedDataByMonth(page1, month); |
|
|
|
IPage<RehearsalMonthVO> finishedPage = baseMapper.selectFinishedDataByMonth(page1, unit, month); |
|
|
|
List<RehearsalMonthVO> finishedList = finishedPage.getRecords(); |
|
|
|
List<RehearsalMonthVO> finishedList = finishedPage.getRecords(); |
|
|
|
// 处理统计数据
|
|
|
|
// 处理统计数据
|
|
|
|
for (RehearsalMonthVO unit : unitList) { |
|
|
|
for (RehearsalMonthVO u : unitList) { |
|
|
|
Long taskNum = unit.getScheduledTaskNum(); |
|
|
|
Long taskNum = u.getScheduledTaskNum(); |
|
|
|
Optional<RehearsalMonthVO> finishedRehearsal = finishedList.stream().filter(x -> x.getUnit().equals(unit.getUnit())).findFirst(); |
|
|
|
Optional<RehearsalMonthVO> finishedRehearsal = finishedList.stream().filter(x -> x.getUnit().equals(u.getUnit())).findFirst(); |
|
|
|
Long finishedTaskNum = finishedRehearsal.isPresent() ? finishedRehearsal.get().getFinishedTaskNum() : 0L; |
|
|
|
Long finishedTaskNum = finishedRehearsal.isPresent() ? finishedRehearsal.get().getFinishedTaskNum() : 0L; |
|
|
|
unit.setFinishedTaskNum(finishedTaskNum); |
|
|
|
u.setFinishedTaskNum(finishedTaskNum); |
|
|
|
unit.setUnfinishedTaskNum(taskNum - finishedTaskNum); |
|
|
|
u.setUnfinishedTaskNum(taskNum - finishedTaskNum); |
|
|
|
BigDecimal taskDecimal = new BigDecimal(taskNum); |
|
|
|
BigDecimal taskDecimal = new BigDecimal(taskNum); |
|
|
|
BigDecimal finishedDecimal = new BigDecimal(finishedTaskNum); |
|
|
|
BigDecimal finishedDecimal = new BigDecimal(finishedTaskNum); |
|
|
|
unit.setTaskCompletionRate(finishedDecimal.divide(taskDecimal, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")) |
|
|
|
u.setTaskCompletionRate(finishedDecimal.divide(taskDecimal, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")) |
|
|
|
.setScale(2, RoundingMode.HALF_UP)); |
|
|
|
.setScale(2, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
} |
|
|
|
unitPage.setRecords(unitList); |
|
|
|
unitPage.setRecords(unitList); |
|
|
@ -101,10 +102,10 @@ public class RehearsalPlanServiceImpl extends ServiceImpl<RehearsalPlanMapper, R |
|
|
|
* 演练年度数据 |
|
|
|
* 演练年度数据 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public IPage<RehearsalYearVO> dataByYear(String year, Query query) { |
|
|
|
public IPage<RehearsalYearVO> dataByYear(String year, String unit, Query query) { |
|
|
|
IPage<RehearsalYearVO> page = new Page<>(query.getCurrent(), query.getSize()); |
|
|
|
IPage<RehearsalYearVO> page = new Page<>(query.getCurrent(), query.getSize()); |
|
|
|
// 查询当年的所有单位
|
|
|
|
// 查询当年的所有单位
|
|
|
|
IPage<RehearsalYearVO> unitPage = baseMapper.selectUnitByYear(page, year); |
|
|
|
IPage<RehearsalYearVO> unitPage = baseMapper.selectUnitByYear(page, unit, year); |
|
|
|
List<RehearsalYearVO> records = unitPage.getRecords(); |
|
|
|
List<RehearsalYearVO> records = unitPage.getRecords(); |
|
|
|
// 若无数据,返回空页面
|
|
|
|
// 若无数据,返回空页面
|
|
|
|
if (CollectionUtils.isEmpty(records)) { |
|
|
|
if (CollectionUtils.isEmpty(records)) { |
|
|
@ -114,49 +115,66 @@ public class RehearsalPlanServiceImpl extends ServiceImpl<RehearsalPlanMapper, R |
|
|
|
// 查询各单位全年已完成的演练数据
|
|
|
|
// 查询各单位全年已完成的演练数据
|
|
|
|
List<AnalysisYearDTO> unitMonthDataList = baseMapper.selectFinishedDataByUnit(unitList, year); |
|
|
|
List<AnalysisYearDTO> unitMonthDataList = baseMapper.selectFinishedDataByUnit(unitList, year); |
|
|
|
// 将各单位每个月的演练数据写入统计列表
|
|
|
|
// 将各单位每个月的演练数据写入统计列表
|
|
|
|
|
|
|
|
List<RehearsalYearVO> res = new ArrayList<>(); |
|
|
|
unitMonthDataList.forEach(data -> { |
|
|
|
unitMonthDataList.forEach(data -> { |
|
|
|
RehearsalYearVO rehearsalYearVO = records.stream().filter(x -> x.getUnit().equals(data.getUnit())) |
|
|
|
RehearsalYearVO rehearsalYearVO = records.stream().filter(x -> x.getUnit().equals(data.getUnit())) |
|
|
|
.collect(Collectors.toList()).get(0); |
|
|
|
.collect(Collectors.toList()).get(0); |
|
|
|
|
|
|
|
long sum = rehearsalYearVO.getSum() == null ? 0 : rehearsalYearVO.getSum(); |
|
|
|
// 根据月份匹配写入对应字段
|
|
|
|
// 根据月份匹配写入对应字段
|
|
|
|
switch (data.getDateTime()) { |
|
|
|
switch (data.getDateTime()) { |
|
|
|
case "01": |
|
|
|
case "01": |
|
|
|
rehearsalYearVO.setJanuaryNum(data.getFinishedNum()); |
|
|
|
rehearsalYearVO.setJanuaryNum(data.getFinishedNum()); |
|
|
|
|
|
|
|
rehearsalYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "02": |
|
|
|
case "02": |
|
|
|
rehearsalYearVO.setFebruaryNum(data.getFinishedNum()); |
|
|
|
rehearsalYearVO.setFebruaryNum(data.getFinishedNum()); |
|
|
|
|
|
|
|
rehearsalYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "03": |
|
|
|
case "03": |
|
|
|
rehearsalYearVO.setMarchNum(data.getFinishedNum()); |
|
|
|
rehearsalYearVO.setMarchNum(data.getFinishedNum()); |
|
|
|
|
|
|
|
rehearsalYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "04": |
|
|
|
case "04": |
|
|
|
rehearsalYearVO.setAprilNum(data.getFinishedNum()); |
|
|
|
rehearsalYearVO.setAprilNum(data.getFinishedNum()); |
|
|
|
|
|
|
|
rehearsalYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "05": |
|
|
|
case "05": |
|
|
|
rehearsalYearVO.setMayNum(data.getFinishedNum()); |
|
|
|
rehearsalYearVO.setMayNum(data.getFinishedNum()); |
|
|
|
|
|
|
|
rehearsalYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "06": |
|
|
|
case "06": |
|
|
|
rehearsalYearVO.setJuneNum(data.getFinishedNum()); |
|
|
|
rehearsalYearVO.setJuneNum(data.getFinishedNum()); |
|
|
|
|
|
|
|
rehearsalYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "07": |
|
|
|
case "07": |
|
|
|
rehearsalYearVO.setJulyNum(data.getFinishedNum()); |
|
|
|
rehearsalYearVO.setJulyNum(data.getFinishedNum()); |
|
|
|
|
|
|
|
rehearsalYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "08": |
|
|
|
case "08": |
|
|
|
rehearsalYearVO.setAugustNum(data.getFinishedNum()); |
|
|
|
rehearsalYearVO.setAugustNum(data.getFinishedNum()); |
|
|
|
|
|
|
|
rehearsalYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "09": |
|
|
|
case "09": |
|
|
|
rehearsalYearVO.setSeptemberNum(data.getFinishedNum()); |
|
|
|
rehearsalYearVO.setSeptemberNum(data.getFinishedNum()); |
|
|
|
|
|
|
|
rehearsalYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "10": |
|
|
|
case "10": |
|
|
|
rehearsalYearVO.setOctoberNum(data.getFinishedNum()); |
|
|
|
rehearsalYearVO.setOctoberNum(data.getFinishedNum()); |
|
|
|
|
|
|
|
rehearsalYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "11": |
|
|
|
case "11": |
|
|
|
rehearsalYearVO.setNovemberNum(data.getFinishedNum()); |
|
|
|
rehearsalYearVO.setNovemberNum(data.getFinishedNum()); |
|
|
|
|
|
|
|
rehearsalYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "12": |
|
|
|
case "12": |
|
|
|
rehearsalYearVO.setDecemberNum(data.getFinishedNum()); |
|
|
|
rehearsalYearVO.setDecemberNum(data.getFinishedNum()); |
|
|
|
|
|
|
|
rehearsalYearVO.setSum(sum + data.getFinishedNum()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (rehearsalYearVO.getSum() != 0) { |
|
|
|
|
|
|
|
res.add(rehearsalYearVO); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
unitPage.setRecords(records); |
|
|
|
unitPage.setRecords(res); |
|
|
|
return unitPage; |
|
|
|
return unitPage; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|