Commit 7349fcedf6b8e194f54caefdb7d06058377240a9

Authored by liquanyu
1 parent b3bccd1b8a

update code

Showing 1 changed file with 116 additions and 4 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java View file @ 7349fce
... ... @@ -33,10 +33,9 @@
33 33 import com.lyms.platform.operate.web.worker.AntexcOtherHighRiskWorker;
34 34 import com.lyms.platform.operate.web.worker.BabyBuildSerToPatientSerWorker;
35 35 import com.lyms.platform.operate.web.worker.BuildSerToPatientSerWorker;
36   -import com.lyms.platform.permission.model.Organization;
37   -import com.lyms.platform.permission.model.OrganizationQuery;
38   -import com.lyms.platform.permission.model.PatientService;
39   -import com.lyms.platform.permission.model.PatientServiceQuery;
  36 +import com.lyms.platform.permission.dao.master.CouponMapper;
  37 +import com.lyms.platform.permission.model.*;
  38 +import com.lyms.platform.permission.service.CouponService;
40 39 import com.lyms.platform.permission.service.OrganizationService;
41 40 import com.lyms.platform.permission.service.PatientServiceService;
42 41 import com.lyms.platform.pojo.*;
... ... @@ -45,6 +44,7 @@
45 44 import org.apache.commons.collections.CollectionUtils;
46 45 import org.apache.commons.io.FileUtils;
47 46 import org.apache.commons.lang.StringUtils;
  47 +import org.apache.commons.lang3.time.DateUtils;
48 48 import org.springframework.beans.factory.annotation.Autowired;
49 49 import org.springframework.beans.factory.annotation.Qualifier;
50 50 import org.springframework.data.authentication.UserCredentials;
51 51  
... ... @@ -2747,7 +2747,119 @@
2747 2747 }
2748 2748 return "finishing。。。。。。";
2749 2749 }
  2750 + @Autowired
  2751 + private CouponService couponService;
  2752 + @Autowired
  2753 + private CouponMapper couponMapper;
