| | |
| | | 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; |
| | |
| | | @Resource |
| | | private IMachineXYZHistoryService machineXYZHistoryService; |
| | | |
| | | @Resource |
| | | private IEquipmentWorkLineService equipmentWorkLineService; |
| | | |
| | | @Resource |
| | | private IEquipmentXYZService equipmentXYZService; |
| | | |
| | | @Override |
| | | public void execute(JobExecutionContext context) throws JobExecutionException { |
| | | SysQuartzLog quartzLog = new SysQuartzLog(); |
| | |
| | | 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); |