Browse Source

fix: 演练年度统计数据重复问题

zhongwei
liwen 3 months ago
parent
commit
7f2e5180a3
  1. 22
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java

22
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java

@ -20,6 +20,7 @@ import com.hnac.hzims.safeproduct.service.IRehearsalPlanService;
import com.hnac.hzims.safeproduct.service.IRehearsalRecordService;
import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO;
import com.hnac.hzims.safeproduct.vo.RehearsalYearVO;
import org.apache.commons.collections4.map.HashedMap;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.DateUtil;
@ -34,10 +35,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;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -119,7 +117,7 @@ public class RehearsalPlanServiceImpl extends ServiceImpl<RehearsalPlanMapper, R
// 查询各单位全年已完成的演练数据
List<AnalysisYearDTO> unitMonthDataList = baseMapper.selectFinishedDataByUnit(unitList, year);
// 将各单位每个月的演练数据写入统计列表
List<RehearsalYearVO> res = new ArrayList<>();
HashedMap<String, RehearsalYearVO> map = new HashedMap<>();
unitMonthDataList.forEach(data -> {
RehearsalYearVO rehearsalYearVO = records.stream().filter(x -> x.getUnit().equals(data.getUnit()))
.collect(Collectors.toList()).get(0);
@ -175,9 +173,11 @@ public class RehearsalPlanServiceImpl extends ServiceImpl<RehearsalPlanMapper, R
rehearsalYearVO.setSum(sum + data.getFinishedNum());
}
if (rehearsalYearVO.getSum() != 0) {
res.add(rehearsalYearVO);
map.put(rehearsalYearVO.getUnit(), rehearsalYearVO);
}
});
List<RehearsalYearVO> list = new ArrayList<>(map.values());
List<RehearsalYearVO> res = list.stream().sorted(Comparator.comparing(RehearsalYearVO::getUnit)).collect(Collectors.toList());
unitPage.setRecords(res);
return unitPage;
}
@ -299,18 +299,18 @@ public class RehearsalPlanServiceImpl extends ServiceImpl<RehearsalPlanMapper, R
String startTime = String.valueOf(param.get("scheduledStartTime"));
String endTime = String.valueOf(param.get("scheduledEndTime"));
String rehearsalStatus = String.valueOf(param.get("rehearsalStatus"));
if (!unit.equals("null") && !unit.equals("")) {
if (!"null".equals(unit) && !unit.isEmpty()) {
queryWrapper.lambda().like(RehearsalPlanEntity::getUnit, unit);
}
if (!startTime.equals("null") && !startTime.equals("")) {
if (!"null".equals(startTime) && !startTime.isEmpty()) {
queryWrapper.lambda().ge(RehearsalPlanEntity::getScheduledEndTime, startTime);
}
if (!endTime.equals("null") && !endTime.equals("")) {
if (!"null".equals(endTime) && !endTime.isEmpty()) {
queryWrapper.lambda().le(RehearsalPlanEntity::getScheduledEndTime, endTime);
}
if (!rehearsalStatus.equals("null") && !rehearsalStatus.equals("")) {
if (!"null".equals(rehearsalStatus) && !rehearsalStatus.isEmpty()) {
// 未完成计划包括UNFINISHED和WAITING两种状态
if (rehearsalStatus.equals("UNFINISHED+WAITING")) {
if ("UNFINISHED+WAITING".equals(rehearsalStatus)) {
queryWrapper.lambda().and(wrapper -> wrapper.eq(RehearsalPlanEntity::getRehearsalStatus, RehearsalStatusEnum.UNFINISHED.getValue())
.or()
.eq(RehearsalPlanEntity::getRehearsalStatus, RehearsalStatusEnum.WAITING.getValue()));

Loading…
Cancel
Save