Commit 29abd00b by 高晓磊

砂石趋势图,循环错误,导致只新增了最后一条数据

parent 3b6788d0
...@@ -71,7 +71,7 @@ public class DischargingServiceImpl implements DischargingService { ...@@ -71,7 +71,7 @@ public class DischargingServiceImpl implements DischargingService {
@Override @Override
public List<HashMap<String, Object>> groupInfoByYear(List<UUID> regionalCompanyIds, Integer year, Boolean isGroupByMonth, Boolean isGroupByRegionalCompany, Boolean isGroupBySandMiningArea) { public List<HashMap<String, Object>> groupInfoByYear(List<UUID> regionalCompanyIds, Integer year, Boolean isGroupByMonth, Boolean isGroupByRegionalCompany, Boolean isGroupBySandMiningArea) {
return dischargingDao.groupInfo(null,regionalCompanyIds, DateTimeUtils.getYearStart(year), DateTimeUtils.getYearEnd(year), null, isGroupByMonth, isGroupByRegionalCompany, isGroupBySandMiningArea, false, false); return dischargingDao.groupInfo(null, regionalCompanyIds, DateTimeUtils.getYearStart(year), DateTimeUtils.getYearEnd(year), null, isGroupByMonth, isGroupByRegionalCompany, isGroupBySandMiningArea, false, false);
} }
@Override @Override
...@@ -92,7 +92,7 @@ public class DischargingServiceImpl implements DischargingService { ...@@ -92,7 +92,7 @@ public class DischargingServiceImpl implements DischargingService {
* @return * @return
*/ */
@Override @Override
public List<TimeValueParentEntity> getDischargingGroup(Date startDate, Date endDate, List<UUID> stationIds,List<UUID> regionalCompanyIds, Boolean isGroupByArea, Boolean isGroupByRegionalCompany, Boolean isGroupByStation, Integer showType) { public List<TimeValueParentEntity> getDischargingGroup(Date startDate, Date endDate, List<UUID> stationIds, List<UUID> regionalCompanyIds, Boolean isGroupByArea, Boolean isGroupByRegionalCompany, Boolean isGroupByStation, Integer showType) {
Date startDateTimeOfMonth = DateTimeUtils.getStartDateTimeOfMonth(startDate); Date startDateTimeOfMonth = DateTimeUtils.getStartDateTimeOfMonth(startDate);
...@@ -102,9 +102,9 @@ public class DischargingServiceImpl implements DischargingService { ...@@ -102,9 +102,9 @@ public class DischargingServiceImpl implements DischargingService {
Map<UUID, TimeValueParentEntity> sandMiningAreaTimeValueEntityHashMap = new HashMap<>(12); Map<UUID, TimeValueParentEntity> sandMiningAreaTimeValueEntityHashMap = new HashMap<>(12);
List<TimeValueParentEntity> timeValueParentEntities = new ArrayList<>(); List<TimeValueParentEntity> timeValueParentEntities = new ArrayList<>();
//处理时间.首先获取时间范围内所有修正数据 //处理时间.首先获取时间范围内所有修正数据
groupByRevise(stationIds,regionalCompanyIds, startDateTimeOfMonth, endDateTimeOfMonth, sandMiningAreaTimeValueEntityHashMap, timeValueParentEntities,isGroupByArea,isGroupByRegionalCompany,isGroupByStation); groupByRevise(stationIds, regionalCompanyIds, startDateTimeOfMonth, endDateTimeOfMonth, sandMiningAreaTimeValueEntityHashMap, timeValueParentEntities, isGroupByArea, isGroupByRegionalCompany, isGroupByStation);
//对非修正数据进行补充 //对非修正数据进行补充
groupByNormal(startDate, endDate, stationIds,regionalCompanyIds, sandMiningAreaTimeValueEntityHashMap, timeValueParentEntities,isGroupByArea,isGroupByRegionalCompany,isGroupByStation); groupByNormal(startDate, endDate, stationIds, regionalCompanyIds, sandMiningAreaTimeValueEntityHashMap, timeValueParentEntities, isGroupByArea, isGroupByRegionalCompany, isGroupByStation);
//对数据做补充,没有的日期填充0 //对数据做补充,没有的日期填充0
for (TimeValueParentEntity miningAreaTimeValueEntity : timeValueParentEntities) { for (TimeValueParentEntity miningAreaTimeValueEntity : timeValueParentEntities) {
...@@ -119,12 +119,12 @@ public class DischargingServiceImpl implements DischargingService { ...@@ -119,12 +119,12 @@ public class DischargingServiceImpl implements DischargingService {
@Override @Override
public List<TimeValueParentEntity> replaceShowType(Integer showType, List<TimeValueParentEntity> timeValueParentEntities) { public List<TimeValueParentEntity> replaceShowType(Integer showType, List<TimeValueParentEntity> timeValueParentEntities) {
if(null==showType || 0==showType){ if (null == showType || 0 == showType) {
return timeValueParentEntities; return timeValueParentEntities;
} }
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMM"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMM");
if(2==showType){ if (2 == showType) {
dateFormat= new SimpleDateFormat("yyyy"); dateFormat = new SimpleDateFormat("yyyy");
} }
SimpleDateFormat finalDateFormat = dateFormat; SimpleDateFormat finalDateFormat = dateFormat;
for (TimeValueParentEntity valueParentEntity : timeValueParentEntities) { for (TimeValueParentEntity valueParentEntity : timeValueParentEntities) {
...@@ -133,7 +133,7 @@ public class DischargingServiceImpl implements DischargingService { ...@@ -133,7 +133,7 @@ public class DischargingServiceImpl implements DischargingService {
Map<String, List<TimeValue>> collect = timeValues.stream().collect(Collectors.groupingBy(timeValue -> finalDateFormat.format(timeValue.getTime()))); Map<String, List<TimeValue>> collect = timeValues.stream().collect(Collectors.groupingBy(timeValue -> finalDateFormat.format(timeValue.getTime())));
collect.forEach((s, timeValues1) -> { collect.forEach((s, timeValues1) -> {
try { try {
timeValues2.add(new TimeValue(UUID.randomUUID(),finalDateFormat.parse(s),timeValues1.stream().mapToDouble(TimeValue::getValue).summaryStatistics().getSum())); timeValues2.add(new TimeValue(UUID.randomUUID(), finalDateFormat.parse(s), timeValues1.stream().mapToDouble(TimeValue::getValue).summaryStatistics().getSum()));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -145,12 +145,12 @@ public class DischargingServiceImpl implements DischargingService { ...@@ -145,12 +145,12 @@ public class DischargingServiceImpl implements DischargingService {
return timeValueParentEntities; return timeValueParentEntities;
} }
private void groupByNormal(Date startDate, Date endDate, List<UUID> stationIds,List<UUID> regionalCompanyIds, private void groupByNormal(Date startDate, Date endDate, List<UUID> stationIds, List<UUID> regionalCompanyIds,
Map<UUID, TimeValueParentEntity> sandMiningAreaTimeValueEntityHashMap, Map<UUID, TimeValueParentEntity> sandMiningAreaTimeValueEntityHashMap,
List<TimeValueParentEntity> timeValueParentEntityList, Boolean isGroupByArea, Boolean isGroupByRegionalCompany, Boolean isGroupByStation) { List<TimeValueParentEntity> timeValueParentEntityList, Boolean isGroupByArea, Boolean isGroupByRegionalCompany, Boolean isGroupByStation) {
TimeValueParentEntity timeValueParentEntity; TimeValueParentEntity timeValueParentEntity;
//查询时间段内的非修正数据 //查询时间段内的非修正数据
List<HashMap<String, Object>> dischargingNormalDataList = dischargingDao.groupInfo(stationIds,regionalCompanyIds, startDate, endDate, List<HashMap<String, Object>> dischargingNormalDataList = dischargingDao.groupInfo(stationIds, regionalCompanyIds, startDate, endDate,
DischargingTypeEnum.NORMAL_DATA.getValue(), DischargingTypeEnum.NORMAL_DATA.getValue(),
true, isGroupByRegionalCompany, isGroupByArea, Boolean.TRUE, isGroupByStation); true, isGroupByRegionalCompany, isGroupByArea, Boolean.TRUE, isGroupByStation);
//将修正数据平均到每一天的数据与非修正数据相加 //将修正数据平均到每一天的数据与非修正数据相加
...@@ -161,14 +161,16 @@ public class DischargingServiceImpl implements DischargingService { ...@@ -161,14 +161,16 @@ public class DischargingServiceImpl implements DischargingService {
timeValueParentEntity = sandMiningAreaTimeValueEntityHashMap.get(sandMiningAreaId); timeValueParentEntity = sandMiningAreaTimeValueEntityHashMap.get(sandMiningAreaId);
List<TimeValue> timeValues = timeValueParentEntity.getTimeValues(); List<TimeValue> timeValues = timeValueParentEntity.getTimeValues();
List<TimeValue> timeValueNew = new ArrayList<>(); List<TimeValue> timeValueNew = new ArrayList<>();
if (timeValues.size() > 0) { boolean isAdd = false;
for (TimeValue timeValue : timeValues) { for (TimeValue timeValue : timeValues) {
//如果修正数据中有非修正数据的天数,加起来 //如果修正数据中有非修正数据的天数,加起来
if (DateUtils.isSameDay(timeValue.getTime(), dischargingTime)) { if (DateUtils.isSameDay(timeValue.getTime(), dischargingTime)) {
timeValue.setValue(timeValue.getValue() + dischargingWeight); timeValue.setValue(timeValue.getValue() + dischargingWeight);
isAdd = true;
} }
} }
} else { //如果已经加和到了修正数据中,那就不新增该数据
if (!isAdd) {
timeValues.add(new TimeValue(UUID.randomUUID(), dischargingTime, dischargingWeight)); timeValues.add(new TimeValue(UUID.randomUUID(), dischargingTime, dischargingWeight));
} }
for (TimeValue timeValue : timeValues) { for (TimeValue timeValue : timeValues) {
...@@ -181,11 +183,11 @@ public class DischargingServiceImpl implements DischargingService { ...@@ -181,11 +183,11 @@ public class DischargingServiceImpl implements DischargingService {
} }
} }
private void groupByRevise(List<UUID> stationIds,List<UUID> regionalCompanyIds, Date startDateTimeOfMonth, Date endDateTimeOfMonth, private void groupByRevise(List<UUID> stationIds, List<UUID> regionalCompanyIds, Date startDateTimeOfMonth, Date endDateTimeOfMonth,
Map<UUID, TimeValueParentEntity> sandMiningAreaTimeValueEntityHashMap, Map<UUID, TimeValueParentEntity> sandMiningAreaTimeValueEntityHashMap,
List<TimeValueParentEntity> timeValueParentEntityList, Boolean isGroupByArea, Boolean isGroupByRegionalCompany, Boolean isGroupByStation) { List<TimeValueParentEntity> timeValueParentEntityList, Boolean isGroupByArea, Boolean isGroupByRegionalCompany, Boolean isGroupByStation) {
//查询修正数据 //查询修正数据
List<HashMap<String, Object>> dischargingReviseList = dischargingDao.groupInfo(stationIds,regionalCompanyIds, startDateTimeOfMonth, endDateTimeOfMonth, List<HashMap<String, Object>> dischargingReviseList = dischargingDao.groupInfo(stationIds, regionalCompanyIds, startDateTimeOfMonth, endDateTimeOfMonth,
DischargingTypeEnum.REVISE_DATA.getValue(), DischargingTypeEnum.REVISE_DATA.getValue(),
true, isGroupByRegionalCompany, isGroupByArea, false, isGroupByStation); true, isGroupByRegionalCompany, isGroupByArea, false, isGroupByStation);
//组装数据 改成 采区-> {时间,值} 格式 //组装数据 改成 采区-> {时间,值} 格式
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment