| | |
| | | package com.ruoyi.process.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.YearMonth; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | |
| | | template.write(os); |
| | | os.flush(); |
| | | os.close(); |
| | | inputStream.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("导出失败"); |
| | |
| | | |
| | | // 查询上一个月第一条的记录信息, 判断被监督人去另外一个 |
| | | if (detailsRecord == null) { |
| | | |
| | | // 查询详情信息 |
| | | QualitySuperviseDetails qualitySuperviseDetails = qualitySuperviseDetailsMapper.selectById(superviseDetailsId); |
| | | // 查询上一个月第一条的记录信息, 判断被监督人去另外一个 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.M"); |
| | | YearMonth yearMonth = YearMonth.parse(qualitySuperviseDetails.getSuperviseTime(), formatter); |
| | | YearMonth previousYearMonth = yearMonth.minusMonths(1); |
| | | |
| | | LocalDate startDate = previousYearMonth.atDay(1); |
| | | LocalDate endDate = previousYearMonth.atEndOfMonth(); |
| | | |
| | | LocalDateTime startDateTime = startDate.atStartOfDay(); |
| | | LocalDateTime endDateTime = endDate.atTime(23, 59, 59); |
| | | |
| | | DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | // 获取开始时间和结束时间 |
| | | String startDateTimeStr = startDateTime.format(outputFormatter); |
| | | String endDateTimeStr = endDateTime.format(outputFormatter); |
| | | |
| | | QualitySuperviseDetailsRecord laseRecord = qualitySuperviseDetailsRecordMapper.selectOne(Wrappers.<QualitySuperviseDetailsRecord>lambdaQuery() |
| | | .between(QualitySuperviseDetailsRecord::getCreateTime, startDateTimeStr, endDateTimeStr) |
| | | .isNotNull(QualitySuperviseDetailsRecord::getSupervisor) |
| | | .last("limit 1")); |
| | | |
| | | String supervisor = null; |
| | | |
| | | if (laseRecord != null) { |
| | | // 查询计划获取另一个监督员 |
| | | QualitySupervise qualitySupervise = baseMapper.selectById(qualitySuperviseDetails.getSuperviseId()); |
| | | if (StringUtils.isNotBlank(qualitySupervise.getRecordUserIds())) { |
| | | List<String> recordUserIds = StrUtil.split(qualitySupervise.getRecordUserIds(), ','); |
| | | List<User> users = userMapper.selectList(Wrappers.<User>lambdaQuery() |
| | | .in(User::getId, recordUserIds)); |
| | | if (CollectionUtils.isNotEmpty(users) && users.size() == 2) { |
| | | // 判断是否一样, 一样获取另外一个 |
| | | if (users.get(0).getName().equals(laseRecord.getSupervisor())) { |
| | | supervisor = users.get(1).getName(); |
| | | } else { |
| | | supervisor = users.get(0).getName(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | detailsRecord = new QualitySuperviseDetailsRecord(); |
| | | detailsRecord.setSuperviseDetailsId(superviseDetailsId); |
| | | detailsRecord.setTestMember(qualitySuperviseDetails.getSupervisee()); |
| | | detailsRecord.setSupervisor(null); |
| | | detailsRecord.setSupervisor(supervisor); |
| | | |
| | | detailsRecord.setPersonnel("()有相应检测员的上岗证"); |
| | | detailsRecord.setPersonnel(SecurityUtils.getLoginUser().getUser().getNickName() + "有相应检测员的上岗证"); |
| | | detailsRecord.setEnvironment("温度:()℃ 湿度:()%"); |
| | | detailsRecord.setInspectionRecord("检测人员()进行检测记录,记录内容真实有效"); |
| | | detailsRecord.setExaminingReport("由()黄秋实出示的检测报告符合规范要求"); |
| | | detailsRecord.setInspectionRecord("检测人员" + SecurityUtils.getLoginUser().getUser().getNickName() + "进行检测记录,记录内容真实有效"); |
| | | detailsRecord.setExaminingReport("由" + SecurityUtils.getLoginUser().getUser().getNickName() + "出示的检测报告符合规范要求"); |
| | | detailsRecord.setSupervisionEvaluation("检测按照要求进行,判定为满意"); |
| | | detailsRecord.setHandlingAdvice("/"); |
| | | |
| | |
| | | public void exportSuperviseDetailRecord(Integer superviseDetailsId, HttpServletResponse response) { |
| | | QualitySuperviseDetailsRecord recordDto = qualitySuperviseDetailsRecordMapper.selectSuperviseDetailRecord(superviseDetailsId); |
| | | |
| | | //获取技术负责人的签名地址 |
| | | String ratifyUrl = null; |
| | | if (recordDto.getRatifyUserId() != null) { |
| | | ratifyUrl = userMapper.selectById(recordDto.getRatifyUserId()).getSignatureUrl(); |
| | | if (StringUtils.isBlank(ratifyUrl)) { |
| | | throw new ErrorException("找不到技术负责人的签名"); |
| | | } |
| | | // 查询检测人员 |
| | | User tserUser = new User(); |
| | | if (StringUtils.isNotBlank(recordDto.getTestMember())) { |
| | | tserUser = userMapper.selectOne(Wrappers.<User>lambdaQuery() |
| | | .eq(User::getName, recordDto.getTestMember()) |
| | | .last("limit 1")); |
| | | } |
| | | |
| | | // 获取路径 |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/supervision-detail-record.docx"); |
| | | ConfigureBuilder builder = Configure.builder(); |
| | | builder.useSpringEL(true); |
| | | String finalRatifyUrl = ratifyUrl; |
| | | User finalTserUser = tserUser; |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream, builder.build()).render( |
| | | new HashMap<String, Object>() {{ |
| | | put("supervision", recordDto); |
| | | put("testMemberUrl", UserUtils.getFinalUserSignatureUrl(finalTserUser.getId())); |
| | | put("supervisoruUrl", UserUtils.getFinalUserSignatureUrl(recordDto.getSupervisor())); |
| | | put("technicalDirectorUrl", StringUtils.isNotBlank(finalRatifyUrl) ? Pictures.ofLocal(imgUrl + "/" + finalRatifyUrl).create() : null); |
| | | put("technicalDirectorUrl", UserUtils.getFinalUserSignatureUrl(recordDto.getRatifyUserId())); |
| | | put("technicalDirectorDateUrl", recordDto.getRatifyTime() != null ? |
| | | Pictures.ofStream(DateImageUtil.createDateImage(recordDto.getRatifyTime())).create() : null); |
| | | }}); |
| | |
| | | template.write(os); |
| | | os.flush(); |
| | | os.close(); |
| | | inputStream.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("导出失败"); |
| | |
| | | template.write(os); |
| | | os.flush(); |
| | | os.close(); |
| | | inputStream.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("导出失败"); |
| | |
| | | template.write(os); |
| | | os.flush(); |
| | | os.close(); |
| | | inputStream.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("导出失败"); |