From e8d223967ea612f4eb24603ed7ae941ec00fd76f Mon Sep 17 00:00:00 2001 From: Lius <Lius2225@163.com> Date: 星期三, 13 三月 2024 11:33:07 +0800 Subject: [PATCH] 车间管理添加字段,算法bug修复 --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml | 5 -- lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/entity/MdcProduction.java | 5 ++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningMonitoringSpeedJob.java | 29 ++++++++------ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningOvertimeDurationJob.java | 8 ++-- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java | 20 +++++++-- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentAlarmAnalyzeServiceImpl.java | 13 ++++++ 6 files changed, 54 insertions(+), 26 deletions(-) diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningMonitoringSpeedJob.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningMonitoringSpeedJob.java index 016b062..ebf871a 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningMonitoringSpeedJob.java +++ b/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浠g爜璁惧畾鍊间綆鎶ヨ"); 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浠g爜璁惧畾鍊间綆鎶ヨ"); mdcOverrunAlarmService.save(mdcOverrunAlarm); - } else if (spindlespeed < actualspindlespeed) { + } else if (spindlespeed.compareTo(actualspindlespeed) == -1) { // 璁惧畾鍊煎皬浜庡疄闄呭�� 楂� messageDTO.setContent("璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶囪繍琛岃浆閫熼珮鎶ヨ锛�"); sysBaseApi.sendSysAnnouncement(messageDTO); diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningOvertimeDurationJob.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningOvertimeDurationJob.java index 3c42552..32f01e6 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningOvertimeDurationJob.java +++ b/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); } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml index a63838e..b47450f 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml +++ b/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 } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java index 238de3a..2b3ae6f 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java +++ b/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; } } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentAlarmAnalyzeServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentAlarmAnalyzeServiceImpl.java index d0f0311..01e7d16 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentAlarmAnalyzeServiceImpl.java +++ b/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); } } diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/entity/MdcProduction.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/entity/MdcProduction.java index f23d1f6..5d36ad0 100644 --- a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/entity/MdcProduction.java +++ b/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) -- Gitblit v1.9.3