Commit 628e3b8bae1bba23da8c727e7493782f0bb3fd7d

Authored by liquanyu
1 parent 87e23791d0

短信修改

Showing 15 changed files with 237 additions and 26 deletions

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IBabyBookBuildingDao.java View file @ 628e3b8
... ... @@ -21,5 +21,7 @@
21 21 List<BabyCheckModel> queryBabyYuYueRecord(Date yuYueDate, String tempHid);
22 22  
23 23 List<BabyCheckModel> queryBabyOrder(Date startDate, String tempHid, String pid);
  24 +
  25 + List<String> getBirthBabies(String dateStr);
24 26 }
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IYunBookBuildingDao.java View file @ 628e3b8
... ... @@ -11,5 +11,9 @@
11 11 public void updatePatient(Patients obj, String id);
12 12  
13 13 public List<Patients> queryPatientWithQuery(MongoQuery id);
  14 +
  15 + List<String> getBirthIds(String dateStr);
  16 +
  17 + List<String> getBirthHusbands(String dateStr);
14 18 }
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/AntenatalExaminationDaoImpl.java View file @ 628e3b8
... ... @@ -62,7 +62,7 @@
62 62  
63 63 @Override
64 64 public List<AntenatalExaminationModel> queryYuyueAntenatalExamination(Date yuYueDate,String hospitalId) {
65   - AggregationOperation match = Aggregation.match(Criteria.where("nextCheckTime").gte(yuYueDate).and("nextCheckTime").lte(yuYueDate).and("hospitalId").is(hospitalId));
  65 + AggregationOperation match = Aggregation.match(Criteria.where("nextCheckTime").gte(yuYueDate).lte(yuYueDate).and("hospitalId").is(hospitalId));
66 66 AggregationOperation group = Aggregation.group("parentId").max("modified").as("modified");
67 67 Aggregation aggregation = Aggregation.newAggregation(match, group);
68 68 AggregationResults<AntenatalExaminationModel> result = this.mongoTemplate.aggregate(aggregation, "lyms_antex", AntenatalExaminationModel.class);
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/BabyBookbuildingDaoImpl.java View file @ 628e3b8
1 1 package com.lyms.platform.biz.dal.impl;
2 2  
  3 +import com.lyms.platform.common.utils.StringUtils;
3 4 import com.lyms.platform.pojo.BabyCheckModel;
  5 +import com.mongodb.DBCollection;
  6 +import com.mongodb.DBObject;
  7 +import com.mongodb.MapReduceCommand;
  8 +import com.mongodb.MapReduceOutput;
4 9 import org.springframework.data.mongodb.core.aggregation.Aggregation;
5 10 import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
6 11 import org.springframework.data.mongodb.core.aggregation.AggregationResults;
... ... @@ -14,6 +19,7 @@
14 19 import com.lyms.platform.common.dao.operator.MongoQuery;
15 20 import com.lyms.platform.pojo.BabyModel;
16 21  
  22 +import java.util.ArrayList;
17 23 import java.util.Date;
18 24 import java.util.List;
19 25  
... ... @@ -56,6 +62,35 @@
56 62 Aggregation aggregation = Aggregation.newAggregation(match, group);
57 63 AggregationResults<BabyCheckModel> result = this.mongoTemplate.aggregate(aggregation, "lyms_babycheck", BabyCheckModel.class);
58 64 return result.getMappedResults();
  65 + }
  66 +
  67 + @Override
  68 + public List<String> getBirthBabies(String dateStr) {
  69 + String map = "function(){"+
  70 + "if (this.birth != null) {"+
  71 + "var dateStr = (this.birth.getMonth()+1) + \"-\" +this.birth.getDate();"+
  72 + "if (\""+dateStr+"\" == dateStr)"+
  73 + "{"+
  74 + " emit(this._id,{bdate:dateStr});"+
  75 + "}"+
  76 + " }}";
  77 +
  78 + String reduce = "function(key, values) { return values;} ";
  79 + DBCollection collections =this.mongoTemplate.getCollection("lyms_baby");
  80 + MapReduceCommand cmd = new MapReduceCommand(collections, map, reduce,
  81 + null, MapReduceCommand.OutputType.INLINE, null);
  82 +
  83 + MapReduceOutput out = collections.mapReduce(cmd);
  84 +
  85 + List<String> ids = new ArrayList<>();
  86 +
  87 + for (DBObject o : out.results()) {
  88 + if (o != null && o.get("_id") != null && StringUtils.isNotEmpty(String.valueOf(o.get("_id"))))
  89 + {
  90 + ids.add(String.valueOf(o.get("_id")));
  91 + }
  92 + }
  93 + return ids;
59 94 }
60 95  
61 96 }
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/YunBookbuildingDaoImpl.java View file @ 628e3b8
... ... @@ -3,6 +3,12 @@
3 3 import com.lyms.platform.common.dao.operator.MongoCondition;
4 4 import com.lyms.platform.common.dao.operator.MongoOper;
5 5 import com.lyms.platform.common.dao.operator.MongoQuery;
  6 +import com.lyms.platform.common.utils.DateUtil;
  7 +import com.lyms.platform.common.utils.StringUtils;
  8 +import com.mongodb.DBCollection;
  9 +import com.mongodb.DBObject;
  10 +import com.mongodb.MapReduceCommand;
  11 +import com.mongodb.MapReduceOutput;
