Commit bb12f5a10a6ec09fae0d6859d261711d7307a663

Authored by liquanyu
1 parent fdc1290ca7

update

Showing 2 changed files with 40 additions and 4 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PremaritalCheckupFacade.java View file @ bb12f5a
... ... @@ -583,7 +583,7 @@
583 583 * 修改妇女的婚检状态
584 584 * */
585 585 ResidentsArchiveModel residentsArchiveModel = new ResidentsArchiveModel();
586   - residentsArchiveModel.setCheckup("1");
  586 + residentsArchiveModel.setCheckup(StringUtils.isEmpty(archiveModel.getCheckup()) ? "1" : String.valueOf(Integer.parseInt(archiveModel.getCheckup())+1));
587 587 residentsArchiveModel.setCheckupTime(new Date());
588 588 residentsArchiveService.updateResident(residentsArchiveModel, archiveModel.getId());
589 589 id = addOrUpdate(addRequest, userId, archiveModel);
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PreEugebicsServiceImpl.java View file @ bb12f5a
... ... @@ -21,6 +21,9 @@
21 21 import org.springframework.beans.factory.annotation.Autowired;
22 22 import org.springframework.data.domain.Sort;
23 23 import org.springframework.data.mongodb.core.MongoTemplate;
  24 +import org.springframework.data.mongodb.core.aggregation.Aggregation;
  25 +import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
  26 +import org.springframework.data.mongodb.core.aggregation.AggregationResults;
24 27 import org.springframework.data.mongodb.core.query.Criteria;
25 28 import org.springframework.data.mongodb.core.query.Query;
26 29 import org.springframework.data.mongodb.core.query.Update;
... ... @@ -550,7 +553,7 @@
550 553 @Override
551 554 public BaseObjectResponse getRcCount(String time, Integer userId) {
552 555  
553   - List<Map<String,Object>> datas = getDatas( time, userId);
  556 + List<Map<String,Object>> datas = getDatas(time, userId);
554 557  
555 558 return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(datas);
556 559 }
... ... @@ -604,7 +607,7 @@
604 607 e.printStackTrace();
605 608 }
606 609 }
607   - int hjCount = residentsArchiveService.queryResidentCount(query.convertToQuery());
  610 + long hjCount = sumField("lyms_resident", "checkup", query.convertToQuery().getCriteria());
608 611 hjAllCount+=hjCount;
609 612 Query yquery = new Query();
610 613  
... ... @@ -644,6 +647,38 @@
644 647 datas.add(data);
645 648 }
646 649 return datas;
  650 + }
  651 +
  652 + public Integer sumField(String collection,String filedName,Criteria criteria) {
  653 +
  654 + Integer total = 0;
  655 + Query query = new Query();
  656 + if(criteria!=null){
  657 + query.addCriteria(criteria);
  658 + }
  659 + List<AggregationOperation> operations = new ArrayList<>();
  660 + operations.add(Aggregation.match(criteria));
  661 + operations.add(Aggregation.group().sum(filedName).as("total"));
  662 + Aggregation aggregation = Aggregation.newAggregation(operations);
  663 + AggregationResults<Total> results =mongoTemplate.aggregate(aggregation, collection, Total.class);
  664 + List<Total> totals = results.getMappedResults();
  665 + if (CollectionUtils.isNotEmpty(totals))
  666 + {
  667 + total = totals.get(0).getTotal();
  668 + }
  669 + return total;
  670 + }
  671 +}
  672 +class Total
  673 +{
  674 + private int total;
  675 +
  676 + public int getTotal() {
  677 + return total;
  678 + }
  679 +
  680 + public void setTotal(int total) {
  681 + this.total = total;
647 682 }
648 683 }