| | |
| | | |
| | | import java.io.*; |
| | | import java.net.URL; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Paths; |
| | | import java.text.NumberFormat; |
| | |
| | | import com.itextpdf.text.*; |
| | | import com.itextpdf.text.pdf.*; |
| | | import com.itextpdf.text.pdf.draw.LineSeparator; |
| | | import com.ltkj.common.annotation.Log; |
| | | import com.ltkj.common.core.domain.entity.SysDictData; |
| | | import com.ltkj.common.utils.DateUtils; |
| | | import com.ltkj.common.utils.PDFDocumentUtil; |
| | |
| | | import com.ltkj.framework.config.MatchUtils; |
| | | import com.ltkj.hosp.domain.*; |
| | | import com.ltkj.hosp.service.*; |
| | | import com.ltkj.hosp.vodomain.UpdateOrderRemarkVo; |
| | | import com.ltkj.mall.mallOrderUtils.TjConstants; |
| | | import com.ltkj.system.service.ISysConfigService; |
| | | import com.ltkj.system.service.ISysDictDataService; |
| | | import com.ltkj.system.service.ISysUserService; |
| | | import com.ltkj.web.config.pdfutils.MergePdf; |
| | | import com.ltkj.web.config.pdfutils.MyHeaderFooter; |
| | | import com.ltkj.web.config.pdfutils.PDFBinaryUtil; |
| | | import com.ltkj.web.config.pdfutils.PdfUtils; |
| | | import com.ltkj.web.controller.his.HisPDFUtil; |
| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | params.put("jsrq", jsrq); |
| | | params.put("pagecount", 100); |
| | | params.put("page", 1); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | LambdaQueryWrapper<TjCustomer> wq1 = new LambdaQueryWrapper<>(); |
| | | wq1.eq(TjCustomer::getCusId, tjOrder.getUserId()); |
| | | TjCustomer tjCustomer = tjCustomerService.getOne(wq1); |
| | | // return hisPDFUtil.execHisRequest(map, params, tjOrder, reportTemplate); |
| | | try { |
| | | return hisPDFUtil.hisPDF(tjOrder,tjCustomer,reportTemplate); |
| | | } catch (DocumentException e) { |
| | | logger.error("生成报告异常"); |
| | | AjaxResult ajaxResult = hisPDFUtil.hisPDF(tjOrder, tjCustomer, reportTemplate); |
| | | if (!ajaxResult.get("code").toString().equals("200")) { |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } else { |
| | | Long userId = tjCustomer.getCusId(); |
| | | String outputFileName1 = userId + tjNumber + tjCustomer.getCusName() + "_报告.pdf"; |
| | | TjReport tjReport = new TjReport(); |
| | | tjReport.setTjNumber(String.valueOf(tjNumber)); |
| | | tjReport.setPath(urlValue + outputFileName1); |
| | | String outputPath1 = value + "\\"; |
| | | String pdfBinary = getPDFBinary(outputPath1 + outputFileName1); |
| | | tjReport.setReport(pdfBinary); |
| | | tjReport.setType("体检报告"); |
| | | tjReport.setPrint("pdf"); |
| | | tjReportService.save(tjReport); |
| | | LambdaUpdateWrapper<TjOrder> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(TjOrder::getTjNumber, tjNumber); |
| | | updateWrapper.set(TjOrder::getReportTime, new Date()); |
| | | updateWrapper.set(TjOrder::getPrintLastTime, new Date()); |
| | | updateWrapper.set(TjOrder::getDownloadLastTime, new Date()); |
| | | updateWrapper.set(TjOrder::getStatus, TjConstants.TJ_END); |
| | | tjOrderService.update(updateWrapper); |
| | | } |
| | | return ajaxResult; |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | e.printStackTrace(); |
| | | return AjaxResult.error("生成报告异常"); |
| | | // 调用撤销 |
| | | // tjReportController.backOnlyCheckType(tjNumber); |
| | | logger.error("生成报告异常"); |
| | | return AjaxResult.error("生成报告失败"); |
| | | } |
| | | } else { |
| | | return AjaxResult.error("请先总检"); |
| | | } |
| | | } |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | @Autowired |
| | | private TjReportController tjReportController; |
| | | |
| | | /** |
| | | * 撤销 |
| | | * @param tjNumber |
| | | */ |
| | | @Transactional(propagation = Propagation.REQUIRES_NEW) |
| | | public void backOnlyCheckType(String tjNumber) { |
| | | QueryWrapper<TjOrder> wq2 = new QueryWrapper<>(); |
| | | wq2.eq("tj_number", tjNumber); |
| | | TjOrder one = tjOrderService.getOne(wq2); |
| | | one.setCheckStatus(0); |
| | | String config = configService.selectConfigByKey("tj_confirm"); |
| | | if ("Y".equals(config)) { |
| | | one.setStatus(TjConstants.TJ_CHECK); |
| | | } else { |
| | | one.setStatus(TjConstants.TJ_CONFIRM); |
| | | } |
| | | //将状态改为未审核 |
| | | tjOrderService.updateById(one); |
| | | } |
| | | |
| | | private AjaxResult newFun(String tjNumber) { |
| | |
| | | for (String key : data.keySet()) { |
| | | form.setField(key, data.get(key).toString()); |
| | | } |
| | | System.out.println("pdf填充表单数据耗时:"+(System.currentTimeMillis() - pdfMkStart)); |
| | | System.out.println("pdf填充表单数据耗时:" + (System.currentTimeMillis() - pdfMkStart)); |
| | | //设置为无法编辑 |
| | | ps.setFormFlattening(true); |
| | | ps.close(); |
| | |
| | | } |
| | | } |
| | | long fujianEnd = System.currentTimeMillis(); |
| | | System.out.println("附件查询耗时:"+(fujianEnd - fujianStart)); |
| | | System.out.println("文件保存前耗时:"+(fujianEnd - pdfMkStart)); |
| | | System.out.println("附件查询耗时:" + (fujianEnd - fujianStart)); |
| | | System.out.println("文件保存前耗时:" + (fujianEnd - pdfMkStart)); |
| | | // 保存pdf文件 |
| | | copy.close(); |
| | | String outputPath1 = value + "\\"; |
| | |
| | | }); |
| | | List<Long> proIds = tjOrderDetails.stream().map(TjOrderDetail::getProId).collect(Collectors.toList()); |
| | | LambdaQueryWrapper<TjProject> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.in(TjProject::getProId,proIds); |
| | | queryWrapper.in(TjProject::getProId, proIds); |
| | | List<TjProject> projectList = projectService.list(queryWrapper); |
| | | for (TjOrderDetail tjOrderDetail : tjOrderDetails) { |
| | | TjProject tjProject = projectList.stream().filter(item -> item.getProId().equals(tjOrderDetail.getProId())).collect(Collectors.toList()).get(0); |
| | |
| | | System.out.println("'''''''''''''''''''''''''''''''''''" + tjOrderDetail.getOrderDetailId()); |
| | | } |
| | | // 判断在collect中是否存在 |
| | | if (collect.contains(tjOrderDetail.getProject().getProParentId())){ |
| | | if (collect.contains(tjOrderDetail.getProject().getProParentId())) { |
| | | LambdaQueryWrapper<TjStandard> wq6 = new LambdaQueryWrapper<>(); |
| | | wq6.eq(TjStandard::getProId, tjOrderDetail.getProId()); |
| | | List<TjStandard> list2 = tjStandardService.list(wq6); |
| | |
| | | tjPdfVOS.add(tjPdfVO); |
| | | } |
| | | } |
| | | printReport.entrySet().stream().forEach(item->{ |
| | | printReport.entrySet().stream().forEach(item -> { |
| | | List<TjPdfVO> pdfVOS = hashMap.get(item.getKey().getProId()); |
| | | printReport.put(item.getKey(),pdfVOS); |
| | | printReport.put(item.getKey(), pdfVOS); |
| | | }); |
| | | } |
| | | |
| | |
| | | @PostMapping("/preview/batch") |
| | | @ApiOperation(value = "批量体检报告") |
| | | @Transactional |
| | | public AjaxResult preview(@RequestBody String data){ |
| | | public AjaxResult preview(@RequestBody String data) { |
| | | String is_batch_report_use_sql = configService.selectConfigByKey("is_batch_report_use_sql"); |
| | | List<String> tjNumbers = Arrays.stream(data.split(",")).collect(Collectors.toList()); |
| | | if ("true".equals(is_batch_report_use_sql)) { |
| | | return tjReportService.makeBatchReport(tjNumbers); |
| | | }else { |
| | | } else { |
| | | return makeReport(tjNumbers); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 通过sql 重整数据模板 全部重新生成 |
| | | * |
| | | * @param tjNumbers |
| | | * @return |
| | | */ |
| | | private AjaxResult makeReport(List<String > tjNumbers) { |
| | | private AjaxResult makeReport(List<String> tjNumbers) { |
| | | ArrayList<String> base64Pdfs = new ArrayList<>(); |
| | | for (String tjNumber : tjNumbers) { |
| | | LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>(); |
| | |
| | | // outputStream.flush(); |
| | | // outputStream.close(); |
| | | String s = Base64.getEncoder().encodeToString(mergePDFs); |
| | | return AjaxResult.success().put("file",s); |
| | | return AjaxResult.success().put("file", s); |
| | | } catch (DocumentException | IOException e) { |
| | | e.printStackTrace(); |
| | | return AjaxResult.error("批量生成失败"); |