Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java
zhongwei
yang_shj 1 year ago
parent
commit
4216714506
  1. 8
      hzims-service/assets/src/main/java/com/hnac/hzims/spare/aspect/LimitRemindAspect.java
  2. 8
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java
  3. 2
      hzims-service/hzims-middle/src/main/resources/db/1.0.1.sql
  4. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java
  5. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAreaMonthReportService.java
  6. 277
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java
  7. 4
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java
  8. 5
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketCountServiceImpl.java
  9. 40
      hzims-service/ticket/src/main/resources/db/2.0.0.sql

8
hzims-service/assets/src/main/java/com/hnac/hzims/spare/aspect/LimitRemindAspect.java

@ -171,9 +171,9 @@ public class LimitRemindAspect {
private void warningPush(String alert, User pusher,Long warehouseId) { private void warningPush(String alert, User pusher,Long warehouseId) {
MessagePushRecordDto message = new MessagePushRecordDto(); MessagePushRecordDto message = new MessagePushRecordDto();
message.setBusinessClassify("business"); message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.ASSETS.getKey());
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.ASSETS.getKey()); message.setBusinessKey("资产预警");
message.setSubject(MessageConstants.BusinessClassifyEnum.ASSETS.getDescription()); message.setSubject("资产预警");
message.setTaskId(warehouseId); message.setTaskId(warehouseId);
message.setTenantId("200000"); message.setTenantId("200000");
message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH));
@ -191,7 +191,7 @@ public class LimitRemindAspect {
} }
message.setPusher(userId.toString()); message.setPusher(userId.toString());
message.setPusherName(pusher.getName()); message.setPusherName(pusher.getName());
message.setAccount(pusher.getAccount()); message.setAccount(pusher.getId().toString());
message.setCreateUser(userId); message.setCreateUser(userId);
messageClient.sendMessage(message); messageClient.sendMessage(message);

8
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java