6 12 import org.springframework.data.mongodb.core.aggregation.Aggregation;
7 13 import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
8 14 import org.springframework.data.mongodb.core.aggregation.AggregationResults;
... ... @@ -13,6 +19,8 @@
13 19 import com.lyms.platform.common.dao.BaseMongoDAOImpl;
14 20 import com.lyms.platform.pojo.Patients;
15 21  
  22 +import java.util.ArrayList;
  23 +import java.util.Date;
16 24 import java.util.List;
17 25  
18 26 @Repository("yunBookBuildingDao")
... ... @@ -32,6 +40,64 @@
32 40 @Override
33 41 public List<Patients> queryPatientWithQuery(MongoQuery query) {
34 42 return find(query.convertToMongoQuery());
  43 + }
  44 + @Override
  45 + public List<String> getBirthIds(String dateStr)
  46 + {
  47 + String map = "function(){"+
  48 + "if (this.birth != null) {"+
  49 + "var dateStr = (this.birth.getMonth()+1) + \"-\" +this.birth.getDate();"+
  50 + "if (\""+dateStr+"\" == dateStr)"+
  51 + "{"+
  52 + " emit(this._id,{bdate:dateStr});"+
  53 + "}"+
  54 + " }}";
  55 +
  56 + String reduce = "function(key, values) { return values;} ";
  57 + DBCollection collections =this.mongoTemplate.getCollection("lyms_patient");
  58 + MapReduceCommand cmd = new MapReduceCommand(collections, map, reduce,
  59 + null, MapReduceCommand.OutputType.INLINE, null);
  60 +
  61 + MapReduceOutput out = collections.mapReduce(cmd);
  62 +
  63 + List<String> ids = new ArrayList<>();
  64 +
  65 + for (DBObject o : out.results()) {
  66 + if (o != null && o.get("_id") != null && StringUtils.isNotEmpty(String.valueOf(o.get("_id"))))
  67 + {
  68 + ids.add(String.valueOf(o.get("_id")));
  69 + }
  70 + }
  71 + return ids;
  72 + }
  73 +
  74 + @Override
  75 + public List<String> getBirthHusbands(String dateStr) {
  76 + String map = "function(){"+
  77 + "if (this.husbandBirth != null) {"+
  78 + "var dateStr = (this.husbandBirth.getMonth()+1) + \"-\" +this.husbandBirth.getDate();"+
  79 + "if (\""+dateStr+"\" == dateStr)"+
  80 + "{"+
  81 + " emit(this._id,{bdate:dateStr});"+
  82 + "}"+
  83 + " }}";
  84 +
  85 + String reduce = "function(key, values) { return values;} ";
  86 + DBCollection collections =this.mongoTemplate.getCollection("lyms_patient");
  87 + MapReduceCommand cmd = new MapReduceCommand(collections, map, reduce,
  88 + null, MapReduceCommand.OutputType.INLINE, null);
  89 +
  90 + MapReduceOutput out = collections.mapReduce(cmd);
  91 +
  92 + List<String> ids = new ArrayList<>();
  93 +
  94 + for (DBObject o : out.results()) {
  95 + if (o != null && o.get("_id") != null && StringUtils.isNotEmpty(String.valueOf(o.get("_id"))))
  96 + {
  97 + ids.add(String.valueOf(o.get("_id")));
  98 + }
  99 + }
  100 + return ids;
35 101 }
36 102 }
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/BabyBookbuildingService.java View file @ 628e3b8
... ... @@ -60,5 +60,9 @@
60 60 public List<BabyCheckModel> queryBabyOrder(Date startDate, String tempHid, String pid) {
61 61 return babyBookBuildingDao.queryBabyOrder(startDate, tempHid, pid);
62 62 }
  63 +
  64 + public List<String> getBirthBabies(String dateStr) {
  65 + return babyBookBuildingDao.getBirthBabies(dateStr);
  66 + }
