lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentStatisticalDto.java
@@ -37,6 +37,22 @@ */ private BigDecimal totalLong = new BigDecimal("0"); /** * 故障时长 */ private BigDecimal faultLong = new BigDecimal("0"); /** * 故障率 */ private BigDecimal faultRate = new BigDecimal("0"); /** * 运行时长(去除故障时间) */ private BigDecimal removeFaultRunLong = new BigDecimal("0"); /** * 去除故障时间利用率 */ private BigDecimal removeFaultRate = new BigDecimal("0"); /** * 天数 */ private BigDecimal dayNum; lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalInfoMonth.java
@@ -78,6 +78,18 @@ @ApiModelProperty(value = "报警时长") private Integer errorLong; /** * 故障时长 */ @Excel(name = "故障时长", width = 15) @ApiModelProperty(value = "故障时长") private Integer faultLong; /** * 去除故障时间的运行时间 */ @Excel(name = "去除故障时间的运行时间", width = 15) @ApiModelProperty(value = "去除故障时间的运行时间") private Integer removeFaultRunLong; /** * 利用率 */ @Excel(name = "利用率", width = 15) @@ -96,6 +108,18 @@ @ApiModelProperty(value = "开机率") private BigDecimal openRate; /** * 故障率 */ @Excel(name = "故障率", width = 15) @ApiModelProperty(value = "故障率") private BigDecimal faultRate; /** * 去除故障时间利用率 */ @Excel(name = "去除故障时间利用率", width = 15) @ApiModelProperty(value = "去除故障时间利用率") private BigDecimal removeFaultRate; /** * 创建时间 */ @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss") lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java
@@ -100,6 +100,7 @@ MdcEquipmentStatisticalInfoMonth mdcEquipmentStatisticalInfoMonth = new MdcEquipmentStatisticalInfoMonth(); mdcEquipmentStatisticalInfoMonth.setEquipmentId(mdcEquipment.getEquipmentId()); mdcEquipmentStatisticalInfoMonth.setTheMonth(date); if (mdcEquipmentStatisticalDto != null) { mdcEquipmentStatisticalInfoMonth.setCloseLong(mdcEquipmentStatisticalDto.getCloseLong().intValue()); mdcEquipmentStatisticalInfoMonth.setErrorLong(mdcEquipmentStatisticalDto.getErrorLong().intValue()); mdcEquipmentStatisticalInfoMonth.setOpenLong(mdcEquipmentStatisticalDto.getOpenLong().intValue()); @@ -108,6 +109,11 @@ mdcEquipmentStatisticalInfoMonth.setOpenRate(mdcEquipmentStatisticalDto.getOpenLong().divide((new BigDecimal("86400").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP)); mdcEquipmentStatisticalInfoMonth.setStartRate(mdcEquipmentStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentStatisticalDto.getProcessLong().divide(mdcEquipmentStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO); mdcEquipmentStatisticalInfoMonth.setUtilizationRate(mdcEquipmentStatisticalDto.getProcessLong().divide((new BigDecimal("86400").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP)); mdcEquipmentStatisticalInfoMonth.setFaultLong(mdcEquipmentStatisticalDto.getFaultLong().intValue()); mdcEquipmentStatisticalInfoMonth.setFaultRate(mdcEquipmentStatisticalDto.getFaultRate()); mdcEquipmentStatisticalInfoMonth.setRemoveFaultRate(mdcEquipmentStatisticalDto.getRemoveFaultRate()); mdcEquipmentStatisticalInfoMonth.setRemoveFaultRunLong(mdcEquipmentStatisticalDto.getRemoveFaultRunLong().intValue()); } mdcEquipmentStatisticalInfoMonthList.add(mdcEquipmentStatisticalInfoMonth); // step.3 汇总班次利用率数据 MdcEquipmentStatisticalDto mdcEquipmentShiftStatisticalDto = mdcEquipmentStatisticalShiftInfoService.findByEquipmentAndMonth(mdcEquipment.getEquipmentId(), date); @@ -115,6 +121,7 @@ mdcEquipmentShiftInfoMonth.setEquipmentId(mdcEquipment.getEquipmentId()); mdcEquipmentShiftInfoMonth.setTheMonth(date); mdcEquipmentShiftInfoMonth.setShiftType(CommonConstant.SHIFT_TYPE_1); if (mdcEquipmentShiftStatisticalDto != null) { mdcEquipmentShiftInfoMonth.setCloseLong(mdcEquipmentShiftStatisticalDto.getCloseLong().intValue()); mdcEquipmentShiftInfoMonth.setTotalLong(mdcEquipmentShiftStatisticalDto.getTotalLong().intValue()); mdcEquipmentShiftInfoMonth.setOpenLong(mdcEquipmentShiftStatisticalDto.getOpenLong().intValue()); @@ -124,6 +131,7 @@ mdcEquipmentShiftInfoMonth.setUtilizationRate(mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO); mdcEquipmentShiftInfoMonth.setStartRate(mdcEquipmentShiftStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO); mdcEquipmentShiftInfoMonth.setOpenRate(mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getOpenLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO); } mdcEquipmentStatisticalShiftInfoMonthList.add(mdcEquipmentShiftInfoMonth); // step.4 汇总各班次利用率数据 List<MdcEquipmentStatisticalDto> essdList = mdcEquipmentStatisticalShiftInfoService.findShiftByEquipmentAndMonth(mdcEquipment.getEquipmentId(), date); lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml
@@ -195,7 +195,8 @@ SELECT t3.equipment_name, t1.utilization_rate AS utilizationRate, t2.utilization_rate AS shiftUtilizationRate t2.utilization_rate AS shiftUtilizationRate, t1.remove_fault_rate AS amendUtilizationRate FROM mdc_equipment_statistical_info_month t1 LEFT JOIN mdc_equipment_statistical_shift_info_month t2 ON t1.the_month = t2.the_month AND t2.shift_type = 1 @@ -215,7 +216,8 @@ SELECT t3.team_code AS teamCode, t1.utilization_rate AS utilizationRate, t2.utilization_rate AS shiftUtilizationRate t2.utilization_rate AS shiftUtilizationRate, t1.remove_fault_rate AS amendUtilizationRate FROM mdc_equipment_statistical_info_month t1 LEFT JOIN mdc_equipment_statistical_shift_info_month t2 ON t1.the_month = t2.the_month AND t2.shift_type = 1 @@ -234,6 +236,7 @@ t1.the_month AS theMonth, AVG ( t1.utilization_rate ) AS utilizationRate, AVG ( t2.utilization_rate ) AS shiftUtilizationRate, AVG ( t1.remove_fault_rate ) AS amendUtilizationRate, SUM ( t1.process_long ) AS processLong FROM mdc_equipment_statistical_info_month t1 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml
@@ -15,16 +15,20 @@ <select id="findByEquipmentAndMonth" resultType="org.jeecg.modules.mdc.dto.MdcEquipmentStatisticalDto"> SELECT SUM(open_long) openLong, SUM(close_long) closeLong, SUM(wait_long) waitLong, SUM(process_long) processLong, SUM(error_long) errorLong, SUM ( t1.open_long ) openLong, SUM ( t1.close_long ) closeLong, SUM ( t1.wait_long ) waitLong, SUM ( t1.process_long ) processLong, SUM ( t1.error_long ) errorLong, SUM ( t2.fault_long ) faultLong, AVG ( t2.fault_rate ) faultRate, SUM ( t2.remove_fault_run_long ) removeFaultRunLong, AVG ( t2.remove_fault_rate ) removeFaultRate, COUNT(*) dayNum FROM mdc_equipment_statistical_info mdc_equipment_statistical_info t1 LEFT JOIN mdc_equipment_fault_info t2 ON t1.equipment_id = t2.equipment_id AND t1.the_date = t2.the_date WHERE equipment_id = #{equipmentId} AND the_date LIKE CONCAT(#{date}, '%') t1.equipment_id = #{equipmentId} AND t1.the_date LIKE CONCAT(#{date}, '%') </select> <select id="findByEquIdsAndMonth" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo"> lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java
@@ -86,18 +86,18 @@ if (equFaultRecordList != null && !equFaultRecordList.isEmpty()) { // 修整时间 Map<String, List<EquFaultRecord>> equFaultRecordMap = equFaultRecordList.stream().collect(Collectors.groupingBy(EquFaultRecord::getEquipmentId)); equFaultRecordMap.forEach((key, value) -> { if (map.containsKey(key)) { MdcEquipmentFaultInfo equFaultRecords = map.get(key); map.forEach((key, value1) -> { MdcEquipmentFaultInfo equFaultRecords = value1; if (equFaultRecordMap.containsKey(key)) { List<EquFaultRecord> value = equFaultRecordMap.get(key); long faultLong = calculateTotalFaultDuration(value, start, end); equFaultRecords.setFaultLong((int) faultLong); if (faultLong != 0) { equFaultRecords.setFaultRate(new BigDecimal(faultLong).divide(new BigDecimal("86400"), 2, RoundingMode.HALF_UP)); equFaultRecords.setFaultRate(new BigDecimal(faultLong).divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP)); } // 计算去除故障时长的加工时间 // step.1 查询加工时间 List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.selectRunningData(key, start, end); List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.listEquipmentRunningSectionRun(key, start.getTime(), end.getTime()); if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) { // 时间修正 if (mdcEquipmentRunningSections.get(0).getStartTime().before(start)) { @@ -112,17 +112,49 @@ mdcEquipmentRunningSections.get(0).setEndTime(end); } } List<MdcEquipmentRunningSection> collect = mdcEquipmentRunningSections.stream().filter(mdcEquipmentRunningSection -> mdcEquipmentRunningSection.getStatus() == 3).collect(Collectors.toList()); if (!collect.isEmpty()) { // step.2 计算去除故障时长的加工时间 long processingTime = calculateProcessingTimeWithoutFaults(mdcEquipmentRunningSections, value, start, end); long processingTime = calculateProcessingTimeWithoutFaults(collect, value, start, end); equFaultRecords.setRemoveFaultRunLong((int) processingTime); if (faultLong != 0) { if (faultLong != 0 && faultLong != 86400) { // 计算去除故障时长的利用率 BigDecimal removeFaultRate = new BigDecimal(processingTime).divide(new BigDecimal("86400").subtract(new BigDecimal(faultLong)), 2, RoundingMode.HALF_UP); BigDecimal removeFaultRate = new BigDecimal(processingTime).divide(new BigDecimal("864").subtract(new BigDecimal(faultLong)), 2, RoundingMode.HALF_UP); equFaultRecords.setRemoveFaultRate(removeFaultRate); } } map.put(key, equFaultRecords); } } else { List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.listEquipmentRunningSectionRun(key, start.getTime(), end.getTime()); if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) { // 时间修正 if (mdcEquipmentRunningSections.get(0).getStartTime().before(start)) { mdcEquipmentRunningSections.get(0).setStartTime(start); } if (mdcEquipmentRunningSections.size() > 1) { if (mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).getEndTime().after(end)) { mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).setEndTime(end); } } else { if (mdcEquipmentRunningSections.get(0).getEndTime().after(end)) { mdcEquipmentRunningSections.get(0).setEndTime(end); } } List<MdcEquipmentRunningSection> collect = mdcEquipmentRunningSections.stream().filter(mdcEquipmentRunningSection -> mdcEquipmentRunningSection.getStatus() == 3).collect(Collectors.toList()); if (!collect.isEmpty()) { long totalProcessingTime = 0; for (MdcEquipmentRunningSection mdcEquipmentRunningSection : collect) { totalProcessingTime += ChronoUnit.SECONDS.between(DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getStartTime()), DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getEndTime())); } equFaultRecords.setRemoveFaultRunLong((int) totalProcessingTime); // 计算去除故障时长的利用率 BigDecimal removeFaultRate = new BigDecimal(totalProcessingTime).divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP); equFaultRecords.setRemoveFaultRate(removeFaultRate); } } } map.put(key, equFaultRecords); }); } if (!map.isEmpty()) { @@ -215,13 +247,9 @@ LocalDateTime start = DateUtils.convertToLocalDateTime(startTime); LocalDateTime end = DateUtils.convertToLocalDateTime(endTime); // 将故障记录转换为时间区间并合并重叠部分 // List<TimeInterval> faultIntervals = faultRecords.stream() // .map(record -> new TimeInterval( // convertToLocalDateTime(record.getStartTime()), // convertToLocalDateTime(record.getEndTime()))) // .collect(Collectors.toList()); List<TimeInterval> mergedFaultIntervals = mergeIntervals(faultRecords); // 修正记录时间 List<EquFaultRecord> correctedRecords = correctRecordTimes(faultRecords, start, end); List<TimeInterval> mergedFaultIntervals = mergeIntervals(correctedRecords); long totalProcessingTime = 0;