@ -109,8 +109,12 @@ public class StatisticsServiceImpl extends ServiceImpl<StatisticsMapper, Statist
*/ */
@Override @Override
public IPage<StatisticsResponseVo> selectPage(Page<StatisticsResponseVo> page1, StatisticsVo statistics) { public IPage<StatisticsResponseVo> selectPage(Page<StatisticsResponseVo> page1, StatisticsVo statistics) {
statistics.setCreateTime(statistics.getCreateTime().substring(0, 10)); if (statistics.getCreateTime() != null) {
statistics.setEndTime(statistics.getEndTime().substring(0, 10)); statistics.setCreateTime(statistics.getCreateTime().substring(0, 10));
}
if (statistics.getEndTime() != null) {
statistics.setEndTime(statistics.getEndTime().substring(0, 10));
}
IPage<StatisticsResponseVo> statisticsResponseVoIPage = baseMapper.selectPages(page1, statistics); IPage<StatisticsResponseVo> statisticsResponseVoIPage = baseMapper.selectPages(page1, statistics);
// List<StatisticsResponseVo> records = statisticsResponseVoIPage.getRecords(); // List<StatisticsResponseVo> records = statisticsResponseVoIPage.getRecords();
// List<StatisticsResponseVo> collect = records.stream().sorted(Comparator.comparing(StatisticsResponseVo::getSort)).collect(Collectors.toList()); // List<StatisticsResponseVo> collect = records.stream().sorted(Comparator.comparing(StatisticsResponseVo::getSort)).collect(Collectors.toList());

2
hzims-service/hzims-middle/src/main/resources/db/1.0.1.sql

@ -1,3 +1,5 @@
alter table hzims_workflow_operation_log add is_operation_log tinyint(1) comment '1 正常日志 0 错误日志';
alter table hzims_statistics add sort int comment '排序';
create table log_options_module_name create table log_options_module_name
( (
id bigint primary key auto_increment, id bigint primary key auto_increment,

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java

@ -123,11 +123,11 @@ public class AreaMonthReportController extends BladeController {
@ApiOperation("导出水电站月报") @ApiOperation("导出水电站月报")
@GetMapping("/exportHydropowerStationMonthReport") @GetMapping("/exportHydropowerStationMonthReport")
public R exportHydropowerStationMonthReport(HttpServletResponse response, @ApiParam(value = "日期-年", required = true) Integer year,@ApiParam(value = "日期-月", required = true) Integer month, public R exportHydropowerStationMonthReport(HttpServletResponse response, @ApiParam(value = "日期-年", required = true) Integer year,@ApiParam(value = "日期-月", required = true) Integer month,
@ApiParam(value = "日期-日", required = true) Integer date,@ApiParam(value = "站点Id", required = true) Long stationId,@ApiParam(value = "月报类型", required = true) Long type) { @ApiParam(value = "站点Id", required = true) Long deptId,@ApiParam(value = "月报类型", required = true) Long type) {
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
if (type==1){ if (type==1){
service.exportHydropowerStationMonthReport(response, map,year,month,date,stationId); service.exportHydropowerStationMonthReport(response, map,year,month,deptId);
//word模板相对路径、word生成路径、word生成的文件名称、数据源 //word模板相对路径、word生成路径、word生成的文件名称、数据源
} }
XWPFDocument xwpfDocument = WordUtils.exportWordV2("template/waterMonReport.docx", map); XWPFDocument xwpfDocument = WordUtils.exportWordV2("template/waterMonReport.docx", map);

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAreaMonthReportService.java

@ -18,5 +18,5 @@ public interface IAreaMonthReportService {
R export(HttpServletResponse response, String date); R export(HttpServletResponse response, String date);
R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month, Integer date,Long stationId); R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month,Long deptId);
} }

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

@ -48,7 +48,6 @@ 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;
@ -82,7 +81,6 @@ import java.util.stream.Collectors;
/** /**
* 区域月报实现类 * 区域月报实现类
* @author ysj
*/ */
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@ -187,7 +185,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; ServletOutputStream outputStream = null;
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"));
@ -204,7 +202,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
return R.data("success"); return R.data("success");
} }
@Override @Override
public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month, Integer date, Long deptId) { public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month, Long deptId) {
R<List<Dept>> deptByCurrentUser = sysClient.getDeptByCurrentUser(); R<List<Dept>> deptByCurrentUser = sysClient.getDeptByCurrentUser();
if (!deptByCurrentUser.isSuccess()||deptByCurrentUser.getData()!=null){ if (!deptByCurrentUser.isSuccess()||deptByCurrentUser.getData()!=null){
return R.fail("用户权限查询失败"); return R.fail("用户权限查询失败");
@ -219,7 +217,10 @@ 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());
List<Long> deptByUser = deptByCurrentUser.getData().stream().map(Dept::getId).collect(Collectors.toList()); if (deptList == null) {
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("该用户不包含该机构权限,请申请权限再试");
} }
@ -230,7 +231,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(BaseEntity::getId).collect(Collectors.toList()); List<Long> stationIds = stationEntityList.stream().map(s -> s.getId()).collect(Collectors.toList());
//其它普通数据 //其它普通数据
map.put("year", year); map.put("year", year);
Integer yearBefore = year - 1; Integer yearBefore = year - 1;
@ -238,7 +239,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
map.put("month", month); map.put("month", month);
Integer monthBefore = month - 1; Integer monthBefore = month - 1;
map.put("monthBefore", monthBefore); map.put("monthBefore", monthBefore);
map.put("date", date); // map.put("date", date);
map.put("commissionTime", commissionTime.toString()); map.put("commissionTime", commissionTime.toString());
map.put("stationName", deptName); map.put("stationName", deptName);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
@ -273,6 +274,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
.mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum(); .mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum();
BigDecimal sumData=new BigDecimal(sum).divide(new BigDecimal(1000),2,BigDecimal.ROUND_UP); BigDecimal sumData=new BigDecimal(sum).divide(new BigDecimal(1000),2,BigDecimal.ROUND_UP);
map.put("installedCapacity", sumData); map.put("installedCapacity", sumData);
//各站点分组 //各站点分组
Map<Long, List<HydropowerUnitRealVo>> listMap = Optional.ofNullable(realsByDept) Map<Long, List<HydropowerUnitRealVo>> listMap = Optional.ofNullable(realsByDept)
.orElse(new ArrayList<>()).stream() .orElse(new ArrayList<>()).stream()
@ -294,73 +296,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(String::valueOf).collect(Collectors.toList()); List<MonPowerPercentageVo> powerPercentageVoList = getMonPowerPercentageVos(year, month, deptList, deptIds, stationEntityList, stationIds, yearBefore, monthBefore);
List<PlanGenerationEntity> planYearData = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, year.toString());
List<MonPowerPercentageVo> powerPercentageVoList = new ArrayList<>();
//水电站,光伏站和带代运维数据近三年数据
Map<Long, Map<String, Float>> powerMapThree = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
List<String> listByYear = TimeUtils.getListByYear(year);
List<String> listByYearBefore = TimeUtils.getListByYear(yearBefore);
String monStart = TimeUtils.getMon(year, month);
String monStartYearBefore = TimeUtils.getMon(yearBefore, month);
String monStartMonBefore = TimeUtils.getMon(year, monthBefore);
for (Map.Entry<Long, Map<String, Float>> deviceMap : powerMapThree.entrySet()) {
String deptNameByKey;
if (stationIds.contains(deviceMap.getKey())) {
MonPowerPercentageVo powerVo = new MonPowerPercentageVo();
powerVo.setDeptId(deviceMap.getKey());
List<StationEntity> collect = stationEntityList.stream().filter(s -> deviceMap.getKey().equals(s.getId())).collect(Collectors.toList());
Long dept = collect.get(0).getRefDept();
List<Dept> dep = deptList.stream().filter(s -> dept.equals(s.getId())).collect(Collectors.toList());
deptNameByKey=dep.get(0).getDeptName();
powerVo.setDeptName(deptNameByKey);
BigDecimal powerYear;
BigDecimal powerYearBefore;
BigDecimal powerMonth;
BigDecimal powerMonthBefore;
BigDecimal powerMonthYearBefore;
Double planGeneration = 0d;
List<PlanGenerationEntity> planGenerationById = planYearData.stream().filter(s -> collect.get(0).getRefDept().equals(s.getStationDeptId())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(planGenerationById)) {
planGeneration = Double.valueOf(planGenerationById.get(0).getPlanGeneration());
}
//当前机构近三年的数据
Map<String, Float> value = deviceMap.getValue();
//今年发电量
powerYear=value.entrySet().stream().filter(s->listByYear.contains(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add);
//转换单位kwh-》万Kwh
powerYear=powerYear.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP);
powerYearBefore=value.entrySet().stream().filter(s->listByYearBefore.contains(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add);
powerYearBefore=powerYearBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP);
powerMonth=value.entrySet().stream().filter(s->monStart.equals(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonth=powerMonth.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP);
powerMonthBefore=value.entrySet().stream().filter(s->monStartMonBefore.equals(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonthBefore=powerMonthBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP);
powerMonthYearBefore=value.entrySet().stream().filter(s->monStartYearBefore.equals(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonthYearBefore=powerMonthYearBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP);
powerVo.setPowerYear(powerYear.doubleValue());
powerVo.setPowerYearBefore(powerYearBefore.doubleValue());
BigDecimal yearPercentage = new BigDecimal(0);
BigDecimal planPercentage = new BigDecimal(0);
if (powerYearBefore.compareTo(BigDecimal.ZERO) != 0) {
yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, BigDecimal.ROUND_UP);
}
if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO) != 0) {
planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, BigDecimal.ROUND_UP);
}
powerVo.setPlanPercentage(planPercentage.doubleValue());
powerVo.setPowerYearPercentage(yearPercentage.doubleValue());
powerVo.setPowerMon(powerMonth.doubleValue());
powerVo.setPowerMonBefore(powerMonthBefore.doubleValue());
powerVo.setPowerMonYearBefore(powerMonthYearBefore.doubleValue());
BigDecimal monPercentage = new BigDecimal(0);
if (powerMonthYearBefore.compareTo(BigDecimal.ZERO) != 0) {
monPercentage = (powerMonth.subtract(powerMonthYearBefore)).divide(powerMonthYearBefore, 2, BigDecimal.ROUND_UP);
}
powerVo.setPowerMonPercentage(monPercentage.doubleValue());
powerPercentageVoList.add(powerVo);
}
}
// getPowerData(deptList, yearStart, yearEnd, yearBeforeStart, yearBeforeEnd, monthStart, monthEnd, beforeMonthStart, beforeMonthEnd, monthStartBeforeYear, monthEndBeforeYear, devices, planYearData, powerPercentageVoList); // getPowerData(deptList, yearStart, yearEnd, yearBeforeStart, yearBeforeEnd, monthStart, monthEnd, beforeMonthStart, beforeMonthEnd, monthStartBeforeYear, monthEndBeforeYear, devices, planYearData, powerPercentageVoList);
// 各发电站发电量环比图数据组装 // 各发电站发电量环比图数据组装
//柱状图图数据 //柱状图图数据
@ -376,34 +312,38 @@ 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);
//柱状图下添加的表格 //柱状图下添加的表格
ArrayList<HashMap<String, String>> powerMap = new ArrayList<>(powerPercentageVoList.size()); if (powerPercentageVoList != null) {
for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) { ArrayList<HashMap<String, String>> powerMap = new ArrayList<>(powerPercentageVoList.size());
HashMap<String, String> power = new HashMap<>(); for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) {
power.put("name", monPowerPercentageVo.getDeptName()); HashMap<String, String> power = new HashMap<>();
power.put("monthBefore", monPowerPercentageVo.getPowerMonBefore()+"MW"); power.put("name", monPowerPercentageVo.getDeptName());
power.put("month",monPowerPercentageVo.getPowerMon()+"MW"); power.put("monthBefore", monPowerPercentageVo.getPowerMonBefore()+"MW");
powerMap.add(power); power.put("month",monPowerPercentageVo.getPowerMon()+"MW");
powerMap.add(power);
}
map.put("power", powerMap);
} }
map.put("power", powerMap);
//表格总计 //表格总计
List<PlanGenerationEntity> planYearAll = planGenertionClient.getPlanGenerationByParam(null, Collections.singletonList(deptId.toString()), year.toString()); List<PlanGenerationEntity> planYearAll = planGenertionClient.getPlanGenerationByParam(null, Arrays.asList(deptId.toString()), year.toString());
List<PlanGenerationEntity> planMonAll = planGenertionClient.getPlanGenerationByParam(null, Collections.singletonList(deptId.toString()), year + "-" + month); List<PlanGenerationEntity> planMonAll = planGenertionClient.getPlanGenerationByParam(null, Arrays.asList(deptId.toString()), year + "-" + month);
getTabelSum(deptId, powerPercentageVoList, planYearAll, planMonAll, map); getTabelSum(deptId, powerPercentageVoList, planYearAll, planMonAll, map);
//发电情况统计表数据 //发电情况统计表数据
ArrayList<HashMap<String, String>> list = new ArrayList<>(powerPercentageVoList.size()); if (powerPercentageVoList != null) {
for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) { ArrayList<HashMap<String, String>> list = new ArrayList<>(powerPercentageVoList.size());
HashMap<String, String> temp = new HashMap<>(8); for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) {
temp.put("name", monPowerPercentageVo.getDeptName()); HashMap<String, String> temp = new HashMap<>(8);
temp.put("powerMonBefore", String.valueOf(monPowerPercentageVo.getPowerMonYearBefore())); temp.put("name", monPowerPercentageVo.getDeptName());
temp.put("powerYearBefore", String.valueOf(monPowerPercentageVo.getPowerYearBefore())); temp.put("powerMonBefore", String.valueOf(monPowerPercentageVo.getPowerMonYearBefore()));
temp.put("mon", String.valueOf(monPowerPercentageVo.getPowerMon())); temp.put("powerYearBefore", String.valueOf(monPowerPercentageVo.getPowerYearBefore()));
temp.put("year", String.valueOf(monPowerPercentageVo.getPowerYear())); temp.put("mon", String.valueOf(monPowerPercentageVo.getPowerMon()));
temp.put("monPercentage", monPowerPercentageVo.getPowerMonPercentage() * 100 + "%"); temp.put("year", String.valueOf(monPowerPercentageVo.getPowerYear()));
temp.put("yearPercentage", monPowerPercentageVo.getPowerYearPercentage() * 100 + "%"); temp.put("monPercentage", monPowerPercentageVo.getPowerMonPercentage() * 100 + "%");
temp.put("plan", monPowerPercentageVo.getPlanPercentage() * 100 + "%"); temp.put("yearPercentage", monPowerPercentageVo.getPowerYearPercentage() * 100 + "%");
list.add(temp); temp.put("plan", monPowerPercentageVo.getPlanPercentage() * 100 + "%");
list.add(temp);
}
map.put("powerGeneration", list);
} }
map.put("powerGeneration", list);
//本月缺陷 //本月缺陷
@ -415,9 +355,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 -> "1".equals(s.getConclusionStatus())).collect(Collectors.toList()); List<OperPhenomenonEntity> monConclusionList = monPhenomenonList.stream().filter(s -> s.getConclusionStatus().equals("1")).collect(Collectors.toList());
// 只填写二类及以上缺陷 // 只填写二类及以上缺陷
List<OperPhenomenonEntity> monConclusionListBy = monConclusionList.stream().filter(s -> !"1".equals(s.getDefectGrading())).collect(Collectors.toList()); List<OperPhenomenonEntity> monConclusionListBy = monConclusionList.stream().filter(s -> !s.getDefectGrading().equals("1")).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<>();
@ -431,13 +371,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("1".equals(operPhenomenonEntity.getDefectGrading())) { if(operPhenomenonEntity.getDefectGrading().equals("1")) {
checkLevel="Ⅰ级缺陷"; checkLevel="Ⅰ级缺陷";
} }
if("2".equals(operPhenomenonEntity.getDefectGrading()) ){ if(operPhenomenonEntity.getDefectGrading().equals("2") ){
checkLevel="Ⅱ级缺陷"; checkLevel="Ⅱ级缺陷";
} }
if("3".equals(operPhenomenonEntity.getDefectGrading()) ){ if(operPhenomenonEntity.getDefectGrading().equals("3") ){
checkLevel="Ⅲ级缺陷"; checkLevel="Ⅲ级缺陷";
} }
temp.put("level", checkLevel); temp.put("level", checkLevel);
@ -483,14 +423,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()) {
int findShortagesYear = levelList.getValue().size(); Integer findShortagesYear = levelList.getValue().size();
int shortagesYear = (int) yearConclusionList.stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).count(); Integer shortagesYear = yearConclusionList.stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).collect(Collectors.toList()).size();
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 = (int) Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).count(); Integer findShortagesMon = Optional.ofNullable(monPhenomenonList).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(); Integer shortagesMon = Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).collect(Collectors.toList()).size();
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);
} }
@ -498,14 +438,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()) {
int findShortagesYear = levelPhenomenon.getValue().size(); Integer findShortagesYear = levelPhenomenon.getValue().size();
int shortagesYear = (int) Optional.ofNullable(yearConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).count(); Integer shortagesYear = Optional.ofNullable(yearConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).collect(Collectors.toList()).size();
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 = (int) Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).count(); Integer findShortagesMon = Optional.ofNullable(monPhenomenonList).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(); Integer shortagesMon = Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).collect(Collectors.toList()).size();
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);
} }
@ -514,13 +454,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("1".equals(checkChartRe.getCheckLevel())) { if(checkChartRe.getCheckLevel().equals("1")) {
checkLevel="Ⅰ级缺陷"; checkLevel="Ⅰ级缺陷";
} }
if("2".equals(checkChartRe.getCheckLevel())) { if(checkChartRe.getCheckLevel().equals("2")) {
checkLevel="Ⅱ级缺陷"; checkLevel="Ⅱ级缺陷";
} }
if("3".equals(checkChartRe.getCheckLevel())) { if(checkChartRe.getCheckLevel().equals("3")) {
checkLevel="Ⅲ级缺陷"; checkLevel="Ⅲ级缺陷";
} }
temp.put("checkLevel", checkLevel); temp.put("checkLevel", checkLevel);
@ -564,23 +504,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)) {
//年合格率和数量 //年合格率和数量
int count = yearTicketCollect.size(); Integer count = yearTicketCollect.size();
ticketChartCell.setTicketYear(count); ticketChartCell.setTicketYear(count);
List<Long> ticketIds = yearTicketCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); List<Long> ticketIds = yearTicketCollect.stream().map(s -> s.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)) {
//月合格率和数量 //月合格率和数量
int count = monthTicketCollect.size(); Integer count = monthTicketCollect.size();
ticketChartCell.setTicketMon(count); ticketChartCell.setTicketMon(count);
List<Long> monthTicketIds = monthTicketCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); List<Long> monthTicketIds = monthTicketCollect.stream().map(s -> s.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);
} }
} }
@ -594,23 +534,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)) {
//年合格率和数量 //年合格率和数量
int count = yearOperateCollect.size(); Integer count = yearOperateCollect.size();
ticketChartCell.setTicketYear(count); ticketChartCell.setTicketYear(count);
List<Long> ticketIds = yearOperateCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); List<Long> ticketIds = yearOperateCollect.stream().map(s -> s.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)) {
//月合格率和数量 //月合格率和数量
int count = monthOperateCollect.size(); Integer count = monthOperateCollect.size();
ticketChartCell.setTicketMon(count); ticketChartCell.setTicketMon(count);
List<Long> monthTicketIds = monthOperateCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); List<Long> monthTicketIds = monthOperateCollect.stream().map(s -> s.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);
} }
} }
@ -681,6 +621,79 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
return R.success("成功"); return R.success("成功");
} }
private List<MonPowerPercentageVo> getMonPowerPercentageVos(Integer year, Integer month, List<Dept> deptList, List<Long> deptIds, List<StationEntity> stationEntityList, List<Long> stationIds, Integer yearBefore, Integer monthBefore) {
List<String> deptIdsString = deptIds.stream().map(s -> String.valueOf(s)).collect(Collectors.toList());
List<PlanGenerationEntity> planYearData = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, year.toString());
List<MonPowerPercentageVo> powerPercentageVoList = new ArrayList<>();
//水电站,光伏站和带代运维数据近三年数据
Map<Long, Map<String, Float>> powerMapThree = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
List<String> listByYear = TimeUtils.getListByYear(year);
List<String> listByYearBefore = TimeUtils.getListByYear(yearBefore);
String monStart = TimeUtils.getMon(year, month);
String monStartYearBefore = TimeUtils.getMon(yearBefore, month);
String monStartMonBefore = TimeUtils.getMon(year, monthBefore);
for (Map.Entry<Long, Map<String, Float>> deviceMap : powerMapThree.entrySet()) {
String deptNameByKey = "";
if (stationIds.contains(deviceMap.getKey())) {
MonPowerPercentageVo powerVo = new MonPowerPercentageVo();
powerVo.setDeptId(deviceMap.getKey());
List<StationEntity> collect = stationEntityList.stream().filter(s -> deviceMap.getKey().equals(s.getId())).collect(Collectors.toList());
if (collect!=null) {
Long dept = collect.get(0).getRefDept();
List<Dept> dep = deptList.stream().filter(s -> dept.equals(s.getId())).collect(Collectors.toList());
deptNameByKey=dep.get(0).getDeptName();
}
powerVo.setDeptName(deptNameByKey);
BigDecimal powerYear = new BigDecimal(0);
BigDecimal powerYearBefore = new BigDecimal(0);
BigDecimal powerMonth = new BigDecimal(0);
BigDecimal powerMonthBefore = new BigDecimal(0);
BigDecimal powerMonthYearBefore = new BigDecimal(0);
Double planGeneration = 0d;
List<PlanGenerationEntity> planGenerationById = planYearData.stream().filter(s -> collect.get(0).getRefDept().equals(s.getStationDeptId())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(planGenerationById)) {
planGeneration = Double.valueOf(planGenerationById.get(0).getPlanGeneration());
}
//当前机构近三年的数据
Map<String, Float> value = deviceMap.getValue();
//今年发电量
powerYear=value.entrySet().stream().filter(s->listByYear.contains(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add);
//转换单位kwh-》万Kwh
powerYear=powerYear.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP);
powerYearBefore=value.entrySet().stream().filter(s->listByYearBefore.contains(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add);
powerYearBefore=powerYearBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP);
powerMonth=value.entrySet().stream().filter(s->monStart.equals(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonth=powerMonth.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP);
powerMonthBefore=value.entrySet().stream().filter(s->monStartMonBefore.equals(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonthBefore=powerMonthBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP);
powerMonthYearBefore=value.entrySet().stream().filter(s->monStartYearBefore.equals(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonthYearBefore=powerMonthYearBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP);
powerVo.setPowerYear(powerYear.doubleValue());
powerVo.setPowerYearBefore(powerYearBefore.doubleValue());
BigDecimal yearPercentage = new BigDecimal(0);
BigDecimal planPercentage = new BigDecimal(0);
if (powerYearBefore.compareTo(BigDecimal.ZERO) != 0) {
yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, BigDecimal.ROUND_UP);
}
if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO) != 0) {
planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, BigDecimal.ROUND_UP);
}
powerVo.setPlanPercentage(planPercentage.doubleValue());
powerVo.setPowerYearPercentage(yearPercentage.doubleValue());
powerVo.setPowerMon(powerMonth.doubleValue());
powerVo.setPowerMonBefore(powerMonthBefore.doubleValue());
powerVo.setPowerMonYearBefore(powerMonthYearBefore.doubleValue());
BigDecimal monPercentage = new BigDecimal(0);
if (powerMonthYearBefore.compareTo(BigDecimal.ZERO) != 0) {
monPercentage = (powerMonth.subtract(powerMonthYearBefore)).divide(powerMonthYearBefore, 2, BigDecimal.ROUND_UP);
}
powerVo.setPowerMonPercentage(monPercentage.doubleValue());
powerPercentageVoList.add(powerVo);
}
}
return powerPercentageVoList;
}
private void getPowerData(List<Dept> deptList, String yearStart, String yearEnd, String yearBeforeStart, String yearBeforeEnd, String monthStart, String monthEnd, String beforeMonthStart, String beforeMonthEnd, String monthStartBeforeYear, String monthEndBeforeYear, List<EminfoAndEmParamVo> devices, List<PlanGenerationEntity> planYearData, List<MonPowerPercentageVo> powerPercentageVoList) { private void getPowerData(List<Dept> deptList, String yearStart, String yearEnd, String yearBeforeStart, String yearBeforeEnd, String monthStart, String monthEnd, String beforeMonthStart, String beforeMonthEnd, String monthStartBeforeYear, String monthEndBeforeYear, List<EminfoAndEmParamVo> devices, List<PlanGenerationEntity> planYearData, List<MonPowerPercentageVo> powerPercentageVoList) {
for (Dept dept : deptList) { for (Dept dept : deptList) {
MonPowerPercentageVo powerVo = new MonPowerPercentageVo(); MonPowerPercentageVo powerVo = new MonPowerPercentageVo();
@ -704,7 +717,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.parseDouble(ktv.getVal()))) .map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
powerYear = powerYear.add(yearPower); powerYear = powerYear.add(yearPower);
} }
@ -712,7 +725,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.parseDouble(ktv.getVal()))) .map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
powerYearBefore = powerYearBefore.add(powerBefore); powerYearBefore = powerYearBefore.add(powerBefore);
} }
@ -720,7 +733,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.parseDouble(ktv.getVal()))) .map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonth = powerMonth.add(powerBefore); powerMonth = powerMonth.add(powerBefore);
} }
@ -728,7 +741,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.parseDouble(ktv.getVal()))) .map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonthBefore = powerMonthBefore.add(powerBefore); powerMonthBefore = powerMonthBefore.add(powerBefore);
} }
@ -736,7 +749,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.parseDouble(ktv.getVal()))) .map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonthYearBefore = powerMonthYearBefore.add(powerBefore); powerMonthYearBefore = powerMonthYearBefore.add(powerBefore);
} }

