Lius
2024-03-13 e8d223967ea612f4eb24603ed7ae941ec00fd76f
车间管理添加字段,算法bug修复
已修改6个文件
80 ■■■■■ 文件已修改
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningMonitoringSpeedJob.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningOvertimeDurationJob.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentAlarmAnalyzeServiceImpl.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/entity/MdcProduction.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningMonitoringSpeedJob.java
@@ -23,6 +23,8 @@
import org.quartz.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.List;
@@ -72,9 +74,9 @@
            // 获取字典数据
            List<DictModel> dictModelList = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_OPERATING_SPEED_RANGE);
            Integer range = 0;
            BigDecimal range = BigDecimal.ZERO;
            if (dictModelList != null && !dictModelList.isEmpty()) {
                range = Integer.valueOf(dictModelList.get(0).getValue());
                range = new BigDecimal(dictModelList.get(0).getValue());
            }
            for (MdcEquipment mdcEquipment : mdcEquipmentList) {
@@ -87,29 +89,29 @@
                } catch (Exception e) {
                    log.error("查询单表数据失败!", e);
                }
                if (StringUtils.isNotBlank(mdcEquipmentDto.getSpindlespeed()) && StringUtils.isNotBlank(mdcEquipmentDto.getActualspindlespeed())) {
                if (mdcEquipmentDto != null && StringUtils.isNotBlank(mdcEquipmentDto.getSpindlespeed()) && StringUtils.isNotBlank(mdcEquipmentDto.getActualspindlespeed())) {
                    MessageDTO messageDTO = new MessageDTO();
                    messageDTO.setTitle("设备运行转速报警!");
                    messageDTO.setCategory("预警消息");
                    messageDTO.setFromUser("admin");
                    messageDTO.setToUser("admin");
                    //设定
                    Integer spindlespeed = Integer.valueOf(mdcEquipmentDto.getSpindlespeed());
                    BigDecimal spindlespeed = new BigDecimal(mdcEquipmentDto.getSpindlespeed());
                    //实际
                    Integer actualspindlespeed = Integer.valueOf(mdcEquipmentDto.getActualspindlespeed());
                    BigDecimal actualspindlespeed = new BigDecimal(mdcEquipmentDto.getActualspindlespeed());
                    MdcOverrunAlarm mdcOverrunAlarm = new MdcOverrunAlarm();
                    mdcOverrunAlarm.setEquipmentId(mdcEquipment.getEquipmentId());
                    mdcOverrunAlarm.setSetValue(spindlespeed.toString());
                    mdcOverrunAlarm.setRealValue(actualspindlespeed.toString());
                    if (range.equals(0)) {
                        if (spindlespeed > actualspindlespeed) {
                    if (range.equals(BigDecimal.ZERO)) {
                        if (spindlespeed.compareTo(actualspindlespeed) == 1) {
                            // 设定值大于实际值   低
                            messageDTO.setContent("设备编号为 [" + mdcEquipment.getEquipmentId() + "] 的设备运行转速低报警!");
                            sysBaseApi.sendSysAnnouncement(messageDTO);
                            mdcOverrunAlarm.setAlarmContent("设备运行转速比NC代码设定值低报警");
                            mdcOverrunAlarmService.save(mdcOverrunAlarm);
                        } else if (spindlespeed < actualspindlespeed) {
                        } else if (spindlespeed.compareTo(actualspindlespeed) == -1) {
                            // 设定值小于实际值   高
                            messageDTO.setContent("设备编号为 [" + mdcEquipment.getEquipmentId() + "] 的设备运行转速高报警!");
                            sysBaseApi.sendSysAnnouncement(messageDTO);
@@ -117,16 +119,17 @@
                            mdcOverrunAlarmService.save(mdcOverrunAlarm);
                        }
                    } else {
                        int max = spindlespeed + spindlespeed * (range / 100);
                        int min = spindlespeed - spindlespeed * (range / 100);
                        if (actualspindlespeed > max || actualspindlespeed < min) {
                            if (spindlespeed > actualspindlespeed) {
                        BigDecimal multiply = spindlespeed.multiply(range.divide(new BigDecimal(100), 4, RoundingMode.HALF_UP));
                        BigDecimal max = spindlespeed.add(multiply);
                        BigDecimal min = spindlespeed.subtract(multiply);
                        if (actualspindlespeed.compareTo(max) == 1 || actualspindlespeed.compareTo(min) == -1) {
                            if (spindlespeed.compareTo(actualspindlespeed) == 1) {
                                // 设定值大于实际值   低
                                messageDTO.setContent("设备编号为 [" + mdcEquipment.getEquipmentId() + "] 的设备运行转速低报警!");
                                sysBaseApi.sendSysAnnouncement(messageDTO);
                                mdcOverrunAlarm.setAlarmContent("设备运行转速比NC代码设定值低报警");
                                mdcOverrunAlarmService.save(mdcOverrunAlarm);
                            } else if (spindlespeed < actualspindlespeed) {
                            } else if (spindlespeed.compareTo(actualspindlespeed) == -1) {
                                // 设定值小于实际值   高
                                messageDTO.setContent("设备编号为 [" + mdcEquipment.getEquipmentId() + "] 的设备运行转速高报警!");
                                sysBaseApi.sendSysAnnouncement(messageDTO);
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningOvertimeDurationJob.java
@@ -79,8 +79,8 @@
        quartzLog.setParams(this.parameter);
        log.info(String.format("定时统计设备加班时长任务 param: %s RunningOvertimeDurationJob start!  时间:" + DateUtils.getNow(), this.parameter));
        long startTime = System.currentTimeMillis();
        String date = "";
        try {
            String date = "";
            if (StringUtils.isNotBlank(this.parameter)) {
                date = DateUtils.format(DateUtils.toDate(this.parameter, DateUtils.STRDATE), DateUtils.STR_DATE);
                Date initDate = DateUtils.toDate(this.parameter, DateUtils.STRDATE);
@@ -99,7 +99,7 @@
            List<MdcEquipmentOvertime> result = new ArrayList<>();
            for (MdcEquipment mdcEquipment : equipmentList) {
                // 获取设备工作日历
                List<MdcDeviceCalendarVo> mdcDeviceCalendarVos = mdcDeviceCalendarService.listByEquipmentIdAndDate(mdcEquipment.getEquipmentId(), this.parameter);
                List<MdcDeviceCalendarVo> mdcDeviceCalendarVos = mdcDeviceCalendarService.listByEquipmentIdAndDate(mdcEquipment.getEquipmentId(), DateUtils.format(DateUtils.toDate(date, DateUtils.STR_DATE),DateUtils.STRDATE));
                if (mdcDeviceCalendarVos != null && !mdcDeviceCalendarVos.isEmpty()) {
                    //获取最后一个班次结束时间
                    Date startDate = this.getCalendarEndDate(mdcDeviceCalendarVos, date);
@@ -121,7 +121,7 @@
                        mdcEquipmentOvertime.setEquipmentId(mdcEquipment.getEquipmentId());
                        mdcEquipmentOvertime.setDuration(duration);
                        mdcEquipmentOvertime.setAutoFlag(CommonConstant.AUTO_FLAG_Y);
                        mdcEquipmentOvertime.setTheDate(this.parameter);
                        mdcEquipmentOvertime.setTheDate(DateUtils.format(DateUtils.toDate(date, DateUtils.STR_DATE),DateUtils.STRDATE));
                        result.add(mdcEquipmentOvertime);
                    }
@@ -146,7 +146,7 @@
                        mdcEquipmentOvertime.setEquipmentId(mdcEquipment.getEquipmentId());
                        mdcEquipmentOvertime.setDuration(duration);
                        mdcEquipmentOvertime.setAutoFlag(CommonConstant.AUTO_FLAG_Y);
                        mdcEquipmentOvertime.setTheDate(this.parameter);
                        mdcEquipmentOvertime.setTheDate(DateUtils.format(DateUtils.toDate(date, DateUtils.STR_DATE),DateUtils.STRDATE));
                        result.add(mdcEquipmentOvertime);
                    }
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml
@@ -52,15 +52,12 @@
            t3.sleep_start_date,
            t3.sleep_end_date,
            t3.is_day_span,
            t4.equipment_name,
            t5.start_time overtimeStartTime,
            t5.end_time overtimeEndTime
            t4.equipment_name
        FROM
            mdc_device_calendar t1
            LEFT JOIN mdc_shift t2 ON t1.shift_id = t2.id
            LEFT JOIN mdc_shift_sub t3 ON t1.shift_sub_id = t3.id
            LEFT JOIN mdc_equipment t4 ON t1.equipment_id = t4.equipment_id
            LEFT JOIN mdc_equipment_overtime t5 ON t5.calendar_id = t1.id
        <where>
            <if test="equipmentId != null and equipmentId != ''">
                AND t4.equipment_id = #{ equipmentId }
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java
@@ -7,10 +7,7 @@
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.mdc.entity.*;
import org.jeecg.modules.mdc.mapper.MdcDeviceCalendarMapper;
import org.jeecg.modules.mdc.service.IMdcDeviceCalendarService;
import org.jeecg.modules.mdc.service.IMdcEquipmentService;
import org.jeecg.modules.mdc.service.IMdcShiftSubService;
import org.jeecg.modules.mdc.service.IMdcVacationManagementService;
import org.jeecg.modules.mdc.service.*;
import org.jeecg.modules.mdc.vo.EquipmentCalendarVo;
import org.jeecg.modules.mdc.vo.MdcDeviceCalendarQueryVo;
import org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo;
@@ -41,6 +38,9 @@
    @Resource
    private IMdcVacationManagementService mdcVacationManagementService;
    @Resource
    private IMdcEquipmentOvertimeService mdcEquipmentOvertimeService;
    /**
     * 分页列表查询
@@ -212,7 +212,17 @@
    @Override
    public List<MdcDeviceCalendarVo> listByEquipmentIdAndDate(String equipmentId, String date) {
        return this.baseMapper.listByEquipmentAndDate(equipmentId, date);
        List<MdcDeviceCalendarVo> mdcDeviceCalendarVos = this.baseMapper.listByEquipmentAndDate(equipmentId, date);
        if (mdcDeviceCalendarVos != null && !mdcDeviceCalendarVos.isEmpty()) {
            for (MdcDeviceCalendarVo mdcDeviceCalendarVo : mdcDeviceCalendarVos) {
                List<MdcEquipmentOvertime> list = mdcEquipmentOvertimeService.list(new LambdaQueryWrapper<MdcEquipmentOvertime>().eq(MdcEquipmentOvertime::getEquipmentId, mdcDeviceCalendarVo.getEquipmentId()).eq(MdcEquipmentOvertime::getTheDate, mdcDeviceCalendarVo.getEndDate()));
                if (list != null && !list.isEmpty()) {
                    mdcDeviceCalendarVo.setOvertimeStartTime(list.get(0).getStartTime());
                    mdcDeviceCalendarVo.setOvertimeEndTime(list.get(0).getEndTime());
                }
            }
        }
        return mdcDeviceCalendarVos;
    }
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentAlarmAnalyzeServiceImpl.java
@@ -1,11 +1,15 @@
package org.jeecg.modules.mdc.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.mdc.dto.MdcAlarmAnalyzeDto;
import org.jeecg.modules.mdc.dto.MdcAlarmDto;
import org.jeecg.modules.mdc.dto.MdcAlarmListDto;
import org.jeecg.modules.mdc.dto.MdcAlarmTrendDto;
import org.jeecg.modules.mdc.entity.MdcAlarmInfo;
import org.jeecg.modules.mdc.entity.MdcEquipment;
import org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection;
import org.jeecg.modules.mdc.service.IMdcAlarmInfoService;
import org.jeecg.modules.mdc.service.IMdcEquipmentRunningSectionService;
import org.jeecg.modules.mdc.service.IMdcEquipmentService;
import org.jeecg.modules.mdc.service.MdcEquipmentAlarmAnalyzeService;
@@ -29,6 +33,9 @@
    @Resource
    private IMdcEquipmentService mdcEquipmentService;
    @Resource
    private IMdcAlarmInfoService mdcAlarmInfoService;
    @Override
    public List<MdcAlarmAnalyzeDto> alarmList(String userId, MdcAlarmAnalyzeQueryVo vo) {
@@ -77,6 +84,12 @@
                    mdcAlarmAnalyzeDto.setAlarmCode(mdcEquipmentRunningSection.getAlarm());
                    mdcAlarmAnalyzeDto.setCount(1);
                    mdcAlarmAnalyzeDto.setTimeCount(new BigDecimal(mdcEquipmentRunningSection.getDuration()));
                    //查询报警号内容
                    List<MdcEquipment> list = mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, mdcEquipmentRunningSection.getEquipmentId()));
                    List<MdcAlarmInfo> mdcAlarmInfo = mdcAlarmInfoService.list(new LambdaQueryWrapper<MdcAlarmInfo>().eq(MdcAlarmInfo::getDriveType, list.get(0).getDriveType()).eq(MdcAlarmInfo::getAlarmCode, mdcEquipmentRunningSection.getAlarm()).eq(MdcAlarmInfo::getIsUse, 0));
                    if (mdcAlarmInfo != null && !mdcAlarmInfo.isEmpty()) {
                        mdcAlarmAnalyzeDto.setAlarmContent(mdcAlarmInfo.get(0).getAlarmContent());
                    }
                    map.put(mdcEquipmentRunningSection.getAlarm(), mdcAlarmAnalyzeDto);
                }
            }
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/entity/MdcProduction.java
@@ -64,6 +64,11 @@
    @ApiModelProperty(value = "产线编码")
    private String orgCode;
    /**
     * 产线编码
     */
    @ApiModelProperty(value = "车间编码")
    private String productionCode;
    /**
     * 地址
     */
    @Excel(name = "地址", width = 15)