Commit 8ab25fd5af3b7744591ae3ade09d59230f9a19ec
1 parent
8f33209fa2
Exists in
master
and in
8 other branches
发送特殊短信
Showing 2 changed files with 115 additions and 7 deletions
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java
View file @
8ab25fd
... | ... | @@ -11,6 +11,8 @@ |
11 | 11 | import com.lyms.platform.common.dao.operator.MongoCondition; |
12 | 12 | import com.lyms.platform.common.dao.operator.MongoOper; |
13 | 13 | import com.lyms.platform.common.dao.operator.MongoQuery; |
14 | +import com.lyms.platform.common.enums.ServiceStatusEnums; | |
15 | +import com.lyms.platform.common.enums.ServiceTypeEnums; | |
14 | 16 | import com.lyms.platform.common.enums.YnEnums; |
15 | 17 | import com.lyms.platform.common.pojo.SyncDataModel; |
16 | 18 | import com.lyms.platform.common.utils.*; |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/SmsConfigController.java
View file @
8ab25fd
1 | 1 | package com.lyms.platform.operate.web.controller; |
2 | 2 | |
3 | +import com.lyms.platform.biz.service.BabyBookbuildingService; | |
4 | +import com.lyms.platform.biz.service.SmsTemplateService; | |
3 | 5 | import com.lyms.platform.common.base.BaseController; |
4 | 6 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
5 | -import com.lyms.platform.common.enums.SendTimeEnums; | |
6 | -import com.lyms.platform.common.enums.SmsServiceEnums; | |
7 | +import com.lyms.platform.common.enums.*; | |
7 | 8 | import com.lyms.platform.common.result.BaseObjectResponse; |
8 | 9 | import com.lyms.platform.common.result.BaseResponse; |
10 | +import com.lyms.platform.common.utils.DateUtil; | |
11 | +import com.lyms.platform.common.utils.ExceptionUtils; | |
9 | 12 | import com.lyms.platform.common.utils.JsonUtil; |
10 | 13 | import com.lyms.platform.common.utils.StringUtils; |
11 | 14 | import com.lyms.platform.operate.web.facade.SmsConfigFacade; |
15 | +import com.lyms.platform.operate.web.request.MessageListRequest; | |
16 | +import com.lyms.platform.operate.web.request.MessageRequest; | |
12 | 17 | import com.lyms.platform.operate.web.request.SmsConfigRequest; |
18 | +import com.lyms.platform.operate.web.utils.MessageCenterService; | |
19 | +import com.lyms.platform.pojo.BabyModel; | |
20 | +import com.lyms.platform.pojo.Patients; | |
21 | +import com.lyms.platform.pojo.SmsConfigModel; | |
22 | +import com.lyms.platform.pojo.SmsTemplateModel; | |
23 | +import com.lyms.platform.query.BabyModelQuery; | |
24 | +import com.lyms.platform.query.PatientsQuery; | |
25 | +import com.lyms.platform.query.SmsTemplateQuery; | |
26 | +import org.apache.commons.collections.CollectionUtils; | |
13 | 27 | import org.springframework.beans.factory.annotation.Autowired; |
28 | +import org.springframework.data.mongodb.core.query.Query; | |
14 | 29 | import org.springframework.stereotype.Controller; |
15 | 30 | import org.springframework.web.bind.annotation.*; |
16 | 31 | |
17 | 32 | import javax.validation.Valid; |
18 | -import java.util.ArrayList; | |
19 | -import java.util.HashMap; | |
20 | -import java.util.List; | |
21 | -import java.util.Map; | |
33 | +import java.util.*; | |
22 | 34 | |
23 | 35 | |
24 | 36 | /** |
... | ... | @@ -31,6 +43,12 @@ |
31 | 43 | @Autowired |
32 | 44 | private SmsConfigFacade smsConfigFacade; |
33 | 45 | |
46 | + @Autowired | |
47 | + private BabyBookbuildingService babyBookbuildingService; | |
48 | + | |
49 | + @Autowired | |
50 | + private SmsTemplateService smsTemplateService; | |
51 | + | |
34 | 52 | /** |
35 | 53 | * 添加/更新 短信服务配置 |
36 | 54 | * @param request |
37 | 55 | |
... | ... | @@ -190,7 +208,95 @@ |
190 | 208 | @RequestParam(required = false) String actualTime, |
191 | 209 | @RequestParam(required = false) Integer page, |
192 | 210 | @RequestParam(required = false) Integer limit) { |
193 | - return smsConfigFacade.querySmsList(hospitalName, phone, smsType, smsStatus, content,planTime,actualTime,objType, page, limit); | |
211 | + return smsConfigFacade.querySmsList(hospitalName, phone, smsType, smsStatus, content, planTime, actualTime, objType, page, limit); | |
194 | 212 | } |
213 | + | |
214 | + | |
215 | + @RequestMapping(value = "/sendBabyBuildSms", method = RequestMethod.GET) | |
216 | + @ResponseBody | |
217 | + public String sendBabyBuildSms() { | |
218 | + BabyModelQuery babyModelQuery = new BabyModelQuery(); | |
219 | + List<String> hospitalIds = new ArrayList<>(); | |
220 | + hospitalIds.add("204");//青龙满族自治县医院 | |
221 | + hospitalIds.add("197");//抚宁县妇幼保健院 | |
222 | + hospitalIds.add("248");//北戴河医院 | |
223 | + | |
224 | + babyModelQuery.setServiceType(ServiceTypeEnums.ADD_SERVICE.getId());//增值服务 | |
225 | + babyModelQuery.setServiceStatus(ServiceStatusEnums.ADD_OPEN.getId());//开通 | |
226 | + babyModelQuery.setYn(YnEnums.YES.getId()); | |
227 | + Date startDate = DateUtil.parseYMD("2016-11-01"); | |
228 | + Date startEnd = DateUtil.parseYMD("2016-11-30"); | |
229 | + babyModelQuery.setBuildDateStart(startDate); | |
230 | + babyModelQuery.setBuildDateEnd(startEnd); | |
231 | + for (String hid:hospitalIds) { | |
232 | + if (hid != null) { | |
233 | + //判断医院是否启动和对应的服务项是否启用 | |
234 | + SmsConfigModel configModel = new SmsConfigModel(); | |
235 | + BaseResponse response = smsConfigFacade.hospitalIsStart(hid, configModel, SmsServiceEnums.FWKT.getId()); | |
236 | + if (response != null) { | |
237 | + continue; | |
238 | + } | |
239 | + | |
240 | + SmsTemplateQuery query = new SmsTemplateQuery(); | |
241 | + query.setYn(YnEnums.YES.getId()); | |
242 | + query.setStatus(1); | |
243 | + query.setHospitalId(hid); | |
244 | + query.setServiceObj(ServiceObjEnums.BABYOBJ.getId()); | |
245 | + query.setSpecialDateType(SpecialDateEnums.JD.getId()); | |
246 | + | |
247 | + //查询建档短信服务模板 | |
248 | + List<SmsTemplateModel> temps = smsTemplateService.querySmsTemplates(query); | |
249 | + if (CollectionUtils.isNotEmpty(temps)) { | |
250 | + SmsTemplateModel templateModel = temps.get(0); | |
251 | + babyModelQuery.setHospitalId(hid); | |
252 | + //查询医院符合条件的儿童 | |
253 | + List<BabyModel> list = babyBookbuildingService.queryBabyBuildByCond(babyModelQuery); | |
254 | + if (CollectionUtils.isNotEmpty(list)) { | |
255 | + | |
256 | + for (BabyModel babyModel : list) | |
257 | + { | |
258 | + //短信前缀 | |
259 | + String messagePrefix = configModel.getHospitalPrefix(); | |
260 | + if (templateModel != null && templateModel.getStatus() == 1) { | |
261 | + MessageListRequest smsList = new MessageListRequest(); | |
262 | + List<MessageRequest> messages = new ArrayList<>(); | |
263 | + MessageRequest mr = new MessageRequest(); | |
264 | + String content = "【" + messagePrefix + "】" + templateModel.getContent(); | |
265 | + mr.setContent(StringUtils.replaceBaby(babyModel.getName(), babyModel.getBirth(), content)); | |
266 | + mr.setObjType(ServiceObjEnums.BABYOBJ.getId()); | |
267 | + mr.setPhone(babyModel.getMphone()); | |
268 | + //短信商 | |
269 | + mr.setServiceType(SmsProviderEnums.YM.getId()); | |
270 | + mr.setTypeId(ProjectTypeEnums.YNXT.getId()); | |
271 | + mr.setPlanTime(DateUtil.getyyyy_MM_dd_hms(new Date())); | |
272 | + mr.setSubTypeId(SmsServiceEnums.FWKT.getId()); | |
273 | + mr.setStatus(SmsStatusEnums.WFS.getId()); | |
274 | + mr.setTimeType(SmsTimeTypeEnums.ONTIME.getId()); | |
275 | + | |
276 | + mr.setExt1(hid); | |
277 | + mr.setExt2(templateModel.getId()); | |
278 | + mr.setExt3(babyModel.getId()); | |
279 | + messages.add(mr); | |
280 | + | |
281 | + if (CollectionUtils.isNotEmpty(messages)) { | |
282 | + smsList.setTypeId(ProjectTypeEnums.YNXT.getId()); | |
283 | + smsList.setMessages(messages); | |
284 | + | |
285 | + for (MessageRequest msg : messages) | |
286 | + { | |
287 | + System.out.println("phone="+msg.getPhone()+" | content="+msg.getContent()); | |
288 | + } | |
289 | + //这行代码是保存到短信中心 ,config.properties中配置了短信中心地址 线上环境地址是(http://sms.healthbaby.com.cn/v1/) | |
290 | + // MessageCenterService.saveSmsCenter(smsList); | |
291 | + } | |
292 | + } | |
293 | + } | |
294 | + } | |
295 | + } | |
296 | + } | |
297 | + } | |
298 | + return "sendBabyBuildSms finish"; | |
299 | + } | |
300 | + | |
195 | 301 | } |