| | |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Paths; |
| | | import java.text.NumberFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | |
| | | 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.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | |
| | | |
| | | @Autowired |
| | | private ITjBigPositiveService tjBigPositiveService; |
| | | @Autowired |
| | | private HisPDFUtil hisPDFUtil; |
| | | |
| | | @GetMapping("/savePdf") |
| | | @ApiOperation(value = "从本地存储模板到数据库") |
| | |
| | | // remarkVo.setProId("1633660948860522555"); |
| | | // updateOrderRemarkVos.add(remarkVo); |
| | | // tjCheckController.checkUpdateOrderRemark(updateOrderRemarkVos); |
| | | System.out.println("---------------------------------------newFun开始--------------------------------------------------"); |
| | | error = newFun(tjNumber); |
| | | System.out.println("-------------------------------------------结束----------------------------------------------"); |
| | | // System.out.println("---------------------------------------newFun开始--------------------------------------------------"); |
| | | // 以前测试pdf方法 |
| | | // error = newFun(tjNumber); |
| | | // System.out.println("-------------------------------------------结束----------------------------------------------"); |
| | | // 撤销 |
| | | // revocationReport(tjNumber); |
| | | if (error != null) { |
| | | return error; |
| | | // if (error != null) { |
| | | // return error; |
| | | // } |
| | | // return AjaxResult.success("该用户体检未完成,不能打印报告!!!"); |
| | | int num = tjOrderRemarkService.getTjYqOrderRemarkByTjNum(tjNumber); |
| | | if (num > 0) { |
| | | return AjaxResult.error("有延期项目暂不能生成报告!!!"); |
| | | } |
| | | return AjaxResult.success("该用户体检未完成,不能打印报告!!!"); |
| | | //判断表中有没有该体检报告 不能重复生成 |
| | | LambdaQueryWrapper<TjReport> wqa = new LambdaQueryWrapper<>(); |
| | | wqa.eq(TjReport::getTjNumber, tjNumber); |
| | | wqa.eq(TjReport::getType, "体检报告"); |
| | | Integer count = tjReportService.getSelectCount(wqa); |
| | | if (count != 0) { |
| | | return AjaxResult.error("该客户报告已生成!不能重复生成!可直接预览或打印!"); |
| | | } |
| | | String configByKey = configService.selectConfigByKey("sfkqdyhis"); |
| | | if (configByKey.equals("Y")) { |
| | | LambdaQueryWrapper<TjOrder> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(TjOrder::getTjNumber, tjNumber); |
| | | TjOrder tjOrder = tjOrderService.getOne(queryWrapper); |
| | | if (null != tjOrder) { |
| | | LambdaQueryWrapper<TjReportTemplate> tjReportTemplateLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | TjReportTemplate reportTemplate = null; |
| | | if (tjOrder.getTjCategory() != null) { |
| | | //查询字典 |
| | | LambdaQueryWrapper<SysDictData> wqq = new LambdaQueryWrapper<>(); |
| | | wqq.eq(SysDictData::getDictType, "dict_tjtype"); |
| | | wqq.eq(SysDictData::getDictValue, tjOrder.getTjCategory()); |
| | | SysDictData one = dictDataService.getOne(wqq); |
| | | if (one != null) { |
| | | //查询字典 |
| | | LambdaQueryWrapper<SysDictData> wqq1 = new LambdaQueryWrapper<>(); |
| | | wqq1.eq(SysDictData::getDictType, "report_template_type"); |
| | | wqq1.eq(SysDictData::getDictLabel, one.getDictLabel()); |
| | | SysDictData one1 = dictDataService.getOne(wqq1); |
| | | if (one1 != null) { |
| | | tjReportTemplateLambdaQueryWrapper.eq(TjReportTemplate::getFlag, one1.getDictValue()); |
| | | } else { |
| | | tjReportTemplateLambdaQueryWrapper.eq(TjReportTemplate::getFlag, 1); |
| | | } |
| | | } else { |
| | | tjReportTemplateLambdaQueryWrapper.eq(TjReportTemplate::getFlag, 1); |
| | | } |
| | | tjReportTemplateLambdaQueryWrapper.eq(TjReportTemplate::getOpen, 0); |
| | | reportTemplate = reportTemplateService.getOne(tjReportTemplateLambdaQueryWrapper); |
| | | } else { |
| | | tjReportTemplateLambdaQueryWrapper.eq(TjReportTemplate::getOpen, 0); |
| | | reportTemplate = reportTemplateService.list(tjReportTemplateLambdaQueryWrapper).get(2); |
| | | } |
| | | Integer checkStatus = tjOrder.getCheckStatus(); |
| | | if (checkStatus == 1) { |
| | | String hisRegistrationId = tjOrder.getCardId(); |
| | | Date createTime = tjOrder.getCreateTime(); |
| | | Date finishTime = tjOrder.getFinishTime(); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String ksrq = dateFormat.format(createTime); |
| | | String jsrq = dateFormat.format(finishTime); |
| | | HashMap<String, Object> params = new HashMap<>(); |
| | | params.put("his_registration_id", hisRegistrationId); |
| | | params.put("ksbm", ""); |
| | | params.put("pationid", ""); |
| | | params.put("ksrq", ksrq); |
| | | 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("生成报告异常"); |
| | | e.printStackTrace(); |
| | | return AjaxResult.error("生成报告异常"); |
| | | } |
| | | } else { |
| | | return AjaxResult.error("请先总检"); |
| | | } |
| | | } |
| | | } |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | private AjaxResult newFun(String tjNumber) { |
| | |
| | | e.printStackTrace(); |
| | | return AjaxResult.success("PDF导出失败"); |
| | | } finally { |
| | | transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(), tjOrder.getCardId()); |
| | | // transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(), tjOrder.getCardId()); |
| | | } |
| | | } |
| | | } |