Commit 8f9cdf820a56282eb56ffffb32ef32b90e419ce0
1 parent
89410124f9
Exists in
master
and in
6 other branches
bug
Showing 1 changed file with 20 additions and 26 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
View file @
8f9cdf8
... | ... | @@ -379,7 +379,8 @@ |
379 | 379 | public BaseResponse wxAddOrUpdate(PatientWeight patientWeight) { |
380 | 380 | String nowWeight = patientWeight.getNowWeight(); |
381 | 381 | Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); |
382 | - PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(patientWeight.getPid())), PatientWeight.class); | |
382 | +// PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(patientWeight.getPid())), PatientWeight.class); | |
383 | + PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientWeight.getPatientId())), PatientWeight.class); | |
383 | 384 | Map<String, String> dayWeights = new LinkedHashMap<>(); |
384 | 385 | List<Map<String, Object>> dayWeights2 = new ArrayList<>(); |
385 | 386 | String ymdDate = DateUtil.getyyyy_MM_dd(new Date()); |
... | ... | @@ -391,6 +392,9 @@ |
391 | 392 | if(pw != null && StringUtils.isNotEmpty(patientWeight.getBeforeWeight())) { |
392 | 393 | return RespBuilder.buildErro(ResponseCode.PATIENT_WEIGHT_IS_EXIST); |
393 | 394 | } |
395 | + if(patients == null) { | |
396 | + return RespBuilder.buildSuccess("patients未找到,patientWeight>>> " + patientWeight); | |
397 | + } | |
394 | 398 | if(pw != null) { // 修改 |
395 | 399 | if(MapUtils.isNotEmpty(pw.getDayWeights())) { |
396 | 400 | dayWeights = pw.getDayWeights(); |
397 | 401 | |
398 | 402 | |
... | ... | @@ -430,36 +434,26 @@ |
430 | 434 | return RespBuilder.buildSuccess(pw); |
431 | 435 | } |
432 | 436 | |
433 | - | |
434 | 437 | Map<String, Object> m = new HashMap<>(); |
435 | 438 | m.put("hospitalId", hospitalId); |
436 | 439 | m.put("hospitalName", couponMapper.getHospitalName(hospitalId)); |
437 | 440 | m.put("date", ymdDate); |
438 | 441 | m.put("nowWeight", nowWeight); |
439 | 442 | dayWeights2.add(m); |
440 | - if(StringUtils.isEmpty(patientWeight.getId()) && patients != null) { | |
441 | - patientWeight.setCreated(new Date()); | |
442 | - patientWeight.setHospitalId(patients.getHospitalId()); | |
443 | - if(StringUtils.isNotBlank(patientWeight.getBeforeWeight()) && patientWeight.getBeforeHeight() != null) { | |
444 | - patientWeight.setBmi(getBmi(patientWeight.getBeforeWeight(), patientWeight.getBeforeHeight())); | |
445 | - } | |
446 | - patientWeight.setYn("1"); | |
447 | - patientWeight.setPid(patients.getPid()); | |
448 | - pw.setDayWeights2(dayWeights2); | |
449 | - patientWeightService2.add(patientWeight); | |
450 | - return RespBuilder.buildSuccess(patientWeight); | |
451 | - } else { | |
452 | - patientWeight.setCreated(new Date()); | |
453 | - patientWeight.setHospitalId(patients.getHospitalId()); | |
454 | - if(StringUtils.isNotBlank(patientWeight.getBeforeWeight()) && patientWeight.getBeforeHeight() != null) { | |
455 | - patientWeight.setBmi(getBmi(patientWeight.getBeforeWeight(), patientWeight.getBeforeHeight())); | |
456 | - } | |
457 | - patientWeight.setYn("1"); | |
458 | - patientWeight.setPid(patients.getPid()); | |
459 | - pw.setDayWeights2(dayWeights2); | |
460 | - patientWeightService2.add(patientWeight); | |
461 | - return RespBuilder.buildSuccess(patientWeight); | |
443 | + dayWeights.put(DateUtil.getyyyy_MM_dd(new Date()), nowWeight); | |
444 | + patientWeight.setCreated(new Date()); | |
445 | + patientWeight.setHospitalId(patients.getHospitalId()); | |
446 | + if(StringUtils.isNotBlank(patientWeight.getBeforeWeight()) && patientWeight.getBeforeHeight() != null) { | |
447 | + patientWeight.setBmi(getBmi(patientWeight.getBeforeWeight(), patientWeight.getBeforeHeight())); | |
462 | 448 | } |
449 | + patientWeight.setYn("1"); | |
450 | + patientWeight.setPid(patients.getPid()); | |
451 | + patientWeight.setDayWeights2(dayWeights2); | |
452 | + patientWeight.setDayWeights(dayWeights); | |
453 | + patientWeight.setId(null); | |
454 | + patientWeightService2.add(patientWeight); | |
455 | + return RespBuilder.buildSuccess(patientWeight); | |
456 | + | |
463 | 457 | } |
464 | 458 | |
465 | 459 | @Override |
... | ... | @@ -474,7 +468,7 @@ |
474 | 468 | patientWeight.setDayWeights(map); |
475 | 469 | |
476 | 470 | JSONArray dayWeights2 = JSONArray.fromObject(patientWeight.getDayWeights2Json()); |
477 | - List<Map<String, Object>> dayWeights2List = new ArrayList<>(); | |
471 | + /*List<Map<String, Object>> dayWeights2List = new ArrayList<>(); | |
478 | 472 | Iterator iterator = dayWeights2.iterator(); |
479 | 473 | while (iterator.hasNext()) { |
480 | 474 | JSONObject jsonObject = JSONObject.fromObject(iterator.next().toString()); |
... | ... | @@ -484,7 +478,7 @@ |
484 | 478 | temp.put("date", jsonObject.getString("date")); |
485 | 479 | temp.put("nowWeight", jsonObject.getString("nowWeight")); |
486 | 480 | dayWeights2List.add(temp); |
487 | - } | |
481 | + }*/ | |
488 | 482 | |
489 | 483 | patientWeight.setDayWeigthsJson(null); |
490 | 484 | patientWeight.setDayWeights2Json(null); |