Lius
2024-09-27 435c2e83b4caefee5676fedfd7a27d7b0362693d
update
已添加2个文件
已修改5个文件
214 ■■■■■ 文件已修改
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcOverallEquipmentEfficiencyController.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcOverallEquipmentEfficiencyMapper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOverallEquipmentEfficiencyMapper.xml 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcOverallEquipmentEfficiencyService.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOverallEquipmentEfficiencyServiceImpl.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/OeeStatisticsChartVo.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/OeeStatisticsVo.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcOverallEquipmentEfficiencyController.java
@@ -13,6 +13,8 @@
import org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency;
import org.jeecg.modules.mdc.service.IMdcOverallEquipmentEfficiencyService;
import org.jeecg.modules.mdc.vo.MdcOverallEquipmentEfficiencyVo;
import org.jeecg.modules.mdc.vo.OeeStatisticsChartVo;
import org.jeecg.modules.mdc.vo.OeeStatisticsVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -20,6 +22,7 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
 * @Description: OEE设备综合效率表
@@ -58,5 +61,25 @@
        return Result.OK(pageList);
    }
    /**
     *
     * @return
     */
    @AutoLog(value = "OEE设备综合效率表-oee统计")
    @ApiOperation(value = "OEE设备综合效率表-oee统计", notes = "OEE设备综合效率表-oee统计")
    @GetMapping("/oeeStatisticsList")
    public Result oeeStatisticsList(String date) {
        List<OeeStatisticsVo> result = mdcOverallEquipmentEfficiencyService.oeeStatisticsList(date);
        return Result.OK(result);
    }
    @AutoLog(value = "OEE设备综合效率表-oee统计柱状图")
    @ApiOperation(value = "OEE设备综合效率表-oee统计柱状图", notes = "OEE设备综合效率表-oee统计柱状图")
    @GetMapping("/oeeStatisticsChart")
    public Result oeeStatisticsChart(String date, String equipmentType) {
        List<OeeStatisticsChartVo> result = mdcOverallEquipmentEfficiencyService.oeeStatisticsChart(date, equipmentType);
        return Result.OK(result);
    }
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcOverallEquipmentEfficiencyMapper.java
@@ -7,6 +7,9 @@
import org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency;
import org.jeecg.modules.mdc.vo.MdcOverallEquipmentEfficiencyVo;
import java.math.BigDecimal;
import java.util.List;
/**
 * @author Lius
 * @date 2023/11/3 14:29
@@ -22,4 +25,7 @@
     */
    IPage<MdcOverallEquipmentEfficiency> pageList(Page<MdcOverallEquipmentEfficiency> page, @Param("mdcOverallEquipmentEfficiency") MdcOverallEquipmentEfficiencyVo mdcOverallEquipmentEfficiencyVo);
    List<MdcOverallEquipmentEfficiency> findOeeByDate(@Param("date") String date, @Param("productionId") String id);
    BigDecimal findAvgOee(@Param("date") String date, @Param("equipmentType") String equipmentType, @Param("productionId") String id);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOverallEquipmentEfficiencyMapper.xml
