| | |
| | | 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.MdcEquipment; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentRepair; |
| | | import org.jeecg.modules.mdc.entity.MdcNoplanClose; |
| | | import org.jeecg.modules.mdc.entity.MdcTorqueConfig; |
| | | import org.jeecg.modules.mdc.mapper.MdcNoplanCloseMapper; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.mdc.service.IMdcNoplanCloseService; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.mdc.vo.MdcNoplanCloseVo; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | List<MdcNoplanClose> mdcNoplanCloseList = new ArrayList<>(); |
| | | a: |
| | | for (String equipmentId : equipmentIds) { |
| | | Date startTime = DateUtils.getFormatDate(mdcNoplanCloseVo.getStartTime(), DateUtils.STR_DATE_TIME_SMALL); |
| | | Date endTime = DateUtils.getFormatDate(mdcNoplanCloseVo.getEndTime(), DateUtils.STR_DATE_TIME_SMALL); |
| | | Date startTime = DateUtils.getFormatDate(mdcNoplanCloseVo.getStartTime(), DateUtils.STR_DATE_TIME_MIN); |
| | | Date endTime = DateUtils.getFormatDate(mdcNoplanCloseVo.getEndTime(), DateUtils.STR_DATE_TIME_MIN); |
| | | MdcEquipment mdcEquipment = mdcEquipmentService.findEquipmentNameByEquipmentId(equipmentId); |
| | | LambdaQueryWrapper<MdcNoplanClose> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(MdcNoplanClose::getEquipmentId, equipmentId); |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 导出 |
| | | * |
| | | * @param userId |
| | | * @param mdcNoplanClose |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ModelAndView exportXls(String userId, MdcNoplanClose mdcNoplanClose) { |
| | | LambdaQueryWrapper<MdcNoplanClose> queryWrapper = new LambdaQueryWrapper<>(); |
| | | List<String> equipmentIds = new ArrayList<>(); |
| | | if (StringUtils.isNotEmpty(mdcNoplanClose.getParentId()) && StringUtils.isEmpty(mdcNoplanClose.getEquipmentId())) { |
| | | if ("2".equals(mdcNoplanClose.getTypeTree())) { |
| | | //部门层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, mdcNoplanClose.getParentId()); |
| | | } else { |
| | | //产线层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcNoplanClose.getParentId()); |
| | | } |
| | | } else if (StringUtils.isNotEmpty(mdcNoplanClose.getEquipmentId())) { |
| | | //单台设备信息 |
| | | mdcNoplanClose.setMdcSectionIds(Collections.singletonList(mdcNoplanClose.getEquipmentId())); |
| | | } else { |
| | | //查询用户所拥有的所有设备信息 |
| | | if ("2".equals(mdcNoplanClose.getTypeTree())) { |
| | | //部门层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null); |
| | | } else { |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null); |
| | | } |
| | | } |
| | | if (mdcNoplanClose.getMdcSectionIds() == null || mdcNoplanClose.getMdcSectionIds().isEmpty()) { |
| | | mdcNoplanClose.setMdcSectionIds(equipmentIds); |
| | | } |
| | | if (mdcNoplanClose.getMdcSectionIds() == null || mdcNoplanClose.getMdcSectionIds().isEmpty()) { |
| | | return null; |
| | | } else { |
| | | queryWrapper.in(MdcNoplanClose::getEquipmentId, mdcNoplanClose.getMdcSectionIds()); |
| | | } |
| | | if (StringUtils.isNotEmpty(mdcNoplanClose.getEquipmentId())) { |
| | | queryWrapper.like(MdcNoplanClose::getEquipmentId, mdcNoplanClose.getEquipmentId()); |
| | | } |
| | | if (StringUtils.isNotEmpty(mdcNoplanClose.getEquipmentName())) { |
| | | queryWrapper.like(MdcNoplanClose::getEquipmentName, mdcNoplanClose.getEquipmentName()); |
| | | } |
| | | if (mdcNoplanClose.getEndTime() != null) { |
| | | queryWrapper.le(MdcNoplanClose::getStartTime, mdcNoplanClose.getEndTime()); |
| | | } |
| | | if (mdcNoplanClose.getStartTime() != null) { |
| | | queryWrapper.ge(MdcNoplanClose::getEndTime, mdcNoplanClose.getStartTime()); |
| | | } |
| | | queryWrapper.orderByAsc(MdcNoplanClose::getStartTime); |
| | | // Step.2 AutoPoi 导出Excel |
| | | ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); |
| | | List<MdcNoplanClose> mdcNoplanCloses = this.baseMapper.selectList(queryWrapper); |
| | | // 导出文件名称 |
| | | mv.addObject(NormalExcelConstants.FILE_NAME, "非计划停机维护列表"); |
| | | mv.addObject(NormalExcelConstants.CLASS, MdcNoplanClose.class); |
| | | //获取当前登录用户 |
| | | //update-begin---author:wangshuai ---date:20211227 for:[JTC-116]导出人写死了------------ |
| | | 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, mdcNoplanCloses); |
| | | return mv; |
| | | } |
| | | } |