2750 2754  
  2755 +
  2756 + @RequestMapping(value = "/handleQhdCoupon1", method = RequestMethod.GET)
  2757 + @ResponseBody
  2758 + public void handleQhdCoupon1(@RequestParam(required = true) String hid,@RequestParam(required = false) String patientId) {
  2759 + List<Patients> patients = mongoTemplate.find(Query.query(Criteria.where("isSendCoupon").is(true).and("yn").is(1)).with(new Sort(Sort.Direction.DESC, "created")), Patients.class);
  2760 + List<String> ids = new ArrayList<>();
  2761 + if (CollectionUtils.isNotEmpty(patients))
  2762 + {
  2763 + for(Patients pat : patients)
  2764 + {
  2765 + AntExChuQuery antExChuQuery = new AntExChuQuery();
  2766 + antExChuQuery.setYn(YnEnums.YES.getId());
  2767 + antExChuQuery.setParentId(pat.getId());
  2768 + antExChuQuery.setHospitalId(hid);
  2769 + List<AntExChuModel> chus = antenatalExaminationService.queryAntExChu(antExChuQuery);
  2770 + if (CollectionUtils.isNotEmpty(chus))
  2771 + {
  2772 + AntExChuModel chu = chus.get(0);
  2773 + }
  2774 + }
  2775 + }
  2776 + }
  2777 +
  2778 + @RequestMapping(value = "/handleQhdCoupon", method = RequestMethod.GET)
  2779 + @ResponseBody
  2780 + public void handleQhdCoupon(@RequestParam(required = true) String hid,@RequestParam(required = false) String patientId) {
  2781 + AntExChuQuery antExChuQuery = new AntExChuQuery();
  2782 + antExChuQuery.setEnd(new Date());
  2783 + antExChuQuery.setStart(DateUtil.addMonth(new Date(),-2));
  2784 + antExChuQuery.setYn(YnEnums.YES.getId());
  2785 + antExChuQuery.setHospitalId(hid);
  2786 + List<AntExChuModel> chus = antenatalExaminationService.queryAntExChu(antExChuQuery);
  2787 + List<String> ids = new ArrayList<>();
  2788 + if (CollectionUtils.isNotEmpty(chus)) {
  2789 + for (AntExChuModel chu : chus) {
  2790 + if (StringUtils.isNotEmpty(chu.getPid())) {
  2791 + Map<String, Object> param = new HashMap<>();
  2792 + param.put("userId", chu.getPid());
  2793 + List<CouponInfo> list = couponMapper.findList(param);
  2794 + if (CollectionUtils.isNotEmpty(list)) {
  2795 + for (CouponInfo couponInfo : list) {
  2796 + Map<String, Object> param1 = new HashMap<>();
  2797 + param.put("code", couponInfo.getSequenceId());
  2798 + param.put("type", 2);
  2799 + Map<String, Object> data = couponMapper.findValidateParam(param1);
  2800 +
  2801 + if (data == null)
  2802 + {
  2803 + continue;
  2804 + }
  2805 + Integer start = Integer.parseInt(data.get("actual_start").toString());
  2806 + Integer end = Integer.parseInt(data.get("actual_end").toString());
  2807 +
  2808 + Date startDate = DateUtils.addDays(chu.getLastMenses(), start * 7);
  2809 + Date endDate = DateUtils.addDays(chu.getLastMenses(), end * 7 + 6);
  2810 +
  2811 + if (DateUtil.isBetween(chu.getCheckTime(), startDate, DateUtils.addDays(endDate, 1)) && couponInfo.getStatus() == 1) {
  2812 + ids.add(chu.getParentId());
  2813 + break;
  2814 + }
  2815 + }
  2816 +
  2817 + }
  2818 + }
  2819 + }
  2820 + }
  2821 +
  2822 + AntExQuery antExQuery = new AntExQuery();
  2823 + antExQuery.setYn(YnEnums.YES.getId());
  2824 + antExQuery.setHospitalId(hid);
  2825 + antExQuery.setCreatedTimeEnd(new Date());
  2826 + antExQuery.setCreatedTimeStart(DateUtil.addMonth(new Date(),-2));
  2827 + List<AntenatalExaminationModel> fus = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery());
  2828 + if (CollectionUtils.isNotEmpty(fus)) {
  2829 + for (AntenatalExaminationModel fu : fus) {
  2830 + if (StringUtils.isNotEmpty(fu.getPid())) {
  2831 + Map<String, Object> param = new HashMap<>();
  2832 + param.put("userId", fu.getPid());
  2833 + List<CouponInfo> list = couponMapper.findList(param);
  2834 + if (CollectionUtils.isNotEmpty(list)) {
  2835 + for (CouponInfo couponInfo : list) {
  2836 + Map<String, Object> param1 = new HashMap<>();
  2837 + param.put("code", couponInfo.getSequenceId());
  2838 + param.put("type", 2);
  2839 + Map<String, Object> data = couponMapper.findValidateParam(param1);
  2840 + if (data == null)
  2841 + {
  2842 + continue;
  2843 + }
  2844 + Integer start = Integer.parseInt(data.get("actual_start").toString());
  2845 + Integer end = Integer.parseInt(data.get("actual_end").toString());
  2846 +
  2847 + Date startDate = DateUtils.addDays(fu.getLastMenses(), start * 7);
  2848 + Date endDate = DateUtils.addDays(fu.getLastMenses(), end * 7 + 6);
  2849 +
  2850 + if (DateUtil.isBetween(fu.getCheckDate(), startDate, DateUtils.addDays(endDate, 1)) && couponInfo.getStatus() == 1) {
  2851 + if (!ids.contains(fu.getParentId()))
  2852 + {
  2853 + break;
  2854 + }
  2855 + }
  2856 + }
  2857 + }
  2858 + }
  2859 + }
  2860 + }
  2861 + System.out.println(ids.size());
  2862 + }
2751 2863  
2752 2864 }