lius
2023-07-27 40c22341b74d5bec60cbec08e338d8c8b22fcc92
班次利用率
已添加2个文件
已修改14个文件
948 ■■■■■ 文件已修改
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyShiftListDto.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyShiftResultDto.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalShiftInfo.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEfficiencyReportMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRepairMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRepairMapper.xml 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRepairService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRunningSectionService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java 244 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRepairServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalShiftInfoServiceImpl.java 478 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcDateVo.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyShiftListDto.java
@@ -36,5 +36,5 @@
    /**
     * åˆ©ç”¨çŽ‡æ•°æ®
     */
    private List<MdcEfficiencyResultDto> dataList;
    private List<MdcEfficiencyShiftResultDto> dataList;
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyShiftResultDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,49 @@
package org.jeecg.modules.mdc.dto;
import lombok.Data;
import java.math.BigDecimal;
/**
 * @author: LiuS
 * @create: 2023-07-26 16:04
 */
@Data
public class MdcEfficiencyShiftResultDto {
    /**
     * æœ‰æ•ˆæ—¥æœŸ
     */
    private String theDate;
    /**
     * åŠ å·¥æ—¶é•¿
     */
    private BigDecimal processLong;
    /**
     * åˆ©ç”¨çއ
     */
    private BigDecimal utilizationRate;
    /**
     * å¼€åŠ¨çŽ‡
     */
    private BigDecimal startRate;
    /**
     * å¼€æœºçއ
     */
    private BigDecimal openRate;
    /**
     * å¼€æœºæ—¶é•¿
     */
    private BigDecimal openLong;
    /**
     * å¾…机时长
     */
    private BigDecimal waitLong;
    /**
     * å…³æœºæ—¶é•¿
     */
    private BigDecimal closeLong;
    /**
     * é¢œè‰²
     */
    private String color;
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalShiftInfo.java
@@ -76,6 +76,11 @@
    @ApiModelProperty(value = "报警时长")
    private BigDecimal errorLong = new BigDecimal("0");
    /**
     * æœ‰æ•ˆæ€»æ—¶é•¿
     */
    @ApiModelProperty(value = "有效总时长")
    private BigDecimal totalLong = new BigDecimal("0");
    /**
     * æœ‰æ•ˆæ—¥æœŸ
     */
    @ApiModelProperty(value = "有效日期")
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEfficiencyReportMapper.java
@@ -2,7 +2,9 @@
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.mdc.dto.MdcEfficiencyDto;
import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalShiftInfo;
import org.jeecg.modules.mdc.vo.MdcEfficiencyReportQueryVo;
import org.jeecg.modules.mdc.vo.MdcEfficiencyReportShiftQueryVo;
import java.util.List;
@@ -27,4 +29,12 @@
     * @return
     */
    List<MdcEfficiencyDto> efficiencyPOList(@Param("vo") MdcEfficiencyReportQueryVo vo);
    /**
     * å¾—到所有班次数据之和
     *
     * @param vo
     * @return
     */
    List<MdcEquipmentStatisticalShiftInfo> efficiencyShiftSumList(@Param("vo") MdcEfficiencyReportShiftQueryVo vo);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRepairMapper.java
@@ -5,6 +5,9 @@
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.mdc.entity.MdcEquipmentRepair;
import java.util.Date;
import java.util.List;
/**
 * @Description: è®¾å¤‡ç»´ä¿®ä¼‘班
@@ -21,4 +24,5 @@
     */
    IPage<MdcEquipmentRepair> pageList(IPage<MdcEquipmentRepair> pageData, @Param("repair") MdcEquipmentRepair repair);
    List<MdcEquipmentRepair> selectByIdAndTime(@Param("equipmentId") String equipmentid, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java
@@ -39,4 +39,14 @@
     * è®¡ç®—一段时间内的数据
     */
    List<MdcEquipmentRunningSection> listEquipmentRunningSection(@Param("equipmentId") String equipmentid, @Param("startLong") long start, @Param("endLong") long end);
    /**
     * è®¡ç®—一段时间内的运行数据
     */
    List<MdcEquipmentRunningSection> listEquipmentRunningSectionRun(@Param("equipmentId") String equipmentid, @Param("startLong") long start, @Param("endLong") long end);
    /**
     * è®¡ç®—一段时间内的故障数据
     */
    List<MdcEquipmentRunningSection> listEquipmentRunningSectionError(@Param("equipmentId") String equipmentid, @Param("startLong") long start, @Param("endLong") long end);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml
@@ -68,4 +68,47 @@
        </if>
        ORDER BY t1.the_date
    </select>
    <!--得到所有班次数据之和-->
    <select id="efficiencyShiftSumList" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalShiftInfo">
        SELECT
            t2.equipment_id equipmentId,
            t2.equipment_name equipmentName,
            t2.equipment_type equipmentType,
            t1.the_date theDate,
            t1.shift_id shiftId,
            t1.shift_sub_id shiftSubId,
            SUM ( t1.process_long ) processLong,
            SUM ( t1.open_long ) openLong,
            SUM ( t1.wait_long ) waitLong,
            SUM ( t1.close_long ) closeLong
        FROM
            mdc_equipment t2
            LEFT JOIN mdc_equipment_statistical_shift_info t1 ON t1.equipment_id = t2.equipment_id
        <where>
            AND t1.the_date &lt;= #{ endTime }
            AND t1.the_date &gt;= #{ startTime }
            <if test="vo.equipmentIdList != null and vo.equipmentIdList.size() > 0 ">
                AND t2.equipment_id IN
                <foreach collection="vo.equipmentIdList" item="id" index="index" open="(" close=")" separator=",">
                    #{ id }
                </foreach>
            </if>
            <if test="vo.shiftId != null and vo.shiftId != ''">
                AND t1.shift_id = #{ vo.shiftId }
            </if>
            <if test="vo.shiftSubId != null and vo.shiftSubId != ''">
                AND t1.shift_sub_id = #{ vo.shiftSubId }
            </if>
        </where>
        GROUP BY
            t2.equipment_id,
            t2.equipment_name,
            t2.equipment_type,
            t1.the_date,
            t1.shift_id,
            t1.shift_sub_id
        ORDER BY
            t1.the_date
    </select>
</mapper>
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRepairMapper.xml
@@ -31,4 +31,26 @@
        ORDER BY START_TIME ASC
    </select>
    <!--查询某段时间内是否有维修休班数据-->
    <select id="selectByIdAndTime" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentRepair">
        SELECT
            *
        FROM
            mdc_equipment_repair
        <where>
            <if test="equipmentId != null and equipmentId!= ''">
                AND equipment_id = #{ equipmentId }
            </if>
            <if test="startTime != null and endTime!= null">
                AND (
                ( START_TIME  <![CDATA[ >= ]]>  #{ startTime }  AND START_TIME <![CDATA[ <= ]]>  #{ endTime } )
                OR ( START_TIME <![CDATA[ <= ]]> #{ startTime }  AND END_TIME <![CDATA[ >= ]]> #{ endTime })
                OR ( END_TIME <![CDATA[ >= ]]> #{ startTime }  AND END_TIME <![CDATA[ <= ]]>  #{ endTime } )
                OR ( START_TIME <![CDATA[ <= ]]> #{ startTime }  AND END_TIME <![CDATA[ >= ]]> #{ endTime } )
                )
            </if>
        </where>
        ORDER BY start_time ASC
    </select>
</mapper>
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml
@@ -43,5 +43,33 @@
            start_time
    </select>
    <!--计算一段时间内的运行数据-->
    <select id="listEquipmentRunningSectionRun" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection">
        SELECT
            *
        FROM
            mdc_equipment_running_section
        WHERE
            equipment_id = #{ equipmentId }
            AND status <![CDATA[ <> ]]> '22'
            AND  (start_long &lt;= #{ endLong } AND end_long &gt;= #{ startLong })
        ORDER BY
            start_time
    </select>
    <!--计算一段时间内的故障数据-->
    <select id="listEquipmentRunningSectionError" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection">
        SELECT
            *
        FROM
            mdc_equipment_running_section
        WHERE
            equipment_id = #{ equipmentId }
            AND status = '22'
            AND  (start_long &lt;= #{ endLong } AND end_long &gt;= #{ startLong })
        ORDER BY
            start_time
    </select>
</mapper>
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRepairService.java
@@ -28,6 +28,7 @@
    /**
     * åˆ†é¡µæŸ¥è¯¢
     *
     * @param userId
     * @param page
     * @param repair
@@ -43,4 +44,14 @@
     * @return
     */
    boolean updateMdcRepair(MdcEquipmentRepair repair);
    /**
     * æŸ¥è¯¢æŸæ®µæ—¶é—´å†…是否有维修休班数据
     *
     * @param equipmentid
     * @param startDate
     * @param endDate
     * @return
     */
    List<MdcEquipmentRepair> mdcRepairListDate(String equipmentid, Date startDate, Date endDate);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRunningSectionService.java
@@ -51,4 +51,14 @@
     * æŸ¥è¯¢æŸä¸ªè®¾å¤‡ä¸€æ®µæ—¶é—´å†…的数据
     */
    List<MdcEquipmentRunningSection> listRunningSectionFromLog(String equipmentid, long start, long end);
    /**
     * æŸ¥è¯¢æ‘¸ä¸ªè®¾å¤‡ä¸€æ®µæ—¶é—´å†…的运行数据
     */
    List<MdcEquipmentRunningSection> listEquipmentRunningSectionRun(String equipmentid, long start, long end);
    /**
     * æŸ¥è¯¢æ‘¸ä¸ªè®¾å¤‡ä¸€æ®µæ—¶é—´å†…的故障数据
     */
    List<MdcEquipmentRunningSection> listEquipmentRunningSectionError(String equipmentid, long start, long end);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java
@@ -6,9 +6,12 @@
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.modules.mdc.dto.*;
import org.jeecg.modules.mdc.entity.MdcEquipment;
import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalShiftInfo;
import org.jeecg.modules.mdc.entity.MdcShiftSub;
import org.jeecg.modules.mdc.entity.MdcUtilizationRate;
import org.jeecg.modules.mdc.mapper.MdcEfficiencyReportMapper;
import org.jeecg.modules.mdc.service.IMdcEquipmentService;
import org.jeecg.modules.mdc.service.IMdcShiftSubService;
import org.jeecg.modules.mdc.service.IMdcUtilizationRateService;
import org.jeecg.modules.mdc.service.MdcEfficiencyReportService;
import org.jeecg.modules.mdc.util.DateUtils;
@@ -22,6 +25,7 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
 * @author: LiuS
@@ -44,6 +48,9 @@
    @Resource
    private IMdcProductionService mdcProductionService;
    @Resource
    private IMdcShiftSubService mdcShiftSubService;
    /**
     * åˆ©ç”¨çŽ‡æŠ¥è¡¨
@@ -449,10 +456,244 @@
            result.setMdcEfficiencyList(listDtos);
        } else {
            // ç­æ¬¡åˆ©ç”¨çŽ‡ç­‰çº§
            List<MdcUtilizationRate> mdcUtilizationRateList = mdcUtilizationRateService.listByType("kdl");
            List<MdcUtilizationRate> mdcUtilizationRateList = mdcUtilizationRateService.listByType("bclyl");
            // ç­æ¬¡åˆ©ç”¨çŽ‡æ•°æ®
            List<MdcEquipmentStatisticalShiftInfo> mdcEquipmentStatisticalShiftInfoList = mdcEfficiencyReportMapper.efficiencyShiftSumList(vo);
            // å°è£…结果
            if ("2".equals(vo.getTypeTree())) {
                // éƒ¨é—¨å±‚级
                List<MdcEquDepDto> equipmentList = mdcEquipmentService.findEquDepList(vo.getEquipmentIdList());
                // æŸ¥è¯¢æ‰€æœ‰éƒ¨é—¨ä¿¡æ¯
                List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()));
                // ç­æ¬¡åç§°æ˜¾ç¤ºå¤„理
                String shiftSubName = "";
                if (StringUtils.isBlank(vo.getShiftId())) {
                    // åˆå¹¶è®¾å¤‡æ¯å¤©æ‰€æœ‰ç­æ¬¡çš„æ•°æ®
                    shiftSubName = "全部";
                } else {
                    List<MdcShiftSub> mdcShiftSubList = new ArrayList<>();
                    if (StringUtils.isBlank(vo.getShiftSubId())) {
                        // æ‹¼æŽ¥æ‰€é€‰ç­åˆ¶ä¸‹çš„æ‰€æœ‰ç­æ¬¡åç§°
                        mdcShiftSubList = mdcShiftSubService.list(new LambdaQueryWrapper<MdcShiftSub>().eq(MdcShiftSub::getShiftId, vo.getShiftId()).eq(MdcShiftSub::getShiftSubStatus, "1"));
                        mdcEquipmentStatisticalShiftInfoList = mdcEquipmentStatisticalShiftInfoList.stream().filter(mdcEquipmentShiftRateVo -> mdcEquipmentShiftRateVo.getShiftId().equals(vo.getShiftId())).collect(Collectors.toList());
                    } else {
                        // è®¾ç½®å½“前选择的班次名称
                        mdcShiftSubList = mdcShiftSubService.list(new LambdaQueryWrapper<MdcShiftSub>().eq(MdcShiftSub::getId, vo.getShiftSubId()).eq(MdcShiftSub::getShiftSubStatus, "1"));
                        mdcEquipmentStatisticalShiftInfoList = mdcEquipmentStatisticalShiftInfoList.stream().filter(mdcEquipmentShiftRateVo -> mdcEquipmentShiftRateVo.getShiftId().equals(vo.getShiftId()) && mdcEquipmentShiftRateVo.getShiftSubId().equals(vo.getShiftSubId())).collect(Collectors.toList());
                    }
                    List<String> shiftSubNames = mdcShiftSubList.stream().map(MdcShiftSub::getShiftSubName).collect(Collectors.toList());
                    shiftSubName = String.join(",", shiftSubNames);
                }
                // åˆå¹¶åŒä¸€å¤©å¤šç­æ¬¡æ•°æ®
                mdcEquipmentStatisticalShiftInfoList = this.handleEfficiencyShiftList(mdcEquipmentStatisticalShiftInfoList);
                for (MdcEquDepDto mdcEquDepDto : equipmentList) {
                    MdcEfficiencyShiftListDto mdcEfficiencyShiftListDto = new MdcEfficiencyShiftListDto();
                    mdcEfficiencyShiftListDto.setEquipmentId(mdcEquDepDto.getEquipmentId());
                    mdcEfficiencyShiftListDto.setEquipmentName(mdcEquDepDto.getEquipmentName());
                    mdcEfficiencyShiftListDto.setEquipmentType(mdcEquDepDto.getEquipmentType());
                    mdcEfficiencyShiftListDto.setShiftSubName(shiftSubName);
                    switch (mdcEquDepDto.getOrgType()) {
                        case "1":
                            mdcEfficiencyShiftListDto.setLevel1(mdcEquDepDto.getDepartName());
                            break;
                        case "2":
                            mdcEfficiencyShiftListDto.setLevel2(mdcEquDepDto.getDepartName());
                            break;
                        case "3":
                            mdcEfficiencyShiftListDto.setLevel3(mdcEquDepDto.getDepartName());
                            break;
                        default:
                    }
                    SysDepart sysDepart = departList.stream().filter(depart -> depart.getId().equals(mdcEquDepDto.getParentId())).findAny().orElse(null);
                    if (sysDepart != null) {
                        switch (sysDepart.getOrgType()) {
                            case "1":
                                mdcEfficiencyShiftListDto.setLevel1(sysDepart.getDepartName());
                                break;
                            case "2":
                                mdcEfficiencyShiftListDto.setLevel2(sysDepart.getDepartName());
                                break;
                            case "3":
                                mdcEfficiencyShiftListDto.setLevel3(sysDepart.getDepartName());
                                break;
                            default:
                        }
                        if (StringUtils.isNotEmpty(sysDepart.getParentId())) {
                            departList.stream().filter(depart -> depart.getId().equals(sysDepart.getParentId())).findAny().ifPresent(depart1 -> {
                                switch (depart1.getOrgType()) {
                                    case "1":
                                        mdcEfficiencyShiftListDto.setLevel1(depart1.getDepartName());
                                        break;
                                    case "2":
                                        mdcEfficiencyShiftListDto.setLevel2(depart1.getDepartName());
                                        break;
                                    case "3":
                                        mdcEfficiencyShiftListDto.setLevel3(depart1.getDepartName());
                                        break;
                                    default:
                                }
                            });
                        }
                    }
                    List<MdcEfficiencyShiftResultDto> list = new ArrayList<>();
                    for (String date : dates) {
                        list.add(this.efficiencyShiftRate(mdcEquipmentStatisticalShiftInfoList, date, mdcEquDepDto.getEquipmentId(), mdcUtilizationRateList));
                    }
                    mdcEfficiencyShiftListDto.setDataList(list);
                    listDtos.add(mdcEfficiencyShiftListDto);
                }
            } else {
                // äº§çº¿å±‚级
                List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList());
                // æŸ¥è¯¢æ‰€æœ‰äº§çº¿ä¿¡æ¯
                List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()));
                // ç­æ¬¡åç§°æ˜¾ç¤ºå¤„理
                String shiftSubName = "";
                if (StringUtils.isBlank(vo.getShiftId())) {
                    // åˆå¹¶è®¾å¤‡æ¯å¤©æ‰€æœ‰ç­æ¬¡çš„æ•°æ®
                    shiftSubName = "全部";
                } else {
                    List<MdcShiftSub> mdcShiftSubList = new ArrayList<>();
                    if (StringUtils.isBlank(vo.getShiftSubId())) {
                        // æ‹¼æŽ¥æ‰€é€‰ç­åˆ¶ä¸‹çš„æ‰€æœ‰ç­æ¬¡åç§°
                        mdcShiftSubList = mdcShiftSubService.list(new LambdaQueryWrapper<MdcShiftSub>().eq(MdcShiftSub::getShiftId, vo.getShiftId()).eq(MdcShiftSub::getShiftSubStatus, "1"));
                        mdcEquipmentStatisticalShiftInfoList = mdcEquipmentStatisticalShiftInfoList.stream().filter(mdcEquipmentShiftRateVo -> mdcEquipmentShiftRateVo.getShiftId().equals(vo.getShiftId())).collect(Collectors.toList());
                    } else {
                        // è®¾ç½®å½“前选择的班次名称
                        mdcShiftSubList = mdcShiftSubService.list(new LambdaQueryWrapper<MdcShiftSub>().eq(MdcShiftSub::getId, vo.getShiftSubId()).eq(MdcShiftSub::getShiftSubStatus, "1"));
                        mdcEquipmentStatisticalShiftInfoList = mdcEquipmentStatisticalShiftInfoList.stream().filter(mdcEquipmentShiftRateVo -> mdcEquipmentShiftRateVo.getShiftId().equals(vo.getShiftId()) && mdcEquipmentShiftRateVo.getShiftSubId().equals(vo.getShiftSubId())).collect(Collectors.toList());
                    }
                    List<String> shiftSubNames = mdcShiftSubList.stream().map(MdcShiftSub::getShiftSubName).collect(Collectors.toList());
                    shiftSubName = String.join(",", shiftSubNames);
                }
                // åˆå¹¶åŒä¸€å¤©å¤šç­æ¬¡æ•°æ®
                mdcEquipmentStatisticalShiftInfoList = this.handleEfficiencyShiftList(mdcEquipmentStatisticalShiftInfoList);
                for (MdcEquProDto mdcEquProDto : equipmentList) {
                    MdcEfficiencyShiftListDto mdcEfficiencyShiftListDto = new MdcEfficiencyShiftListDto();
                    mdcEfficiencyShiftListDto.setEquipmentId(mdcEquProDto.getEquipmentId());
                    mdcEfficiencyShiftListDto.setEquipmentName(mdcEquProDto.getEquipmentName());
                    mdcEfficiencyShiftListDto.setEquipmentType(mdcEquProDto.getEquipmentType());
                    mdcEfficiencyShiftListDto.setShiftSubName(shiftSubName);
                    switch (mdcEquProDto.getOrgType()) {
                        case "1":
                            mdcEfficiencyShiftListDto.setLevel1(mdcEquProDto.getProductionName());
                            break;
                        case "2":
                            mdcEfficiencyShiftListDto.setLevel2(mdcEquProDto.getProductionName());
                            break;
                        case "3":
                            mdcEfficiencyShiftListDto.setLevel3(mdcEquProDto.getProductionName());
                            break;
                        default:
                    }
                    MdcProduction mdcProduction = productionList.stream().filter(production -> production.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null);
                    if (mdcProduction != null) {
                        switch (mdcProduction.getOrgType()) {
                            case "1":
                                mdcEfficiencyShiftListDto.setLevel1(mdcProduction.getProductionName());
                                break;
                            case "2":
                                mdcEfficiencyShiftListDto.setLevel2(mdcProduction.getProductionName());
                                break;
                            case "3":
                                mdcEfficiencyShiftListDto.setLevel3(mdcProduction.getProductionName());
                                break;
                            default:
                        }
                        if (StringUtils.isNotEmpty(mdcProduction.getParentId())) {
                            productionList.stream().filter(production -> production.getId().equals(mdcProduction.getParentId())).findAny().ifPresent(production1 -> {
                                switch (production1.getOrgType()) {
                                    case "1":
                                        mdcEfficiencyShiftListDto.setLevel1(production1.getProductionName());
                                        break;
                                    case "2":
                                        mdcEfficiencyShiftListDto.setLevel2(production1.getProductionName());
                                        break;
                                    case "3":
                                        mdcEfficiencyShiftListDto.setLevel3(production1.getProductionName());
                                        break;
                                    default:
                                }
                            });
                        }
                    }
                    List<MdcEfficiencyShiftResultDto> list = new ArrayList<>();
                    for (String date : dates) {
                        list.add(this.efficiencyShiftRate(mdcEquipmentStatisticalShiftInfoList, date, mdcEquProDto.getEquipmentId(), mdcUtilizationRateList));
                    }
                    mdcEfficiencyShiftListDto.setDataList(list);
                    listDtos.add(mdcEfficiencyShiftListDto);
                }
            }
            result.setMdcEfficiencyList(listDtos);
        }
        return result;
    }
    private MdcEfficiencyShiftResultDto efficiencyShiftRate(List<MdcEquipmentStatisticalShiftInfo> mdcEquipmentStatisticalShiftInfoList, String date, String equipmentId, List<MdcUtilizationRate> mdcUtilizationRateList) {
        MdcEfficiencyShiftResultDto mdcEfficiencyShiftResultDto = new MdcEfficiencyShiftResultDto();
        if (mdcEquipmentStatisticalShiftInfoList != null && !mdcEquipmentStatisticalShiftInfoList.isEmpty()) {
            for (MdcEquipmentStatisticalShiftInfo equipmentStatisticalShiftInfo : mdcEquipmentStatisticalShiftInfoList) {
                if (date.equals(equipmentStatisticalShiftInfo.getTheDate()) && equipmentStatisticalShiftInfo.getEquipmentId().equals(equipmentId)) {
                    mdcEfficiencyShiftResultDto.setTheDate(equipmentStatisticalShiftInfo.getTheDate());
                    mdcEfficiencyShiftResultDto.setProcessLong(equipmentStatisticalShiftInfo.getProcessLong());
                    mdcEfficiencyShiftResultDto.setUtilizationRate(equipmentStatisticalShiftInfo.getProcessLong().divide(equipmentStatisticalShiftInfo.getTotalLong(), 6, BigDecimal.ROUND_HALF_UP));
                    mdcEfficiencyShiftResultDto.setCloseLong(equipmentStatisticalShiftInfo.getCloseLong());
                    mdcEfficiencyShiftResultDto.setOpenLong(equipmentStatisticalShiftInfo.getOpenLong());
                    mdcEfficiencyShiftResultDto.setWaitLong(equipmentStatisticalShiftInfo.getWaitLong());
                    mdcEfficiencyShiftResultDto.setOpenRate(equipmentStatisticalShiftInfo.getOpenLong().divide(equipmentStatisticalShiftInfo.getTotalLong(), 6, BigDecimal.ROUND_HALF_UP));
                    for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) {
                        if (mdcEfficiencyShiftResultDto.getUtilizationRate().longValue() * 100 >= mdcUtilizationRate.getMinimumRange() && mdcEfficiencyShiftResultDto.getUtilizationRate().longValue() * 100 < mdcUtilizationRate.getMaximumRange()) {
                            mdcEfficiencyShiftResultDto.setColor(mdcUtilizationRate.getRateParameterColor());
                        }
                    }
                }
            }
        } else {
            mdcEfficiencyShiftResultDto.setTheDate(date);
            mdcEfficiencyShiftResultDto.setProcessLong(new BigDecimal("0"));
            mdcEfficiencyShiftResultDto.setUtilizationRate(new BigDecimal("0"));
            mdcEfficiencyShiftResultDto.setStartRate(new BigDecimal("0"));
            mdcEfficiencyShiftResultDto.setOpenRate(new BigDecimal("0"));
            mdcEfficiencyShiftResultDto.setOpenLong(new BigDecimal("0"));
            mdcEfficiencyShiftResultDto.setWaitLong(new BigDecimal("0"));
            mdcEfficiencyShiftResultDto.setCloseLong(new BigDecimal("0"));
            for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) {
                if (0 >= mdcUtilizationRate.getMinimumRange() && 0 < mdcUtilizationRate.getMaximumRange()) {
                    mdcEfficiencyShiftResultDto.setColor(mdcUtilizationRate.getRateParameterColor());
                }
            }
        }
        return mdcEfficiencyShiftResultDto;
    }
    /**
     * åˆå¹¶åŒä¸€å¤©åŒç­æ¬¡æ•°æ®
     *
     * @param mdcEquipmentStatisticalShiftInfoList
     * @return
     */
    private List<MdcEquipmentStatisticalShiftInfo> handleEfficiencyShiftList(List<MdcEquipmentStatisticalShiftInfo> mdcEquipmentStatisticalShiftInfoList) {
        List<MdcEquipmentStatisticalShiftInfo> result = new ArrayList<>();
        Map<String, MdcEquipmentStatisticalShiftInfo> map = new HashMap<>();
        for (MdcEquipmentStatisticalShiftInfo equipmentStatisticalShiftInfo : mdcEquipmentStatisticalShiftInfoList) {
            if (map.containsKey(equipmentStatisticalShiftInfo.getEquipmentId() + "_" + equipmentStatisticalShiftInfo.getTheDate())) {
                MdcEquipmentStatisticalShiftInfo vo = map.get(equipmentStatisticalShiftInfo.getEquipmentId() + "_" + equipmentStatisticalShiftInfo.getTheDate());
                vo.setProcessLong(vo.getProcessLong().add(equipmentStatisticalShiftInfo.getProcessLong()));
                vo.setOpenLong(vo.getOpenLong().add(equipmentStatisticalShiftInfo.getOpenLong()));
                vo.setWaitLong(vo.getWaitLong().add(equipmentStatisticalShiftInfo.getWaitLong()));
                vo.setCloseLong(vo.getCloseLong().add(equipmentStatisticalShiftInfo.getCloseLong()));
            } else {
                map.put(equipmentStatisticalShiftInfo.getEquipmentId() + "_" + equipmentStatisticalShiftInfo.getTheDate(), equipmentStatisticalShiftInfo);
            }
        }
        for (String s : map.keySet()) {
            result.add(map.get(s));
        }
        return result;
    }
@@ -548,7 +789,6 @@
                            mdcEfficiencyResultDto.setColor(mdcUtilizationRate.getRateParameterColor());
                        }
                    }
                }
            }
        } else {
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRepairServiceImpl.java
@@ -239,4 +239,9 @@
        return result;
    }
    @Override
    public List<MdcEquipmentRepair> mdcRepairListDate(String equipmentid, Date startDate, Date endDate) {
        return this.baseMapper.selectByIdAndTime(equipmentid, startDate, endDate);
    }
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java
@@ -579,6 +579,16 @@
        return running;
    }
    @Override
    public List<MdcEquipmentRunningSection> listEquipmentRunningSectionRun(String equipmentid, long start, long end) {
        return this.baseMapper.listEquipmentRunningSectionRun(equipmentid, start, end);
    }
    @Override
    public List<MdcEquipmentRunningSection> listEquipmentRunningSectionError(String equipmentid, long start, long end) {
        return this.baseMapper.listEquipmentRunningSectionError(equipmentid, start, end);
    }
    private Map<String, List<MdcEquipmentRunningSectionDto>> logCharts(MdcEquipmentRunningSectionVo equipmentRunningSectionVo, String date) {
        Map<String, List<MdcEquipmentRunningSectionDto>> map = new HashMap<>();
        List<MdcEquipmentRunningSectionDto> normal = new ArrayList<>();
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalShiftInfoServiceImpl.java
@@ -4,14 +4,13 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.mdc.entity.Equipment;
import org.jeecg.modules.mdc.entity.MdcEquipmentRepair;
import org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection;
import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalShiftInfo;
import org.jeecg.modules.mdc.mapper.MdcEquipmentStatisticalShiftInfoMapper;
import org.jeecg.modules.mdc.service.IEquipmentService;
import org.jeecg.modules.mdc.service.IMdcDeviceCalendarService;
import org.jeecg.modules.mdc.service.IMdcEquipmentRunningSectionService;
import org.jeecg.modules.mdc.service.IMdcEquipmentStatisticalShiftInfoService;
import org.jeecg.modules.mdc.service.*;
import org.jeecg.modules.mdc.util.DateUtils;
import org.jeecg.modules.mdc.vo.MdcDateVo;
import org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo;
import org.jeecg.modules.mdc.vo.MdcShiftDateVo;
import org.springframework.stereotype.Service;
@@ -22,6 +21,7 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
 * @Description: è®¾å¤‡å•日班次运行数据表
@@ -39,6 +39,9 @@
    @Resource
    private IMdcDeviceCalendarService mdcDeviceCalendarService;
    @Resource
    private IMdcEquipmentRepairService mdcEquipmentRepairService;
    /**
     * è®¡ç®—设备单日班次运行数据
@@ -141,6 +144,7 @@
                        equipmentStatisticalShiftInfo.setOpenLong(equipmentStatisticalShiftInfo.getOpenLong().add(shiftInfo.getOpenLong()));
                        equipmentStatisticalShiftInfo.setErrorLong(equipmentStatisticalShiftInfo.getErrorLong().add(shiftInfo.getErrorLong()));
                    }
                    resultList.add(equipmentStatisticalShiftInfo);
                }
            }
        }
@@ -158,79 +162,423 @@
        if (dates == null || StringUtils.isBlank(equipmentid)) {
            return null;
        }
        //不过滤休班和维修
        //获取班次时间段内数据
        List<MdcEquipmentRunningSection> sectionList = mdcEquipmentRunningSectionService.listEquipmentRunningSection(equipmentid, dates.getStart(), dates.getEnd());
        //查询无数据需要EquipmentLog解析
        if (sectionList.isEmpty()) {
            sectionList = mdcEquipmentRunningSectionService.listRunningSectionFromLog(equipmentid, dates.getStart(), dates.getEnd());
        }
        if (sectionList == null || sectionList.isEmpty()) {
            sectionList = new ArrayList<>();
        }
        //处理数据
        long datesStart = dates.getStart();
        long datesEnd = dates.getEnd();
        for (int i = 0; i < sectionList.size(); i++) {
            MdcEquipmentRunningSection equipmentRunningSection = sectionList.get(i);
            long start = equipmentRunningSection.getStartTime().getTime();
            long end = equipmentRunningSection.getEndTime().getTime();
            if (datesStart <= start) {
                equipmentRunningSection.setStartTime(equipmentRunningSection.getStartTime());
        //查询是否需要维修的设备
        List<MdcEquipmentRepair> repairs = mdcEquipmentRepairService.mdcRepairListDate(equipmentid, dates.getStartDate(), dates.getEndDate());
        //制度时间段内的休班和维修时间段筛选
        List<MdcEquipmentRepair> repairList = this.findSubRepairs(repairs, dates);
        List<MdcDateVo> dateList = new ArrayList<>();
        if (repairList == null || repairList.isEmpty()) {
            //制度时间段内没有维修和休班时间段
            MdcEquipmentStatisticalShiftInfo shiftInfo = mdcRateEquipment(equipmentid, dates.getStartDate(), dates.getEndDate());
            return shiftInfo;
        } else {
            if (repairList.size() == 1 ) {
                long start = repairList.get(0).getStartTime().getTime();
                long end = repairList.get(0).getEndTime().getTime();
                if ( start > dates.getStart() && end < dates.getEnd() ) {
                    MdcDateVo d1 = new MdcDateVo();
                    d1.setStartTime(dates.getStartDate());
                    d1.setEndTime(repairList.get(0).getStartTime());
                    dateList.add(d1);
                    MdcDateVo d2 = new MdcDateVo();
                    d2.setStartTime(repairList.get(0).getEndTime());
                    d2.setEndTime(dates.getEndDate());
                    dateList.add(d2);
                } else  if (start == dates.getStart() && end < dates.getEnd()){
                    MdcDateVo d2 = new MdcDateVo();
                    d2.setStartTime(repairList.get(0).getEndTime());
                    d2.setEndTime(dates.getEndDate());
                    dateList.add(d2);
                } else if (start > dates.getStart() && end == dates.getEnd()) {
                    MdcDateVo d1 = new MdcDateVo();
                    d1.setStartTime(dates.getStartDate());
                    d1.setEndTime(repairList.get(0).getStartTime());
                    dateList.add(d1);
                } else {
                    //休班
                    MdcEquipmentStatisticalShiftInfo vo = new MdcEquipmentStatisticalShiftInfo();
                    vo.setTotalLong(BigDecimal.ZERO);
                    vo.setErrorLong(BigDecimal.ZERO);
                    vo.setProcessLong(BigDecimal.ZERO);
                    vo.setWaitLong(BigDecimal.ZERO);
                    vo.setCloseLong(BigDecimal.ZERO);
                    vo.setOpenLong(BigDecimal.ZERO);
                    return vo;
                }
            } else {
                equipmentRunningSection.setStartTime(dates.getStartDate());
            }
            if (datesEnd >= end) {
                equipmentRunningSection.setEndTime(equipmentRunningSection.getEndTime());
            } else {
                equipmentRunningSection.setEndTime(dates.getEndDate());
            }
            Long sen = DateUtils.differentSecond(equipmentRunningSection.getStartTime(), equipmentRunningSection.getEndTime());
            if (sen <= 0) {
                sectionList.remove(i);
                i--;
            } else {
                equipmentRunningSection.setDuration(sen);
                equipmentRunningSection.setStartLong(equipmentRunningSection.getStartTime().getTime());
                equipmentRunningSection.setEndLong(equipmentRunningSection.getEndTime().getTime());
                long s = dates.getStartDate().getTime();
                for (int i = 0 ; i < repairList.size(); i ++) {
                    long start = repairList.get(i).getStartTime().getTime();
                    long end = repairList.get(i).getEndTime().getTime();
                    if (start > s ) {
                        MdcDateVo d = new MdcDateVo();
                        d.setStartTime(dates.getStartDate());
                        d.setEndTime(repairList.get(i).getStartTime());
                        if (d.getEndTime().getTime() != d.getStartTime().getTime()) {
                            dateList.add(d);
                        }
                        dates.setStartDate(repairList.get(i).getEndTime());
                    } else if (start == s) {
                        dates.setStartDate(repairList.get(i).getEndTime());
                    }
                    if(i == repairList.size() -1 ) {
                        if(dates.getStartDate().getTime() >= end) {
                            MdcDateVo d = new MdcDateVo();
                            d.setStartTime(repairList.get(i).getEndTime());
                            d.setEndTime(dates.getEndDate());
                            if (d.getEndTime().getTime() != d.getStartTime().getTime()) {
                                dateList.add(d);
                            }
                        }
                    }
                }
            }
        }
        MdcEquipmentStatisticalShiftInfo shiftInfo = new MdcEquipmentStatisticalShiftInfo();
        shiftInfo.setEquipmentId(equipmentid);
        shiftInfo.setShiftId(dates.getShiftId());
        shiftInfo.setShiftSubId(dates.getShiftSubId());
        shiftInfo.setTheDate(dates.getDay());
        long waitLong = 0L;
        long processLong = 0L;
        long closeLong = 0L;
        long errorLong = 0L;
        for (MdcEquipmentRunningSection equipmentRunningSection : sectionList) {
            Long duration = equipmentRunningSection.getDuration();
            int status = equipmentRunningSection.getStatus();
            if (status == 2) {
                waitLong += duration;
        for (MdcDateVo date : dateList) {
            MdcEquipmentStatisticalShiftInfo v = mdcRateEquipment(equipmentid, date.getStartTime(), date.getEndTime());
            shiftInfo.setTotalLong(v.getTotalLong().add(shiftInfo.getTotalLong()));
            shiftInfo.setOpenLong(v.getOpenLong().add(shiftInfo.getOpenLong()));
            shiftInfo.setCloseLong(v.getCloseLong().add(shiftInfo.getCloseLong()));
            shiftInfo.setWaitLong(v.getWaitLong().add(shiftInfo.getWaitLong()));
            shiftInfo.setProcessLong(v.getProcessLong().add(shiftInfo.getProcessLong()));
            shiftInfo.setErrorLong(v.getErrorLong().add(shiftInfo.getErrorLong()));
        }
        return shiftInfo;
    }
    private MdcEquipmentStatisticalShiftInfo mdcRateEquipment(String equipmentid, Date startDate, Date endDate) {
        MdcDateVo date = new MdcDateVo();
        date.setStartTime(startDate);
        date.setEndTime(endDate);
        List<MdcEquipmentRunningSection> runningSections = new ArrayList<>();
        runningSections = mdcEquipmentRunningSectionService.listEquipmentRunningSectionRun(equipmentid, startDate.getTime(), endDate.getTime());
        //查询如果无数据需要 EquipmentLog è§£æž
        if (runningSections == null || runningSections.isEmpty()) {
            runningSections = mdcEquipmentRunningSectionService.listRunningSectionFromLog(equipmentid, startDate.getTime(), endDate.getTime());
        }
        if(runningSections == null || runningSections.isEmpty()) {
            runningSections = new ArrayList<>();
        }
        List<MdcEquipmentRunningSection> sectionErrors = mdcEquipmentRunningSectionService.listEquipmentRunningSectionError(equipmentid, startDate.getTime(), endDate.getTime());
        // æŽ’除基础配置报警号(基础配置报警号的不算报警)
        //sectionErrors = filterSectionErrors(equipmentId, sectionErrors);
        MdcEquipmentStatisticalShiftInfo shiftInfo = new MdcEquipmentStatisticalShiftInfo();
        BigDecimal totalLongRairs = new BigDecimal("0");
        List<MdcEquipmentRunningSection> sectionList = findStatsEquipment(null, runningSections, date, sectionErrors);
        if (sectionList == null || sectionList.isEmpty()) {
            shiftInfo.setEquipmentId(equipmentid);
            return shiftInfo;
        }
        List<MdcEquipmentRunningSection> runs = new ArrayList<>();
        List<MdcEquipmentRunningSection> errs = new ArrayList<>();
        for (MdcEquipmentRunningSection section : sectionList) {
            if (section.getStatus() == 22 || section.getStatus() == 0) {
                errs.add(section);
            }
            if (status == 3) {
                processLong += duration;
            }
            if (status == 0) {
                closeLong += duration;
            }
            if (status == 22) {
                errorLong += duration;
            if (section.getStatus() == 3) {
                runs.add(section);
            }
        }
        shiftInfo.setWaitLong(new BigDecimal(waitLong));
        shiftInfo.setProcessLong(new BigDecimal(processLong));
        shiftInfo.setCloseLong(new BigDecimal(closeLong));
        //开机时间计算为 æœ‰æ•ˆæ—¶é•¿ - å…³æœºæ—¶é•¿
        shiftInfo.setOpenLong(new BigDecimal((datesEnd - datesStart) / 1000).subtract(shiftInfo.getCloseLong()));
        shiftInfo.setErrorLong(new BigDecimal(errorLong));
        // åŠæ€»å·¥æ—¶ => æœ‰æ•ˆæ—¶é•¿å‡
        BigDecimal totalLong = new BigDecimal(DateUtils.getSeconds(startDate, endDate)).subtract(totalLongRairs);
        // è®¡ç®—加工
        BigDecimal processLong = new BigDecimal("0");
        if (runs != null && !runs.isEmpty()) {
            processLong = processLongInfo(runs);
        }
        // å…³æœºæ•°æ®
        List<MdcEquipmentRunningSection> closes = errs.stream().filter(section -> section.getStatus() != 22).collect(Collectors.toList());
        // å…³æœºæ—¶é•¿
        BigDecimal closeLong = new BigDecimal("0");
        closeLong = closeLong(closes);
        /*故障时间  errs => å…³æœºæ•°æ® + æŠ¥è­¦æ•°æ® */
        BigDecimal faultLong = new BigDecimal("0");
        faultLong =  faultLongInfo(errs);
        //报警数据
        List<MdcEquipmentRunningSection> alarms = errs.stream().filter(section -> section.getStatus() == 22).collect(Collectors.toList());
        //报警时长
        BigDecimal alarmLong = new BigDecimal("0");
        alarmLong = alarmLong(alarms);
        //待机时长 => æœ‰æ•ˆæ—¶é•¿ - è¿è¡Œæ—¶é•¿ - æŠ¥è­¦æ—¶é•¿
        BigDecimal waitLong = totalLong.subtract(processLong).subtract(alarmLong);
        if (waitLong.compareTo(BigDecimal.ZERO) < 0) {
            waitLong = new BigDecimal("0");
        }
        // å¼€æœºæ—¶é•¿ => æœ‰æ•ˆæ—¶é•¿ - å…³æœºæ—¶é•¿
        BigDecimal openLong = totalLong.subtract(closeLong);
        if (openLong.compareTo(BigDecimal.ZERO) < 0) {
            openLong = new BigDecimal("0");
        }
        shiftInfo.setProcessLong(processLong);
        shiftInfo.setTotalLong(totalLong);
        shiftInfo.setWaitLong(waitLong);
        shiftInfo.setErrorLong(alarmLong);
        shiftInfo.setCloseLong(closeLong);
        shiftInfo.setOpenLong(openLong);
        return shiftInfo;
    }
    /**
     * ç»Ÿè®¡å…³æœºæ—¶é•¿
     */
    private BigDecimal closeLong(List<MdcEquipmentRunningSection> closes) {
        BigDecimal closeLong = new BigDecimal("0");
        for (MdcEquipmentRunningSection alarm : closes) {
            closeLong = closeLong.add(new BigDecimal(alarm.getDuration()));
        }
        return closeLong;
    }
    /**
     * ç»Ÿè®¡æŠ¥è­¦æ—¶é•¿
     */
    private BigDecimal alarmLong(List<MdcEquipmentRunningSection> alarms) {
        BigDecimal alarmLong = new BigDecimal("0");
        for (MdcEquipmentRunningSection alarm : alarms) {
            alarmLong = alarmLong.add(new BigDecimal(alarm.getDuration()));
        }
        return alarmLong;
    }
    /**
     * ç»Ÿè®¡æ•…障时长
     */
    private BigDecimal faultLongInfo(List<MdcEquipmentRunningSection> errs) {
        BigDecimal faultLong = new BigDecimal("0");
        for (MdcEquipmentRunningSection e : errs) {
            faultLong = faultLong.add(new BigDecimal(e.getDuration()));
        }
        return faultLong;
    }
    /**
     * ç»Ÿè®¡åŠ å·¥æ—¶é•¿
     */
    private BigDecimal processLongInfo(List<MdcEquipmentRunningSection> runs) {
        BigDecimal processLong = new BigDecimal("0");
        for (MdcEquipmentRunningSection se : runs) {
            if (se.getStatus() == 3) {
                processLong = processLong.add(new BigDecimal(se.getDuration()));
            }
        }
        return processLong;
    }
    private List<MdcEquipmentRunningSection> findStatsEquipment(List<MdcEquipmentRepair> repairs, List<MdcEquipmentRunningSection> sRun, MdcDateVo mdcDate, List<MdcEquipmentRunningSection> errors) {
        if (sRun == null || sRun.isEmpty()) {
            //无数据处理
            //TODO
            return null;
        }
        Long  startMdc =  mdcDate.getStartTime().getTime();
        Long  endMdc =  mdcDate.getEndTime().getTime();
        if (sRun != null && !sRun.isEmpty()) {
            for (int i = 0 ; i < sRun.size() ; i ++) {
                Long start = sRun.get(i).getStartTime().getTime();
                Long end =  sRun.get(i).getEndTime().getTime();
                if (startMdc <= start ) {
                    sRun.get(i).setStartTime( sRun.get(i).getStartTime());
                } else {
                    sRun.get(i).setStartTime(mdcDate.getStartTime());
                }
                if (endMdc >= end) {
                    sRun.get(i).setEndTime( sRun.get(i).getEndTime());
                } else {
                    sRun.get(i).setEndTime(mdcDate.getEndTime());
                }
                Long sen = DateUtils.differentSecond( sRun.get(i).getStartTime(),
                        sRun.get(i).getEndTime());
                if (sen <= 0) {
                    sRun.remove(i);
                    i--;
                } else {
                    sRun.get(i).setDuration(sen);
                    sRun.get(i).setStartLong( sRun.get(i).getStartTime().getTime());
                    sRun.get(i).setEndLong( sRun.get(i).getEndTime().getTime());
                }
            }
        }
        //部分数据是维修  1、运行状态下报警情况
        List<MdcEquipmentRunningSection> faultRun = new ArrayList<>();
        //制度时间段内报警数据
        if (errors != null && !errors.isEmpty() ) {
            for (int i = 0 ; i < errors.size() ; i ++) {
                Long start = errors.get(i).getStartTime().getTime();
                Long end =  errors.get(i).getEndTime().getTime();
                if (startMdc <= start ) {
                    errors.get(i).setStartTime( errors.get(i).getStartTime());
                } else {
                    errors.get(i).setStartTime(mdcDate.getStartTime());
                }
                if (endMdc >= end) {
                    errors.get(i).setEndTime( errors.get(i).getEndTime());
                } else {
                    errors.get(i).setEndTime(mdcDate.getEndTime());
                }
                Long sen = DateUtils.differentSecond( errors.get(i).getStartTime(),
                        errors.get(i).getEndTime());
                if (sen <= 0) {
                    errors.remove(i);
                    i--;
                } else {
                    errors.get(i).setDuration(sen);
                    errors.get(i).setStartLong( errors.get(i).getStartTime().getTime());
                    errors.get(i).setEndLong( errors.get(i).getEndTime().getTime());
                }
            }
            //把运行中存在的报警剔除掉
            for (MdcEquipmentRunningSection se : sRun) {
                long runStart = se.getStartTime().getTime();
                long runEnd =  se.getEndTime().getTime();
                if (se.getStatus() == 3) {
                    if (errors != null && !errors.isEmpty() ) {
                        //处理报警数据
                        for (int i = 0 ; i < errors.size(); i ++ ) {
                            long errStart = errors.get(i).getStartTime().getTime();
                            long errEnd = errors.get(i).getEndTime().getTime();
                            // æŠ¥è­¦å¼€å§‹ å°äºŽ è¿è¡Œå¼€å§‹  æŠ¥è­¦ç»“束 å°äºŽè¿è¡Œç»“束 æŠ¥è­¦ç»“束 å¤§äºŽ è¿è¡Œå¼€å§‹
                            if ( errStart  < runStart && errEnd <= runEnd && errEnd >  runStart ) {
                                errors.get(i).setEndTime(se.getStartTime());
                                Long sen = DateUtils.differentSecond(errors.get(i).getStartTime(),
                                        errors.get(i).getEndTime());
                                errors.get(i).setDuration(sen);
                                errors.get(i).setStartLong(errors.get(i).getStartTime().getTime());
                                errors.get(i).setEndLong(errors.get(i).getEndTime().getTime());
                            }
                            // æŠ¥è­¦å¼€å§‹ å¤§äºŽ è¿è¡Œå¼€å§‹ ï¼Œ æŠ¥è­¦å¼€å§‹ å°äºŽ è¿è¡Œç»“束 ï¼ŒæŠ¥è­¦ç»“束 å¤§äºŽ è¿è¡Œç»“束
                            else if (errStart >=  runStart && errStart < runEnd &&  errEnd > runEnd ) {
                                errors.get(i).setStartTime(se.getEndTime());
                                Long sen = DateUtils.differentSecond(errors.get(i).getStartTime(),
                                        errors.get(i).getEndTime());
                                errors.get(i).setDuration(sen);
                                errors.get(i).setStartLong(errors.get(i).getStartTime().getTime());
                                errors.get(i).setEndLong(errors.get(i).getEndTime().getTime());
                            }
                            // æŠ¥è­¦å¼€å§‹ å¤§äºŽ è¿è¡Œå¼€å§‹ ï¼Œ æŠ¥è­¦å¼€å§‹ å°äºŽ è¿è¡Œç»“束 ï¼ŒæŠ¥è­¦ç»“束 å¤§äºŽ è¿è¡Œå¼€å§‹ï¼ŒæŠ¥è­¦ç»“束 å°äºŽ  è¿è¡Œç»“束
                            else if (errStart >= runStart && errStart < runEnd &&
                                    errEnd > runStart && errEnd <= runEnd ){
                                errors.remove(i);
                                i--;
                            }
                            //如果超出范围
                            else if (errStart <= runStart && errStart < runEnd &&
                                    errEnd > runStart && errEnd >= runEnd ) {
                                MdcEquipmentRunningSection errOne = new MdcEquipmentRunningSection();
                                errOne.setEndTime(errors.get(i).getEndTime());
                                errors.get(i).setStartTime(errors.get(i).getStartTime());
                                errors.get(i).setEndTime(se.getStartTime());
                                Long sen = DateUtils.differentSecond(errors.get(i).getStartTime(),
                                        errors.get(i).getEndTime());
                                //
                                //TODO
                                errOne.setStatus(22);
                                errOne.setEquipmentId(errors.get(i).getEquipmentId());
                                errOne.setStartTime(se.getEndTime());
                                errors.get(i).setDuration(sen);
                                errors.get(i).setStartLong(errors.get(i).getStartTime().getTime());
                                errors.get(i).setEndLong(errors.get(i).getEndTime().getTime());
                                Long one = DateUtils.differentSecond(errOne.getStartTime(), errOne.getEndTime());
                                errOne.setDuration(one);
                                errOne.setStartLong(errOne.getStartTime().getTime());
                                errOne.setEndLong(errOne.getEndTime().getTime());
                                if (sen <= 0) {
                                    errors.remove(i);
                                    errors.add(i,errOne);
                                } else {
                                    errors.add(i+1,errOne);
                                    i++;
                                }
                            } else {
                                continue;
                            }
                        }
                    }
                }
            }
        }
        //处理报警数据
        List<MdcEquipmentRunningSection> sectionList = new ArrayList<>();
        if (sRun != null && !sRun.isEmpty()) {
            for (MdcEquipmentRunningSection se : sRun) {
                sectionList.add(se);
            }
        }
        //报警剔除运行报警
        if (errors != null && !errors.isEmpty()) {
            sectionList.addAll(errors);
        }
        //关机处理为故障报警
        if (faultRun != null && !faultRun.isEmpty()) {
            sectionList.addAll(faultRun);
        }
        return sectionList;
    }
    private List<MdcEquipmentRepair> findSubRepairs(List<MdcEquipmentRepair> repairs, MdcShiftDateVo dates) {
        if (repairs == null || repairs.isEmpty() || dates == null) {
            return null;
        }
        for (MdcEquipmentRepair repair : repairs) {
            //调整
            Date start = null;
            Date end = null;
            long dStart = dates.getStartDate().getTime();
            long dEnd = dates.getEndDate().getTime();
            long rStart = repair.getStartTime().getTime();
            long rEnd = repair.getEndTime().getTime();
            if (rStart <= dStart && rEnd >= dStart && rEnd <= dEnd) {
                start = dates.getStartDate();
                end = repair.getEndTime();
            } else if (rStart >= dStart && rEnd <= dEnd) {
                start = repair.getStartTime();
                end = repair.getEndTime();
            } else if (rStart >= dStart && rStart <= dEnd && rEnd >= dEnd) {
                start = repair.getStartTime();
                end = dates.getEndDate();
            } else if (rStart <= dStart && rEnd >= dEnd) {
                start = dates.getStartDate();
                end = dates.getEndDate();
            }
            repair.setStartTime(start);
            repair.setEndTime(end);
            //处理异常数据
            if (start == null || end == null) {
                repair.setSecondLong(0);
            } else {
                try {
                    repair.setSecondLong(DateUtils.getSeconds(start, end));
                } catch (Exception e) {
                    repair.setSecondLong(0);
                }
            }
        }
        for (int i = 0; i < repairs.size(); i++) {
            if (repairs.get(i).getStartTime() == null || repairs.get(i).getEndTime() == null || repairs.get(i).getSecondLong() == 0) {
                repairs.remove(i);
                i--;
            }
        }
        return repairs;
    }
    /**
     * æ—¶é—´é—®é¢˜å¤„理 å¦‚果当天最末尾时间大于当前时间 è¿”回0
     *
     * @param temp
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcDateVo.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
package org.jeecg.modules.mdc.vo;
import lombok.Data;
import java.util.Date;
/**
 * @author: LiuS
 * @create: 2023-07-27 09:58
 */
@Data
public class MdcDateVo {
    private Date startTime;
    private Date endTime;
    private Long start;
    private Long end;
}