PatientArchivesController.java 5.8 KB

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