63 67 }
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/YunBookbuildingService.java View file @ 628e3b8
... ... @@ -39,5 +39,12 @@
39 39 return yunBookBuildingDao.queryPatientWithQuery(query.addOrder(Sort.Direction.DESC, "created"));
40 40 }
41 41  
  42 + public List<String> getBirthPatients(String dateStr) {
  43 + return yunBookBuildingDao.getBirthIds(dateStr);
  44 + }
  45 +
  46 + public List<String> getBirthHusbands(String dateStr) {
  47 + return yunBookBuildingDao.getBirthHusbands(dateStr);
  48 + }
42 49 }
platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java View file @ 628e3b8
... ... @@ -596,7 +596,17 @@
596 596 return parseYMD(time);
597 597 }
598 598  
  599 + public static String formatSimpleDate(Date date)
  600 + {
  601 + if (date == null)
  602 + {
  603 + return "";
  604 + }
  605 + SimpleDateFormat md = new SimpleDateFormat("M-d");
  606 + return md.format(date);
  607 + }
599 608  
  609 +
600 610 public static void main(String[] arg) {
601 611 /* Date today = new Date(1448336360000L);
602 612  
... ... @@ -637,6 +647,10 @@
637 647 //
638 648 // Date actualSendDate = DateUtil.addDay(d, -2);
639 649 // String sendDateStr = DateUtil.getDD(actualSendDate);
  650 +
  651 +// SimpleDateFormat md = new SimpleDateFormat("M-d");
  652 +// String st = md.format(new Date());
  653 +// System.out.print(st);
640 654 } catch (Exception e)
641 655 {
642 656  
platform-common/src/main/java/com/lyms/platform/common/utils/StringUtils.java View file @ 628e3b8
1 1 package com.lyms.platform.common.utils;
2 2  
  3 +import java.util.Date;
  4 +
3 5 /**
4 6 * 添加类的一句话简单描述。
5 7 * <p>
... ... @@ -99,6 +101,19 @@
99 101 }
100 102 return "";
101 103 }
  104 +
  105 + public static Date getBirthDay(String idCard){
  106 + if (isEmpty(idCard))
  107 + {
  108 + return null;
  109 + }
  110 + String year = idCard.substring(6, 10);
  111 + String mouth = idCard.substring(10, 12);
  112 + String day = idCard.substring(12, 14);
  113 + String birthday = year + "-" + mouth + "-" + day;
  114 + return DateUtil.parseYMD(birthday);
  115 + }
  116 +
102 117 // public static void main(String[] arg) {
103 118 // System.out.print(encryPhone("18382670036"));
104 119 // }
platform-dal/src/main/java/com/lyms/platform/pojo/Patients.java View file @ 628e3b8
... ... @@ -210,6 +210,8 @@
210 210 private String mommyPatientId;
211 211 private String husbandName;
212 212 private String husbandPhone;
  213 + //丈夫生日
  214 + private Date husbandBirth;
213 215 private String vcCardNo;
214 216  
215 217 //丈夫文化程度Id
... ... @@ -220,6 +222,14 @@
220 222  
221 223 //person表主键
222 224 private String pid;
  225 +
  226 + public Date getHusbandBirth() {
  227 + return husbandBirth;
  228 + }
  229 +
  230 + public void setHusbandBirth(Date husbandBirth) {
  231 + this.husbandBirth = husbandBirth;
  232 + }
223 233  
224 234 public String getPid() {
225 235 return pid;
platform-data-api/src/main/java/com/lyms/platform/data/controller/SmsController.java View file @ 628e3b8
... ... @@ -22,7 +22,7 @@
22 22 */
23 23 @RequestMapping(value = "/template")
24 24 public void productSms(HttpServletResponse response){
25   - smsService.productTemplateSms();
  25 + smsService.getBirthPatients();
26 26  
27 27 // MessageListRequest list = new MessageListRequest();
28 28 // List<MessageRequest> messages = new ArrayList<>();
platform-data-api/src/main/java/com/lyms/platform/data/service/SmsService.java View file @ 628e3b8
... ... @@ -15,5 +15,7 @@
15 15 void productChanAmsSms();
16 16  
17 17 void serviceEnd();
  18 +
  19 + void getBirthPatients();
18 20 }
platform-data-api/src/main/java/com/lyms/platform/data/service/impl/SmsServiceImpl.java View file @ 628e3b8
... ... @@ -735,38 +735,53 @@
735 735 if (specialDateType == SpecialDateEnums.ZFSR.getId())
736 736 {
737 737 Date birthday = DateUtil.addDay(new Date(),sendTimeType);
738   - //生成年月日时间去匹配丈夫身份证号
739   - String bstr = DateUtil.getYmd(birthday);
740   - patientsQuery.setHcertificateNum(bstr);
741   -
742   - //查询符合条件丈夫信息
743   - List<Patients> patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery);
744   - if (CollectionUtils.isNotEmpty(patients))
  738 + List<String> ids = yunBookbuildingService.getBirthHusbands(DateUtil.formatSimpleDate(birthday));
  739 + if(CollectionUtils.isNotEmpty(ids))
745 740 {
746   - for (Patients pat : patients)
  741 + for(String id : ids)
747 742 {
748   - if (pat != null && StringUtils.isEmpty(pat.getHusbandPhone()))
  743 + patientsQuery.setId(id);
  744 + //查询符合条件丈夫信息
  745 + List<Patients> patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery);
  746 + if (CollectionUtils.isNotEmpty(patients))
749 747 {
750   - continue;
751   - }
  748 + for (Patients pat : patients)
  749 + {
  750 + if (pat != null && StringUtils.isEmpty(pat.getPhone()))
  751 + {
  752 + continue;
  753 + }
752 754  
753   - //短信前缀
754   - String messagePrefix = getSmsPrefix(config,pat.getBookbuildingDoctor());
755   - String messageContent = "【"+messagePrefix+"】"+template.getContent();
756   - messageContent = replaceName(pat.getHusbandName(), messageContent);
757   - MessageRequest request = getMessageRequest( messageContent,pat.getPhone(),ServiceObjEnums.YUNOBJ.getId(), template.getSmsType(),
758   - pat.getHospitalId(),template.getId(),pat.getId());
  755 + //短信前缀
  756 + String messagePrefix = getSmsPrefix(config,pat.getBookbuildingDoctor());
  757 + String messageContent = "【"+messagePrefix+"】"+template.getContent();
  758 + messageContent = replaceName(pat.getHusbandName(), messageContent);
  759 + MessageRequest request = getMessageRequest( messageContent,pat.getPhone(),ServiceObjEnums.YUNOBJ.getId(), template.getSmsType(),
  760 + pat.getHospitalId(),template.getId(),pat.getId());
759 761  
760   - messages.add(request);
  762 + messages.add(request);
  763 + }
  764 + }
761 765 }
762 766 }
  767 +
  768 +
