zjh
2025-03-14 0f658843b92eb41a87cb113c9eb6416e25e76a2e
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjReservationController.java
@@ -95,6 +95,12 @@
    private ISysDictDataService dictDataService;
    @Autowired
    private ISysConfigService configService;
    @Autowired
    private IDictCompService dictCompService;
    @Autowired
    private ITjDwDeptService tjDwDeptService;
    @Autowired
    private ITjDwGroupingService tjDwGroupingService;
    @Value("${path.filePath}")
    private String value;
@@ -103,56 +109,61 @@
    @ApiOperation(value = "导出excel表模板")
    public void importTemplate(HttpServletResponse response) {
        //原来的下载模板调用接口
        String base64String = PDFBinaryUtil.getPDFBinary(configService.selectConfigByKey("default_excelTemplate"));
        if (null != base64String) {
            PDFBinaryUtil.base64StringToPDF(base64String, FileUtil.mkdir(value).getPath() + File.separator + "团体预约Excel模版.xls");
            String filePath = value + File.separator + "团体预约Excel模版.xls";
            File f = new File(filePath);
            BufferedInputStream br = null;
            OutputStream out = null;
            FileInputStream fileInputStream = null;
            try {
                fileInputStream = new FileInputStream(f);
                br = new BufferedInputStream(fileInputStream);
                byte[] bs = new byte[1024];
                int len = 0;
                response.reset(); // 非常重要
                if (true) {
                    // 在线打开方式
                    URL u = new URL("file:///" + filePath);
                    //System.out.println(u);
                    String contentType = u.openConnection().getContentType();
                    response.setContentType(contentType);
                    response.setHeader("Content-Disposition", "inline;filename=团体预约Excel模版.xls");
                } else {
                    // 纯下载方式
                    response.setContentType("application/x-msdownload");
                    response.setContentType("application/pdf;charset=utf-8");
                    response.setHeader("Content-Disposition", "attachment;filename=团体预约Excel模版.xls");
                }
                out = response.getOutputStream();
                while ((len = br.read(bs)) > 0) {
                    out.write(bs, 0, len);
                }
                out.flush();
                out.close();
                br.close();
                fileInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
                //System.out.println("pdf处理文件异常" + e);
            } finally {
                if (out != null) {
                    try {
                        out.close();
                        br.close();
                        fileInputStream.close();
        try {
            String base64String = PDFBinaryUtil.getPDFBinary(value + File.separator + "西安路泰机电科技有限公司.xls");
            if (null != base64String) {
                PDFBinaryUtil.base64StringToPDF(base64String, FileUtil.mkdir(value).getPath() + File.separator + "团体预约Excel模版.xls");
                String filePath = value + File.separator + "团体预约Excel模版.xls";
                File f = new File(filePath);
                BufferedInputStream br = null;
                OutputStream out = null;
                FileInputStream fileInputStream = null;
                try {
                    fileInputStream = new FileInputStream(f);
                    br = new BufferedInputStream(fileInputStream);
                    byte[] bs = new byte[1024];
                    int len = 0;
                    response.reset(); // 非常重要
                    if (true) {
                        // 在线打开方式
                        URL u = new URL("file:///" + filePath);
                        //System.out.println(u);
                        String contentType = u.openConnection().getContentType();
                        response.setContentType(contentType);
                        response.setHeader("Content-Disposition", "inline;filename=团体预约Excel模版.xls");
                    } else {
                        // 纯下载方式
                        response.setContentType("application/x-msdownload");
                        response.setContentType("application/pdf;charset=utf-8");
                        response.setHeader("Content-Disposition", "attachment;filename=团体预约Excel模版.xls");
                    }
                    out = response.getOutputStream();
                    while ((len = br.read(bs)) > 0) {
                        out.write(bs, 0, len);
                    }
                    out.flush();
                    out.close();
                    br.close();
                    fileInputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                    //System.out.println("pdf处理文件异常" + e);
                } finally {
                    if (out != null) {
                        try {
                            out.close();
                            br.close();
                            fileInputStream.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        } catch (Exception e) {
            ExcelUtils.exportTemplate(response,"团体预约Excel模版",TjReservation.class);
            throw new RuntimeException(e);
        }
    }
@@ -743,11 +754,11 @@
        LambdaQueryWrapper<TjGroupingPro> wq = new LambdaQueryWrapper<>();
        wq.eq(TjGroupingPro::getGroupingId, groupingId);
        List<TjGroupingPro> proList = groupingProService.list(wq);
        if (null != proList && proList.size() > 0) {
        if (null != proList && !proList.isEmpty()) {
            for (TjGroupingPro groupingPro : proList) {
                TjProject project = projectService.getById(groupingPro.getProId());
                if (null != project) {
                    if (project.getProType() == null || project.getProType().equals("")) {
                    if (project.getProType() == null || project.getProType().isEmpty()) {
                        groupingPro.setProType("2");
                    } else {
                        groupingPro.setProType(project.getProType());
@@ -947,7 +958,7 @@
                }
                reservation.setPacId(dwDept.getId());
                reservation.setPacId(dwGrouping.getId());
                compPay = compPay.add(dwGrouping.getYsPrice());
//                reservation.setTjType(String.valueOf(1));
                reservation.setTeamNo(teamNo);
@@ -1014,4 +1025,46 @@
        return AjaxResult.error("请选择预约对象");
    }
    /**
     * 团体预约体检信息 联动下拉框
     * @param pid
     * @param type
     * @return
     */
    @GetMapping("/linkage")
    public String linkage(@RequestParam("pid") String pid, @RequestParam("type") String type) {
        switch (type){
            case "1":
                List<DictComp> list = dictCompService.list();
                List<HashMap<String, Object>> collect = list.stream().map(i -> {
                    HashMap<String, Object> hashMap = new HashMap<>();
                    hashMap.put("value", i.getDrugManufacturerId());
                    hashMap.put("text", i.getCnName());
                    return hashMap;
                }).collect(Collectors.toList());
                return JSONUtil.toJsonStr(collect);
            case "2":
                List<TjDwDept> list1 = tjDwDeptService.getDwDeptListByTjDwDeptId(pid);
                List<HashMap<String, Object>> collect1 = list1.stream().map(i -> {
                    HashMap<String, Object> hashMap = new HashMap<>();
                    hashMap.put("value", i.getId());
                    hashMap.put("text", i.getDwDeptName());
                    return hashMap;
                }).collect(Collectors.toList());
                return JSONUtil.toJsonStr(collect1);
            case "3":
                LambdaQueryWrapper<TjDwGrouping> wrapper = new LambdaQueryWrapper<>();
                wrapper.eq(TjDwGrouping::getDwDeptId,pid);
                List<TjDwGrouping> list2 = tjDwGroupingService.list(wrapper);
                List<HashMap<String, Object>> collect2 = list2.stream().map(i -> {
                    HashMap<String, Object> hashMap = new HashMap<>();
                    hashMap.put("value", i.getId());
                    hashMap.put("text", i.getGroupingName());
                    return hashMap;
                }).collect(Collectors.toList());
                return JSONUtil.toJsonStr(collect2);
        }
        return null;
    }
}