@@ -79,4 +79,34 @@
            AND t2.device_abnormal_status = 1
        </where>
    </select>
    <select id="findOeeByDate" resultType="org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency">
        SELECT
            t1.*
        FROM
            mdc_overall_equipment_efficiency t1
                LEFT JOIN mdc_equipment t2 ON t1.equipment_id = t2.equipment_id
                LEFT JOIN mdc_production_equipment t3 ON t2.id = t3.equipment_id
                LEFT JOIN mdc_production t4 ON t4.id = t3.production_id
        WHERE
            ( t4.id = #{productionId} OR t4.parent_id = #{productionId} )
          AND t1.valid_date = #{date}
    </select>
    <select id="findAvgOee" resultType="java.math.BigDecimal">
        SELECT
            SUM( t1.overall_equipment_efficiency ) / COUNT ( t1.equipment_id ) oee
        FROM
            mdc_overall_equipment_efficiency t1
                LEFT JOIN mdc_equipment t2 ON t1.equipment_id = t2.equipment_id
                LEFT JOIN mdc_production_equipment t3 ON t2.id = t3.equipment_id
                LEFT JOIN mdc_production t4 ON t4.id = t3.production_id
        WHERE
            ( t4.id = #{productionId} OR t4.parent_id = #{productionId} )
          AND t1.valid_date = #{date}
        <if test="equipmentType != null and equipmentType != ''">
            AND t2.equipment_type = #{equipmentType}
        </if>
    </select>
</mapper>
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcOverallEquipmentEfficiencyService.java
@@ -5,8 +5,11 @@
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency;
import org.jeecg.modules.mdc.vo.MdcOverallEquipmentEfficiencyVo;
import org.jeecg.modules.mdc.vo.OeeStatisticsChartVo;
import org.jeecg.modules.mdc.vo.OeeStatisticsVo;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
 * @author: LiuS
@@ -29,4 +32,19 @@
     * @return
     */
    IPage<MdcOverallEquipmentEfficiency> pageList(String userId, Page<MdcOverallEquipmentEfficiency> page, MdcOverallEquipmentEfficiencyVo mdcOverallEquipmentEfficiencyVo, HttpServletRequest req);
    /**
     *
     * @param date
     * @return
     */
    List<OeeStatisticsVo> oeeStatisticsList(String date);
    /**
     *
     * @param date
     * @param equipmentType
     * @return
     */
    List<OeeStatisticsChartVo> oeeStatisticsChart(String date, String equipmentType);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOverallEquipmentEfficiencyServiceImpl.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.modules.mdc.constant.MdcConstant;
import org.jeecg.modules.mdc.entity.MdcEquipment;
import org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency;
@@ -12,6 +13,8 @@
import org.jeecg.modules.mdc.service.*;
import org.jeecg.modules.mdc.util.DateUtils;
import org.jeecg.modules.mdc.vo.MdcOverallEquipmentEfficiencyVo;
import org.jeecg.modules.mdc.vo.OeeStatisticsChartVo;
import org.jeecg.modules.mdc.vo.OeeStatisticsVo;
import org.jeecg.modules.system.entity.MdcProduction;
import org.jeecg.modules.system.service.IMdcProductionService;
import org.springframework.stereotype.Service;
@@ -20,11 +23,11 @@
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
 * @author: LiuS
@@ -316,6 +319,75 @@
        return mdcOverallEquipmentEfficiencyIPage;
    }
    /**
     *
     * @param date
     * @return
     */
    @Override
    public List<OeeStatisticsVo> oeeStatisticsList(String date) {
        List<OeeStatisticsVo> result = new ArrayList<>();
        if (StringUtils.isEmpty(date)) {
            date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(-1));
        }
        List<MdcProduction> mdcProductionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getOrgType, 2).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0));
        if (mdcProductionList != null && !mdcProductionList.isEmpty()) {
            for (MdcProduction mdcProduction : mdcProductionList) {
                OeeStatisticsVo oeeStatisticsVo = new OeeStatisticsVo();
                oeeStatisticsVo.setProductionName(mdcProduction.getProductionName());
                List<MdcOverallEquipmentEfficiency> mdcOverallEquipmentEfficiencyList = this.baseMapper.findOeeByDate(date, mdcProduction.getId());
                if (mdcOverallEquipmentEfficiencyList != null && !mdcOverallEquipmentEfficiencyList.isEmpty()) {
                    for (MdcOverallEquipmentEfficiency mdcOverallEquipmentEfficiency : mdcOverallEquipmentEfficiencyList) {
                        int oee = mdcOverallEquipmentEfficiency.getOverallEquipmentEfficiency().multiply(new BigDecimal("10000")).intValue();
                        if (oee < 500) {
                            oeeStatisticsVo.setLevel1(oeeStatisticsVo.getLevel1() + 1);
                        } else if (oee >= 500 && oee < 1000) {
                            oeeStatisticsVo.setLevel2(oeeStatisticsVo.getLevel2() + 1);
                        } else if (oee >= 1000 && oee <  3000) {
                            oeeStatisticsVo.setLevel3(oeeStatisticsVo.getLevel3() + 1);
                        } else if (oee >= 3000 && oee < 6000) {
                            oeeStatisticsVo.setLevel4(oeeStatisticsVo.getLevel4() + 1);
                        } else if (oee >= 6000) {
                            oeeStatisticsVo.setLevel5(oeeStatisticsVo.getLevel5() + 1);
                        }
                    }
                }
                result.add(oeeStatisticsVo);
            }
        }
        return result;
    }
    /**
     *
     * @param date
     * @param equipmentType
     * @return
     */
    @Override
    public List<OeeStatisticsChartVo> oeeStatisticsChart(String date, String equipmentType) {
        List<OeeStatisticsChartVo> result = new ArrayList<>();
        if (StringUtils.isEmpty(date)) {
            date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(-1));
        }
        List<MdcProduction> mdcProductionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getOrgType, 2).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0));
        if (mdcProductionList != null && !mdcProductionList.isEmpty()) {
            for (MdcProduction mdcProduction : mdcProductionList) {
                OeeStatisticsChartVo oeeStatisticsChartVo = new OeeStatisticsChartVo();
                oeeStatisticsChartVo.setKey(mdcProduction.getProductionName());
                BigDecimal oee = this.baseMapper.findAvgOee(date, equipmentType, mdcProduction.getId());
                if (oee != null) {
                    oeeStatisticsChartVo.setValue(oee);
                }
                result.add(oeeStatisticsChartVo);
            }
        }
        if (!result.isEmpty()) {
            result = result.stream().sorted(Comparator.comparing(OeeStatisticsChartVo::getValue)).collect(Collectors.toList());
        }
        return result;
    }
    /**
     * é€’归查询设备车间名称
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/OeeStatisticsChartVo.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
package org.jeecg.modules.mdc.vo;
import lombok.Data;
import java.math.BigDecimal;
/**
 * @author Lius
 * @date 2024/9/27 14:17
 */
@Data
public class OeeStatisticsChartVo {
    /**
     * è½¦é—´åç§°
     */
    private String key;
    /**
     * oee
     */
    private BigDecimal value = BigDecimal.ZERO;
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/OeeStatisticsVo.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
package org.jeecg.modules.mdc.vo;
import lombok.Data;
/**
 * @author Lius
 * @date 2024/9/27 10:19
 */
@Data
public class OeeStatisticsVo {
    /**
     * ä½¿ç”¨å•位
     */
    private String productionName;
    /**
     * å°äºŽ5%
     */
    private Integer level1 = 0;
    /**
     * 5%-10%
     */
    private Integer level2 = 0;
    /**
     * 10%-30%
     */
    private Integer level3 = 0;
    /**
     * 30%-60%
     */
    private Integer level4 = 0;
    /**
     * 60%以上
     */
    private Integer level5 = 0;
}