Browse Source

Merge remote-tracking branch 'origin/prod-20240506' into prod-20240506

zhongwei
ty 4 months ago
parent
commit
af327bd1a6
  1. 12
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java

12
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java

@ -20,6 +20,7 @@ import com.hnac.hzims.safeproduct.service.ITrainPlanService;
import com.hnac.hzims.safeproduct.service.ITrainRecordService; import com.hnac.hzims.safeproduct.service.ITrainRecordService;
import com.hnac.hzims.safeproduct.vo.TrainMonthVO; import com.hnac.hzims.safeproduct.vo.TrainMonthVO;
import com.hnac.hzims.safeproduct.vo.TrainYearVO; import com.hnac.hzims.safeproduct.vo.TrainYearVO;
import org.apache.commons.collections4.map.HashedMap;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
@ -34,10 +35,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.*;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -105,7 +103,7 @@ public class TrainPlanServiceImpl extends ServiceImpl<TrainPlanMapper, TrainPlan
// 查询各单位全年已完成的培训计划数 // 查询各单位全年已完成的培训计划数
List<AnalysisYearDTO> unitMonthDataList = baseMapper.selectFinishedDataByUnit(unitList, year); List<AnalysisYearDTO> unitMonthDataList = baseMapper.selectFinishedDataByUnit(unitList, year);
// 将各单位每个月的培训计划数据写入统计列表 // 将各单位每个月的培训计划数据写入统计列表
List<TrainYearVO> res = new ArrayList<>(); HashedMap<String, TrainYearVO> map = new HashedMap<>();
unitMonthDataList.forEach(data -> { unitMonthDataList.forEach(data -> {
TrainYearVO trainYearVO = records.stream().filter(x -> x.getUnit().equals(data.getUnit())) TrainYearVO trainYearVO = records.stream().filter(x -> x.getUnit().equals(data.getUnit()))
.collect(Collectors.toList()).get(0); .collect(Collectors.toList()).get(0);
@ -161,9 +159,11 @@ public class TrainPlanServiceImpl extends ServiceImpl<TrainPlanMapper, TrainPlan
trainYearVO.setSum(sum + data.getFinishedNum()); trainYearVO.setSum(sum + data.getFinishedNum());
} }
if (trainYearVO.getSum() != 0) { if (trainYearVO.getSum() != 0) {
res.add(trainYearVO); map.put(trainYearVO.getUnit(), trainYearVO);
} }
}); });
List<TrainYearVO> list = new ArrayList<>(map.values());
List<TrainYearVO> res = list.stream().sorted(Comparator.comparing(TrainYearVO::getUnit)).collect(Collectors.toList());
unitPage.setRecords(res); unitPage.setRecords(res);
return unitPage; return unitPage;
} }

Loading…
Cancel
Save