AccountController.java 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. package com.yihu.jw.controller;/**
  2. * Created by nature of king on 2018/5/10.
  3. */
  4. import com.alibaba.fastjson.JSONArray;
  5. import com.alibaba.fastjson.JSONObject;
  6. import com.yihu.jw.entity.health.bank.AccountDO;
  7. import com.yihu.jw.entity.health.bank.CreditsDetailDO;
  8. import com.yihu.jw.restmodel.web.MixEnvelop;
  9. import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
  10. import com.yihu.jw.rm.health.bank.HealthBankMapping;
  11. import com.yihu.jw.service.AccountService;
  12. import com.yihu.jw.service.CreditsDetailService;
  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.ArrayList;
  20. import java.util.List;
  21. /**
  22. * @author wangzhinan
  23. * @create 2018-05-10 11:44
  24. * @desc account Controller
  25. **/
  26. @RestController
  27. @RequestMapping(HealthBankMapping.api_health_bank_common)
  28. @Api(tags = "银行账户相关操作",description = "银行账户相关操作")
  29. public class AccountController extends EnvelopRestEndpoint {
  30. @Autowired
  31. private AccountService service;
  32. @Autowired
  33. private CreditsDetailService creditsDetailService;
  34. @Autowired
  35. private Tracer tracer;
  36. /**
  37. * 添加账户
  38. * @param account 实体类account
  39. *
  40. * @return
  41. */
  42. @PostMapping(value = HealthBankMapping.healthBank.createAccount)
  43. @ApiOperation(value = "添加账户")
  44. public MixEnvelop<Boolean, Boolean> insert(@ApiParam(name = "account",value = "账户JSON")
  45. @RequestParam(value = "account",required = true)String account){
  46. try {
  47. AccountDO accountDO = toEntity(account,AccountDO.class);
  48. return service.insert(accountDO);
  49. } catch (Exception e){
  50. e.printStackTrace();
  51. tracer.getCurrentSpan().logEvent(e.getMessage());
  52. return MixEnvelop.getError(e.getMessage());
  53. }
  54. }
  55. /**
  56. * 获取账户
  57. *
  58. * @param creditsDetail 积分对象
  59. * @return
  60. */
  61. @PostMapping(value = HealthBankMapping.healthBank.selectAccount)
  62. @ApiOperation(value = "获取账户信息")
  63. public MixEnvelop<AccountDO, AccountDO> selectByAccount(@ApiParam(name = "creditsDetail",value = "积分JSON")
  64. @RequestParam(value = "creditsDetail",required = false)String creditsDetail){
  65. try {
  66. CreditsDetailDO creditsDetailDO = toEntity(creditsDetail,CreditsDetailDO.class);
  67. return creditsDetailService.findByTradeDirection(creditsDetailDO);
  68. }catch (Exception e){
  69. e.printStackTrace();
  70. tracer.getCurrentSpan().logEvent(e.getMessage());
  71. return MixEnvelop.getError(e.getMessage());
  72. }
  73. }
  74. /**
  75. * 获取银行账户
  76. *
  77. * @param account 银行账户对象
  78. * @param page 页码
  79. * @param size 分页大小
  80. * @return
  81. */
  82. @PostMapping(value = HealthBankMapping.healthBank.findAccount)
  83. @ApiOperation(value = "获取银行账户信息")
  84. public MixEnvelop<AccountDO, AccountDO> select(@ApiParam(name = "account",value = "账户JSON")
  85. @RequestParam(value = "account",required = false)String account,
  86. @ApiParam(name = "page", value = "第几页,从1开始")
  87. @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
  88. @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
  89. @RequestParam(value = "size", required = false)Integer size){
  90. try{
  91. AccountDO accountDO = toEntity(account,AccountDO.class);
  92. return service.findByCondition(accountDO,page,size);
  93. }catch (Exception e){
  94. e.printStackTrace();
  95. tracer.getCurrentSpan().logEvent(e.getMessage());
  96. return MixEnvelop.getError(e.getMessage());
  97. }
  98. }
  99. /**
  100. * 查看银行账户信息
  101. *
  102. * @param account 账户信息对象
  103. * @param page 页码
  104. * @param size 每页大小
  105. * @return
  106. */
  107. /* @PostMapping(value = HealthBankMapping.healthBank.findAccount)
  108. @ApiOperation(value = "查看账户信息")
  109. public Envelop<AccountDO> getAccount(@ApiParam(name = "account",value = "账户JSON")
  110. @RequestParam(value = "account",required = false)String account,
  111. @ApiParam(name = "page", value = "第几页,从1开始")
  112. @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
  113. @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
  114. @RequestParam(value = "size", required = false)Integer size){
  115. try{
  116. AccountDO accountDO = toEntity(account,AccountDO.class);
  117. return service.findByCondition(accountDO,page,size);
  118. }catch (Exception e){
  119. e.printStackTrace();
  120. tracer.getCurrentSpan().logEvent(e.getMessage());
  121. return Envelop.getError(e.getMessage());
  122. }
  123. }*/
  124. /**
  125. * 筛选用户
  126. * @param object
  127. * @return
  128. */
  129. @PostMapping(value = HealthBankMapping.healthBank.findAccounByCondition)
  130. @ApiOperation(value = "按条件获取用户信息")
  131. public MixEnvelop<AccountDO, AccountDO> select(@RequestBody JSONObject object){
  132. try{
  133. JSONArray patientIds = object.getJSONArray("patients");
  134. JSONArray deviceTypes = object.getJSONArray("deviceTypes");
  135. int bindStatus = object.getInteger("bindStatus");
  136. String ruleId = object.getString("ruleId");
  137. Integer page = object.getInteger("page");
  138. Integer size = object.getInteger("size");
  139. List<String> deviceTypes1 = new ArrayList<>();
  140. return service.findByCondition1(patientIds,ruleId,page,size);
  141. } catch (Exception e){
  142. e.printStackTrace();
  143. tracer.getCurrentSpan().logEvent(e.getMessage());
  144. return MixEnvelop.getError(e.getMessage());
  145. }
  146. }
  147. /**
  148. * 根据居民id获取银行账户信息
  149. *
  150. * @param patientId
  151. * @return
  152. */
  153. @PostMapping(value = HealthBankMapping.healthBank.selectAccountByPatient)
  154. @ApiOperation(value = "根据id获取居民账户")
  155. public MixEnvelop<AccountDO, AccountDO> selectByPatient(@ApiParam(name = "patientId",value = "居民id")
  156. @RequestParam(value = "patientId",required = true)String patientId,
  157. @ApiParam(name = "name",value = "名字")
  158. @RequestParam(value = "name",required = false)String name,
  159. @ApiParam(name = "hospital",value = "机构code")
  160. @RequestParam(value = "hospital",required = false)String hospital,
  161. @ApiParam(name = "hospitalName",value = "机构名称")
  162. @RequestParam(value = "hospitalName",required = false)String hospitalName,
  163. @ApiParam(name = "idcard",value = "身份证")
  164. @RequestParam(value = "idcard",required = false)String idcard){
  165. try {
  166. return service.selectByPatient(patientId,name,hospital,hospitalName,idcard);
  167. }catch (Exception e){
  168. e.printStackTrace();
  169. tracer.getCurrentSpan().logEvent(e.getMessage());
  170. return MixEnvelop.getError(e.getMessage());
  171. }
  172. }
  173. }