diff --git a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/monitor/CacheController.java b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/monitor/CacheController.java index 83c77701..027cbe47 100644 --- a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/monitor/CacheController.java +++ b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/monitor/CacheController.java @@ -95,6 +95,7 @@ public class CacheController @DeleteMapping("/clearCacheName/{cacheName}") public AjaxResult clearCacheName(@PathVariable String cacheName) { + caches.remove(cacheName); Collection cacheKeys = redisTemplate.keys(cacheName + "*"); redisTemplate.delete(cacheKeys); return AjaxResult.success(); @@ -119,9 +120,9 @@ public class CacheController @PreAuthorize("@ss.hasPermi('monitor:cache:list')") @GetMapping("/add") - public AjaxResult add(@RequestParam("key") String key, @RequestParam("value") String value) + public AjaxResult add(@RequestParam("cacheName") String cacheName, @RequestParam("remark") String remark) { - redisTemplate.opsForValue().set(key, value); - return AjaxResult.success(); + caches.add(new SysCache(cacheName, remark)); + return AjaxResult.success(caches); } } diff --git a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/AdminPmsTreatmentController.java b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/AdminPmsTreatmentController.java index 2f976d16..ca7a3c34 100644 --- a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/AdminPmsTreatmentController.java +++ b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/AdminPmsTreatmentController.java @@ -4,6 +4,7 @@ import com.acupuncture.common.annotation.DataSource; import com.acupuncture.common.core.domain.BaseDto; import com.acupuncture.common.core.domain.JsonResponse; import com.acupuncture.common.enums.DataSourceType; +import com.acupuncture.common.utils.SecurityUtils; import com.acupuncture.framework.datasource.DynamicDataSourceContextHolder; import com.acupuncture.system.domain.dto.PmsTreatmentDto; import com.acupuncture.system.domain.po.DmsTenant; @@ -12,6 +13,7 @@ import com.acupuncture.system.domain.vo.PmsTreatmentVo; import com.acupuncture.system.domain.vo.UmsDataSourceVo; import com.acupuncture.system.persist.mapper.DmsTenantMapper; import com.acupuncture.system.persist.mapper.UmsDataSourceMapper; +import com.acupuncture.system.service.DmsLoginService; import com.acupuncture.system.service.PmsTreatmentService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -43,6 +45,8 @@ public class AdminPmsTreatmentController { @Resource private PmsTreatmentService treatmentService; + @Resource + private DmsLoginService dmsLoginService; @ApiOperation("查询诊疗档案") @PostMapping("/list") @@ -68,6 +72,21 @@ public class AdminPmsTreatmentController { treatmentService.adminExportTreatment(response, dto); } + @DataSource(DataSourceType.MASTER) + @ApiOperation("导入诊疗档案数据") + @PostMapping("/importTreatment") + public JsonResponse importTreatment(MultipartFile file) throws IOException { + //切换数据源 + String[] strs = treatmentService.getTenantId(file); + DynamicDataSourceContextHolder.setDataSourceType(strs[0]); + + treatmentService.importTreatmentAdmin(file, Long.parseLong(strs[1])); + + //销毁数据源 + DynamicDataSourceContextHolder.clearDataSourceType(); + return JsonResponse.ok(); + } + // @ApiOperation("修改诊疗档案") // @PostMapping("/upd") // public JsonResponse updateTreatment(@RequestBody @Validated PmsTreatmentDto.TreatmentUpdateDTO dto) { @@ -82,9 +101,33 @@ public class AdminPmsTreatmentController { // return JsonResponse.ok(treatmentService.exportTreatmentPg(response, dto)); // } + @DataSource(DataSourceType.MASTER) @ApiOperation("后台导出诊疗档案评估报告") @PostMapping("/exportTreatmentPg") public JsonResponse adminExportTreatmentPg(HttpServletResponse response, @RequestBody @Validated PmsTreatmentDto.ExportVO dto){ return JsonResponse.ok(treatmentService.adminExportTreatmentPg(response, dto)); } + + @DataSource(DataSourceType.MASTER) + @ApiOperation("后台导出诊疗档案评估报告zip") + @PostMapping("/adminExportTreatmentPgZip") + public JsonResponse adminExportTreatmentPgZip(HttpServletResponse response, @RequestBody @Validated PmsTreatmentDto.ExportZipVO dto) throws IOException{ + return JsonResponse.ok(treatmentService.adminExportTreatmentPgZip(response, dto)); + } + + @ApiOperation("审核") + @PostMapping("/aduit") + public JsonResponse aduit( @RequestBody @Validated PmsTreatmentDto.Aduit dto){ + try { + + UmsDataSource dataSourceByTenantId = dmsLoginService.getDataSourceByTenantId(dto.getTenantId()); + if (dataSourceByTenantId != null) { + DynamicDataSourceContextHolder.setDataSourceType(dataSourceByTenantId.getDataSourceKey()); + } + treatmentService.aduit(dto.getTreatmentId(), dto.getStatus()); + return JsonResponse.ok(); + }finally { + DynamicDataSourceContextHolder.clearDataSourceType(); + } + } } diff --git a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/AdminReportController.java b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/AdminReportController.java index c78ba2de..a4759126 100644 --- a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/AdminReportController.java +++ b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/AdminReportController.java @@ -1,10 +1,15 @@ package com.acupuncture.web.controller.web; +import com.acupuncture.common.annotation.DataScope; +import com.acupuncture.common.annotation.DataSource; import com.acupuncture.common.core.domain.BaseDto; import com.acupuncture.common.core.domain.JsonResponse; +import com.acupuncture.common.enums.DataSourceType; import com.acupuncture.system.domain.dto.AdminReportDto; import com.acupuncture.system.domain.vo.AdminReportVo; import com.acupuncture.system.service.AdminReportService; +import com.acupuncture.system.service.RmsReportService; +import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -32,51 +37,66 @@ public class AdminReportController { @Resource private AdminReportService reportService; + + @DataSource(DataSourceType.MASTER) @ApiOperation("查询上报类型") @PostMapping("/list") - public JsonResponse> queryTypeList(@RequestBody @Validated BaseDto dto){ + public JsonResponse> queryTypeList(@RequestBody @Validated BaseDto dto) { + if (dto.getPageNum() > 0) { + PageHelper.startPage(dto.getPageNum(), dto.getPageSize()); + } return JsonResponse.ok(new PageInfo<>(reportService.queryTypeList(dto.getParam().getName()))); } @ApiOperation("新增上报类型") @PostMapping("/add") - public JsonResponse insert(@RequestBody @Validated AdminReportDto.AddDto dto){ + public JsonResponse insert(@RequestBody @Validated AdminReportDto.AddDto dto) { return JsonResponse.ok(reportService.insert(dto)); } @ApiOperation("修改上报类型") @PostMapping("/upd") - public JsonResponse update(@RequestBody @Validated AdminReportDto.UpdDto dto){ + public JsonResponse update(@RequestBody @Validated AdminReportDto.UpdDto dto) { return JsonResponse.ok(reportService.update(dto)); } @ApiOperation("删除上报类型") @PostMapping("/del") - public JsonResponse delete(@RequestBody @Validated AdminReportDto.DeleteDto dto){ + public JsonResponse delete(@RequestBody @Validated AdminReportDto.DeleteDto dto) { return JsonResponse.ok(reportService.delete(dto)); } + @DataSource(DataSourceType.MASTER) + @ApiOperation("查询我的上报管理") + @PostMapping("/queryManagerMy") + public JsonResponse> queryManagerMy(@RequestBody @Validated BaseDto dto) { + return JsonResponse.ok(new PageInfo<>(reportService.queryManagerListMy(dto.getParam()))); + } + @ApiOperation("查询上报管理") @PostMapping("/queryManager") - public JsonResponse> queryManagerList(@RequestBody @Validated BaseDto dto){ + public JsonResponse> queryManagerList(@RequestBody @Validated BaseDto dto) { + if (dto.getPageNum() > 0) { + PageHelper.startPage(dto.getPageNum(), dto.getPageSize()); + } return JsonResponse.ok(new PageInfo<>(reportService.queryManagerList(dto.getParam()))); } @ApiOperation("新增上报管理") @PostMapping("/addManager") - public JsonResponse insertManager(@RequestBody @Validated AdminReportDto.AddManagerDto dto){ + public JsonResponse insertManager(@RequestBody @Validated AdminReportDto.AddManagerDto dto) { return JsonResponse.ok(reportService.insertManager(dto)); } @ApiOperation("修改上报管理") @PostMapping("/updManager") - public JsonResponse updateManager(@RequestBody @Validated AdminReportDto.UpdManagerDto dto){ + public JsonResponse updateManager(@RequestBody @Validated AdminReportDto.UpdManagerDto dto) { return JsonResponse.ok(reportService.updateManager(dto)); } @ApiOperation("删除上报管理") @PostMapping("/delManager") - public JsonResponse deleteManager(@RequestBody @Validated AdminReportDto.DeleteManagerDto dto){ + public JsonResponse deleteManager(@RequestBody @Validated AdminReportDto.DeleteManagerDto dto) { return JsonResponse.ok(reportService.deleteManager(dto)); } diff --git a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/PmsTreatmentController.java b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/PmsTreatmentController.java index 2812aa6f..74a119dc 100644 --- a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/PmsTreatmentController.java +++ b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/PmsTreatmentController.java @@ -1,10 +1,22 @@ package com.acupuncture.web.controller.web; +import cn.hutool.core.collection.CollectionUtil; +import com.acupuncture.common.annotation.DataSource; import com.acupuncture.common.core.domain.BaseDto; import com.acupuncture.common.core.domain.JsonResponse; +import com.acupuncture.common.enums.DataSourceType; +import com.acupuncture.common.utils.SecurityUtils; +import com.acupuncture.framework.datasource.DynamicDataSourceContextHolder; import com.acupuncture.system.domain.dto.PmsTreatmentDto; +import com.acupuncture.system.domain.po.RmsReportManagement; +import com.acupuncture.system.domain.po.RmsReportManagementExample; +import com.acupuncture.system.domain.po.UmsDataSource; import com.acupuncture.system.domain.vo.PmsTreatmentVo; +import com.acupuncture.system.persist.mapper.RmsReportManagementMapper; +import com.acupuncture.system.service.AdminReportService; +import com.acupuncture.system.service.DmsLoginService; import com.acupuncture.system.service.PmsTreatmentService; +import com.acupuncture.system.service.RmsReportService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; @@ -22,6 +34,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List; +import java.util.stream.Collectors; /** * @Author zzc @@ -37,6 +50,12 @@ public class PmsTreatmentController { @Resource private PmsTreatmentService treatmentService; + @Resource + private AdminReportService adminReportService; + @Resource + private DmsLoginService dmsLoginService; + @Resource + private RmsReportManagementMapper rmsReportManagementMapper; @ApiOperation("添加诊疗档案") @PostMapping("/add") @@ -59,13 +78,35 @@ public class PmsTreatmentController { return JsonResponse.ok(); } + @DataSource(DataSourceType.MASTER) @ApiOperation("查询诊疗档案") @PostMapping("/list") public JsonResponse> listTreatment(@RequestBody @Validated BaseDto queryDTO) { - if (queryDTO.getPageNum() > 0) { - PageHelper.startPage(queryDTO.getPageNum(), queryDTO.getPageSize()); + + try { + List rmsReportManagements1 = rmsReportManagementMapper.selectByExample(new RmsReportManagementExample()); + + PmsTreatmentDto.TreatmentQueryDTO param = queryDTO.getParam(); + if (queryDTO.getParam().getReportTypeId() != null) { + List rmsReportManagements = adminReportService.queryManagerListByType(queryDTO.getParam().getReportTypeId()); + if (CollectionUtil.isNotEmpty(rmsReportManagements)) { + param.setManagementIdList(rmsReportManagements.stream().map(RmsReportManagement::getId).collect(Collectors.toList())); + } else { + return JsonResponse.ok(new PageInfo<>()); + } + } + UmsDataSource dataSourceByTenantId = dmsLoginService.getDataSourceByTenantId(SecurityUtils.getTenantId()); + if (dataSourceByTenantId != null) { + DynamicDataSourceContextHolder.setDataSourceType(dataSourceByTenantId.getDataSourceKey()); + } + if (queryDTO.getPageNum() > 0) { + PageHelper.startPage(queryDTO.getPageNum(), queryDTO.getPageSize()); + } + return JsonResponse.ok(new PageInfo<>(treatmentService.listTreatment(param, rmsReportManagements1))); + } finally { + DynamicDataSourceContextHolder.clearDataSourceType(); } - return JsonResponse.ok(new PageInfo<>(treatmentService.listTreatment(queryDTO.getParam()))); + } @ApiOperation("新增诊疗档案数据") @@ -96,7 +137,7 @@ public class PmsTreatmentController { @ApiOperation("导出诊疗档案评估报告") @PostMapping("/exportTreatmentPg") - public JsonResponse exportTreatmentPg(HttpServletResponse response, @RequestBody @Validated PmsTreatmentDto.ExportVO dto){ + public JsonResponse exportTreatmentPg(HttpServletResponse response, @RequestBody @Validated PmsTreatmentDto.ExportVO dto) { return JsonResponse.ok(treatmentService.exportTreatmentPg(response, dto)); } } diff --git a/acupuncture-common/src/main/java/com/acupuncture/common/utils/ZipUtils.java b/acupuncture-common/src/main/java/com/acupuncture/common/utils/ZipUtils.java new file mode 100644 index 00000000..5c010ae1 --- /dev/null +++ b/acupuncture-common/src/main/java/com/acupuncture/common/utils/ZipUtils.java @@ -0,0 +1,147 @@ +package com.acupuncture.common.utils; + +import java.io.*; +import java.util.ArrayList; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + + +public class ZipUtils { + + private static final int BUFFER_SIZE = 2 * 1024; + + /** + * 压缩成ZIP 方法1 + * @param srcDir 压缩文件夹路径 + * @param out 压缩文件输出流 + * @param KeepDirStructure 是否保留原来的目录结构,true:保留目录结构; + * false:所有文件跑到压缩包根目录下(注意:不保留目录结构可能会出现同名文件,会压缩失败) + * @throws RuntimeException 压缩失败会抛出运行时异常 + */ + public static void toZip(String srcDir, OutputStream out, boolean KeepDirStructure) + throws RuntimeException{ + + long start = System.currentTimeMillis(); + ZipOutputStream zos = null ; + try { + zos = new ZipOutputStream(out); + File sourceFile = new File(srcDir); + compress(sourceFile,zos,sourceFile.getName(),KeepDirStructure); + long end = System.currentTimeMillis(); + System.out.println("压缩完成,耗时:" + (end - start) +" ms"); + } catch (Exception e) { + throw new RuntimeException("zip error from ZipUtils",e); + }finally{ + if(zos != null){ + try { + zos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + } + + /** + * 压缩成ZIP 方法2 + * @param srcFiles 需要压缩的文件列表 + * @param out 压缩文件输出流 + * @throws RuntimeException 压缩失败会抛出运行时异常 + */ + public static void toZip(List srcFiles , OutputStream out)throws RuntimeException { + long start = System.currentTimeMillis(); + ZipOutputStream zos = null ; + try { + zos = new ZipOutputStream(out); + for (File srcFile : srcFiles) { + byte[] buf = new byte[BUFFER_SIZE]; + zos.putNextEntry(new ZipEntry(srcFile.getName())); + int len; + FileInputStream in = new FileInputStream(srcFile); + while ((len = in.read(buf)) != -1){ + zos.write(buf, 0, len); + } + zos.closeEntry(); + in.close(); + } + long end = System.currentTimeMillis(); + System.out.println("压缩完成,耗时:" + (end - start) +" ms"); + } catch (Exception e) { +// throw new RuntimeException("zip error from ZipUtils",e); + }finally{ + if(zos != null){ + try { + zos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + + /** + * 递归压缩方法 + * @param sourceFile 源文件 + * @param zos zip输出流 + * @param name 压缩后的名称 + * @param KeepDirStructure 是否保留原来的目录结构,true:保留目录结构; + * false:所有文件跑到压缩包根目录下(注意:不保留目录结构可能会出现同名文件,会压缩失败) + * @throws Exception + */ + private static void compress(File sourceFile, ZipOutputStream zos, String name, + boolean KeepDirStructure) throws Exception{ + byte[] buf = new byte[BUFFER_SIZE]; + if(sourceFile.isFile()){ + // 向zip输出流中添加一个zip实体,构造器中name为zip实体的文件的名字 + zos.putNextEntry(new ZipEntry(name)); + // copy文件到zip输出流中 + int len; + FileInputStream in = new FileInputStream(sourceFile); + while ((len = in.read(buf)) != -1){ + zos.write(buf, 0, len); + } + // Complete the entry + zos.closeEntry(); + in.close(); + } else { + File[] listFiles = sourceFile.listFiles(); + if(listFiles == null || listFiles.length == 0){ + // 需要保留原来的文件结构时,需要对空文件夹进行处理 + if(KeepDirStructure){ + // 空文件夹的处理 + zos.putNextEntry(new ZipEntry(name + "/")); + // 没有文件,不需要文件的copy + zos.closeEntry(); + } + + }else { + for (File file : listFiles) { + // 判断是否需要保留原来的文件结构 + if (KeepDirStructure) { + // 注意:file.getName()前面需要带上父文件夹的名字加一斜杠, + // 不然最后压缩包中就不能保留原来的文件结构,即:所有文件都跑到压缩包根目录下了 + compress(file, zos, name + "/" + file.getName(),KeepDirStructure); + } else { + compress(file, zos, file.getName(),KeepDirStructure); + } + + } + } + } + } + + public static void main(String[] args) throws Exception { + /** 测试压缩方法1 */ +// FileOutputStream fos1 = new FileOutputStream(new File("c:/mytest01.zip")); +// ZipUtils.toZip("D:/log", fos1,true); + + /** 测试压缩方法2 */ + List fileList = new ArrayList<>(); + fileList.add(new File("C:/Users/zzc16/Desktop/admin.sh")); + FileOutputStream fos2 = new FileOutputStream(new File("C:/Users/zzc16/Desktop/admin.zip")); + ZipUtils.toZip(fileList, fos2); + } +} diff --git a/acupuncture-framework/src/main/java/com/acupuncture/framework/web/service/WebDmsLoginService.java b/acupuncture-framework/src/main/java/com/acupuncture/framework/web/service/WebDmsLoginService.java index f5a40b40..9f65dacb 100644 --- a/acupuncture-framework/src/main/java/com/acupuncture/framework/web/service/WebDmsLoginService.java +++ b/acupuncture-framework/src/main/java/com/acupuncture/framework/web/service/WebDmsLoginService.java @@ -62,7 +62,7 @@ public class WebDmsLoginService public String login(String username, String password, String code, String uuid) { // 验证码校验 - validateCaptcha(username, code, uuid); +// validateCaptcha(username, code, uuid); // 登录前置校验 loginPreCheck(username, password); // 用户验证 diff --git a/acupuncture-generator/src/main/resources/mbg.xml b/acupuncture-generator/src/main/resources/mbg.xml index d70d1298..0f881f1b 100644 --- a/acupuncture-generator/src/main/resources/mbg.xml +++ b/acupuncture-generator/src/main/resources/mbg.xml @@ -82,13 +82,15 @@ - + -
+ + +