Commit e82c0c7ec9cdab78bbf5276ccd87bbee7a95503a

Authored by liquanyu
1 parent da95e1adda

短信配置取消

Showing 5 changed files with 97 additions and 19 deletions

platform-common/src/main/java/com/lyms/platform/common/utils/HttpRequest.java View file @ e82c0c7
... ... @@ -258,6 +258,60 @@
258 258 return result;
259 259 }
260 260  
  261 + public static String sendPut(String url, String param,String auth) {
  262 + PrintWriter out = null;
  263 + BufferedReader in = null;
  264 + String result = "";
  265 + try {
  266 + URL realUrl = new URL(url);
  267 + // 打开和URL之间的连接
  268 + HttpURLConnection conn = (HttpURLConnection)realUrl.openConnection();
  269 + // 设置通用的请求属性
  270 + conn.setRequestProperty("accept", "*/*");
  271 + conn.setRequestProperty("connection", "Keep-Alive");
  272 + conn.setRequestProperty("Authorization",auth);
  273 + conn.setRequestProperty("Content-Type", "application/json");
  274 + conn.setRequestProperty("user-agent",
  275 + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
  276 + // 发送POST请求必须设置如下两行
  277 + conn.setDoOutput(true);
  278 + conn.setDoInput(true);
  279 + conn.setRequestMethod("PUT");
  280 + conn.setRequestProperty("Charset", "UTF-8");
  281 + // 获取URLConnection对象对应的输出流
  282 + out = new PrintWriter(conn.getOutputStream());
  283 + // 发送请求参数
  284 + out.print(param);
  285 + // flush输出流的缓冲
  286 + out.flush();
  287 + // 定义BufferedReader输入流来读取URL的响应
  288 + in = new BufferedReader(
  289 + new InputStreamReader(conn.getInputStream()));
  290 + String line;
  291 + while ((line = in.readLine()) != null) {
  292 + result += line;
  293 + }
  294 + } catch (Exception e) {
  295 + System.out.println("发送 POST 请求出现异常!"+e);
  296 + e.printStackTrace();
  297 + }
  298 + //使用finally块来关闭输出流、输入流
  299 + finally{
  300 + try{
  301 + if(out!=null){
  302 + out.close();
  303 + }
  304 + if(in!=null){
  305 + in.close();
  306 + }
  307 + }
  308 + catch(IOException ex){
  309 + ex.printStackTrace();
  310 + }
  311 + }
  312 + return result;
  313 + }
  314 +
261 315 public static String Send(String sendUrl,String param){
262 316 String retValue = null;
263 317 HttpURLConnection con = null;
... ... @@ -291,17 +345,19 @@
291 345 public static void main(String[] args) {
292 346 // sendGet("http://localhost:8080/message_develop/sendMMS","id=222222");
293 347 // String str = sendGet("http://data.api.healthbaby.com.cn/v1/messages","hospitalId=1&tagName=,高血压,&page=1&limit=9999");
294   - Map<String, String> headers = new HashMap<String, String>();
295   - headers.put("Authorization", "healthbaby2015");
296   - Map<String, String> params = new HashMap<String, String>();
297   - params.put("hospitalId", "e66aafcf-1be5-4cd0-89bc-cf65db7297cc");
298   - params.put("tagName", "1周");
299   - params.put("page", "1");
300   - params.put("limit", "999");
301   -
302   - String str = sendGet("http://data.api.healthbaby.com.cn/v1/messages",
303   - params,headers);
304   - System.out.println(str);
  348 +// Map<String, String> headers = new HashMap<String, String>();
  349 +// headers.put("Authorization", "healthbaby2015");
  350 +// Map<String, String> params = new HashMap<String, String>();
  351 +// params.put("hospitalId", "e66aafcf-1be5-4cd0-89bc-cf65db7297cc");
  352 +// params.put("tagName", "1周");
  353 +// params.put("page", "1");
  354 +// params.put("limit", "999");
  355 +//
  356 +// String str = sendGet("http://data.api.healthbaby.com.cn/v1/messages",
  357 +// params,headers);
  358 +// System.out.println(str);
  359 + String json = "[{\"key\":\"6\",\"value\":\"true\"},{\"key\":\"7\",\"value\":\"true\"},{\"key\":\"2\",\"value\":\"false\"},{\"key\":\"3\",\"value\":\"false\"},{\"key\":\"8\",\"value\":\"false\"},{\"key\":\"9\",\"value\":\"false\"},{\"key\":\"10\",\"value\":\"false\"},{\"key\":\"12\",\"value\":\"false\"},{\"key\":\"13\",\"value\":\"false\"},{\"key\":\"15\",\"value\":\"false\"},{\"key\":\"16\",\"value\":\"false\"},{\"key\":\"17\",\"value\":\"false\"},{\"key\":\"19\",\"value\":\"false\"},{\"key\":\"20\",\"value\":\"false\"},{\"key\":\"22\",\"value\":\"false\"},{\"key\":\"23\",\"value\":\"false\"}]";
  360 + String result = HttpRequest.sendPut("http://192.168.5.13:8080/v1/serviceConfig/196",json,"YMer2016");
305 361 }
306 362 }
platform-data-api/src/main/java/com/lyms/platform/data/pojo/MessageRequest.java View file @ e82c0c7
... ... @@ -8,6 +8,7 @@
8 8 private String content;
9 9 private Integer typeId;
10 10 private Integer subTypeId;
  11 + private Integer status;
11 12  
12 13  
13 14 //计划发送时间
... ... @@ -28,6 +29,15 @@
28 29  
29 30 //患者ID
30 31 private String ext3;
  32 +
  33 +
  34 + public Integer getStatus() {
  35 + return status;
  36 + }
  37 +
  38 + public void setStatus(Integer status) {
  39 + this.status = status;
  40 + }
31 41  
32 42 public String getPhone() {
33 43 return phone;
platform-data-api/src/main/java/com/lyms/platform/data/util/SaveMessageService.java View file @ e82c0c7
... ... @@ -21,7 +21,8 @@
21 21 public static boolean saveSmsCenter(MessageListRequest list)
22 22 {
23 23 String json = JsonUtil.obj2JsonString(list);
24   - String result = HttpRequest.sendPost(CENTER_BASE_URL+"saveCreatedSMS",json,CENTER_TOKEN);
  24 + //String result = HttpRequest.sendPost(CENTER_BASE_URL+"saveCreatedSMS",json,CENTER_TOKEN);
  25 + String result = HttpRequest.sendPost("http://192.168.5.13:8080/v1/saveCreatedSMS",json,"YMer2016");
25 26 if (StringUtils.isNotEmpty(result))
26 27 {
27 28 Map<String,String> map = JsonUtil.str2Obj(result, Map.class);
28 29  
29 30  
30 31  
31 32  
32 33  
... ... @@ -55,21 +56,31 @@
55 56 List<MessageRequest> messages = new ArrayList<>();
56 57 MessageRequest request = new MessageRequest();
57 58 request.setTypeId(1);
58   - request.setContent("222222222222222");
  59 + request.setStatus(0);
  60 + request.setContent("cccccccccccccccccc");
59 61 request.setObjType(1);
60   - request.setPhone("18382670032");
  62 + request.setPhone("18382670000");
61 63 request.setPlanTime("2015-01-06 15:22:12");
62 64 request.setServiceType(1);
  65 + request.setExt1("196");
  66 + request.setExt2("10");
  67 + request.setExt3("10");
  68 + request.setSubTypeId(6);
63 69 messages.add(request);
64 70  
65 71  
66 72 MessageRequest request1 = new MessageRequest();
67 73 request1.setTypeId(1);
68   - request1.setContent("1111111111111111");
  74 + request1.setStatus(0);
  75 + request1.setContent("bbbbbbbbbbbbbb");
69 76 request1.setObjType(1);
70   - request1.setPhone("18382670031");
  77 + request1.setPhone("18382670001");
71 78 request1.setPlanTime("2015-01-06 15:22:12");
72 79 request1.setServiceType(1);
  80 + request.setSubTypeId(7);
  81 + request1.setExt1("196");
  82 + request1.setExt2("10");
  83 + request1.setExt3("10");
73 84 messages.add(request1);
74 85  
75 86 list.setTypeId(1);
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/ConfigTask.java View file @ e82c0c7
... ... @@ -67,7 +67,7 @@
67 67 }
68 68 }
69 69  
70   - MessageCenterService.serviceConfig(resultServices,hid);
  70 + //MessageCenterService.serviceConfig(resultServices,hid);
71 71 }
72 72 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MessageCenterService.java View file @ e82c0c7
... ... @@ -26,8 +26,9 @@
26 26 */
27 27 public static boolean serviceConfig(List<Config> configs,String hid)
28 28 {
29   - String json = JsonUtil.obj2JsonString(configs);
30   - String result = HttpRequest.sendPost(CENTER_BASE_URL+"serviceConfig/{"+hid+"}", json, CENTER_TOKEN);
  29 + String json = JsonUtil.array2JsonString(configs);
  30 +// String result = HttpRequest.sendPost(CENTER_BASE_URL + "serviceConfig/{" + hid + "}", json, CENTER_TOKEN);
  31 + String result = HttpRequest.sendPut("http://192.168.5.13:8080/v1/serviceConfig/"+hid,json,"YMer2016");
31 32 if (StringUtils.isNotEmpty(result))
32 33 {
33 34 Map<String,String> map = JsonUtil.str2Obj(result, Map.class);