PatientArchivesController.java 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package com.yihu.jw.controller;
  2. import com.fasterxml.jackson.core.type.TypeReference;
  3. import com.fasterxml.jackson.databind.ObjectMapper;
  4. import com.yihu.jw.entity.archives.PatientArchivesDO;
  5. import com.yihu.jw.entity.archives.PatientArchivesInfoDO;
  6. import com.yihu.jw.restmodel.archives.PatientArchivesInfoVO;
  7. import com.yihu.jw.restmodel.archives.PatientArchivesVO;
  8. import com.yihu.jw.restmodel.archives.Test;
  9. import com.yihu.jw.restmodel.web.Envelop;
  10. import com.yihu.jw.restmodel.web.EnvelopRestController;
  11. import com.yihu.jw.rm.archives.PatientArchivesMapping;
  12. import com.yihu.jw.service.PatientArchivesSevice;
  13. import io.swagger.annotations.Api;
  14. import io.swagger.annotations.ApiOperation;
  15. import io.swagger.annotations.ApiParam;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.cloud.sleuth.Tracer;
  18. import java.util.List;
  19. /**
  20. * Created by Trick on 2018/2/7.
  21. */
  22. @RestController
  23. @RequestMapping(PatientArchivesMapping.api_archives_common)
  24. @Api(tags = "居民建档相关操作", description = "居民建档相关操作")
  25. public class PatientArchivesController extends EnvelopRestController {
  26. @Autowired
  27. private PatientArchivesSevice patientArchivesSevice;
  28. @Autowired
  29. private Tracer tracer;
  30. @GetMapping(value = "test")
  31. @ApiOperation(value = "测试")
  32. public Test test(){
  33. Test t = new Test();
  34. t.setFileName("11");
  35. t.setFileType("1");
  36. return t;
  37. }
  38. @GetMapping(value = PatientArchivesMapping.Archives.findPatientArchives)
  39. @ApiOperation(value = "查询健康信息列表")
  40. public Envelop<PatientArchivesVO> findPatientArchives(@ApiParam(name = "name", value = "姓名(模糊匹配)")
  41. @RequestParam(value = "name", required = false)String name,
  42. @ApiParam(name = "status", value = "档案状态")
  43. @RequestParam(value = "status", required = false)String status,
  44. @ApiParam(name = "cancelReseanType", value = "注销状态")
  45. @RequestParam(value = "cancelReseanType", required = false)String cancelReseanType,
  46. @ApiParam(name = "page", value = "分页") @RequestParam(value = "page", required = false)Integer page,
  47. @ApiParam(name = "size", value = "每一页大小")@RequestParam(value = "size", required = false )Integer size){
  48. try {
  49. return patientArchivesSevice.queryPatientArchivesPage(page,size,status, cancelReseanType ,name);
  50. }catch (Exception e){
  51. e.printStackTrace();
  52. tracer.getCurrentSpan().logEvent(e.getMessage());
  53. return Envelop.getError(e.getMessage());
  54. }
  55. }
  56. @GetMapping(value = PatientArchivesMapping.Archives.findPatientArchivesInfos)
  57. @ApiOperation(value = "查询健康信息详情列表")
  58. public Envelop<PatientArchivesInfoVO> queryPatientArchivesInfoPage(@ApiParam(name = "code", value = "档案编号")
  59. @RequestParam(value = "code", required = false)String code){
  60. try {
  61. return patientArchivesSevice.queryPatientArchivesInfoPage(code);
  62. }catch (Exception e){
  63. e.printStackTrace();
  64. tracer.getCurrentSpan().logEvent(e.getMessage());
  65. return Envelop.getError(e.getMessage());
  66. }
  67. }
  68. @PostMapping(value = PatientArchivesMapping.Archives.createPatientArchives)
  69. @ApiOperation(value = "创建健康信息详情列表")
  70. public Envelop<Boolean> createPatientArchives(@ApiParam(name = "patientArchives", value = "建档基本信息Json")
  71. @RequestParam(value = "patientArchives", required = true)String patientArchives,
  72. @ApiParam(name = "list", value = "建档详情Json")
  73. @RequestParam(value = "list", required = true)String list){
  74. try {
  75. PatientArchivesDO ps = toEntity(patientArchives, PatientArchivesDO.class);
  76. List<PatientArchivesInfoDO> infos = new ObjectMapper().readValue(list, new TypeReference<List<PatientArchivesInfoDO>>(){});
  77. return patientArchivesSevice.createPatientArchives(ps,infos);
  78. }catch (Exception e){
  79. e.printStackTrace();
  80. tracer.getCurrentSpan().logEvent(e.getMessage());
  81. return Envelop.getError(e.getMessage());
  82. }
  83. }
  84. @PutMapping(value = PatientArchivesMapping.Archives.updatePatientArchives)
  85. @ApiOperation(value = "更新健康信息详情列表")
  86. public Envelop<Boolean> updatePatientArchives(@ApiParam(name = "patientArchives", value = "建档基本信息Json")
  87. @RequestParam(value = "patientArchives", required = true)String patientArchives,
  88. @ApiParam(name = "list", value = "建档详情")
  89. @RequestParam(value = "list", required = true)String list){
  90. try {
  91. PatientArchivesDO ps = toEntity(patientArchives, PatientArchivesDO.class);
  92. List<PatientArchivesInfoDO> infos = new ObjectMapper().readValue(list, new TypeReference<List<PatientArchivesInfoDO>>(){});
  93. return patientArchivesSevice.updatePatientArchives(ps,infos);
  94. }catch (Exception e){
  95. e.printStackTrace();
  96. tracer.getCurrentSpan().logEvent(e.getMessage());
  97. return Envelop.getError(e.getMessage());
  98. }
  99. }
  100. }