Commit 84231ad0c8734e618b3615d03e743b7a456b4f3d
1 parent
54c131a756
Exists in
master
and in
6 other branches
update code
Showing 4 changed files with 32 additions and 3 deletions
- platform-msg-generate/src/main/java/com/lyms/platform/msg/remote/AmsMessageService.java
- platform-msg-generate/src/main/java/com/lyms/platform/msg/utils/DateUtils.java
- platform-msg-generate/src/main/java/com/lyms/platform/msg/utils/HelperUtils.java
- platform-msg-generate/src/main/resources/config.properties
platform-msg-generate/src/main/java/com/lyms/platform/msg/remote/AmsMessageService.java
View file @
84231ad
| ... | ... | @@ -154,7 +154,7 @@ |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | public static void main(String[] args) { |
| 157 | - Map<String,List<MessageContent>> list = getMessageTemplateMap("202", | |
| 157 | + Map<String,List<MessageContent>> list = getMessageTemplateMap("216", | |
| 158 | 158 | AmsServiceTypeEnum.YUN_GUIDE); |
| 159 | 159 | List<MessageContent> msgs = list.get("年龄≥35岁"); |
| 160 | 160 | System.out.println(msgs); |
platform-msg-generate/src/main/java/com/lyms/platform/msg/utils/DateUtils.java
View file @
84231ad
| ... | ... | @@ -245,5 +245,30 @@ |
| 245 | 245 | return 0; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | + | |
| 249 | + /** | |
| 250 | + * 获取两个日期相差几个月 | |
| 251 | + * @param start | |
| 252 | + * @param end | |
| 253 | + * @return | |
| 254 | + */ | |
| 255 | + public static int getBetweenMonths(Date start, Date end) { | |
| 256 | + int result = 0; | |
| 257 | + try { | |
| 258 | + Calendar c1 = Calendar.getInstance(); | |
| 259 | + Calendar c2 = Calendar.getInstance(); | |
| 260 | + c1.setTime(start); | |
| 261 | + c2.setTime(end); | |
| 262 | + result = c2.get(Calendar.MONTH) - c1.get(Calendar.MONTH); | |
| 263 | + result += 12 * (c2.get(Calendar.YEAR) - c1.get(Calendar.YEAR)); | |
| 264 | + if(c2.get(Calendar.DAY_OF_MONTH) - c1.get(Calendar.DAY_OF_MONTH) < 0 && result > 0) { | |
| 265 | + result -= 1; | |
| 266 | + } | |
| 267 | + } catch (Exception e) { | |
| 268 | + e.printStackTrace(); | |
| 269 | + } | |
| 270 | + return Math.abs(result); | |
| 271 | + } | |
| 272 | + | |
| 248 | 273 | } |
platform-msg-generate/src/main/java/com/lyms/platform/msg/utils/HelperUtils.java
View file @
84231ad
| ... | ... | @@ -15,6 +15,7 @@ |
| 15 | 15 | import org.slf4j.Logger; |
| 16 | 16 | import org.slf4j.LoggerFactory; |
| 17 | 17 | |
| 18 | +import java.util.Calendar; | |
| 18 | 19 | import java.util.Date; |
| 19 | 20 | import java.util.List; |
| 20 | 21 | import java.util.Map; |
| 21 | 22 | |
| ... | ... | @@ -336,8 +337,11 @@ |
| 336 | 337 | * @return |
| 337 | 338 | */ |
| 338 | 339 | public static String getMonthYear(Date birth, Date currentDate) { |
| 339 | - int month = DateUtils.daysBetween(birth,currentDate); | |
| 340 | + int month = DateUtils.getBetweenMonths(birth, currentDate); | |
| 340 | 341 | return month+"月龄"; |
| 341 | 342 | } |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 342 | 346 | } |
platform-msg-generate/src/main/resources/config.properties
View file @
84231ad
| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | |
| 8 | 8 | #AMS地址 线上:http://data.api.healthbaby.com.cn/v1/messages 测试:http://data.api.stage.healthbaby.com.cn/v1/messages |
| 9 | 9 | #演示地址 https://stage-rp-data-api.healthbaby.com.cn/v1/messages |
| 10 | -ams_sms=http://data.api.stage.healthbaby.com.cn/v1/messages | |
| 10 | +ams_sms=http://data.api.healthbaby.com.cn/v1/messages | |
| 11 | 11 | |
| 12 | 12 | #短信当天发送时间 如16:00 |
| 13 | 13 | send_time=16:00 |