Commit 25debbe21007823dc78d1bfd2e9eedca7d1388b2
1 parent
304016ccc1
Exists in
master
and in
6 other branches
体重管理修改接口 加上同步修改体重数据的逻辑
Showing 4 changed files with 71 additions and 3 deletions
- platform-common/src/main/java/com/lyms/platform/common/enums/RemoteServerEnmus.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
platform-common/src/main/java/com/lyms/platform/common/enums/RemoteServerEnmus.java
View file @
25debbe
| 1 | +package com.lyms.platform.common.enums; | |
| 2 | + | |
| 3 | +public enum RemoteServerEnmus { | |
| 4 | +// LOCAL("http://localhost:9091", "本地环境"), | |
| 5 | + TEST("https://dev-rp-api.healthbaby.com.cn", "测试环境"), | |
| 6 | + ON_LINE("https://rp-api.healthbaby.com.cn", "线上"), | |
| 7 | + LC("https://area-lc-api.healthbaby.com.cn:55581", "聊城"), | |
| 8 | + DZ("https://area-dz-api.healthbaby.com.cn:12356", "德州"), | |
| 9 | + QHD("https://area-qhd-api.healthbaby.com.cn:18019", "秦皇岛"), | |
| 10 | + NC("https://area-nc-api.healthbaby.com.cn:12356", "南充"), | |
| 11 | + LL("https://area-laoling-api.healthbaby.com.cn:12356", "乐陵"), | |
| 12 | + NQ("https://rp-hbnq-api.healthbaby.com.cn:18019", "内丘"), | |
| 13 | + CD("https://area-chengde-api.healthbaby.com.cn:12356", "承德"), | |
| 14 | + KF("https://area-kaifeng-api.healthbaby.com.cn:12356", "开封"); | |
| 15 | + | |
| 16 | + private String address; | |
| 17 | + private String remark; | |
| 18 | + | |
| 19 | + private RemoteServerEnmus(String address, String remark) { | |
| 20 | + this.address = address; | |
| 21 | + this.remark = remark; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public String getAddress() { | |
| 25 | + return address; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public void setAddress(String address) { | |
| 29 | + this.address = address; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public String getRemark() { | |
| 33 | + return remark; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public void setRemark(String remark) { | |
| 37 | + this.remark = remark; | |
| 38 | + } | |
| 39 | + | |
| 40 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java
View file @
25debbe
| ... | ... | @@ -123,8 +123,13 @@ |
| 123 | 123 | @RequestMapping(value = "/update", method = RequestMethod.POST) |
| 124 | 124 | @TokenRequired |
| 125 | 125 | public BaseResponse update(String id, String beforeWeight, String beforeHeight, String date, String nowWeight, HttpServletRequest request, String bregmatic, String bregmaticOther) { |
| 126 | - return patientWeightService.update(getUserId(request), id, beforeWeight, beforeHeight, date, nowWeight, bregmatic, bregmaticOther); | |
| 126 | + return patientWeightService.update(getUserId(request), id, beforeWeight, beforeHeight, date, nowWeight, bregmatic, bregmaticOther, true); | |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | + @ResponseBody | |
| 130 | + @RequestMapping(value = "/sync/update", method = RequestMethod.POST) | |
| 131 | + public BaseResponse syncUpdate(String id, String beforeWeight, String beforeHeight, String date, String nowWeight, Integer userId, String bregmatic, String bregmaticOther) { | |
| 132 | + return patientWeightService.update(userId, id, beforeWeight, beforeHeight, date, nowWeight, bregmatic, bregmaticOther, false); | |
| 133 | + } | |
| 129 | 134 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java
View file @
25debbe
| ... | ... | @@ -27,6 +27,6 @@ |
| 27 | 27 | |
| 28 | 28 | BaseResponse wxAddOrUpdateSync(PatientWeight patientWeight); |
| 29 | 29 | |
| 30 | - BaseResponse update(Integer userId, String id, String beforeWeight, String beforeHeight, String date, String nowWeight, String bregmatic, String bregmaticOther); | |
| 30 | + BaseResponse update(Integer userId, String id, String beforeWeight, String beforeHeight, String date, String nowWeight, String bregmatic, String bregmaticOther, boolean sync); | |
| 31 | 31 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
View file @
25debbe
| ... | ... | @@ -438,7 +438,7 @@ |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | @Override |
| 441 | - public BaseResponse update(Integer userId, String id, String beforeWeight, String beforeHeight, String date, String nowWeight, String bregmatic, String bregmaticOther) { | |
| 441 | + public BaseResponse update(final Integer userId, final String id, final String beforeWeight, final String beforeHeight, final String date, final String nowWeight, final String bregmatic, final String bregmaticOther, boolean sync) { | |
| 442 | 442 | PatientWeight patientWeight = mongoTemplate.findById(id, PatientWeight.class); |
| 443 | 443 | if(patientWeight == null) { |
| 444 | 444 | return RespBuilder.buildSuccess("该体重未找到"); |
| ... | ... | @@ -475,6 +475,29 @@ |
| 475 | 475 | patientWeight.setDayWeights(dayWeights); |
| 476 | 476 | } |
| 477 | 477 | patientWeightService2.update(Query.query(Criteria.where("id").is(id)), patientWeight); |
| 478 | + | |
| 479 | + if(sync) { | |
| 480 | + // 同步修改数据 | |
| 481 | + RemoteServerEnmus[] values = RemoteServerEnmus.values(); | |
| 482 | + for (final RemoteServerEnmus server : values) { | |
| 483 | + new Thread(new Runnable() { | |
| 484 | + @Override | |
| 485 | + public void run() { | |
| 486 | + Map<String, String> param = new HashMap<>(); | |
| 487 | + param.put("userId", userId + ""); | |
| 488 | + param.put("id", id); | |
| 489 | + param.put("beforeWeight", beforeWeight); | |
| 490 | + param.put("beforeHeight", beforeHeight); | |
| 491 | + param.put("date", date); | |
| 492 | + param.put("nowWeight", nowWeight); | |
| 493 | + param.put("bregmatic", bregmatic); | |
| 494 | + param.put("bregmaticOther", bregmaticOther); | |
| 495 | + String s1 = HttpClientUtil.doPost(server.getAddress() + "/patient/weight/sync/update", param, "UTF-8"); | |
| 496 | + System.out.println("add result>> " + s1); | |
| 497 | + } | |
| 498 | + }).start(); | |
| 499 | + } | |
| 500 | + } | |
| 478 | 501 | return RespBuilder.buildSuccess(id); |
| 479 | 502 | } |
| 480 | 503 |