763 769 }
764 770 //孕妇生日
765 771 else if(specialDateType == SpecialDateEnums.MMSR.getId())
766 772 {
767 773 Date birthday = DateUtil.addDay(new Date(), sendTimeType);
768   - patientsQuery.setBirth(birthday);
769   - messages.addAll(getYunMessageRequestList(patientsQuery, config, template));
  774 + String dateStr = DateUtil.formatSimpleDate(birthday);
  775 + List<String> ids = yunBookbuildingService.getBirthPatients(dateStr);
  776 + if (CollectionUtils.isNotEmpty(ids))
  777 + {
  778 + for(String id : ids)
  779 + {
  780 + patientsQuery.setId(id);
  781 + messages.addAll(getYunMessageRequestList(patientsQuery, config, template));
  782 + }
  783 + }
  784 +
770 785 }
771 786 }
772 787 //特殊日期中的公历和农历 每年的公历/农历
773 788  
774 789  
... ... @@ -1057,11 +1072,19 @@
1057 1072 Integer specialDateType = template.getSpecialDateType();
1058 1073 //儿童生日
1059 1074 if (specialDateType == SpecialDateEnums.ETSR.getId()) {
  1075 +
1060 1076 Date birthday = DateUtil.addDay(new Date(), sendTimeType);
1061   - babyModelQuery.setBirthStart(birthday);
1062   - babyModelQuery.setBirthEnd(birthday);
  1077 + String dateStr = DateUtil.formatSimpleDate(birthday);
  1078 + List<String> ids = babyBookbuildingService.getBirthBabies(dateStr);
  1079 + if (CollectionUtils.isNotEmpty(ids))
  1080 + {
  1081 + for(String id : ids)
  1082 + {
  1083 + babyModelQuery.setId(id);
  1084 + messages.addAll(getBabyMessageRequestList(babyModelQuery, config, template));
  1085 + }
  1086 + }
1063 1087  
1064   - messages.addAll(getBabyMessageRequestList(babyModelQuery, config, template));
1065 1088 }
1066 1089 } //儿童 每年的公历和农历
1067 1090 else if (sendDateType == SendDateEnums.GL.getId() || sendDateType == SendDateEnums.NL.getId())
... ... @@ -2266,6 +2289,13 @@
2266 2289 }
2267 2290 }
2268 2291 return data;
  2292 + }
  2293 +
  2294 +
  2295 + @Override
  2296 + public void getBirthPatients() {
  2297 + String dateStr = DateUtil.formatSimpleDate(new Date());
  2298 + yunBookbuildingService.getBirthPatients(dateStr);
2269 2299 }
2270 2300  
2271 2301 }
platform-data-api/src/main/resources/spring/applicationContext.xml View file @ 628e3b8
... ... @@ -89,5 +89,6 @@
89 89 <import resource="classpath:/spring/applicationContext_biz_patient.xml"/>
90 90 <import resource="classpath:/spring/spring-mongodb.xml"/>
91 91 <import resource="classpath:/spring/applicationContext-dal.xml"/>
  92 + <import resource="classpath:/spring/applicationContext-quartz.xml"/>
