| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.common.system.vo.DictModel; |
| | | import org.jeecg.modules.mdc.dto.EquipmentMachingDto; |
| | | import org.jeecg.modules.mdc.dto.MdcAlarmListDto; |
| | | import org.jeecg.modules.mdc.dto.MdcEquipmentRunningSectionDto; |
| | | import org.jeecg.modules.mdc.entity.*; |
| | | import org.jeecg.modules.mdc.mapper.MdcEquipmentRunningSectionMapper; |
| | | import org.jeecg.modules.mdc.service.*; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.mdc.util.TimeFieldUtils; |
| | | import org.jeecg.modules.mdc.vo.MdcAlarmAnalyzeQueryVo; |
| | | import org.jeecg.modules.mdc.vo.MdcEquipmentRunningSectionVo; |
| | | import org.jeecg.modules.system.service.ISysDictService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | @Resource |
| | | private IEquipmentWorkLineService equipmentWorkLineService; |
| | | |
| | | @Resource |
| | | private ISysDictService sysDictService; |
| | | |
| | | @Resource |
| | | private IEquipmentRunningTraceService equipmentRunningTraceService; |
| | | |
| | | @Override |
| | | public List<MdcEquipmentRunningSectionDto> logList(MdcEquipmentRunningSectionVo equipmentRunningSectionVo) { |
| | | |
| | |
| | | for (MdcEquipmentRunningSection entity : running) { |
| | | dto = new MdcEquipmentRunningSectionDto(); |
| | | BeanUtils.copyProperties(entity, dto); |
| | | if (entity.getStatus() == 3 && StringUtils.isBlank(entity.getSequenceNumber()) && isTableExist) { |
| | | if (entity.getStatus() == 3 && StringUtils.isBlank(entity.getSequenceNumber()) && isTableExist && !"ZUOLAN".equals(equip.getDrivetype())) { |
| | | List<EquipmentMachingDto> esList = equipmentWorkLineService.getEquipmentSequencenumber(tableName, entity.getStartTime(), entity.getEndTime()); |
| | | if (esList != null && esList.size() > 1) { |
| | | dto.setSequenceNumber(esList.get(0).getSequencenumber()); |
| | |
| | | * 设备运行状态点时间转为段时间 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void runningAllEquipmentTraceProcess() { |
| | | //获取所有设备 |
| | | List<Equipment> equipmentList = equipmentService.list(); |
| | |
| | | //获取running运行的日志记录 |
| | | List<MdcEquipmentRunningSection> list = this.equipmentRunningTracesLog(equipment.getEquipmentid()); |
| | | if (list != null && !list.isEmpty()) { |
| | | //List<MdcEquipmentRunningSection> equipList = addSequenceNumber(list); //添加程序号 |
| | | this.ergodicTrim(list); |
| | | super.saveBatch(list); |
| | | List<MdcEquipmentRunningSection> equipList = addSequenceNumber(list); //添加程序号 |
| | | this.ergodicTrim(equipList); |
| | | super.saveBatch(equipList); |
| | | } |
| | | //获取报警的日志记录 |
| | | List<MdcEquipmentRunningSection> errorList = this.equipmentRunningTracesErrorLog(equipment.getEquipmentid()); |
| | |
| | | //save errorList |
| | | super.saveBatch(errorList); |
| | | } |
| | | List<DictModel> dictList = sysDictService.queryDictItemsByCode("data_synchronization_flag"); |
| | | if (dictList != null && !dictList.isEmpty() && "0".equals(dictList.get(0).getValue())) { |
| | | this.dataSynchronizationHandler(list, errorList); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设备运行日志添加程序号 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public List<MdcEquipmentRunningSection> addSequenceNumber(List<MdcEquipmentRunningSection> list) { |
| | | if (list == null || list.size() < 1) { |
| | | return Collections.emptyList(); |
| | | } |
| | | Equipment equip = null; |
| | | for (MdcEquipmentRunningSection e : list) { |
| | | if (e.getStatus() == 3) { |
| | | equip = equipmentService.getOne(new LambdaQueryWrapper<Equipment>().eq(Equipment::getEquipmentid, e.getEquipmentId())); |
| | | if (StringUtils.isNotBlank(equip.getDrivetype()) && equip.getDrivetype().startsWith("FANUC")) { |
| | | List<EquipmentMachingDto> esList = equipmentWorkLineService.getEquipProgramNum(equip.getDrivetype(), equip.getEquipmentid(), |
| | | e.getStartTime(), e.getEndTime()); |
| | | if (esList != null && esList.size() > 1) { |
| | | e.setSequenceNumber(esList.get(0).getProgramnumber()); |
| | | } |
| | | } else if (StringUtils.isNotBlank(equip.getDrivetype()) && equip.getDrivetype().startsWith("SIEMENS")) { |
| | | List<EquipmentMachingDto> esList = equipmentWorkLineService.getEquipmentSequencenumber(equip.getDrivetype() + "_" + equip.getEquipmentid(), e.getStartTime(), e.getEndTime()); |
| | | if (esList != null && esList.size() > 1) { |
| | | e.setSequenceNumber(esList.get(0).getSequencenumber()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 数据同步处理 |
| | | * @param list |
| | | * @param errorList |
| | | */ |
| | | private void dataSynchronizationHandler(List<MdcEquipmentRunningSection> list, List<MdcEquipmentRunningSection> errorList) { |
| | | // 数据转换 |
| | | List<EquipmentRunningTrace> equipList = new ArrayList<>(); |
| | | if (list != null && !list.isEmpty()) { |
| | | list.forEach(item -> { |
| | | EquipmentRunningTrace equipmentRunningSection = new EquipmentRunningTrace(); |
| | | equipmentRunningSection.setEquipment(item.getEquipmentId()); |
| | | equipmentRunningSection.setAlarm(item.getAlarm()); |
| | | equipmentRunningSection.setCreateTime(item.getCreateTime()); |
| | | equipmentRunningSection.setDuration(item.getDuration()); |
| | | equipmentRunningSection.setEndTime(item.getEndTime()); |
| | | equipmentRunningSection.setStartTime(item.getStartTime()); |
| | | equipmentRunningSection.setStatus(item.getStatus()); |
| | | equipmentRunningSection.setSequencenumber(item.getSequenceNumber()); |
| | | equipList.add(equipmentRunningSection); |
| | | }); |
| | | } |
| | | if (errorList != null && !errorList.isEmpty()) { |
| | | errorList.forEach(item -> { |
| | | EquipmentRunningTrace equipmentRunningSection = new EquipmentRunningTrace(); |
| | | equipmentRunningSection.setEquipment(item.getEquipmentId()); |
| | | equipmentRunningSection.setAlarm(item.getAlarm()); |
| | | equipmentRunningSection.setCreateTime(item.getCreateTime()); |
| | | equipmentRunningSection.setDuration(item.getDuration()); |
| | | equipmentRunningSection.setEndTime(item.getEndTime()); |
| | | equipmentRunningSection.setStartTime(item.getStartTime()); |
| | | equipmentRunningSection.setStatus(item.getStatus()); |
| | | equipmentRunningSection.setSequencenumber(item.getSequenceNumber()); |
| | | equipList.add(equipmentRunningSection); |
| | | }); |
| | | } |
| | | equipmentRunningTraceService.saveBatch(equipList); |
| | | } |
| | | |
| | | /** |
| | |
| | | //整合加工和待机时间小于n秒的数据 |
| | | erts = mergeLessMinTimeRecords(erts, null); |
| | | List<MdcEquipmentRunningSection> running = mergeRunningTrace(erts); |
| | | if (running != null || !running.isEmpty()) { |
| | | if (running != null && !running.isEmpty()) { |
| | | this.ergodicTrim(running); |
| | | } |
| | | return running; |
| | |
| | | return this.baseMapper.listEquipmentRunningSectionError(equipmentid, start, end); |
| | | } |
| | | |
| | | @Override |
| | | public List<MdcEquipmentRunningSection> findAlarmList(MdcAlarmAnalyzeQueryVo vo) { |
| | | return this.baseMapper.findAlarmList(vo); |
| | | } |
| | | |
| | | @Override |
| | | public Integer findAlarmCount(String equipmentId, String startDate, String endDate, String alarmCode) { |
| | | return this.baseMapper.findAlarmCount(equipmentId, startDate, endDate, alarmCode); |
| | | } |
| | | |
| | | @Override |
| | | public Integer findAlarmCountByDate(String startDate, String endDate, MdcAlarmAnalyzeQueryVo vo) { |
| | | return this.baseMapper.findAlarmCountByDate(startDate, endDate, vo); |
| | | } |
| | | |
| | | @Override |
| | | public List<MdcEquipmentRunningSection> selectRunningData(String equipmentId, Date startDate, Date endDate) { |
| | | return this.baseMapper.selectRunningData(equipmentId, startDate, endDate); |
| | | } |
| | | |
| | | @Override |
| | | public List<MdcAlarmListDto> selectAlarmList(MdcAlarmAnalyzeQueryVo mdcAlarmAnalyzeQueryVo, String startDate, String endDate) { |
| | | return this.baseMapper.selectAlarmList(mdcAlarmAnalyzeQueryVo, startDate, endDate); |
| | | } |
| | | |
| | | @Override |
| | | public List<Integer> getDataList(String equipmentId, Date date) { |
| | | return this.baseMapper.getDataList(equipmentId, date); |
| | | } |
| | | |
| | | private Map<String, List<MdcEquipmentRunningSectionDto>> logCharts(MdcEquipmentRunningSectionVo equipmentRunningSectionVo, String date) { |
| | | Map<String, List<MdcEquipmentRunningSectionDto>> map = new HashMap<>(); |
| | | List<MdcEquipmentRunningSectionDto> normal = new ArrayList<>(); |