Browse Source

#代码优化修改

zhongwei
yang_shj 1 year ago
parent
commit
199366015c
  1. 105
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java

105
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java

@ -48,6 +48,7 @@ import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment; import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.category.DefaultCategoryDataset;
import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
@ -81,6 +82,7 @@ import java.util.stream.Collectors;
/** /**
* 区域月报实现类 * 区域月报实现类
* @author ysj
*/ */
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@ -185,7 +187,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
// 设置头信息 // 设置头信息
response.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.ms-excel"); response.setContentType("application/vnd.ms-excel");
ServletOutputStream outputStream = null; ServletOutputStream outputStream;
try { try {
//设置xlsx格式 //设置xlsx格式
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xlsx", "UTF-8")); response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xlsx", "UTF-8"));
@ -217,10 +219,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
return R.fail("该机构不包含水站信息"); return R.fail("该机构不包含水站信息");
} }
List<Dept> deptList = deptR.getData().stream().filter(s -> s.getStationId() != null).collect(Collectors.toList()); List<Dept> deptList = deptR.getData().stream().filter(s -> s.getStationId() != null).collect(Collectors.toList());
if (deptList == null) { List<Long> deptByUser = deptByCurrentUser.getData().stream().map(Dept::getId).collect(Collectors.toList());
return R.fail("该机构不包含水站信息");
}
List<Long> deptByUser = deptByCurrentUser.getData().stream().map(s -> s.getId()).collect(Collectors.toList());
if (!deptByUser.contains(deptId)){ if (!deptByUser.contains(deptId)){
return R.fail("该用户不包含该机构权限,请申请权限再试"); return R.fail("该用户不包含该机构权限,请申请权限再试");
} }
@ -231,7 +230,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
Integer commissionTime = stationEntityList.stream().map(s -> { Integer commissionTime = stationEntityList.stream().map(s -> {
Duration dur = Duration.between(s.getCommissionTime(), LocalDateTime.now()); Duration dur = Duration.between(s.getCommissionTime(), LocalDateTime.now());
return (int) dur.toDays();}).reduce(Integer::max).get(); return (int) dur.toDays();}).reduce(Integer::max).get();
List<Long> stationIds = stationEntityList.stream().map(s -> s.getId()).collect(Collectors.toList()); List<Long> stationIds = stationEntityList.stream().map(BaseEntity::getId).collect(Collectors.toList());
//其它普通数据 //其它普通数据
map.put("year", year); map.put("year", year);
Integer yearBefore = year - 1; Integer yearBefore = year - 1;
@ -295,7 +294,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
ImageEntity capacityProportionChart = JFreeUtil.pieChartByDouble("水电项目装机容量占比图", capacityProportionMap, 500, 400); ImageEntity capacityProportionChart = JFreeUtil.pieChartByDouble("水电项目装机容量占比图", capacityProportionMap, 500, 400);
map.put("capacityProportionChart", capacityProportionChart); map.put("capacityProportionChart", capacityProportionChart);
//各发电站发电量环比图+表格数据组装 //各发电站发电量环比图+表格数据组装
List<String> deptIdsString = deptIds.stream().map(s -> String.valueOf(s)).collect(Collectors.toList()); List<String> deptIdsString = deptIds.stream().map(String::valueOf).collect(Collectors.toList());
List<PlanGenerationEntity> planYearData = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, year.toString()); List<PlanGenerationEntity> planYearData = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, year.toString());
List<MonPowerPercentageVo> powerPercentageVoList = new ArrayList<>(); List<MonPowerPercentageVo> powerPercentageVoList = new ArrayList<>();
//水电站,光伏站和带代运维数据近三年数据 //水电站,光伏站和带代运维数据近三年数据
@ -306,22 +305,20 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
String monStartYearBefore = TimeUtils.getMon(yearBefore, month); String monStartYearBefore = TimeUtils.getMon(yearBefore, month);
String monStartMonBefore = TimeUtils.getMon(year, monthBefore); String monStartMonBefore = TimeUtils.getMon(year, monthBefore);
for (Map.Entry<Long, Map<String, Float>> deviceMap : powerMapThree.entrySet()) { for (Map.Entry<Long, Map<String, Float>> deviceMap : powerMapThree.entrySet()) {
String deptNameByKey = ""; String deptNameByKey;
if (stationIds.contains(deviceMap.getKey())) { if (stationIds.contains(deviceMap.getKey())) {
MonPowerPercentageVo powerVo = new MonPowerPercentageVo(); MonPowerPercentageVo powerVo = new MonPowerPercentageVo();
powerVo.setDeptId(deviceMap.getKey()); powerVo.setDeptId(deviceMap.getKey());
List<StationEntity> collect = stationEntityList.stream().filter(s -> deviceMap.getKey().equals(s.getId())).collect(Collectors.toList()); List<StationEntity> collect = stationEntityList.stream().filter(s -> deviceMap.getKey().equals(s.getId())).collect(Collectors.toList());
if (collect!=null) {
Long dept = collect.get(0).getRefDept(); Long dept = collect.get(0).getRefDept();
List<Dept> dep = deptList.stream().filter(s -> dept.equals(s.getId())).collect(Collectors.toList()); List<Dept> dep = deptList.stream().filter(s -> dept.equals(s.getId())).collect(Collectors.toList());
deptNameByKey=dep.get(0).getDeptName(); deptNameByKey=dep.get(0).getDeptName();
}
powerVo.setDeptName(deptNameByKey); powerVo.setDeptName(deptNameByKey);
BigDecimal powerYear = new BigDecimal(0); BigDecimal powerYear;
BigDecimal powerYearBefore = new BigDecimal(0); BigDecimal powerYearBefore;
BigDecimal powerMonth = new BigDecimal(0); BigDecimal powerMonth;
BigDecimal powerMonthBefore = new BigDecimal(0); BigDecimal powerMonthBefore;
BigDecimal powerMonthYearBefore = new BigDecimal(0); BigDecimal powerMonthYearBefore;
Double planGeneration = 0d; Double planGeneration = 0d;
List<PlanGenerationEntity> planGenerationById = planYearData.stream().filter(s -> collect.get(0).getRefDept().equals(s.getStationDeptId())).collect(Collectors.toList()); List<PlanGenerationEntity> planGenerationById = planYearData.stream().filter(s -> collect.get(0).getRefDept().equals(s.getStationDeptId())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(planGenerationById)) { if (CollectionUtils.isNotEmpty(planGenerationById)) {
@ -379,7 +376,6 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
ImageEntity powerChainHistogram = JFreeUtil.iCreateBarChart(powerTitle, powerDomainAxis, powerRangeAxis, powerDataset, 500, 400); ImageEntity powerChainHistogram = JFreeUtil.iCreateBarChart(powerTitle, powerDomainAxis, powerRangeAxis, powerDataset, 500, 400);
map.put("powerChainHistogram", powerChainHistogram); map.put("powerChainHistogram", powerChainHistogram);
//柱状图下添加的表格 //柱状图下添加的表格
if (powerPercentageVoList != null) {
ArrayList<HashMap<String, String>> powerMap = new ArrayList<>(powerPercentageVoList.size()); ArrayList<HashMap<String, String>> powerMap = new ArrayList<>(powerPercentageVoList.size());
for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) { for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) {
HashMap<String, String> power = new HashMap<>(); HashMap<String, String> power = new HashMap<>();
@ -389,13 +385,11 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
powerMap.add(power); powerMap.add(power);
} }
map.put("power", powerMap); map.put("power", powerMap);
}
//表格总计 //表格总计
List<PlanGenerationEntity> planYearAll = planGenertionClient.getPlanGenerationByParam(null, Arrays.asList(deptId.toString()), year.toString()); List<PlanGenerationEntity> planYearAll = planGenertionClient.getPlanGenerationByParam(null, Collections.singletonList(deptId.toString()), year.toString());
List<PlanGenerationEntity> planMonAll = planGenertionClient.getPlanGenerationByParam(null, Arrays.asList(deptId.toString()), year + "-" + month); List<PlanGenerationEntity> planMonAll = planGenertionClient.getPlanGenerationByParam(null, Collections.singletonList(deptId.toString()), year + "-" + month);
getTabelSum(deptId, powerPercentageVoList, planYearAll, planMonAll, map); getTabelSum(deptId, powerPercentageVoList, planYearAll, planMonAll, map);
//发电情况统计表数据 //发电情况统计表数据
if (powerPercentageVoList != null) {
ArrayList<HashMap<String, String>> list = new ArrayList<>(powerPercentageVoList.size()); ArrayList<HashMap<String, String>> list = new ArrayList<>(powerPercentageVoList.size());
for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) { for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) {
HashMap<String, String> temp = new HashMap<>(8); HashMap<String, String> temp = new HashMap<>(8);
@ -410,7 +404,6 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
list.add(temp); list.add(temp);
} }
map.put("powerGeneration", list); map.put("powerGeneration", list);
}
//本月缺陷 //本月缺陷
@ -422,9 +415,9 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
wrapper.in(OperPhenomenonEntity::getCreateDept, deptIds); wrapper.in(OperPhenomenonEntity::getCreateDept, deptIds);
List<OperPhenomenonEntity> monPhenomenonList = operPhenomenonService.list(wrapper); List<OperPhenomenonEntity> monPhenomenonList = operPhenomenonService.list(wrapper);
monPhenomenonList = monPhenomenonList.stream().filter(s -> s.getDefectLevel() != null).collect(Collectors.toList()); monPhenomenonList = monPhenomenonList.stream().filter(s -> s.getDefectLevel() != null).collect(Collectors.toList());
List<OperPhenomenonEntity> monConclusionList = monPhenomenonList.stream().filter(s -> s.getConclusionStatus().equals("1")).collect(Collectors.toList()); List<OperPhenomenonEntity> monConclusionList = monPhenomenonList.stream().filter(s -> "1".equals(s.getConclusionStatus())).collect(Collectors.toList());
// 只填写二类及以上缺陷 // 只填写二类及以上缺陷
List<OperPhenomenonEntity> monConclusionListBy = monConclusionList.stream().filter(s -> !s.getDefectGrading().equals("1")).collect(Collectors.toList()); List<OperPhenomenonEntity> monConclusionListBy = monConclusionList.stream().filter(s -> !"1".equals(s.getDefectGrading())).collect(Collectors.toList());
// 各电站缺陷处理统计表 // 各电站缺陷处理统计表
monConclusionListBy.stream().sorted(Comparator.comparing(OperPhenomenonEntity::getCreateDept).reversed().thenComparing(OperPhenomenonEntity::getDefectGrading)); monConclusionListBy.stream().sorted(Comparator.comparing(OperPhenomenonEntity::getCreateDept).reversed().thenComparing(OperPhenomenonEntity::getDefectGrading));
ArrayList<HashMap<String, String>> checkList = new ArrayList<>(); ArrayList<HashMap<String, String>> checkList = new ArrayList<>();
@ -438,13 +431,13 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
HashMap<String, String> temp = new HashMap<>(); HashMap<String, String> temp = new HashMap<>();
temp.put("name", createDeptName.getData()); temp.put("name", createDeptName.getData());
String checkLevel=""; String checkLevel="";
if(operPhenomenonEntity.getDefectGrading().equals("1")) { if("1".equals(operPhenomenonEntity.getDefectGrading())) {
checkLevel="Ⅰ级缺陷"; checkLevel="Ⅰ级缺陷";
} }
if(operPhenomenonEntity.getDefectGrading().equals("2") ){ if("2".equals(operPhenomenonEntity.getDefectGrading()) ){
checkLevel="Ⅱ级缺陷"; checkLevel="Ⅱ级缺陷";
} }
if(operPhenomenonEntity.getDefectGrading().equals("3") ){ if("3".equals(operPhenomenonEntity.getDefectGrading()) ){
checkLevel="Ⅲ级缺陷"; checkLevel="Ⅲ级缺陷";
} }
temp.put("level", checkLevel); temp.put("level", checkLevel);
@ -490,14 +483,14 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
for (Map.Entry<Long, Map<String, List<OperPhenomenonEntity>>> deptMapEntry : phenomenonMap.entrySet()) { for (Map.Entry<Long, Map<String, List<OperPhenomenonEntity>>> deptMapEntry : phenomenonMap.entrySet()) {
R<String> deptName1 = sysClient.getDeptName(deptMapEntry.getKey()); R<String> deptName1 = sysClient.getDeptName(deptMapEntry.getKey());
for (Map.Entry<String, List<OperPhenomenonEntity>> levelList : deptMapEntry.getValue().entrySet()) { for (Map.Entry<String, List<OperPhenomenonEntity>> levelList : deptMapEntry.getValue().entrySet()) {
Integer findShortagesYear = levelList.getValue().size(); int findShortagesYear = levelList.getValue().size();
Integer shortagesYear = yearConclusionList.stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).collect(Collectors.toList()).size(); int shortagesYear = (int) yearConclusionList.stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).count();
Double shortagesRate = 0d; double shortagesRate = 0d;
if (findShortagesYear != 0 && shortagesYear != 0) { if (findShortagesYear != 0 && shortagesYear != 0) {
shortagesRate = BigDecimal.valueOf(shortagesYear).divide(BigDecimal.valueOf(findShortagesYear), 2, BigDecimal.ROUND_UP).doubleValue(); shortagesRate = BigDecimal.valueOf(shortagesYear).divide(BigDecimal.valueOf(findShortagesYear), 2, BigDecimal.ROUND_UP).doubleValue();
} }
Integer findShortagesMon = Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).collect(Collectors.toList()).size(); Integer findShortagesMon = (int) Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).count();
Integer shortagesMon = Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).collect(Collectors.toList()).size(); Integer shortagesMon = (int) Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).count();
CheckChartVo checkChartVo = new CheckChartVo(deptName1.getData(), levelList.getKey(), findShortagesMon, shortagesMon, findShortagesYear, shortagesYear, shortagesRate); CheckChartVo checkChartVo = new CheckChartVo(deptName1.getData(), levelList.getKey(), findShortagesMon, shortagesMon, findShortagesYear, shortagesYear, shortagesRate);
checkChartRes.add(checkChartVo); checkChartRes.add(checkChartVo);
} }
@ -505,14 +498,14 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
// 总计 // 总计
Map<String, List<OperPhenomenonEntity>> levelPhenomenonList = yearPhenomenonEntities.stream().collect(Collectors.groupingBy(OperPhenomenonEntity::getDefectGrading)); Map<String, List<OperPhenomenonEntity>> levelPhenomenonList = yearPhenomenonEntities.stream().collect(Collectors.groupingBy(OperPhenomenonEntity::getDefectGrading));
for (Map.Entry<String, List<OperPhenomenonEntity>> levelPhenomenon : levelPhenomenonList.entrySet()) { for (Map.Entry<String, List<OperPhenomenonEntity>> levelPhenomenon : levelPhenomenonList.entrySet()) {
Integer findShortagesYear = levelPhenomenon.getValue().size(); int findShortagesYear = levelPhenomenon.getValue().size();
Integer shortagesYear = Optional.ofNullable(yearConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).collect(Collectors.toList()).size(); int shortagesYear = (int) Optional.ofNullable(yearConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).count();
Double shortagesRate = 0d; double shortagesRate = 0d;
if (findShortagesYear != 0 && shortagesYear != 0) { if (findShortagesYear != 0 && shortagesYear != 0) {
shortagesRate = BigDecimal.valueOf(shortagesYear).divide(BigDecimal.valueOf(findShortagesYear), 2, BigDecimal.ROUND_UP).doubleValue(); shortagesRate = BigDecimal.valueOf(shortagesYear).divide(BigDecimal.valueOf(findShortagesYear), 2, BigDecimal.ROUND_UP).doubleValue();
} }
Integer findShortagesMon = Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).collect(Collectors.toList()).size(); Integer findShortagesMon = (int) Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).count();
Integer shortagesMon = Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).collect(Collectors.toList()).size(); Integer shortagesMon = (int) Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).count();
CheckChartVo checkChartVo = new CheckChartVo("总计", levelPhenomenon.getKey(), findShortagesMon, shortagesMon, findShortagesYear, shortagesYear, shortagesRate); CheckChartVo checkChartVo = new CheckChartVo("总计", levelPhenomenon.getKey(), findShortagesMon, shortagesMon, findShortagesYear, shortagesYear, shortagesRate);
checkChartRes.add(checkChartVo); checkChartRes.add(checkChartVo);
} }
@ -521,13 +514,13 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
HashMap<String, String> temp = new HashMap<>(); HashMap<String, String> temp = new HashMap<>();
temp.put("deptName", checkChartRe.getDeptName()); temp.put("deptName", checkChartRe.getDeptName());
String checkLevel=null; String checkLevel=null;
if(checkChartRe.getCheckLevel().equals("1")) { if("1".equals(checkChartRe.getCheckLevel())) {
checkLevel="Ⅰ级缺陷"; checkLevel="Ⅰ级缺陷";
} }
if(checkChartRe.getCheckLevel().equals("2")) { if("2".equals(checkChartRe.getCheckLevel())) {
checkLevel="Ⅱ级缺陷"; checkLevel="Ⅱ级缺陷";
} }
if(checkChartRe.getCheckLevel().equals("3")) { if("3".equals(checkChartRe.getCheckLevel())) {
checkLevel="Ⅲ级缺陷"; checkLevel="Ⅲ级缺陷";
} }
temp.put("checkLevel", checkLevel); temp.put("checkLevel", checkLevel);
@ -571,23 +564,23 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
.filter(s -> s.getType().equals(value.getType())).collect(Collectors.toList()); .filter(s -> s.getType().equals(value.getType())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(yearTicketCollect)) { if (CollectionUtils.isNotEmpty(yearTicketCollect)) {
//年合格率和数量 //年合格率和数量
Integer count = yearTicketCollect.size(); int count = yearTicketCollect.size();
ticketChartCell.setTicketYear(count); ticketChartCell.setTicketYear(count);
List<Long> ticketIds = yearTicketCollect.stream().map(s -> s.getId()).collect(Collectors.toList()); List<Long> ticketIds = yearTicketCollect.stream().map(BaseEntity::getId).collect(Collectors.toList());
R<Long> ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds); R<Long> ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds);
if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null && count != 0) { if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null && count != 0) {
Double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketYeaPercr(ticketYearPerc); ticketChartCell.setTicketYeaPercr(ticketYearPerc);
} }
} }
if (CollectionUtils.isNotEmpty(monthTicketCollect)) { if (CollectionUtils.isNotEmpty(monthTicketCollect)) {
//月合格率和数量 //月合格率和数量
Integer count = monthTicketCollect.size(); int count = monthTicketCollect.size();
ticketChartCell.setTicketMon(count); ticketChartCell.setTicketMon(count);
List<Long> monthTicketIds = monthTicketCollect.stream().map(s -> s.getId()).collect(Collectors.toList()); List<Long> monthTicketIds = monthTicketCollect.stream().map(BaseEntity::getId).collect(Collectors.toList());
R<Long> ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds); R<Long> ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds);
if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null && count != 0) { if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null && count != 0) {
Double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketMonPerc(ticketMonthPerc); ticketChartCell.setTicketMonPerc(ticketMonthPerc);
} }
} }
@ -601,23 +594,23 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
.filter(s -> s.getTicketType().equals(value.getType())).collect(Collectors.toList()); .filter(s -> s.getTicketType().equals(value.getType())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(yearOperateCollect)) { if (CollectionUtils.isNotEmpty(yearOperateCollect)) {
//年合格率和数量 //年合格率和数量
Integer count = yearOperateCollect.size(); int count = yearOperateCollect.size();
ticketChartCell.setTicketYear(count); ticketChartCell.setTicketYear(count);
List<Long> ticketIds = yearOperateCollect.stream().map(s -> s.getId()).collect(Collectors.toList()); List<Long> ticketIds = yearOperateCollect.stream().map(BaseEntity::getId).collect(Collectors.toList());
R<Long> ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds); R<Long> ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds);
if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null && count != 0) { if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null && count != 0) {
Double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketYeaPercr(ticketYearPerc); ticketChartCell.setTicketYeaPercr(ticketYearPerc);
} }
} }
if (CollectionUtils.isNotEmpty(monthOperateCollect)) { if (CollectionUtils.isNotEmpty(monthOperateCollect)) {
//月合格率和数量 //月合格率和数量
Integer count = monthOperateCollect.size(); int count = monthOperateCollect.size();
ticketChartCell.setTicketMon(count); ticketChartCell.setTicketMon(count);
List<Long> monthTicketIds = monthOperateCollect.stream().map(s -> s.getId()).collect(Collectors.toList()); List<Long> monthTicketIds = monthOperateCollect.stream().map(BaseEntity::getId).collect(Collectors.toList());
R<Long> ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds); R<Long> ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds);
if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null && count != 0) { if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null && count != 0) {
Double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketMonPerc(ticketMonthPerc); ticketChartCell.setTicketMonPerc(ticketMonthPerc);
} }
} }
@ -711,7 +704,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
List<AnalyseDataTaosVO> analyseData = analyseDataService.periodTargetData(yearStart, yearEnd, 3, EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION); List<AnalyseDataTaosVO> analyseData = analyseDataService.periodTargetData(yearStart, yearEnd, 3, EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
if (CollectionUtil.isNotEmpty(analyseData)) { if (CollectionUtil.isNotEmpty(analyseData)) {
BigDecimal yearPower = analyseData.stream().filter(ktv -> ktv.getVal() != null) BigDecimal yearPower = analyseData.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal()))) .map(ktv -> BigDecimal.valueOf(Double.parseDouble(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
powerYear = powerYear.add(yearPower); powerYear = powerYear.add(yearPower);
} }
@ -719,7 +712,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
List<AnalyseDataTaosVO> analyseDataYearBefore = analyseDataService.periodTargetData(yearBeforeStart, yearBeforeEnd, 3, EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION); List<AnalyseDataTaosVO> analyseDataYearBefore = analyseDataService.periodTargetData(yearBeforeStart, yearBeforeEnd, 3, EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
if (CollectionUtil.isNotEmpty(analyseDataYearBefore)) { if (CollectionUtil.isNotEmpty(analyseDataYearBefore)) {
BigDecimal powerBefore = analyseDataYearBefore.stream().filter(ktv -> ktv.getVal() != null) BigDecimal powerBefore = analyseDataYearBefore.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal()))) .map(ktv -> BigDecimal.valueOf(Double.parseDouble(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
powerYearBefore = powerYearBefore.add(powerBefore); powerYearBefore = powerYearBefore.add(powerBefore);
} }
@ -727,7 +720,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
List<AnalyseDataTaosVO> analyseDataMonth = analyseDataService.periodTargetData(monthStart, monthEnd, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION); List<AnalyseDataTaosVO> analyseDataMonth = analyseDataService.periodTargetData(monthStart, monthEnd, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
if (CollectionUtil.isNotEmpty(analyseDataMonth)) { if (CollectionUtil.isNotEmpty(analyseDataMonth)) {
BigDecimal powerBefore = analyseDataMonth.stream().filter(ktv -> ktv.getVal() != null) BigDecimal powerBefore = analyseDataMonth.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal()))) .map(ktv -> BigDecimal.valueOf(Double.parseDouble(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonth = powerMonth.add(powerBefore); powerMonth = powerMonth.add(powerBefore);
} }
@ -735,7 +728,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
List<AnalyseDataTaosVO> analyseDataMonthBefore = analyseDataService.periodTargetData(beforeMonthStart, beforeMonthEnd, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION); List<AnalyseDataTaosVO> analyseDataMonthBefore = analyseDataService.periodTargetData(beforeMonthStart, beforeMonthEnd, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
if (CollectionUtil.isNotEmpty(analyseDataMonthBefore)) { if (CollectionUtil.isNotEmpty(analyseDataMonthBefore)) {
BigDecimal powerBefore = analyseDataMonthBefore.stream().filter(ktv -> ktv.getVal() != null) BigDecimal powerBefore = analyseDataMonthBefore.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal()))) .map(ktv -> BigDecimal.valueOf(Double.parseDouble(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonthBefore = powerMonthBefore.add(powerBefore); powerMonthBefore = powerMonthBefore.add(powerBefore);
} }
@ -743,7 +736,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
List<AnalyseDataTaosVO> analyseDataMonthBeforeYear = analyseDataService.periodTargetData(monthStartBeforeYear, monthEndBeforeYear, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION); List<AnalyseDataTaosVO> analyseDataMonthBeforeYear = analyseDataService.periodTargetData(monthStartBeforeYear, monthEndBeforeYear, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
if (CollectionUtil.isNotEmpty(analyseDataMonthBeforeYear)) { if (CollectionUtil.isNotEmpty(analyseDataMonthBeforeYear)) {
BigDecimal powerBefore = analyseDataMonthBeforeYear.stream().filter(ktv -> ktv.getVal() != null) BigDecimal powerBefore = analyseDataMonthBeforeYear.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal()))) .map(ktv -> BigDecimal.valueOf(Double.parseDouble(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonthYearBefore = powerMonthYearBefore.add(powerBefore); powerMonthYearBefore = powerMonthYearBefore.add(powerBefore);
} }

Loading…
Cancel
Save