92 93 </beans>
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java View file @ 628e3b8
... ... @@ -67,6 +67,9 @@
67 67 @Autowired
68 68 private PatientsService patientsService;
69 69  
  70 + @Autowired
  71 + private BasicConfigService basicConfigService;
  72 +
70 73 /**
71 74 * 添加孕妇建档
72 75 * @param yunRequest
... ... @@ -506,6 +509,24 @@
506 509 //丈夫信息
507 510 patient.setHusbandName(yunRequest.getHusbandName());
508 511 patient.setHcertificateTypeId(yunRequest.getHusbandCertificateTypeId());
  512 +
  513 + if (StringUtils.isNotEmpty(yunRequest.getHusbandCertificateTypeId()) && StringUtils.isNotEmpty(yunRequest.getHusbandCertificateNum()))
  514 + {
  515 + BasicConfigQuery basicConfigQuery = new BasicConfigQuery();
  516 + basicConfigQuery.setId(yunRequest.getHusbandCertificateTypeId());
  517 + basicConfigQuery.setYn(YnEnums.YES.getId());
  518 + List<BasicConfig> data = basicConfigService.queryBasicConfig(basicConfigQuery);
  519 + if (CollectionUtils.isNotEmpty(data)) {
  520 + //身份证类型得到丈夫的生日 必须为身份证类型
  521 + if ("SFZ".endsWith(data.get(0).getCode()))
  522 + {
  523 + String cardNo = yunRequest.getHusbandCertificateNum();
  524 + Date birth = StringUtils.getBirthDay(cardNo);
  525 + patient.setHusbandBirth(birth);
  526 + }
  527 + }
  528 + }
  529 +
509 530 patient.setHcertificateNum(yunRequest.getHusbandCertificateNum());
510 531 patient.setHusbandPhone(yunRequest.getHusbandPhone());
511 532 patient.setHcountryId(yunRequest.getHusbandCountryId());