Commit fd10794bcec0705e9d8c19921f09a812679ce2e0
1 parent
303ce292ac
Exists in
master
and in
6 other branches
update code
Showing 5 changed files with 105 additions and 41 deletions
- platform-dal/src/main/java/com/lyms/platform/pojo/SmsConfigModel.java
- platform-dal/src/main/java/com/lyms/platform/pojo/SmsTemplateModel.java
- platform-msg-generate/src/main/java/com/lyms/platform/msg/service/impl/MsgGenerateServiceImpl.java
- platform-msg-generate/src/main/java/com/lyms/platform/msg/utils/HelperUtils.java
- platform-msg-generate/src/main/java/com/lyms/platform/msg/worker/TempleteMsgGenerateWorker.java
platform-dal/src/main/java/com/lyms/platform/pojo/SmsConfigModel.java
View file @
fd10794
| ... | ... | @@ -171,5 +171,24 @@ |
| 171 | 171 | public void setYn(Integer yn) { |
| 172 | 172 | this.yn = yn; |
| 173 | 173 | } |
| 174 | + | |
| 175 | + @Override | |
| 176 | + public String toString() { | |
| 177 | + return "SmsConfigModel{" + | |
| 178 | + "id='" + id + '\'' + | |
| 179 | + ", prefixType=" + prefixType + | |
| 180 | + ", hospitalPrefix='" + hospitalPrefix + '\'' + | |
| 181 | + ", deptPrefix='" + deptPrefix + '\'' + | |
| 182 | + ", guideTime='" + guideTime + '\'' + | |
| 183 | + ", smsService='" + smsService + '\'' + | |
| 184 | + ", created=" + created + | |
| 185 | + ", modified=" + modified + | |
| 186 | + ", createId='" + createId + '\'' + | |
| 187 | + ", yn=" + yn + | |
| 188 | + ", hospitalId='" + hospitalId + '\'' + | |
| 189 | + ", highConfig='" + highConfig + '\'' + | |
| 190 | + ", remark='" + remark + '\'' + | |
| 191 | + '}'; | |
| 192 | + } | |
| 174 | 193 | } |
platform-dal/src/main/java/com/lyms/platform/pojo/SmsTemplateModel.java
View file @
fd10794
| ... | ... | @@ -206,5 +206,26 @@ |
| 206 | 206 | public void setModified(Date modified) { |
| 207 | 207 | this.modified = modified; |
| 208 | 208 | } |
| 209 | + | |
| 210 | + @Override | |
| 211 | + public String toString() { | |
| 212 | + return "SmsTemplateModel{" + | |
| 213 | + "id='" + id + '\'' + | |
| 214 | + ", serviceObj=" + serviceObj + | |
| 215 | + ", serviceType=" + serviceType + | |
| 216 | + ", serviceStatus=" + serviceStatus + | |
| 217 | + ", smsType=" + smsType + | |
| 218 | + ", sendFrequency=" + sendFrequency + | |
| 219 | + ", sendDateType=" + sendDateType + | |
| 220 | + ", sendDate=" + sendDate + | |
| 221 | + ", specialDateType=" + specialDateType + | |
| 222 | + ", start=" + start + | |
| 223 | + ", end=" + end + | |
| 224 | + ", sendTimeType=" + sendTimeType + | |
| 225 | + ", hospitalId='" + hospitalId + '\'' + | |
| 226 | + ", status=" + status + | |
| 227 | + ", yn=" + yn + | |
| 228 | + '}'; | |
| 229 | + } | |
| 209 | 230 | } |
platform-msg-generate/src/main/java/com/lyms/platform/msg/service/impl/MsgGenerateServiceImpl.java
View file @
fd10794
| ... | ... | @@ -55,6 +55,7 @@ |
| 55 | 55 | public void generatePatAmsMsg(String generateHospitalId) { |
| 56 | 56 | String week = DateUtils.getWeekOfDate(new Date()); |
| 57 | 57 | List<SmsConfigModel> configModels = baseService.getHospitalConfigsByWeek(generateHospitalId); |
| 58 | + logger.info("The configs hospital size is {}",configModels.size()); | |
| 58 | 59 | if (CollectionUtils.isNotEmpty(configModels)) |
| 59 | 60 | { |
| 60 | 61 | int batchSize = 5; |
platform-msg-generate/src/main/java/com/lyms/platform/msg/utils/HelperUtils.java
View file @
fd10794
| ... | ... | @@ -15,7 +15,6 @@ |
| 15 | 15 | import org.slf4j.Logger; |
| 16 | 16 | import org.slf4j.LoggerFactory; |
| 17 | 17 | |
| 18 | -import java.util.Calendar; | |
| 19 | 18 | import java.util.Date; |
| 20 | 19 | import java.util.List; |
| 21 | 20 | import java.util.Map; |
| ... | ... | @@ -268,7 +267,7 @@ |
| 268 | 267 | if (end > msgs.size()) { |
| 269 | 268 | end = msgs.size(); |
| 270 | 269 | } |
| 271 | - System.out.println(DateUtil.getyyyy_MM_dd_hms(new Date())+"start:" + i + ",end:" + end); | |
| 270 | + logger.info("start:" + i + ",end:" + end); | |
| 272 | 271 | List<MessageRequest> tempList = msgs.subList(i, end); |
| 273 | 272 | MessageListRequest sentList = new MessageListRequest(); |
| 274 | 273 | sentList.setMessages(tempList); |
platform-msg-generate/src/main/java/com/lyms/platform/msg/worker/TempleteMsgGenerateWorker.java
View file @
fd10794
| ... | ... | @@ -20,18 +20,18 @@ |
| 20 | 20 | import org.slf4j.LoggerFactory; |
| 21 | 21 | |
| 22 | 22 | import java.util.*; |
| 23 | +import java.util.concurrent.ExecutorService; | |
| 24 | +import java.util.concurrent.Executors; | |
| 23 | 25 | |
| 24 | 26 | /** |
| 25 | 27 | * Created by lqy on 2017-07-18. |
| 26 | 28 | */ |
| 27 | 29 | public class TempleteMsgGenerateWorker implements Runnable { |
| 28 | 30 | |
| 29 | - | |
| 30 | 31 | private static final Logger logger = LoggerFactory.getLogger(TempleteMsgGenerateWorker.class); |
| 31 | - private static final Logger errorLogger = LoggerFactory.getLogger("Error"); | |
| 32 | 32 | |
| 33 | + private static ExecutorService pool = Executors.newFixedThreadPool(10); | |
| 33 | 34 | |
| 34 | - | |
| 35 | 35 | private List<SmsConfigModel> configs; |
| 36 | 36 | |
| 37 | 37 | private IBaseService baseService; |
| 38 | 38 | |
| ... | ... | @@ -66,9 +66,9 @@ |
| 66 | 66 | //启用状态 0未启用 1启用 |
| 67 | 67 | tempQuery.setStatus(1); |
| 68 | 68 | |
| 69 | - for(SmsConfigModel config : configs) { | |
| 70 | - | |
| 69 | + for(final SmsConfigModel config : configs) { | |
| 71 | 70 | String hospitalId = config.getHospitalId(); |
| 71 | + logger.info("genernate tempplate hospital id = "+hospitalId); | |
| 72 | 72 | if (StringUtils.isEmpty(hospitalId)) |
| 73 | 73 | { |
| 74 | 74 | continue; |
| 75 | 75 | |
| 76 | 76 | |
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | |
| 82 | 82 | |
| ... | ... | @@ -89,48 +89,72 @@ |
| 89 | 89 | continue; |
| 90 | 90 | } |
| 91 | 91 | try { |
| 92 | - //循环每一个模板,根据模板条件查询到用户 发送短信 | |
| 93 | - for (SmsTemplateModel template : templates) | |
| 94 | - { | |
| 95 | 92 | |
| 96 | - //模板属于的医院id | |
| 97 | - String tempHid = template.getHospitalId(); | |
| 98 | - //服务对象1孕妇 2儿童 3产妇 | |
| 99 | - Integer serviceObj = template.getServiceObj(); | |
| 93 | + int batchSize = 5; | |
| 94 | + int end = 0; | |
| 95 | + for (int i = 0; i < templates.size(); i += batchSize) { | |
| 96 | + end = (end + batchSize); | |
| 97 | + if (end > templates.size()) { | |
| 98 | + end = templates.size(); | |
| 99 | + } | |
| 100 | + final List<SmsTemplateModel> items = templates.subList(i, end); | |
| 101 | + pool.submit(new Runnable() { | |
| 102 | + @Override | |
| 103 | + public void run() { | |
| 100 | 104 | |
| 101 | - //消息类型 | |
| 102 | - Integer smsType = template.getSmsType(); | |
| 105 | + //循环每一个模板,根据模板条件查询到用户 发送短信 | |
| 106 | + for (SmsTemplateModel template : items) | |
| 107 | + { | |
| 108 | + try { | |
| 109 | + //模板属于的医院id | |
| 110 | + String tempHid = template.getHospitalId(); | |
| 111 | + //服务对象1孕妇 2儿童 3产妇 | |
| 112 | + Integer serviceObj = template.getServiceObj(); | |
| 103 | 113 | |
| 104 | - if (tempHid == null || serviceObj == null) { | |
| 105 | - continue; | |
| 106 | - } | |
| 114 | + //消息类型 | |
| 115 | + Integer smsType = template.getSmsType(); | |
| 107 | 116 | |
| 108 | - //false 表示该服务没有启动 smsType为消息类型 | |
| 109 | - boolean isStart = HelperUtils.isStartTemplate(config, smsType); | |
| 110 | - if (!isStart) { | |
| 111 | - continue; | |
| 112 | - } | |
| 117 | + if (tempHid == null || serviceObj == null) { | |
| 118 | + continue; | |
| 119 | + } | |
| 113 | 120 | |
| 114 | - //孕妇 | |
| 115 | - if (serviceObj == ServiceObjEnums.YUNOBJ.getId()) | |
| 116 | - { | |
| 117 | - generateYunTempMsg(template,config); | |
| 118 | - } | |
| 119 | - //儿童 | |
| 120 | - else if (serviceObj == ServiceObjEnums.BABYOBJ.getId()) | |
| 121 | - { | |
| 122 | - generateChildTempMsg(template, config); | |
| 123 | - } | |
| 124 | - //产妇 | |
| 125 | - else if (serviceObj == ServiceObjEnums.CHANOBJ.getId()) | |
| 126 | - { | |
| 121 | + //false 表示该服务没有启动 smsType为消息类型 | |
| 122 | + boolean isStart = HelperUtils.isStartTemplate(config, smsType); | |
| 123 | + if (!isStart) { | |
| 124 | + continue; | |
| 125 | + } | |
| 127 | 126 | |
| 128 | - } | |
| 127 | + //孕妇 | |
| 128 | + if (serviceObj == ServiceObjEnums.YUNOBJ.getId()) | |
| 129 | + { | |
| 130 | + generateYunTempMsg(template,config); | |
| 131 | + } | |
| 132 | + //儿童 | |
| 133 | + else if (serviceObj == ServiceObjEnums.BABYOBJ.getId()) | |
| 134 | + { | |
| 135 | + generateChildTempMsg(template, config); | |
| 136 | + } | |
| 137 | + //产妇 | |
| 138 | + else if (serviceObj == ServiceObjEnums.CHANOBJ.getId()) | |
| 139 | + { | |
| 140 | + | |
| 141 | + } | |
| 142 | + } | |
| 143 | + catch (Exception e) | |
| 144 | + { | |
| 145 | + ExceptionUtils.catchException(e,"genernate templete error. ["+template.toString()+"]"); | |
| 146 | + continue; | |
| 147 | + } | |
| 148 | + } | |
| 149 | + } | |
| 150 | + }); | |
| 129 | 151 | } |
| 152 | + | |
| 153 | + | |
| 130 | 154 | } |
| 131 | 155 | catch (Exception e) |
| 132 | 156 | { |
| 133 | - ExceptionUtils.catchException(e,"gen templete error."); | |
| 157 | + ExceptionUtils.catchException(e,"genernate config error.["+config.toString()+"]"); | |
| 134 | 158 | continue; |
| 135 | 159 | } |
| 136 | 160 | } |