PatientArchivesController.java 6.1 KB

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