diff --git a/platform-common/src/main/java/com/lyms/platform/common/enums/RemoteServerEnmus.java b/platform-common/src/main/java/com/lyms/platform/common/enums/RemoteServerEnmus.java new file mode 100644 index 0000000..df0d2e0 --- /dev/null +++ b/platform-common/src/main/java/com/lyms/platform/common/enums/RemoteServerEnmus.java @@ -0,0 +1,40 @@ +package com.lyms.platform.common.enums; + +public enum RemoteServerEnmus { +// LOCAL("http://localhost:9091", "本地环境"), + TEST("https://dev-rp-api.healthbaby.com.cn", "测试环境"), + ON_LINE("https://rp-api.healthbaby.com.cn", "线上"), + LC("https://area-lc-api.healthbaby.com.cn:55581", "聊城"), + DZ("https://area-dz-api.healthbaby.com.cn:12356", "德州"), + QHD("https://area-qhd-api.healthbaby.com.cn:18019", "秦皇岛"), + NC("https://area-nc-api.healthbaby.com.cn:12356", "南充"), + LL("https://area-laoling-api.healthbaby.com.cn:12356", "乐陵"), + NQ("https://rp-hbnq-api.healthbaby.com.cn:18019", "内丘"), + CD("https://area-chengde-api.healthbaby.com.cn:12356", "承德"), + KF("https://area-kaifeng-api.healthbaby.com.cn:12356", "开封"); + + private String address; + private String remark; + + private RemoteServerEnmus(String address, String remark) { + this.address = address; + this.remark = remark; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + +} diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java index b9117e4..5e9890c 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java @@ -123,7 +123,12 @@ public class PatientWeightController extends BaseController { @RequestMapping(value = "/update", method = RequestMethod.POST) @TokenRequired public BaseResponse update(String id, String beforeWeight, String beforeHeight, String date, String nowWeight, HttpServletRequest request, String bregmatic, String bregmaticOther) { - return patientWeightService.update(getUserId(request), id, beforeWeight, beforeHeight, date, nowWeight, bregmatic, bregmaticOther); + return patientWeightService.update(getUserId(request), id, beforeWeight, beforeHeight, date, nowWeight, bregmatic, bregmaticOther, true); } + @ResponseBody + @RequestMapping(value = "/sync/update", method = RequestMethod.POST) + public BaseResponse syncUpdate(String id, String beforeWeight, String beforeHeight, String date, String nowWeight, Integer userId, String bregmatic, String bregmaticOther) { + return patientWeightService.update(userId, id, beforeWeight, beforeHeight, date, nowWeight, bregmatic, bregmaticOther, false); + } } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java index 4861ba4..e030263 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java @@ -27,5 +27,5 @@ public interface PatientWeightService extends IBaseService { BaseResponse wxAddOrUpdateSync(PatientWeight patientWeight); - BaseResponse update(Integer userId, String id, String beforeWeight, String beforeHeight, String date, String nowWeight, String bregmatic, String bregmaticOther); + BaseResponse update(Integer userId, String id, String beforeWeight, String beforeHeight, String date, String nowWeight, String bregmatic, String bregmaticOther, boolean sync); } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java index 86da78c..397af20 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java @@ -438,7 +438,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient } @Override - public BaseResponse update(Integer userId, String id, String beforeWeight, String beforeHeight, String date, String nowWeight, String bregmatic, String bregmaticOther) { + 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) { PatientWeight patientWeight = mongoTemplate.findById(id, PatientWeight.class); if(patientWeight == null) { return RespBuilder.buildSuccess("该体重未找到"); @@ -475,6 +475,29 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient patientWeight.setDayWeights(dayWeights); } patientWeightService2.update(Query.query(Criteria.where("id").is(id)), patientWeight); + + if(sync) { + // 同步修改数据 + RemoteServerEnmus[] values = RemoteServerEnmus.values(); + for (final RemoteServerEnmus server : values) { + new Thread(new Runnable() { + @Override + public void run() { + Map param = new HashMap<>(); + param.put("userId", userId + ""); + param.put("id", id); + param.put("beforeWeight", beforeWeight); + param.put("beforeHeight", beforeHeight); + param.put("date", date); + param.put("nowWeight", nowWeight); + param.put("bregmatic", bregmatic); + param.put("bregmaticOther", bregmaticOther); + String s1 = HttpClientUtil.doPost(server.getAddress() + "/patient/weight/sync/update", param, "UTF-8"); + System.out.println("add result>> " + s1); + } + }).start(); + } + } return RespBuilder.buildSuccess(id); }