| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.system.vo.DictModel; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | 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.vo.MdcAlarmAnalyzeQueryVo; |
| | | import org.jeecg.modules.mdc.vo.MdcEquipmentRunningSectionVo; |
| | | import org.jeecg.modules.system.service.ISysDictService; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | |
| | | if (!running.isEmpty()) { |
| | | MdcEquipmentRunningSectionDto dto; |
| | | String tableName = ""; |
| | | Boolean isTableExist = false; |
| | | String backupTableName = ""; |
| | | if (equip != null) { |
| | | if (StringUtils.isNotBlank(equip.getDrivetype())) { |
| | | tableName = equip.getDrivetype() + "_" + equip.getEquipmentid(); |
| | | isTableExist = equipmentWorkLineService.isTableExist(tableName); |
| | | backupTableName = equipmentService.checkTableExists(tableName); |
| | | } |
| | | } |
| | | for (MdcEquipmentRunningSection entity : running) { |
| | | dto = new MdcEquipmentRunningSectionDto(); |
| | | BeanUtils.copyProperties(entity, dto); |
| | | if (entity.getStatus() == 3 && StringUtils.isBlank(entity.getSequenceNumber()) && isTableExist && !"ZUOLAN".equals(equip.getDrivetype())) { |
| | | if (entity.getStatus() == 3 && StringUtils.isBlank(entity.getSequenceNumber()) && StringUtils.isNotBlank(backupTableName) && !"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()); |
| | |
| | | } |
| | | } |
| | | } |
| | | // Set<TmpEquipmentAlarm> set = entity.getTmpEquipmentAlarmSet(); |
| | | // if (entity.getStatus() == 22 && set != null && !set.isEmpty()) { |
| | | // Iterator<TmpEquipmentAlarm> iterator = entity.getTmpEquipmentAlarmSet().iterator(); |
| | | // //获取报警编号相同的报警信息 |
| | | // while (iterator.hasNext()) { |
| | | // TmpEquipmentAlarm next = iterator.next(); |
| | | // if (StringUtils.isNotBlank(next.getAlarmNo()) && next.getAlarmNo().equals(entity.getStatus())) { |
| | | // dto.setAlarmContent(next.getAlarmContent()); |
| | | // } |
| | | // } |
| | | // } |
| | | dtos.add(dto); |
| | | } |
| | | } |
| | |
| | | if (!a.getStatus().equals(b.getStatus()) && a.getEndTime().equals(b.getStartTime())) { |
| | | result.add(dtos.get(dtos.size() - 1)); |
| | | } |
| | | } else if (dtos.size() == 1){ |
| | | } else if (dtos.size() == 1) { |
| | | result.addAll(dtos); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 数据同步处理 |
| | | * |
| | | * @param list |
| | | * @param errorList |
| | | */ |
| | |
| | | return this.baseMapper.getDataList(equipmentId, date); |
| | | } |
| | | |
| | | /** |
| | | * 导出 |
| | | */ |
| | | @Override |
| | | public ModelAndView exportXls(MdcEquipmentRunningSectionVo equipmentRunningSectionVo) { |
| | | ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); |
| | | List<MdcEquipmentRunningSectionDto> mdcEquipmentRunningSectionDtos = this.logList(equipmentRunningSectionVo); |
| | | // 导出文件名称 |
| | | mv.addObject(NormalExcelConstants.FILE_NAME, "设备日志"); |
| | | mv.addObject(NormalExcelConstants.CLASS, MdcEquipmentRunningSectionDto.class); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("设备日志列表数据", "导出人:" + user.getRealname(), "设备日志")); |
| | | mv.addObject(NormalExcelConstants.DATA_LIST, mdcEquipmentRunningSectionDtos); |
| | | return mv; |
| | | } |
| | | |
| | | @Override |
| | | public ModelAndView batchExportXls(MdcEquipmentRunningSectionVo equipmentRunningSectionVo) { |
| | | ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); |
| | | List<MdcEquipmentRunningSectionDto> mdcEquipmentRunningSectionDtos = new ArrayList<>(); |
| | | if (StringUtils.isNotBlank(equipmentRunningSectionVo.getStartTime()) && StringUtils.isNotBlank(equipmentRunningSectionVo.getEndTime()) ) { |
| | | Date startDate = DateUtils.toDate(equipmentRunningSectionVo.getStartTime(), DateUtils.STR_DATE); |
| | | Date endDate = DateUtils.toDate(equipmentRunningSectionVo.getEndTime(), DateUtils.STR_DATE); |
| | | List<String> datesStringList = DateUtils.getDatesStringList(startDate, endDate); |
| | | datesStringList.forEach(date -> { |
| | | equipmentRunningSectionVo.setCollectTimeStr(date); |
| | | List<MdcEquipmentRunningSectionDto> equipmentRunningSectionDtos = this.logList(equipmentRunningSectionVo); |
| | | if (equipmentRunningSectionDtos != null && !equipmentRunningSectionDtos.isEmpty()) { |
| | | mdcEquipmentRunningSectionDtos.addAll(equipmentRunningSectionDtos); |
| | | } |
| | | }); |
| | | } |
| | | // 导出文件名称 |
| | | mv.addObject(NormalExcelConstants.FILE_NAME, "设备日志"); |
| | | mv.addObject(NormalExcelConstants.CLASS, MdcEquipmentRunningSectionDto.class); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("设备日志列表数据", "导出人:" + user.getRealname(), "设备日志")); |
| | | mv.addObject(NormalExcelConstants.DATA_LIST, mdcEquipmentRunningSectionDtos); |
| | | return mv; |
| | | } |
| | | |
| | | private Map<String, List<MdcEquipmentRunningSectionDto>> logCharts(MdcEquipmentRunningSectionVo equipmentRunningSectionVo, String date) { |
| | | Map<String, List<MdcEquipmentRunningSectionDto>> map = new HashMap<>(); |
| | | List<MdcEquipmentRunningSectionDto> normal = new ArrayList<>(); |