Commit 3266f906f0fae12900e778cdb16dac8ae9a5b9c2
1 parent
7c4f450020
Exists in
master
and in
8 other branches
config
Showing 6 changed files with 139 additions and 33 deletions
- platform-data-api/src/main/resources/spring/applicationContext-quartz.xml
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/SmsConfigFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/Config.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/ConfigTask.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MessageCenterService.java
platform-data-api/src/main/resources/spring/applicationContext-quartz.xml
View file @
3266f90
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
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 | |
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 | |
9 | + http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd | |
10 | + http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd"> | |
11 | + | |
12 | + <bean id="startWorkJob" class="com.lyms.platform.data.service.impl.SmsServiceImpl"></bean> | |
13 | + <!-- 配置任务的具体类和方法 --> | |
14 | + <bean id="startWorkTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> | |
15 | + <!-- 要调用的bean --> | |
16 | + <property name="targetObject" ref="startWorkJob"></property> | |
17 | + <!-- 要调用的Method --> | |
18 | + <property name="targetMethod" value="productTemplateSms"></property> | |
19 | + <!-- 是否并发,false表示 如果发生错误也不影响下一次的调用 --> | |
20 | + <property name="concurrent" value="false"></property> | |
21 | + </bean> | |
22 | + <!-- 配置一个触发器 --> | |
23 | + <bean id="startWorkTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> | |
24 | + <property name="jobDetail" ref="startWorkTask"></property> | |
25 | + <property name="cronExpression" value="0 * 18 * * ?"></property> <!--每天的下午1点的每分钟的0秒都执行一次--> | |
26 | + </bean> | |
27 | + | |
28 | + <!-- 总调度,用于启动定时器 --> | |
29 | + <bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> | |
30 | + <property name="triggers" > | |
31 | + <list> | |
32 | + <ref bean="startWorkTrigger"/> | |
33 | + </list> | |
34 | + </property> | |
35 | + </bean> | |
36 | +</beans> |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java
View file @
3266f90
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/SmsConfigFacade.java
View file @
3266f90
... | ... | @@ -11,6 +11,7 @@ |
11 | 11 | import com.lyms.platform.common.utils.SystemConfig; |
12 | 12 | import com.lyms.platform.operate.web.request.SmsConfigRequest; |
13 | 13 | import com.lyms.platform.operate.web.result.*; |
14 | +import com.lyms.platform.operate.web.utils.ConfigTask; | |
14 | 15 | import com.lyms.platform.permission.model.Departments; |
15 | 16 | import com.lyms.platform.permission.model.DepartmentsQuery; |
16 | 17 | import com.lyms.platform.permission.model.Organization; |
... | ... | @@ -54,37 +55,7 @@ |
54 | 55 | SmsConfigModel model = getSmsConfigModel(request); |
55 | 56 | model.setModified(new Date()); |
56 | 57 | |
57 | - List<Map<String, String>> resultServices = new ArrayList<>(); | |
58 | - | |
59 | - List<Map<String,String>> allServices = SmsServiceEnums.getSmsServiceLeaf(); | |
60 | - List<Map<String, String>> paramServices = request.getSmsService(); | |
61 | - | |
62 | - resultServices.addAll(paramServices); | |
63 | - for (Map<String, String> all : allServices) | |
64 | - { | |
65 | - String id = String.valueOf(all.get("id")); | |
66 | - boolean isExist = false; | |
67 | - for (Map<String, String> start : paramServices) | |
68 | - { | |
69 | - Set<String> keys = start.keySet(); | |
70 | - for(String key : keys) | |
71 | - { | |
72 | - if (id != null && id.equals(key)) | |
73 | - { | |
74 | - isExist = true; | |
75 | - } | |
76 | - } | |
77 | - | |
78 | - } | |
79 | - if (!isExist) | |
80 | - { | |
81 | - Map<String, String> result = new HashMap<>(); | |
82 | - result.put(id, "false"); | |
83 | - resultServices.add(result); | |
84 | - } | |
85 | - } | |
86 | - | |
87 | - | |
58 | + new Thread(new ConfigTask(request.getSmsService(),request.getHospitalId())).start(); | |
88 | 59 | |
89 | 60 | smsConfigService.updateSmsConfig(model, request.getId()); |
90 | 61 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/Config.java
View file @
3266f90
1 | +package com.lyms.platform.operate.web.result; | |
2 | + | |
3 | +/** | |
4 | + * Created by Administrator on 2016/8/9. | |
5 | + */ | |
6 | +public class Config { | |
7 | + | |
8 | + private String key; | |
9 | + private String value; | |
10 | + | |
11 | + public String getKey() { | |
12 | + return key; | |
13 | + } | |
14 | + | |
15 | + public void setKey(String key) { | |
16 | + this.key = key; | |
17 | + } | |
18 | + | |
19 | + public String getValue() { | |
20 | + return value; | |
21 | + } | |
22 | + | |
23 | + public void setValue(String value) { | |
24 | + this.value = value; | |
25 | + } | |
26 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/ConfigTask.java
View file @
3266f90
1 | +package com.lyms.platform.operate.web.utils; | |
2 | + | |
3 | +import com.lyms.platform.common.enums.SmsServiceEnums; | |
4 | +import com.lyms.platform.operate.web.result.Config; | |
5 | +import org.apache.commons.collections.CollectionUtils; | |
6 | + | |
7 | +import java.util.ArrayList; | |
8 | +import java.util.List; | |
9 | +import java.util.Map; | |
10 | +import java.util.Set; | |
11 | + | |
12 | +/** | |
13 | + * Created by Administrator on 2016/8/9. | |
14 | + */ | |
15 | +public class ConfigTask implements Runnable { | |
16 | + private List<Map<String, String>> paramServices; | |
17 | + private String hid; | |
18 | + public ConfigTask(List<Map<String, String>> paramServices,String hid) | |
19 | + { | |
20 | + this.paramServices = paramServices; | |
21 | + this.hid = hid; | |
22 | + } | |
23 | + | |
24 | + @Override | |
25 | + public void run() { | |
26 | + List<Config> resultServices = new ArrayList<>(); | |
27 | + | |
28 | + List<Map<String,String>> allServices = SmsServiceEnums.getSmsServiceLeaf(); | |
29 | + | |
30 | + if (CollectionUtils.isNotEmpty(paramServices)) | |
31 | + { | |
32 | + for (Map<String, String> start : paramServices) | |
33 | + { | |
34 | + Config config = new Config(); | |
35 | + Set<String> keys = start.keySet(); | |
36 | + for(String key : keys) | |
37 | + { | |
38 | + config.setKey(key); | |
39 | + config.setValue(start.get(key)); | |
40 | + } | |
41 | + resultServices.add(config); | |
42 | + } | |
43 | + } | |
44 | + | |
45 | + for (Map<String, String> all : allServices) | |
46 | + { | |
47 | + String id = String.valueOf(all.get("id")); | |
48 | + boolean isExist = false; | |
49 | + for (Map<String, String> start : paramServices) | |
50 | + { | |
51 | + Set<String> keys = start.keySet(); | |
52 | + for(String key : keys) | |
53 | + { | |
54 | + if (id != null && id.equals(key)) | |
55 | + { | |
56 | + isExist = true; | |
57 | + } | |
58 | + } | |
59 | + | |
60 | + } | |
61 | + if (!isExist) | |
62 | + { | |
63 | + Config config = new Config(); | |
64 | + config.setKey(id); | |
65 | + config.setValue("false"); | |
66 | + resultServices.add(config); | |
67 | + } | |
68 | + } | |
69 | + | |
70 | + MessageCenterService.serviceConfig(resultServices,hid); | |
71 | + } | |
72 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MessageCenterService.java
View file @
3266f90
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | import com.lyms.platform.common.utils.PropertiesUtils; |
7 | 7 | import com.lyms.platform.common.utils.StringUtils; |
8 | 8 | import com.lyms.platform.operate.web.request.MessageListRequest; |
9 | +import com.lyms.platform.operate.web.result.Config; | |
9 | 10 | |
10 | 11 | import java.util.List; |
11 | 12 | import java.util.Map; |
... | ... | @@ -23,7 +24,7 @@ |
23 | 24 | * @param hid |
24 | 25 | * @return |
25 | 26 | */ |
26 | - public static boolean serviceConfig(List<Map<String,String>> configs,String hid) | |
27 | + public static boolean serviceConfig(List<Config> configs,String hid) | |
27 | 28 | { |
28 | 29 | String json = JsonUtil.obj2JsonString(configs); |
29 | 30 | String result = HttpRequest.sendPost(CENTER_BASE_URL+"serviceConfig/{"+hid+"}", json, CENTER_TOKEN); |