From d603739c0320f355cfc3152865918729fea790de Mon Sep 17 00:00:00 2001 From: Lius <Lius2225@163.com> Date: 星期一, 04 十一月 2024 09:45:43 +0800 Subject: [PATCH] license --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/StatisticalSpindleJob.java | 70 +++++++++++++++++++--------------- 1 files changed, 39 insertions(+), 31 deletions(-) diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/StatisticalSpindleJob.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/StatisticalSpindleJob.java index c345bef..bbb7e33 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/StatisticalSpindleJob.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/StatisticalSpindleJob.java @@ -5,10 +5,7 @@ import org.jeecg.modules.mdc.dto.MachineXYZHistoryDto; import org.jeecg.modules.mdc.entity.Equipment; import org.jeecg.modules.mdc.entity.EquipmentSpindleStatistical; -import org.jeecg.modules.mdc.service.IEquipmentMachiningHistoryService; -import org.jeecg.modules.mdc.service.IEquipmentService; -import org.jeecg.modules.mdc.service.IEquipmentSpindleStatisticalService; -import org.jeecg.modules.mdc.service.IMachineXYZHistoryService; +import org.jeecg.modules.mdc.service.*; import org.jeecg.modules.mdc.util.DateUtils; import org.jeecg.modules.mdc.util.ThrowableUtil; import org.jeecg.modules.quartz.entity.QuartzJob; @@ -55,6 +52,12 @@ @Resource private IMachineXYZHistoryService machineXYZHistoryService; + @Resource + private IEquipmentWorkLineService equipmentWorkLineService; + + @Resource + private IEquipmentXYZService equipmentXYZService; + @Override public void execute(JobExecutionContext context) throws JobExecutionException { SysQuartzLog quartzLog = new SysQuartzLog(); @@ -72,36 +75,41 @@ EquipmentSpindleStatistical spindleStatistical; List<EquipmentSpindleStatistical> resultList = new ArrayList<>(); for (Equipment equipment : equipmentList) { - Date lastDate = equipmentSpindleStatisticalService.getMaxDate(equipment.getEquipmentid()); - if (lastDate == null) { - Date minCollectTime = equipmentMachiningHistoryService.getMinDate(equipment.getEquipmentid()); - if (minCollectTime == null) { + if (!equipment.getDrivetype().equals("CurrentState")) { + String saveTableName = equipment.getSavetablename(); + Date lastDate = equipmentSpindleStatisticalService.getMaxDate(equipment.getEquipmentid()); + if (lastDate == null) { + Date minCollectTime = equipmentWorkLineService.getMinDate(saveTableName); + if (minCollectTime == null) { + continue; + } + initDate = DateUtils.removeTime(minCollectTime); + } else { + initDate = DateUtils.plusTime(lastDate, 1); + } + + spindleStatistical = new EquipmentSpindleStatistical(); + EquipmentMachiningHistoryDto machiningHistoryDto = equipmentWorkLineService.getMaxSpindleLoad(saveTableName, initDate, DateUtils.plusTime(initDate, 1)); + if(machiningHistoryDto == null || machiningHistoryDto.getEquipmentID() == null || machiningHistoryDto.getCollectTime() == null) { continue; } - initDate = DateUtils.removeTime(minCollectTime); + spindleStatistical.setCreatedate(initDate); + spindleStatistical.setSpindlespeed(machiningHistoryDto.getSpindleSpeed()); + spindleStatistical.setEquipmentid(equipment.getEquipmentid()); + spindleStatistical.setEquipmentname(equipment.getEquipmentname()); + spindleStatistical.setSpindleload(machiningHistoryDto.getSpindleLoad()); + spindleStatistical.setSpindletime(machiningHistoryDto.getCollectTime()); + MachineXYZHistoryDto machineXYZHistoryDto = equipmentXYZService.getNearAxisType(equipment.getEquipmentid(), initDate, DateUtils.plusTime(initDate, 1), machiningHistoryDto.getCollectTime()); + if(machineXYZHistoryDto != null) { + spindleStatistical.setAxistime(machineXYZHistoryDto.getCollectTime()); + spindleStatistical.setAxisx(machineXYZHistoryDto.getXMachine()); + spindleStatistical.setAxisy(machineXYZHistoryDto.getYMachine()); + spindleStatistical.setAxisz(machineXYZHistoryDto.getZMachine()); + spindleStatistical.setAxisa(machineXYZHistoryDto.getAMachine()); + spindleStatistical.setAxisb(machineXYZHistoryDto.getBMachine()); + } + resultList.add(spindleStatistical); } - - spindleStatistical = new EquipmentSpindleStatistical(); - EquipmentMachiningHistoryDto machiningHistoryDto = equipmentMachiningHistoryService.getMaxSpindleLoad(equipment.getEquipmentid(), initDate, DateUtils.plusTime(initDate, 1)); - if(machiningHistoryDto == null || machiningHistoryDto.getEquipmentID() == null || machiningHistoryDto.getCollectTime() == null) { - continue; - } - spindleStatistical.setCreatedate(initDate); - spindleStatistical.setSpindlespeed(machiningHistoryDto.getSpindleSpeed()); - spindleStatistical.setEquipmentid(equipment.getEquipmentid()); - spindleStatistical.setEquipmentname(equipment.getEquipmentname()); - spindleStatistical.setSpindleload(machiningHistoryDto.getSpindleLoad()); - spindleStatistical.setSpindletime(machiningHistoryDto.getCollectTime()); - MachineXYZHistoryDto machineXYZHistoryDto = machineXYZHistoryService.getNearAxisType(equipment.getEquipmentid(), initDate, DateUtils.plusTime(initDate, 1), machiningHistoryDto.getCollectTime()); - if(machineXYZHistoryDto != null) { - spindleStatistical.setAxistime(machineXYZHistoryDto.getCollectTime()); - spindleStatistical.setAxisx(machineXYZHistoryDto.getXMachine()); - spindleStatistical.setAxisy(machineXYZHistoryDto.getYMachine()); - spindleStatistical.setAxisz(machineXYZHistoryDto.getZMachine()); - spindleStatistical.setAxisa(machineXYZHistoryDto.getAMachine()); - spindleStatistical.setAxisb(machineXYZHistoryDto.getBMachine()); - } - resultList.add(spindleStatistical); } if (!resultList.isEmpty()) { equipmentSpindleStatisticalService.saveBatch(resultList); -- Gitblit v1.9.3