4
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java

@ -729,7 +729,9 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke
BladeUser bladeUser = AuthUtil.getUser(); BladeUser bladeUser = AuthUtil.getUser();
List<Long> createDept = userClient.getDataScope(bladeUser.getUserId()); List<Long> createDept = userClient.getDataScope(bladeUser.getUserId());
log.info("================================================================");
log.info("获取权限Id =======================> ", createDept);
log.info("================================================================");
StandardTicketInfoDto standardTicketInfoDto = new StandardTicketInfoDto(); StandardTicketInfoDto standardTicketInfoDto = new StandardTicketInfoDto();
BeanUtils.copyProperties(ticketCountQueryVo, standardTicketInfoDto); BeanUtils.copyProperties(ticketCountQueryVo, standardTicketInfoDto);
LambdaQueryWrapper<StandardTicketInfoEntity> queryWrapper = this.getQueryWrapper(standardTicketInfoDto); LambdaQueryWrapper<StandardTicketInfoEntity> queryWrapper = this.getQueryWrapper(standardTicketInfoDto);

5
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketCountServiceImpl.java

@ -405,7 +405,8 @@ public class TicketCountServiceImpl extends BaseServiceImpl<TicketCountMapper, T
* @param user * @param user
* @return * @return
*/ */
private List<TicketCount> getStandardTicketCountList(List<Long> createDept, List<TicketCount> items, String ticketType, String dateTime, BladeUser user) { private List<TicketCount>
getStandardTicketCountList(List<Long> createDept, List<TicketCount> items, String ticketType, String dateTime, BladeUser user) {
List<StandardTicketInfoEntity> ticketInfoEntities = List<StandardTicketInfoEntity> ticketInfoEntities =
standardTicketInfoService.selectStandardTicketByDeptIdWithTicketType(createDept, ticketType, dateTime); standardTicketInfoService.selectStandardTicketByDeptIdWithTicketType(createDept, ticketType, dateTime);
if (CollectionUtils.isEmpty(ticketInfoEntities)) { if (CollectionUtils.isEmpty(ticketInfoEntities)) {
@ -459,6 +460,7 @@ public class TicketCountServiceImpl extends BaseServiceImpl<TicketCountMapper, T
LambdaQueryWrapper<TicketInfoEvaluateEntity> evaluateEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TicketInfoEvaluateEntity> evaluateEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
evaluateEntityLambdaQueryWrapper.in(TicketInfoEvaluateEntity::getTicketId, ticketIdList); evaluateEntityLambdaQueryWrapper.in(TicketInfoEvaluateEntity::getTicketId, ticketIdList);
evaluateEntityLambdaQueryWrapper.eq(BaseEntity::getStatus, 1); evaluateEntityLambdaQueryWrapper.eq(BaseEntity::getStatus, 1);
evaluateEntityLambdaQueryWrapper.groupBy(TicketInfoEvaluateEntity::getTicketId);
List<TicketInfoEvaluateEntity> evaluateEntities = ticketInfoEvaluateService.list(evaluateEntityLambdaQueryWrapper); List<TicketInfoEvaluateEntity> evaluateEntities = ticketInfoEvaluateService.list(evaluateEntityLambdaQueryWrapper);
ticketCount.setTicketProportionNum(evaluateEntities.size()); ticketCount.setTicketProportionNum(evaluateEntities.size());
@ -549,6 +551,7 @@ public class TicketCountServiceImpl extends BaseServiceImpl<TicketCountMapper, T
LambdaQueryWrapper<TicketInfoEvaluateEntity> evaluateEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TicketInfoEvaluateEntity> evaluateEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
evaluateEntityLambdaQueryWrapper.in(TicketInfoEvaluateEntity::getTicketId, ticketIdList); evaluateEntityLambdaQueryWrapper.in(TicketInfoEvaluateEntity::getTicketId, ticketIdList);
evaluateEntityLambdaQueryWrapper.eq(BaseEntity::getStatus, 1); evaluateEntityLambdaQueryWrapper.eq(BaseEntity::getStatus, 1);
evaluateEntityLambdaQueryWrapper.groupBy(TicketInfoEvaluateEntity::getTicketId);
List<TicketInfoEvaluateEntity> evaluateEntities = ticketInfoEvaluateService.list(evaluateEntityLambdaQueryWrapper); List<TicketInfoEvaluateEntity> evaluateEntities = ticketInfoEvaluateService.list(evaluateEntityLambdaQueryWrapper);
ticketCount.setTicketProportionNum(evaluateEntities.size()); ticketCount.setTicketProportionNum(evaluateEntities.size());

40
hzims-service/ticket/src/main/resources/db/2.0.0.sql

@ -100,29 +100,35 @@ SET FOREIGN_KEY_CHECKS=1;
-- auto-generated definition -- auto-generated definition
-- auto-generated definition
create table hzims_ticket_count create table hzims_ticket_count
( (
id bigint auto_increment comment '主键ID' id bigint auto_increment comment '主键ID'
primary key, primary key,
date_time varchar(20) null comment '日期', date_time varchar(20) null comment '日期',
dept_id bigint null comment '站点Id', dept_id bigint null comment '站点Id',
dept_name varchar(100) null comment '站点名称', dept_name varchar(100) null comment '站点名称',
ticket_type varchar(255) null comment '票据类型', ticket_type varchar(255) null comment '票据类型',
ticket_number int null comment '开票数量', ticket_number int null comment '开票数量',
ticket_complete_num int null comment '完成数量', ticket_complete_num int null comment '完成数量',
ticket_delay_num int null comment '延期数量', ticket_delay_num int null comment '延期数量',
ticket_proportion_num int null comment '合格数量', ticket_proportion_num int null comment '合格数量',
create_time datetime default CURRENT_TIMESTAMP null comment '创建时间', create_time datetime default CURRENT_TIMESTAMP null comment '创建时间',
update_time datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间', update_time datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
is_deleted tinyint(1) default 0 null comment '逻辑删除', is_deleted tinyint(1) default 0 null comment '逻辑删除',
tenant_id varchar(12) null comment '租户ID', tenant_id varchar(12) null comment '租户ID',
create_dept varchar(30) null comment '创建部门', create_dept varchar(30) null comment '创建部门',
status tinyint null, status tinyint null,
create_user bigint not null comment '创建人', create_user bigint not null comment '创建人',
update_user bigint null update_user bigint null,
invalidated_ticket_num int null comment '废票数量',
wrong_ticket_num int null comment '错票数量',
percent_pass_ticket varchar(50) null comment '合格率'
) )
comment '两票统计分析' row_format = DYNAMIC; comment '两票统计分析' row_format = DYNAMIC;
insert into hzims_work_ticket_finish(ticket_id, ground_num, brake_number) insert into hzims_work_ticket_finish(ticket_id, ground_num, brake_number)
select ticket_id, ground_switch_count,ground_wire_code select ticket_id, ground_switch_count,ground_wire_code
from hzims_work_ticket_flow; from hzims_work_ticket_flow;

Loading…
Cancel
Save