Commit e2ee872a878ff86742a45986733270077446597b

Authored by liquanyu
1 parent 64fa82b361

短信模板

Showing 4 changed files with 53 additions and 20 deletions

platform-msg-generate/src/main/java/com/lyms/platform/msg/service/IBaseService.java View file @ e2ee872
... ... @@ -30,5 +30,7 @@
30 30 public String getSmsPrefix(SmsConfigModel config,String doctorId,int objType);
31 31  
32 32 public Set<String> getYuYuePatient(Integer sendTimeType,String tempHid);
  33 +
  34 + public boolean isSendTemplate(Integer templateType,Integer serviceType);
33 35 }
platform-msg-generate/src/main/java/com/lyms/platform/msg/service/impl/BaseServiceImpl.java View file @ e2ee872
... ... @@ -169,13 +169,33 @@
169 169 }
170 170 }
171 171 }
172   -// List<AntenatalExaminationModel> fuzs = antenatalExaminationService.queryYuyueAntenatalExamination(yuYueDate, tempHid);
173   -//
174   -// for (AntenatalExaminationModel f : fuzs)
175   -// {
176   -// idset.add(f.getId()); //这里的id就是parentid
177   -// }
178 172 return idset;
  173 + }
  174 +
  175 + /**
  176 + * 判断模板类型是否发送,根据服务类型
  177 + * @param templateType 模板类型 0 推送 1 短信
  178 + * @param serviceType 1 推送服务, 2 推送和短信服务 3短信服务,
  179 + * @return true 发送,false 不发送
  180 + */
  181 + @Override
  182 + public boolean isSendTemplate(Integer templateType, Integer serviceType) {
  183 + //推送类型模板
  184 + if (templateType == null || templateType == 0)
  185 + {
  186 + //发送推送类模板建档
  187 + if (serviceType == 3)
  188 + {
  189 + return false;
  190 + }
  191 + }
  192 + //发送短信类模板建档
  193 + else if(templateType == 1 && serviceType == 1)
  194 + {
  195 + return false;
  196 + }
  197 +
  198 + return true;
179 199 }
180 200  
181 201 /**
platform-msg-generate/src/main/java/com/lyms/platform/msg/service/impl/MsgGenerateServiceImpl.java View file @ e2ee872
... ... @@ -30,6 +30,7 @@
30 30  
31 31 private static final Logger logger = LoggerFactory.getLogger(MsgGenerateServiceImpl.class);
32 32  
  33 + private static final int DEFAULT_BATCH_SIZE = 20;
33 34  
34 35 private static ExecutorService pool = Executors.newFixedThreadPool(20);
35 36  
36 37  
... ... @@ -64,10 +65,9 @@
64 65 logger.info("The generatePatAmsMsg configs hospital size is {}",configModels.size());
65 66 if (CollectionUtils.isNotEmpty(configModels))
66 67 {
67   - int batchSize = 10;
68 68 int end = 0;
69   - for (int i = 0; i < configModels.size(); i += batchSize) {
70   - end = (end + batchSize);
  69 + for (int i = 0; i < configModels.size(); i += DEFAULT_BATCH_SIZE) {
  70 + end = (end + DEFAULT_BATCH_SIZE);
71 71 if (end > configModels.size()) {
72 72 end = configModels.size();
73 73 }
74 74  
... ... @@ -90,10 +90,9 @@
90 90 logger.info("The generateBabyAmsMsg configs hospital size is {}",configModels.size());
91 91 if (CollectionUtils.isNotEmpty(configModels))
92 92 {
93   - int batchSize = 10;
94 93 int end = 0;
95   - for (int i = 0; i < configModels.size(); i += batchSize) {
96   - end = (end + batchSize);
  94 + for (int i = 0; i < configModels.size(); i += DEFAULT_BATCH_SIZE) {
  95 + end = (end + DEFAULT_BATCH_SIZE);
97 96 if (end > configModels.size()) {
98 97 end = configModels.size();
99 98 }
100 99  
... ... @@ -116,10 +115,9 @@
116 115 logger.info("The generateChanAmsMsg configs hospital size is {}",configModels.size());
117 116 if (CollectionUtils.isNotEmpty(configModels))
118 117 {
119   - int batchSize = 10;
120 118 int end = 0;
121   - for (int i = 0; i < configModels.size(); i += batchSize) {
122   - end = (end + batchSize);
  119 + for (int i = 0; i < configModels.size(); i += DEFAULT_BATCH_SIZE) {
  120 + end = (end + DEFAULT_BATCH_SIZE);
123 121 if (end > configModels.size()) {
124 122 end = configModels.size();
125 123 }
126 124  
... ... @@ -142,10 +140,9 @@
142 140 logger.info("The generateChanAmsMsg configs hospital size is {}",configModels.size());
143 141 if (CollectionUtils.isNotEmpty(configModels))
144 142 {
145   - int batchSize = 10;
146 143 int end = 0;
147   - for (int i = 0; i < configModels.size(); i += batchSize) {
148   - end = (end + batchSize);
  144 + for (int i = 0; i < configModels.size(); i += DEFAULT_BATCH_SIZE) {
  145 + end = (end + DEFAULT_BATCH_SIZE);
149 146 if (end > configModels.size()) {
150 147 end = configModels.size();
151 148 }
platform-msg-generate/src/main/java/com/lyms/platform/msg/worker/TempleteMsgGenerateWorker.java View file @ e2ee872
... ... @@ -83,7 +83,7 @@
83 83 tempQuery.setHospitalId(hospitalId);
84 84 List<SmsTemplateModel> templates = smsTemplateService.querySmsTemplates(tempQuery);
85 85  
86   - if (!CollectionUtils.isNotEmpty(templates))
  86 + if (CollectionUtils.isEmpty(templates))
87 87 {
88 88 continue;
89 89 }
90 90  
... ... @@ -97,10 +97,15 @@
97 97 end = templates.size();
98 98 }
99 99 final List<SmsTemplateModel> items = templates.subList(i, end);
100   - pool.submit(new Runnable() {
  100 + pool.execute(new Runnable() {
101 101 @Override
102 102 public void run() {
103 103  
  104 + if (CollectionUtils.isEmpty(items))
  105 + {
  106 + return;
  107 + }
  108 +
104 109 //循环每一个模板,根据模板条件查询到用户 发送短信
105 110 for (SmsTemplateModel template : items)
106 111 {
... ... @@ -123,6 +128,15 @@
123 128 if (service == 0) {
124 129 continue;
125 130 }
  131 +
  132 + //判断模板是否发送
  133 + boolean isSendTemplate = baseService.isSendTemplate(template.getTemplateType(),service);
  134 + if (!isSendTemplate)
  135 + {
  136 + continue;
  137 + }
  138 +
  139 + service = (template.getTemplateType() == null || template.getTemplateType() == 0) ? 1 : 3;
126 140  
127 141 //孕妇
128 142 if (serviceObj == ServiceObjEnums.YUNOBJ.getId())