| | |
| | | package org.jeecg.modules.mdc.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.mdc.entity.MdcDownTime; |
| | | import org.jeecg.modules.mdc.entity.MdcRepairInfo; |
| | | import org.jeecg.modules.mdc.mapper.MdcRepairInfoMapper; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.mdc.service.IMdcRepairInfoService; |
| | | import org.jeecg.modules.mdc.vo.MdcRepairInfoVo; |
| | | 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.web.servlet.ModelAndView; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | this.saveBatch(repairInfoList); |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 导出 |
| | | * |
| | | * @param userId |
| | | * @param mdcRepairInfoVo |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ModelAndView exportXls(String userId, MdcRepairInfoVo mdcRepairInfoVo) { |
| | | LambdaQueryWrapper<MdcRepairInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | | List<String> equipmentIds = new ArrayList<>(); |
| | | if (StringUtils.isNotEmpty(mdcRepairInfoVo.getParentId()) && StringUtils.isEmpty(mdcRepairInfoVo.getEquipmentId())) { |
| | | if ("2".equals(mdcRepairInfoVo.getTypeTree())) { |
| | | //部门层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, mdcRepairInfoVo.getParentId()); |
| | | } else { |
| | | //产线层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcRepairInfoVo.getParentId()); |
| | | } |
| | | } else if (StringUtils.isNotEmpty(mdcRepairInfoVo.getEquipmentId())) { |
| | | //单台设备信息 |
| | | mdcRepairInfoVo.setEquipmentIdList(Collections.singletonList(mdcRepairInfoVo.getEquipmentId())); |
| | | } else { |
| | | //查询用户拥有的所有设备信息 |
| | | if ("2".equals(mdcRepairInfoVo.getTypeTree())) { |
| | | //部门层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null); |
| | | } else { |
| | | //产线层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null); |
| | | } |
| | | } |
| | | |
| | | if (mdcRepairInfoVo.getEquipmentIdList() == null || mdcRepairInfoVo.getEquipmentIdList().isEmpty()) { |
| | | mdcRepairInfoVo.setEquipmentIdList(equipmentIds); |
| | | } |
| | | |
| | | if (mdcRepairInfoVo.getEquipmentIdList() == null || mdcRepairInfoVo.getEquipmentIdList().isEmpty()) { |
| | | return null; |
| | | } else { |
| | | queryWrapper.in(MdcRepairInfo::getEquipmentId, mdcRepairInfoVo.getEquipmentIdList()); |
| | | } |
| | | if (StringUtils.isNotEmpty(mdcRepairInfoVo.getEquipmentId())) { |
| | | queryWrapper.eq(MdcRepairInfo::getEquipmentId, mdcRepairInfoVo.getEquipmentId()); |
| | | } |
| | | if (StringUtils.isNotEmpty(mdcRepairInfoVo.getStartTime()) && StringUtils.isNotEmpty(mdcRepairInfoVo.getEndTime())) { |
| | | queryWrapper.between(MdcRepairInfo::getTheDate, mdcRepairInfoVo.getStartTime(), mdcRepairInfoVo.getEndTime()); |
| | | } |
| | | queryWrapper.orderByDesc(MdcRepairInfo::getTheDate).orderByDesc(MdcRepairInfo::getEquipmentId); |
| | | ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); |
| | | List<MdcRepairInfo> repairInfos = this.baseMapper.selectList(queryWrapper); |
| | | // 导出文件名称 |
| | | mv.addObject(NormalExcelConstants.FILE_NAME, "设备维修时长列表"); |
| | | mv.addObject(NormalExcelConstants.CLASS, MdcRepairInfo.class); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("设备维修时长表数据", "导出人:" + user.getRealname(), "设备维修时长数据")); |
| | | //update-end---author:wangshuai ---date:20211227 for:[JTC-116]导出人写死了------------ |
| | | mv.addObject(NormalExcelConstants.DATA_LIST, repairInfos); |
| | | return mv; |
| | | } |
| | | } |