Commit 88926e716cdbd969f72cd96ad2d19d3cbb1ad5bf

Authored by litao@lymsh.com
1 parent a1f3c9ff7e

改同步逻辑

Showing 1 changed file with 12 additions and 2 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java View file @ 88926e7
... ... @@ -383,9 +383,19 @@
383 383 patientWeight.setDayWeigthsJson(null);
384 384 patientWeight.setCreated(new Date(Long.parseLong(patientWeight.getCreated2())));
385 385 patientWeight.setCreated2(null);
386   - if(StringUtils.isNotEmpty(patientWeight.getId())) {
387   - mongoTemplate.save(patientWeight);
  386 +
  387 + PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(patientWeight.getPid())), PatientWeight.class);
  388 + if(pw != null) {
  389 + patientWeight.setId(pw.getId());
  390 + Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(patientWeight));
  391 + mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(pw.getId())), update, PatientWeight.class);
  392 + } else {
  393 + if(StringUtils.isNotEmpty(patientWeight.getId())) {
  394 + mongoTemplate.save(patientWeight);
  395 + }
388 396 }
  397 +
  398 +
389 399 return RespBuilder.buildSuccess(patientWeight.getId());
390 400 }
391 401