Commit 6c83dfefee44dc550b41b19d06fd62afe7e375a0
1 parent
4e3950d3ec
Exists in
luanping
and in
1 other branch
#新增南河课程学院发布课程推送(晚19点)
Showing 6 changed files with 126 additions and 28 deletions
- platform-common/src/main/java/com/lyms/platform/common/enums/WxTempleteIdEnums.java
- platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
- platform-common/src/main/java/com/lyms/platform/common/utils/HttpClientUtil.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/CourseFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MessageCenterService.java
- platform-operate-api/src/main/resources/spring/applicationContext-quartz.xml
platform-common/src/main/java/com/lyms/platform/common/enums/WxTempleteIdEnums.java
View file @
6c83dfe
... | ... | @@ -19,6 +19,7 @@ |
19 | 19 | BABY_YI_BAN_ZHI_DAO("dqvyESU8UXx1V3cIMQDqj4PLxI6T9-sgihQcs3ZGL9E","儿童一般指导"),//儿童 |
20 | 20 | //YUN_XUE_KE_CHEN_TX("UEwcdz3lJL3NR38KRqN6yTO4nUvRgym5mlXl4jXQBik","孕妇学校课程提醒"),//孕妇学校课程提醒 |
21 | 21 | YUN_XUE_KE_CHEN_TX("Qnkzkq5gbmIK_kwWQ5y5DOxKywEA8lc7qQi6SMza0xU","孕妇学校课程提醒"),//孕妇学校课程提醒 |
22 | + YUX_XUE_KE_CHEN_FB("tx-UmDE3YMqYgAeFccXB7HIlTuG_tiP9LMdX2bvBpus","孕妇学校课程发布提醒"),//孕妇学校课程发布提醒 | |
22 | 23 | |
23 | 24 | YUN_XUE_JSTX("jBHP98VRjIf3d0TDnor89V_z2IQ9b0ecKW3fAZW4FS8","孕妇学校课程结束提醒"),//孕妇学校课程结束提醒 |
24 | 25 |
platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
View file @
6c83dfe
... | ... | @@ -1962,7 +1962,8 @@ |
1962 | 1962 | |
1963 | 1963 | |
1964 | 1964 | public static void main(String[] args) { |
1965 | - System.out.println(DateUtil.addDay(new Date(),-20).getTime()); | |
1965 | + System.out.println(DateUtil.parseYMDHMS(DateUtil.getyyyy_MM_dd(new Date(1704384000000L+1500000L)) )); | |
1966 | + | |
1966 | 1967 | } |
1967 | 1968 | |
1968 | 1969 | } |
platform-common/src/main/java/com/lyms/platform/common/utils/HttpClientUtil.java
View file @
6c83dfe
... | ... | @@ -18,6 +18,8 @@ |
18 | 18 | import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; |
19 | 19 | import org.apache.http.message.BasicNameValuePair; |
20 | 20 | import org.apache.http.util.EntityUtils; |
21 | +import org.slf4j.Logger; | |
22 | +import org.slf4j.LoggerFactory; | |
21 | 23 | |
22 | 24 | import java.io.BufferedReader; |
23 | 25 | import java.io.IOException; |
... | ... | @@ -30,7 +32,7 @@ |
30 | 32 | * 利用HttpClient进行post请求的工具类 |
31 | 33 | */ |
32 | 34 | public class HttpClientUtil { |
33 | - | |
35 | + private static Logger logger = LoggerFactory.getLogger("error"); | |
34 | 36 | private static PoolingHttpClientConnectionManager connMgr; |
35 | 37 | private static RequestConfig requestConfig; |
36 | 38 | private static final int MAX_TIMEOUT = 70000; |
... | ... | @@ -201,7 +203,7 @@ |
201 | 203 | } |
202 | 204 | } |
203 | 205 | }catch(Exception ex){ |
204 | - | |
206 | + logger.error("Exception-->doGET"+ex.getMessage()); | |
205 | 207 | } |
206 | 208 | return result; |
207 | 209 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/CourseFacade.java
View file @
6c83dfe
... | ... | @@ -22,6 +22,8 @@ |
22 | 22 | import com.lyms.platform.query.*; |
23 | 23 | import org.apache.commons.collections.CollectionUtils; |
24 | 24 | import org.apache.commons.lang3.StringUtils; |
25 | +import org.slf4j.Logger; | |
26 | +import org.slf4j.LoggerFactory; | |
25 | 27 | import org.springframework.beans.factory.annotation.Autowired; |
26 | 28 | import org.springframework.beans.factory.annotation.Qualifier; |
27 | 29 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
... | ... | @@ -73,6 +75,7 @@ |
73 | 75 | @Autowired |
74 | 76 | @Qualifier("commonThreadPool") |
75 | 77 | private ThreadPoolTaskExecutor commonThreadPool; |
78 | + private static Logger logger = LoggerFactory.getLogger(CourseFacade.class); | |
76 | 79 | |
77 | 80 | public BaseResponse addCourese(CourseRequest request, Integer userId) { |
78 | 81 | |
79 | 82 | |
... | ... | @@ -293,7 +296,65 @@ |
293 | 296 | return objectResponse; |
294 | 297 | } |
295 | 298 | |
299 | + /** | |
300 | + * 南和发布课程定时推送 | |
301 | + */ | |
302 | + public void courseTask(){ | |
303 | + logger.info("courseTask-->startup"); | |
304 | + Date startDate = DateUtil.parseYMDHMS(DateUtil.getyyyy_MM_dd(new Date()) + " 00:00:00"); | |
305 | + Date endDate = DateUtil.parseYMDHMS(DateUtil.getyyyy_MM_dd(new Date()) + " 23:59:59"); | |
306 | + CourseQuery query = new CourseQuery(); | |
307 | + List<String> stringList=new ArrayList<>(); | |
308 | + // 目前把南和及龙源美生(用来测试正式推送) | |
309 | + stringList.add("245"); | |
310 | + stringList.add("1000000115"); | |
311 | + query.setHospitalIds(stringList); | |
312 | + query.setPublishTimeStart(startDate); | |
313 | + query.setPublishTimeEnd(endDate); | |
314 | + query.setStatus(CourseStatusEnums.YFB.getId()); | |
315 | + query.setYn(YnEnums.YES.getId()); | |
316 | + final List<CourseModel> list= courseService.queryCourseList(query); | |
317 | + if (CollectionUtils.isNotEmpty(list)){ | |
296 | 318 | |
319 | + new Thread(new Runnable(){ | |
320 | + @Override | |
321 | + public void run() { | |
322 | + Map<String,CourseModel> params=new HashMap<>(); | |
323 | + for (int i = 0,j=list.size(); i < j; i++) { | |
324 | + CourseModel courseModel= list.get(i); | |
325 | + params.put(courseModel.getHospitalId(),courseModel); | |
326 | + } | |
327 | + Iterator it= params.keySet().iterator(); | |
328 | + while (it.hasNext()){ | |
329 | + String key= String.valueOf(it.next()); | |
330 | + CourseModel courseModel= params.get(key); | |
331 | + String id=courseModel.getId(); | |
332 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
333 | + patientsQuery.setHospitalId(courseModel.getHospitalId()); | |
334 | + patientsQuery.setType(1); | |
335 | + patientsQuery.setExtEnable(false); | |
336 | + patientsQuery.setBuildTypeNot(1); | |
337 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
338 | + | |
339 | + List<Patients> patientsModels = patientsService.queryPatient(patientsQuery); | |
340 | + logger.info("courseTask{},patientsModels-->"+patientsModels.toString()); | |
341 | + if (CollectionUtils.isNotEmpty(patientsModels)) | |
342 | + { | |
343 | + for (Patients model : patientsModels) | |
344 | + { | |
345 | + saveMsg(model.getHospitalId(),model.getPhone(),model.getId(), | |
346 | + courseModel.getCourseName(),courseModel.getCourseSpeaker(),model.getId(),id, | |
347 | + "孕妇学校新课程已发布,点击进入小程序预约",1); | |
348 | + } | |
349 | + } | |
350 | + } | |
351 | + } | |
352 | + }).start(); | |
353 | + | |
354 | + } | |
355 | + logger.info("courseTask-->end"); | |
356 | + } | |
357 | + | |
297 | 358 | /** |
298 | 359 | * 取消课程 |
299 | 360 | * @param id |
... | ... | @@ -328,7 +389,7 @@ |
328 | 389 | { |
329 | 390 | saveMsg(model.getHospitalId(),model.getPhone(),model.getPatientId(), |
330 | 391 | courseModel.getCourseName(),courseModel.getCourseSpeaker(),model.getId(),model.getCourseId(), |
331 | - "您本次参加的孕妇学校课程已经取消,请注意安排时间。"); | |
392 | + "您本次参加的孕妇学校课程已经取消,请注意安排时间。",null); | |
332 | 393 | } |
333 | 394 | } |
334 | 395 | } |
... | ... | @@ -479,7 +540,7 @@ |
479 | 540 | String courseName = CollectionUtils.isNotEmpty(courseModels1) ? courseModels1.get(0).getCourseName() : ""; |
480 | 541 | saveMsg(patientCourseModel.getHospitalId(),patientCourseModel.getPhone(),patientCourseModel.getPatientId(), |
481 | 542 | courseName,speaker,patientCourseModel.getId(),patientCourseModel.getCourseId(), |
482 | - "您本次参加的孕妇学校课程已经结束,请点击详情回顾课程内容并对本次课程评分。我们会根据您的评价结果相应做相应的评估的课程调整等。"); | |
543 | + "您本次参加的孕妇学校课程已经结束,请点击详情回顾课程内容并对本次课程评分。我们会根据您的评价结果相应做相应的评估的课程调整等。",null); | |
483 | 544 | } |
484 | 545 | } |
485 | 546 | } |
... | ... | @@ -487,7 +548,7 @@ |
487 | 548 | } |
488 | 549 | |
489 | 550 | private void saveMsg(String hospitalId,String phone,String patientId,String courseName,String doctorName,String patientCourseId,String courseId, |
490 | - String msg) | |
551 | + String msg,Integer type) | |
491 | 552 | { |
492 | 553 | |
493 | 554 | OrganizationQuery orgQuery = new OrganizationQuery(); |
... | ... | @@ -499,6 +560,10 @@ |
499 | 560 | SmsConfigModel configModel = new SmsConfigModel(); |
500 | 561 | // 1 推送服务, 2 推送和短信服务 3短信服务, |
501 | 562 | int startType = smsConfigFacade.hospitalIsStart(hospitalId, configModel, SmsServiceEnums.YFXXKCTX.getId()); |
563 | + //如果是南和医院或者龙源美生做特殊处理 | |
564 | + if (hospitalId.equals("1000000115")&&hospitalId.equals("245")&&type!=null){ | |
565 | + startType=1; | |
566 | + } | |
502 | 567 | if (startType == 0) { |
503 | 568 | return; |
504 | 569 | } |
505 | 570 | |
506 | 571 | |
... | ... | @@ -522,14 +587,22 @@ |
522 | 587 | mr.setPatientId(patientId); |
523 | 588 | |
524 | 589 | mr.setKeyword1(list.get(0).getName()); |
525 | - mr.setKeyword2(doctorName); | |
590 | + | |
526 | 591 | mr.setRemark(courseId); |
527 | 592 | mr.setCreated(DateUtil.getyyyy_MM_dd_hms(new Date())); |
528 | 593 | mr.setSmsStatus(SmsStatusEnums.WFS.getId()); |
529 | 594 | mr.setServiceType(startType); |
530 | - mr.setWxTempId(WxTempleteIdEnums.YUN_XUE_JSTX.getId()); | |
595 | + if (type!=null){ | |
596 | + mr.setWxTempId(WxTempleteIdEnums.YUX_XUE_KE_CHEN_FB.getId()); | |
597 | + mr.setKeyword2(msg); | |
598 | + }else { | |
599 | + mr.setWxTempId(WxTempleteIdEnums.YUN_XUE_JSTX.getId()); | |
600 | + mr.setKeyword2(doctorName); | |
601 | + } | |
602 | + | |
531 | 603 | messages.add(mr); |
532 | 604 | if (CollectionUtils.isNotEmpty(messages)) { |
605 | + logger.info("messages{},"+messages.toString()); | |
533 | 606 | smsConfigFacade.saveMsg(messages, hospitalId); |
534 | 607 | } |
535 | 608 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MessageCenterService.java
View file @
6c83dfe
... | ... | @@ -6,11 +6,14 @@ |
6 | 6 | import com.lyms.platform.common.enums.*; |
7 | 7 | import com.lyms.platform.common.utils.*; |
8 | 8 | import com.lyms.platform.common.utils.HttpClientUtil; |
9 | +import com.lyms.platform.operate.web.dao.impl.BaseDaoImpl; | |
9 | 10 | import com.lyms.platform.operate.web.request.MessageListRequest; |
10 | 11 | import com.lyms.platform.operate.web.result.Config; |
11 | 12 | import com.lyms.platform.operate.web.result.*; |
12 | 13 | import net.sf.json.JSONArray; |
13 | 14 | import net.sf.json.JSONObject; |
15 | +import org.slf4j.Logger; | |
16 | +import org.slf4j.LoggerFactory; | |
14 | 17 | |
15 | 18 | import java.util.*; |
16 | 19 | |
... | ... | @@ -20,7 +23,7 @@ |
20 | 23 | public class MessageCenterService { |
21 | 24 | public static final String CENTER_BASE_URL = PropertiesUtils.getPropertyValue("center_base_url"); |
22 | 25 | public static final String CENTER_TOKEN = PropertiesUtils.getPropertyValue("center_token"); |
23 | - | |
26 | + private static Logger logger = LoggerFactory.getLogger(MessageCenterService.class); | |
24 | 27 | /** |
25 | 28 | * 服务配置修改 修改这个类短信不发送或者开启发送 |
26 | 29 | * |
27 | 30 | |
... | ... | @@ -234,8 +237,10 @@ |
234 | 237 | param.put("smsActualTimeEnd", smsActualTimeEnd); |
235 | 238 | |
236 | 239 | param.put("objType", objType == null ? null : String.valueOf(objType)); |
240 | + | |
237 | 241 | String result = HttpClientUtil.doGet(CENTER_BASE_URL + "/biz-push-web/push", param, "utf-8", null); |
238 | -// String result = HttpClientUtil.doGet(/*CENTER_BASE_URL+*/"https://push.stage.platform.healthbaby.com.cn/biz-push-web/push", param, "utf-8", null); | |
242 | + logger.info("result-> "+result+"url--> "+CENTER_BASE_URL+"params--->"+param.toString()); | |
243 | + // String result = HttpClientUtil.doGet(/*CENTER_BASE_URL+*/"https://push.stage.platform.healthbaby.com.cn/biz-push-web/push", param, "utf-8", null); | |
239 | 244 | if (result != null) { |
240 | 245 | MsgResult map = JsonUtil.str2Obj(result, MsgResult.class); |
241 | 246 |
platform-operate-api/src/main/resources/spring/applicationContext-quartz.xml
View file @
6c83dfe
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | 2 | <beans xmlns="http://www.springframework.org/schema/beans" |
3 | - xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" | |
4 | - xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
5 | - xmlns:cache="http://www.springframework.org/schema/cache" xmlns:task="http://www.springframework.org/schema/task" | |
6 | - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd | |
3 | + xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" | |
4 | + xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
5 | + xmlns:cache="http://www.springframework.org/schema/cache" xmlns:task="http://www.springframework.org/schema/task" | |
6 | + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd | |
7 | 7 | http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd |
8 | - http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd | |
8 | + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd | |
9 | 9 | http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd |
10 | 10 | http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd"> |
11 | 11 | |
12 | 12 | |
... | ... | @@ -47,10 +47,10 @@ |
47 | 47 | <property name="jobDetail" ref="autoInsertIdTask"></property> |
48 | 48 | <property name="cronExpression" value="${sequence.schedule.expression}"></property> |
49 | 49 | </bean> |
50 | - | |
50 | + | |
51 | 51 | <!--<bean id="patientsServiceLocal" class="com.lyms.platform.biz.service.PatientsService"></bean>--> |
52 | - | |
53 | - | |
52 | + | |
53 | + | |
54 | 54 | <!--自动分娩任务 --> |
55 | 55 | <bean id="autoMatDeliverTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> |
56 | 56 | <!-- 要调用的bean --> |
... | ... | @@ -198,7 +198,7 @@ |
198 | 198 | <bean id="babyBuildClassifyTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> |
199 | 199 | <property name="jobDetail" ref="babyBuildClassifyTimerWork"></property> |
200 | 200 | <property name="cronExpression" value="0 0 3 * * ?"></property> |
201 | -<!-- <property name="cronExpression" value="*/5 * * * * ?"></property><!–测试用每5秒执行–>--> | |
201 | + <!-- <property name="cronExpression" value="*/5 * * * * ?"></property><!–测试用每5秒执行–>--> | |
202 | 202 | </bean> |
203 | 203 | |
204 | 204 | <!-- 配置一个触发器 --> |
... | ... | @@ -509,13 +509,13 @@ |
509 | 509 | |
510 | 510 | <!-- 新生儿出院诊断记录同步 --> |
511 | 511 | <bean id="autoGetBabyDiagnoseJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> |
512 | - <!-- 要调用的bean --> | |
513 | - <property name="targetObject" ref="babyBookbuildingFacade"/> | |
514 | - <!-- 要调用的Method --> | |
515 | - <property name="targetMethod" value="autoGetBabyDiagnose"/> | |
516 | - <!-- 是否并发,false表示 如果发生错误也不影响下一次的调用 --> | |
517 | - <property name="concurrent" value="false"/> | |
518 | -</bean> | |
512 | + <!-- 要调用的bean --> | |
513 | + <property name="targetObject" ref="babyBookbuildingFacade"/> | |
514 | + <!-- 要调用的Method --> | |
515 | + <property name="targetMethod" value="autoGetBabyDiagnose"/> | |
516 | + <!-- 是否并发,false表示 如果发生错误也不影响下一次的调用 --> | |
517 | + <property name="concurrent" value="false"/> | |
518 | + </bean> | |
519 | 519 | |
520 | 520 | <bean id="autoGetBabyDiagnoseJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> |
521 | 521 | <property name="jobDetail" ref="autoGetBabyDiagnoseJob"/> |
... | ... | @@ -567,7 +567,7 @@ |
567 | 567 | |
568 | 568 | <bean id="handleTrackDownTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> |
569 | 569 | <property name="jobDetail" ref="handleTrackDownJob"/> |
570 | - <property name="cronExpression" value="0 20 20 * * ? "></property> | |
570 | + <property name="cronExpression" value="0 20 8 * * ? "></property> | |
571 | 571 | </bean> |
572 | 572 | |
573 | 573 | <!-- 滦平妇幼同步mongodb数据到mysql--> |
574 | 574 | |
... | ... | @@ -638,7 +638,21 @@ |
638 | 638 | <property name="cronExpression" value="0 25 10 * * ?"></property> |
639 | 639 | <!--<property name="cronExpression" value="0/5 * * * * ? "></property>--> |
640 | 640 | </bean> |
641 | + <!--南河课程定时推送19点 --> | |
642 | + <bean id="coursesWork" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> | |
643 | + <!-- 要调用的bean --> | |
644 | + <property name="targetObject" ref="courseFacade"></property> | |
645 | + <!-- 要调用的Method --> | |
646 | + <property name="targetMethod" value="courseTask"></property> | |
647 | + <!-- 是否并发,false表示 如果发生错误也不影响下一次的调用 --> | |
648 | + <property name="concurrent" value="false"></property> | |
649 | + </bean> | |
641 | 650 | |
651 | + <!-- 配置一个触发器 0 0 19 * * ?--> | |
652 | + <bean id="coursesTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> | |
653 | + <property name="jobDetail" ref="coursesWork"></property> | |
654 | + <property name="cronExpression" value="0 0 19 * * ?"></property> | |
655 | + </bean> | |
642 | 656 | |
643 | 657 | |
644 | 658 | |
... | ... | @@ -677,7 +691,7 @@ |
677 | 691 | |
678 | 692 | <ref bean="autoGetSieveTrigger" /> |
679 | 693 | <ref bean="genWeightTrigger" /> |
680 | - <ref bean="handleTrackDownTrigger" /> | |
694 | + <!-- <ref bean="handleTrackDownTrigger" />--> | |
681 | 695 | |
682 | 696 | <!--<ref bean="patientRiskTrigger"/>--> |
683 | 697 | <!--<ref bean="babyRiskTrigger"/>--> |
... | ... | @@ -705,6 +719,8 @@ |
705 | 719 | <!--<ref bean="zcChanJianTrigger"/>--> |
706 | 720 | <ref bean="patientSerivceEndJobTrigger"/> |
707 | 721 | <ref bean="babyBuildClassifyTrigger"/> |
722 | + <!-- 南和课程发布19点推送--> | |
723 | + <ref bean="coursesTrigger"/> | |
708 | 724 | </list> |
709 | 725 | </property> |
710 | 726 | </bean> |