|
|
@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.hnac.hzims.operational.fill.entity.GenerateEntity; |
|
|
|
import com.hnac.hzims.operational.fill.entity.GenerateEntity; |
|
|
|
import com.hnac.hzims.operational.fill.entity.UseEntity; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.fill.mapper.GenerateMapper; |
|
|
|
import com.hnac.hzims.operational.fill.mapper.GenerateMapper; |
|
|
|
import com.hnac.hzims.operational.fill.service.GenerateService; |
|
|
|
import com.hnac.hzims.operational.fill.service.GenerateService; |
|
|
|
import com.hnac.hzims.operational.fill.vo.GenerateVo; |
|
|
|
import com.hnac.hzims.operational.fill.vo.GenerateVo; |
|
|
@ -13,7 +12,6 @@ import com.hnac.hzims.operational.fill.vo.QueryVo; |
|
|
|
import com.hnac.hzims.operational.fill.wrapper.GenerateWrapper; |
|
|
|
import com.hnac.hzims.operational.fill.wrapper.GenerateWrapper; |
|
|
|
import com.hnac.hzims.operational.main.vo.GenerationPowerVo; |
|
|
|
import com.hnac.hzims.operational.main.vo.GenerationPowerVo; |
|
|
|
import com.hnac.hzims.operational.main.vo.PowerMonthVo; |
|
|
|
import com.hnac.hzims.operational.main.vo.PowerMonthVo; |
|
|
|
import com.hnac.hzims.operational.main.vo.UsrPowerVo; |
|
|
|
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
@ -29,6 +27,7 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.Calendar; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
@ -154,19 +153,45 @@ public class GenerateServiceImpl extends BaseServiceImpl<GenerateMapper, Generat |
|
|
|
if(CollectionUtil.isEmpty(records)){ |
|
|
|
if(CollectionUtil.isEmpty(records)){ |
|
|
|
return new ArrayList<>(); |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
List<String> mons = this.mons(2,12,false); |
|
|
|
|
|
|
|
List<GenerateEntity> format = records.stream().peek(record-> record.setFillDate(DateUtil.format(DateUtil.parse(record.getFillDate(),"yyyy-MM"),"yyyy-MM") + "-01")).collect(Collectors.toList()); |
|
|
|
// 返回结果
|
|
|
|
// 返回结果
|
|
|
|
return records.stream().peek( |
|
|
|
return mons.stream().map(mon->{ |
|
|
|
record-> record.setFillDate(DateUtil.format(DateUtil.parse(record.getFillDate(),"yyyy-MM"),"yyyy-MM") + "-01") |
|
|
|
PowerMonthVo powerMonth = new PowerMonthVo(); |
|
|
|
).collect(Collectors.toMap(GenerateEntity::getFillDate,GenerateEntity::getGenerate,Double::sum)). |
|
|
|
powerMonth.setStrMonth(mon); |
|
|
|
entrySet().stream().map(entry->{ |
|
|
|
powerMonth.setPower((float) format.stream().filter(o->o.getFillDate().equals(mon)).mapToDouble(GenerateEntity::getGenerate).sum()); |
|
|
|
PowerMonthVo mon = new PowerMonthVo(); |
|
|
|
return powerMonth; |
|
|
|
mon.setStrMonth(entry.getKey()); |
|
|
|
|
|
|
|
if(Math.abs(entry.getValue()) <= 0){ |
|
|
|
|
|
|
|
mon.setPower(0f); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
mon.setPower(Float.parseFloat(entry.getValue().toString())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return mon; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取近年月份集合 |
|
|
|
|
|
|
|
* @param year |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public List<String> mons(int year, int endMoth, boolean nextMon) { |
|
|
|
|
|
|
|
List<String> list = new ArrayList<>(); |
|
|
|
|
|
|
|
// 开始日期
|
|
|
|
|
|
|
|
Calendar endCal = Calendar.getInstance(); |
|
|
|
|
|
|
|
endCal.setTime(new Date()); |
|
|
|
|
|
|
|
endCal.add(Calendar.MONTH, -endCal.get(Calendar.MONTH) + endMoth); |
|
|
|
|
|
|
|
endCal.add(Calendar.DATE, -endCal.get(Calendar.DATE) + 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 结束日期
|
|
|
|
|
|
|
|
Calendar startCal = Calendar.getInstance(); |
|
|
|
|
|
|
|
startCal.setTime(new Date()); |
|
|
|
|
|
|
|
startCal.set(Calendar.YEAR, startCal.get(Calendar.YEAR) - year); |
|
|
|
|
|
|
|
startCal.add(Calendar.MONTH, -startCal.get(Calendar.MONTH)); |
|
|
|
|
|
|
|
startCal.add(Calendar.DATE, -startCal.get(Calendar.DATE) + 1); |
|
|
|
|
|
|
|
// 获取日期之间的月份
|
|
|
|
|
|
|
|
while (endCal.after(startCal)) { |
|
|
|
|
|
|
|
list.add(DateUtil.format(startCal.getTime(),DateUtil.PATTERN_DATE)); |
|
|
|
|
|
|
|
startCal.add(Calendar.MONTH, 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(nextMon){ |
|
|
|
|
|
|
|
list.add(DateUtil.format(endCal.getTime(),DateUtil.PATTERN_DATE)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return list; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|