Commit ce7dace117e3d3b8b004f3d9b617c7a48bcd8648
1 parent
42c63c9757
Exists in
master
and in
8 other branches
code update
Showing 7 changed files with 342 additions and 15 deletions
- platform-common/src/main/java/com/lyms/platform/common/base/PageInfo.java
- platform-common/src/main/java/com/lyms/platform/common/utils/HttpRequest.java
- platform-common/src/main/java/com/lyms/platform/common/utils/StringUtils.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/SmsObj.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/SmsResult.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MessageCenterService.java
platform-common/src/main/java/com/lyms/platform/common/base/PageInfo.java
View file @
ce7dace
platform-common/src/main/java/com/lyms/platform/common/utils/HttpRequest.java
View file @
ce7dace
... | ... | @@ -32,11 +32,11 @@ |
32 | 32 | URLConnection connection = realUrl.openConnection(); |
33 | 33 | // 设置通用的请求属性 |
34 | 34 | connection.setRequestProperty("accept", "*/*"); |
35 | + connection.setRequestProperty("Method","GET"); | |
35 | 36 | connection.setRequestProperty("connection", "Keep-Alive"); |
36 | 37 | connection.setRequestProperty("user-agent", |
37 | 38 | "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); |
38 | 39 | connection.setRequestProperty("Authorization",auth); |
39 | - connection.setRequestProperty("Authorization", "healthbaby2015"); | |
40 | 40 | // 建立实际的连接 |
41 | 41 | connection.connect(); |
42 | 42 | // 获取所有响应头字段 |
... | ... | @@ -47,7 +47,7 @@ |
47 | 47 | } |
48 | 48 | // 定义 BufferedReader输入流来读取URL的响应 |
49 | 49 | in = new BufferedReader(new InputStreamReader( |
50 | - connection.getInputStream())); | |
50 | + connection.getInputStream(),"utf-8")); | |
51 | 51 | String line; |
52 | 52 | while ((line = in.readLine()) != null) { |
53 | 53 | result += line; |
... | ... | @@ -97,6 +97,7 @@ |
97 | 97 | URLConnection connection = realUrl.openConnection(); |
98 | 98 | // 设置通用的请求属性 |
99 | 99 | connection.setRequestProperty("accept", "*/*"); |
100 | + connection.setRequestProperty("Method","GET"); | |
100 | 101 | connection.setRequestProperty("connection", "Keep-Alive"); |
101 | 102 | connection.setRequestProperty("user-agent", |
102 | 103 | "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); |
platform-common/src/main/java/com/lyms/platform/common/utils/StringUtils.java
View file @
ce7dace
... | ... | @@ -124,6 +124,25 @@ |
124 | 124 | return str; |
125 | 125 | } |
126 | 126 | |
127 | + | |
128 | + public static String emptyStr(String str) | |
129 | + { | |
130 | + if (str == null) | |
131 | + { | |
132 | + return ""; | |
133 | + } | |
134 | + return str; | |
135 | + } | |
136 | + | |
137 | + public static String emptyInt(Integer str) | |
138 | + { | |
139 | + if (str == null) | |
140 | + { | |
141 | + return ""; | |
142 | + } | |
143 | + return String.valueOf(str); | |
144 | + } | |
145 | + | |
127 | 146 | // public static void main(String[] arg) { |
128 | 147 | // System.out.print(encryPhone("18382670036")); |
129 | 148 | // } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/SmsConfigFacade.java
View file @
ce7dace
... | ... | @@ -6,12 +6,14 @@ |
6 | 6 | import com.lyms.platform.common.result.BaseListResponse; |
7 | 7 | import com.lyms.platform.common.result.BaseObjectResponse; |
8 | 8 | import com.lyms.platform.common.result.BaseResponse; |
9 | +import com.lyms.platform.common.utils.DateUtil; | |
9 | 10 | import com.lyms.platform.common.utils.JsonUtil; |
10 | 11 | import com.lyms.platform.common.utils.StringUtils; |
11 | 12 | import com.lyms.platform.common.utils.SystemConfig; |
12 | 13 | import com.lyms.platform.operate.web.request.SmsConfigRequest; |
13 | 14 | import com.lyms.platform.operate.web.result.*; |
14 | 15 | import com.lyms.platform.operate.web.utils.ConfigTask; |
16 | +import com.lyms.platform.operate.web.utils.MessageCenterService; | |
15 | 17 | import com.lyms.platform.permission.model.Departments; |
16 | 18 | import com.lyms.platform.permission.model.DepartmentsQuery; |
17 | 19 | import com.lyms.platform.permission.model.Organization; |
18 | 20 | |
... | ... | @@ -629,9 +631,87 @@ |
629 | 631 | return objectResponse; |
630 | 632 | } |
631 | 633 | |
632 | - public BaseObjectResponse querySmsList(String hospitalId, String phone,Integer smsType,Integer smsStatus,String content,String planTime,String actualTime, Integer page, Integer limit) | |
634 | + public BaseListResponse querySmsList(String hospitalId, String phone,Integer smsType,Integer smsStatus,String content,String planTime,String actualTime, Integer page, Integer limit) | |
633 | 635 | { |
634 | - return null; | |
636 | + String planTimeStart = ""; | |
637 | + String planTimeEnd = ""; | |
638 | + if (StringUtils.isNotEmpty(planTime)) | |
639 | + { | |
640 | + planTimeStart = String.valueOf(DateUtil.getSecond(DateUtil.parseYMD(planTime.split(" - ")[0]))); | |
641 | + planTimeEnd = String.valueOf(DateUtil.getSecond(DateUtil.parseYMD(planTime.split(" - ")[1]))); | |
642 | + } | |
643 | + | |
644 | + String actualTimeStart = ""; | |
645 | + String actualTimeEnd = ""; | |
646 | + if (StringUtils.isNotEmpty(actualTime)) | |
647 | + { | |
648 | + | |
649 | + actualTimeStart = String.valueOf(DateUtil.getSecond(DateUtil.parseYMD(actualTime.split(" - ")[0]))); | |
650 | + actualTimeEnd = String.valueOf(DateUtil.getSecond(DateUtil.parseYMD(actualTime.split(" - ")[1]))); | |
651 | + } | |
652 | + List<Map<String,String>> list = new ArrayList<>(); | |
653 | + | |
654 | + SmsResult sms = MessageCenterService.querySmsList(hospitalId, phone, smsType, smsStatus, content, planTimeStart, planTimeEnd, actualTimeStart, actualTimeEnd, page, limit); | |
655 | + | |
656 | + if (sms != null && sms.getList() != null ) | |
657 | + { | |
658 | + List<SmsObj> smsObjs = sms.getList(); | |
659 | + if (CollectionUtils.isNotEmpty(smsObjs)) | |
660 | + { | |
661 | + for(SmsObj obj : smsObjs) | |
662 | + { | |
663 | + if (obj != null) | |
664 | + { | |
665 | + | |
666 | + Map<String,String> map = new HashMap<>(); | |
667 | + if (StringUtils.isNotEmpty(obj.getExt1())) | |
668 | + { | |
669 | + Organization org= organizationService.getOrganization(Integer.parseInt(obj.getExt1())); | |
670 | + map.put("hospitalName",org.getName()); | |
671 | + } | |
672 | + else | |
673 | + { | |
674 | + map.put("hospitalName",""); | |
675 | + } | |
676 | + map.put("smsType",SmsServiceEnums.getSmsServiceById(obj.getSubTypeId())); | |
677 | + map.put("phone",obj.getPhone()); | |
678 | + map.put("content",obj.getContent()); | |
679 | + | |
680 | + if (obj.getPlanTime() != null && obj.getPlanTime() > 0) | |
681 | + { | |
682 | + long pt = (long)obj.getPlanTime() * 1000; | |
683 | + String strpt = DateUtil.getyyyy_MM_dd(new Date(pt)); | |
684 | + map.put("planTime", strpt); | |
685 | + } | |
686 | + else | |
687 | + { | |
688 | + map.put("planTime", ""); | |
689 | + } | |
690 | + | |
691 | + if (obj.getActualTime() != null && obj.getActualTime() > 0) | |
692 | + { | |
693 | + long pt = (long)obj.getActualTime() * 1000; | |
694 | + String strpt = DateUtil.getyyyy_MM_dd(new Date(pt)); | |
695 | + map.put("actualTime", strpt); | |
696 | + } | |
697 | + else | |
698 | + { | |
699 | + map.put("actualTime", ""); | |
700 | + } | |
701 | + | |
702 | + map.put("smsStatus", SmsStatusEnums.getNameById(obj.getStatus())); | |
703 | + list.add(map); | |
704 | + } | |
705 | + } | |
706 | + } | |
707 | + } | |
708 | + | |
709 | + BaseListResponse objectResponse = new BaseListResponse(); | |
710 | + objectResponse.setData(list); | |
711 | + objectResponse.setPageInfo(sms.getPageInfo()); | |
712 | + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
713 | + objectResponse.setErrormsg("成功"); | |
714 | + return objectResponse; | |
635 | 715 | } |
636 | 716 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/SmsObj.java
View file @
ce7dace
1 | +package com.lyms.platform.operate.web.result; | |
2 | + | |
3 | +/** | |
4 | + * Created by Administrator on 2016/8/25. | |
5 | + */ | |
6 | +public class SmsObj{ | |
7 | + private String phone; | |
8 | + private Integer status; | |
9 | + private Integer serviceType; | |
10 | + private Integer id; | |
11 | + private String content; | |
12 | + private String typeName; | |
13 | + private Integer objType; | |
14 | + private String ext1; | |
15 | + private String ext2; | |
16 | + private Integer created; | |
17 | + private Integer planTime; | |
18 | + private String ext3; | |
19 | + private Integer actualTime; | |
20 | + private Integer sendCount; | |
21 | + private Integer subTypeId; | |
22 | + private Integer typeId; | |
23 | + | |
24 | + public String getPhone() { | |
25 | + return phone; | |
26 | + } | |
27 | + | |
28 | + public void setPhone(String phone) { | |
29 | + this.phone = phone; | |
30 | + } | |
31 | + | |
32 | + public Integer getStatus() { | |
33 | + return status; | |
34 | + } | |
35 | + | |
36 | + public void setStatus(Integer status) { | |
37 | + this.status = status; | |
38 | + } | |
39 | + | |
40 | + public Integer getServiceType() { | |
41 | + return serviceType; | |
42 | + } | |
43 | + | |
44 | + public void setServiceType(Integer serviceType) { | |
45 | + this.serviceType = serviceType; | |
46 | + } | |
47 | + | |
48 | + public Integer getId() { | |
49 | + return id; | |
50 | + } | |
51 | + | |
52 | + public void setId(Integer id) { | |
53 | + this.id = id; | |
54 | + } | |
55 | + | |
56 | + public String getContent() { | |
57 | + return content; | |
58 | + } | |
59 | + | |
60 | + public void setContent(String content) { | |
61 | + this.content = content; | |
62 | + } | |
63 | + | |
64 | + public String getTypeName() { | |
65 | + return typeName; | |
66 | + } | |
67 | + | |
68 | + public void setTypeName(String typeName) { | |
69 | + this.typeName = typeName; | |
70 | + } | |
71 | + | |
72 | + public Integer getObjType() { | |
73 | + return objType; | |
74 | + } | |
75 | + | |
76 | + public void setObjType(Integer objType) { | |
77 | + this.objType = objType; | |
78 | + } | |
79 | + | |
80 | + public String getExt1() { | |
81 | + return ext1; | |
82 | + } | |
83 | + | |
84 | + public void setExt1(String ext1) { | |
85 | + this.ext1 = ext1; | |
86 | + } | |
87 | + | |
88 | + public String getExt2() { | |
89 | + return ext2; | |
90 | + } | |
91 | + | |
92 | + public void setExt2(String ext2) { | |
93 | + this.ext2 = ext2; | |
94 | + } | |
95 | + | |
96 | + public Integer getCreated() { | |
97 | + return created; | |
98 | + } | |
99 | + | |
100 | + public void setCreated(Integer created) { | |
101 | + this.created = created; | |
102 | + } | |
103 | + | |
104 | + public Integer getPlanTime() { | |
105 | + return planTime; | |
106 | + } | |
107 | + | |
108 | + public void setPlanTime(Integer planTime) { | |
109 | + this.planTime = planTime; | |
110 | + } | |
111 | + | |
112 | + public String getExt3() { | |
113 | + return ext3; | |
114 | + } | |
115 | + | |
116 | + public void setExt3(String ext3) { | |
117 | + this.ext3 = ext3; | |
118 | + } | |
119 | + | |
120 | + public Integer getActualTime() { | |
121 | + return actualTime; | |
122 | + } | |
123 | + | |
124 | + public void setActualTime(Integer actualTime) { | |
125 | + this.actualTime = actualTime; | |
126 | + } | |
127 | + | |
128 | + public Integer getSendCount() { | |
129 | + return sendCount; | |
130 | + } | |
131 | + | |
132 | + public void setSendCount(Integer sendCount) { | |
133 | + this.sendCount = sendCount; | |
134 | + } | |
135 | + | |
136 | + public Integer getSubTypeId() { | |
137 | + return subTypeId; | |
138 | + } | |
139 | + | |
140 | + public void setSubTypeId(Integer subTypeId) { | |
141 | + this.subTypeId = subTypeId; | |
142 | + } | |
143 | + | |
144 | + public Integer getTypeId() { | |
145 | + return typeId; | |
146 | + } | |
147 | + | |
148 | + public void setTypeId(Integer typeId) { | |
149 | + this.typeId = typeId; | |
150 | + } | |
151 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/SmsResult.java
View file @
ce7dace
1 | +package com.lyms.platform.operate.web.result; | |
2 | + | |
3 | +import com.lyms.platform.common.base.PageInfo; | |
4 | + | |
5 | +import java.util.List; | |
6 | + | |
7 | +/** | |
8 | + * Created by Administrator on 2016/8/24. | |
9 | + */ | |
10 | +public class SmsResult { | |
11 | + private String errormsg; | |
12 | + private String errorcode; | |
13 | + | |
14 | + private PageInfo pageInfo; | |
15 | + | |
16 | + private List<SmsObj> list; | |
17 | + | |
18 | + | |
19 | + | |
20 | + | |
21 | + public String getErrormsg() { | |
22 | + return errormsg; | |
23 | + } | |
24 | + | |
25 | + public void setErrormsg(String errormsg) { | |
26 | + this.errormsg = errormsg; | |
27 | + } | |
28 | + | |
29 | + public String getErrorcode() { | |
30 | + return errorcode; | |
31 | + } | |
32 | + | |
33 | + public void setErrorcode(String errorcode) { | |
34 | + this.errorcode = errorcode; | |
35 | + } | |
36 | + | |
37 | + public PageInfo getPageInfo() { | |
38 | + return pageInfo; | |
39 | + } | |
40 | + | |
41 | + public void setPageInfo(PageInfo pageInfo) { | |
42 | + this.pageInfo = pageInfo; | |
43 | + } | |
44 | + | |
45 | + public List<SmsObj> getList() { | |
46 | + return list; | |
47 | + } | |
48 | + | |
49 | + public void setList(List<SmsObj> list) { | |
50 | + this.list = list; | |
51 | + } | |
52 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MessageCenterService.java
View file @
ce7dace
... | ... | @@ -7,6 +7,10 @@ |
7 | 7 | import com.lyms.platform.common.utils.StringUtils; |
8 | 8 | import com.lyms.platform.operate.web.request.MessageListRequest; |
9 | 9 | import com.lyms.platform.operate.web.result.Config; |
10 | +import com.lyms.platform.operate.web.result.SmsObj; | |
11 | +import com.lyms.platform.operate.web.result.SmsResult; | |
12 | +import net.sf.json.JSONArray; | |
13 | +import net.sf.json.JSONObject; | |
10 | 14 | |
11 | 15 | import java.util.List; |
12 | 16 | import java.util.Map; |
13 | 17 | |
14 | 18 | |
15 | 19 | |
... | ... | @@ -62,20 +66,37 @@ |
62 | 66 | } |
63 | 67 | |
64 | 68 | |
65 | - public static List<Map> querySmsList(String hospitalId, String phone,Integer smsType,Integer smsStatus,String content,String planTime,String actualTime, Integer page, Integer limit) | |
69 | + public static SmsResult querySmsList(String hospitalId, String phone,Integer smsType,Integer smsStatus,String content,String planTimeStart,String planTimeEnd,String actualTimeStart,String actualTimeEnd, Integer page, Integer limit) | |
66 | 70 | { |
67 | -//// String result = HttpRequest.sendPost(CENTER_BASE_URL + "messages/{" + hid + "}", json, CENTER_TOKEN); | |
68 | -// String result = HttpRequest.sendGet("http://192.168.5.13:8080/v1/messages/" + hid, json, "YMer2016"); | |
69 | -// if (StringUtils.isNotEmpty(result)) | |
71 | + String param = "typeId=4&ext1="+StringUtils.emptyStr(hospitalId)+"&phone="+StringUtils.emptyStr(phone)+"&subTypeId="+StringUtils.emptyInt(smsType)+"&content="+StringUtils.emptyStr(content)+ | |
72 | + "&planTimeStart="+planTimeStart+"&planTimeEnd="+planTimeEnd+"&actualTimeStart="+actualTimeStart+ | |
73 | + "&actualTimeEnd="+actualTimeEnd+"&status="+StringUtils.emptyInt(smsStatus)+"&page="+page+"&limit="+limit; | |
74 | +// String result = HttpRequest.sendGet(CENTER_BASE_URL+"messages", param, CENTER_TOKEN); | |
75 | + SmsResult map = null; | |
76 | +// String result = HttpRequest.sendGet("http://192.168.5.6:8080/v1/messages", param, "YMer2016"); | |
77 | +// SmsResult map = JsonUtil.str2Obj(result, SmsResult.class); | |
78 | +// JSONObject jsonObject = JsonUtil.getObj(result); | |
79 | +// if (jsonObject != null && jsonObject.getJSONArray("list") != null) | |
70 | 80 | // { |
71 | -// Map<String,String> map = JsonUtil.str2Obj(result, Map.class); | |
72 | -// if ("0".equals(map.get("errorcode"))) | |
73 | -// { | |
74 | -// return true; | |
75 | -// } | |
81 | +// JSONArray jsonArray = jsonObject.getJSONArray("list"); | |
82 | +// String list = jsonArray.toString(); | |
83 | +// map.setList(JsonUtil.toList(list,SmsObj.class)); | |
76 | 84 | // } |
77 | -// return false; | |
78 | - return null; | |
85 | + return map; | |
86 | + } | |
87 | + | |
88 | + public static void main(String[] args){ | |
89 | + String param = "phone=&page=1&limit=100&typeId=4"; | |
90 | + | |
91 | + String result = HttpRequest.sendGet("http://192.168.5.6:8080/v1/messages", param, "YMer2016"); | |
92 | + SmsResult map = JsonUtil.str2Obj(result, SmsResult.class); | |
93 | + JSONObject jsonObject = JsonUtil.getObj(result); | |
94 | + JSONArray jsonArray = jsonObject.getJSONArray("list"); | |
95 | + String list = jsonArray.toString(); | |
96 | + map.setList(JsonUtil.toList(list, SmsObj.class)); | |
97 | + System.out.print(map); | |
98 | + | |
99 | + | |
79 | 100 | } |
80 | 101 | } |