Commit c9663acfe4f0effc8693ee5b9f636c222d5388d3
1 parent
6faf7f2a22
Exists in
master
and in
3 other branches
建档预产期修改
Showing 6 changed files with 245 additions and 48 deletions
- platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
- platform-common/src/main/java/com/lyms/platform/common/utils/HttpRequest.java
- platform-data-api/src/main/java/com/lyms/platform/data/controller/SmsController.java
- platform-data-api/src/main/java/com/lyms/platform/data/service/SmsService.java
- platform-data-api/src/main/java/com/lyms/platform/data/service/impl/SmsServiceImpl.java
- platform-data-api/src/main/java/com/lyms/platform/data/util/SaveMessageService.java
platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
View file @
c9663ac
| ... | ... | @@ -772,30 +772,33 @@ |
| 772 | 772 | // System.out.println(s); |
| 773 | 773 | // Date s = addDay(parseYMD("2016-02-26"), 168); |
| 774 | 774 | |
| 775 | - int start = 38; | |
| 776 | - int end = 38; | |
| 775 | +// int start = 38; | |
| 776 | +// int end = 38; | |
| 777 | +//// | |
| 778 | +//// | |
| 779 | +//// Date startDate = DateUtil.getNewDate(-end-1,"周",1+1); | |
| 780 | +//// Date endDate = DateUtil.getNewDate(-start,"周",0+1); | |
| 777 | 781 | // |
| 778 | 782 | // |
| 779 | -// Date startDate = DateUtil.getNewDate(-end-1,"周",1+1); | |
| 780 | -// Date endDate = DateUtil.getNewDate(-start,"周",0+1); | |
| 783 | +// Date startDate = DateUtil.getNewDate(-end-1,"周",2+1); | |
| 784 | +// Date endDate = DateUtil.getNewDate(-start,"周",2); | |
| 785 | +// | |
| 786 | +// | |
| 787 | +// String date = y_m_d_h_m_s.format(startDate.getTime()); | |
| 788 | +//// Date startDate = DateUtil.getNewDate(-end-1,"月",1); | |
| 789 | +//// Date endDate = DateUtil.getNewDate(-start,"月",1); | |
| 790 | +// | |
| 791 | +// System.out.println(date + "==="); | |
| 781 | 792 | |
| 782 | 793 | |
| 783 | - Date startDate = DateUtil.getNewDate(-end-1,"周",2+1); | |
| 784 | - Date endDate = DateUtil.getNewDate(-start,"周",2); | |
| 785 | - | |
| 786 | - | |
| 787 | - String date = y_m_d_h_m_s.format(startDate.getTime()); | |
| 788 | -// Date startDate = DateUtil.getNewDate(-end-1,"月",1); | |
| 789 | -// Date endDate = DateUtil.getNewDate(-start,"月",1); | |
| 790 | - | |
| 791 | - System.out.println(date + "==="); | |
| 792 | - | |
| 793 | - | |
| 794 | 794 | // Date startDate = getRangeDate(parseYMD("2016-09-07"),2,"周",-1); |
| 795 | 795 | // System.out.println(getyyyy_MM_dd(startDate)); |
| 796 | 796 | |
| 797 | 797 | // int a = daysBetween(parseYMD("2013-09-13"),new Date())/7; |
| 798 | 798 | // System.out.println(a); |
| 799 | + | |
| 800 | + Date dueDate = DateUtil.addDay(DateUtil.addMonth(parseYMD("2016-02-08"), 9), 7); | |
| 801 | + System.out.println(getyyyy_MM_dd(dueDate)); | |
| 799 | 802 | } catch (Exception e) |
| 800 | 803 | { |
| 801 | 804 |
platform-common/src/main/java/com/lyms/platform/common/utils/HttpRequest.java
View file @
c9663ac
| ... | ... | @@ -68,6 +68,64 @@ |
| 68 | 68 | } |
| 69 | 69 | return result; |
| 70 | 70 | } |
| 71 | + | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * 删除 | |
| 75 | + * @param url | |
| 76 | + * @param param | |
| 77 | + * @param auth | |
| 78 | + * @return | |
| 79 | + */ | |
| 80 | + public static String sendDelete(String url, String param,String auth) { | |
| 81 | + String result = ""; | |
| 82 | + BufferedReader in = null; | |
| 83 | + try { | |
| 84 | + String urlNameString = url + "?" + param; | |
| 85 | + URL realUrl = new URL(urlNameString); | |
| 86 | + // 打开和URL之间的连接 | |
| 87 | + HttpURLConnection connection = (HttpURLConnection)realUrl.openConnection(); | |
| 88 | + // 设置通用的请求属性 | |
| 89 | + connection.setRequestMethod("DELETE"); | |
| 90 | + | |
| 91 | + connection.setRequestProperty("accept", "*/*"); | |
| 92 | + connection.setRequestProperty("Method","DELETE"); | |
| 93 | + connection.setRequestProperty("connection", "Keep-Alive"); | |
| 94 | + connection.setRequestProperty("user-agent", | |
| 95 | + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); | |
| 96 | + connection.setRequestProperty("Authorization",auth); | |
| 97 | + // 建立实际的连接 | |
| 98 | + connection.connect(); | |
| 99 | + // 获取所有响应头字段 | |
| 100 | + Map<String, List<String>> map = connection.getHeaderFields(); | |
| 101 | + // 遍历所有的响应头字段 | |
| 102 | + for (String key : map.keySet()) { | |
| 103 | + System.out.println(key + "--->" + map.get(key)); | |
| 104 | + } | |
| 105 | + // 定义 BufferedReader输入流来读取URL的响应 | |
| 106 | + in = new BufferedReader(new InputStreamReader( | |
| 107 | + connection.getInputStream(),"utf-8")); | |
| 108 | + String line; | |
| 109 | + while ((line = in.readLine()) != null) { | |
| 110 | + result += line; | |
| 111 | + } | |
| 112 | + } catch (Exception e) { | |
| 113 | + System.out.println("发送DELETE请求出现异常!" + e); | |
| 114 | + e.printStackTrace(); | |
| 115 | + } | |
| 116 | + // 使用finally块来关闭输入流 | |
| 117 | + finally { | |
| 118 | + try { | |
| 119 | + if (in != null) { | |
| 120 | + in.close(); | |
| 121 | + } | |
| 122 | + } catch (Exception e2) { | |
| 123 | + e2.printStackTrace(); | |
| 124 | + } | |
| 125 | + } | |
| 126 | + return result; | |
| 127 | + } | |
| 128 | + | |
| 71 | 129 | /** |
| 72 | 130 | * 向指定URL发送GET方法的请求 |
| 73 | 131 | * @param url |
platform-data-api/src/main/java/com/lyms/platform/data/controller/SmsController.java
View file @
c9663ac
| 1 | 1 | package com.lyms.platform.data.controller; |
| 2 | 2 | |
| 3 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
| 4 | +import com.lyms.platform.common.result.BaseListResponse; | |
| 5 | +import com.lyms.platform.common.result.BaseResponse; | |
| 3 | 6 | import com.lyms.platform.common.utils.ResultUtils; |
| 4 | 7 | import com.lyms.platform.data.service.SmsService; |
| 5 | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 6 | 9 | import org.springframework.stereotype.Controller; |
| 7 | 10 | import org.springframework.web.bind.annotation.RequestMapping; |
| 8 | 11 | import org.springframework.web.bind.annotation.RequestParam; |
| 12 | +import org.springframework.web.bind.annotation.ResponseBody; | |
| 9 | 13 | |
| 10 | 14 | import javax.servlet.http.HttpServletResponse; |
| 11 | 15 | |
| ... | ... | @@ -81,5 +85,29 @@ |
| 81 | 85 | smsService.productChildAmsSms(); |
| 82 | 86 | writeString(response, "child ams success"); |
| 83 | 87 | } |
| 88 | + | |
| 89 | + | |
| 90 | + @RequestMapping(value = "/getDueSms") | |
| 91 | + @ResponseBody | |
| 92 | + public BaseResponse getDueSms(HttpServletResponse response,@RequestParam("token")String token){ | |
| 93 | + if (!"lyms@2016!000".equals(token)) | |
| 94 | + { | |
| 95 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.SYSTEM_ERROR).setErrormsg("没有token"); | |
| 96 | + } | |
| 97 | + return smsService.getDueSms(); | |
| 98 | + } | |
| 99 | + | |
| 100 | + | |
| 101 | + @RequestMapping(value = "/deleteDueSms") | |
| 102 | + public void deleteDueSms(HttpServletResponse response,@RequestParam("token")String token){ | |
| 103 | + if (!"lyms@2016!000".equals(token)) | |
| 104 | + { | |
| 105 | + ResultUtils.buildParameterErrorResultAndWrite(response, "没有token"); | |
| 106 | + return; | |
| 107 | + } | |
| 108 | + smsService.deleteDueSms(); | |
| 109 | + writeString(response, "delete due sms success"); | |
| 110 | + } | |
| 111 | + | |
| 84 | 112 | } |
platform-data-api/src/main/java/com/lyms/platform/data/service/SmsService.java
View file @
c9663ac
| 1 | 1 | package com.lyms.platform.data.service; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +import com.lyms.platform.common.result.BaseListResponse; | |
| 5 | +import com.lyms.platform.common.result.BaseResponse; | |
| 6 | + | |
| 4 | 7 | /** |
| 5 | 8 | * Created by Administrator on 2016/7/5. |
| 6 | 9 | */ |
| ... | ... | @@ -13,6 +16,9 @@ |
| 13 | 16 | void productChildAmsSms(); |
| 14 | 17 | |
| 15 | 18 | void productChanAmsSms(); |
| 19 | + | |
| 20 | + BaseResponse deleteDueSms(); | |
| 21 | + BaseListResponse getDueSms(); | |
| 16 | 22 | |
| 17 | 23 | void serviceEnd(); |
| 18 | 24 |
platform-data-api/src/main/java/com/lyms/platform/data/service/impl/SmsServiceImpl.java
View file @
c9663ac
| 1 | 1 | package com.lyms.platform.data.service.impl; |
| 2 | 2 | |
| 3 | 3 | import com.lyms.platform.biz.service.*; |
| 4 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
| 4 | 5 | import com.lyms.platform.common.enums.*; |
| 6 | +import com.lyms.platform.common.result.BaseListResponse; | |
| 7 | +import com.lyms.platform.common.result.BaseResponse; | |
| 5 | 8 | import com.lyms.platform.common.utils.*; |
| 6 | 9 | import com.lyms.platform.data.pojo.HighScoreResult; |
| 7 | 10 | import com.lyms.platform.data.pojo.MessageContent; |
| ... | ... | @@ -2852,6 +2855,87 @@ |
| 2852 | 2855 | String dateStr = DateUtil.formatSimpleDate(new Date()); |
| 2853 | 2856 | yunBookbuildingService.getBirthPatients(dateStr); |
| 2854 | 2857 | } |
| 2858 | + | |
| 2859 | + | |
| 2860 | + @Override | |
| 2861 | + public BaseResponse deleteDueSms() { | |
| 2862 | + | |
| 2863 | + try { | |
| 2864 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
| 2865 | + patientsQuery.setType(3); | |
| 2866 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
| 2867 | + String startStr = DateUtil.getyyyy_MM_dd(new Date()); | |
| 2868 | + Date startDate = DateUtil.parseYMD(startStr); | |
| 2869 | + Date endDate = new Date(startDate.getTime()+86400000-1); | |
| 2870 | + patientsQuery.setFmDateStart(startDate); | |
| 2871 | + patientsQuery.setFmDateEnd(endDate); | |
| 2872 | + | |
| 2873 | + List<Patients> results = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); | |
| 2874 | + StringBuffer sb = null; | |
| 2875 | + if (CollectionUtils.isNotEmpty(results)) | |
| 2876 | + { | |
| 2877 | + sb = new StringBuffer(); | |
| 2878 | + for (Patients pat : results) | |
| 2879 | + { | |
| 2880 | + sb.append(pat.getPhone()); | |
| 2881 | + sb.append(","); | |
| 2882 | + } | |
| 2883 | + System.out.println(sb); | |
| 2884 | + } | |
| 2885 | + if (sb != null) | |
| 2886 | + { | |
| 2887 | + SaveMessageService.deleteDueSms(sb.toString()); | |
| 2888 | + } | |
| 2889 | + | |
| 2890 | + } catch (Exception e) | |
| 2891 | + { | |
| 2892 | + ExceptionUtils.catchException(e,"删除分娩孕妇异常"); | |
| 2893 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.SYSTEM_ERROR).setErrormsg("失败"); | |
| 2894 | + } | |
| 2895 | + | |
| 2896 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); | |
| 2897 | + } | |
| 2898 | + | |
| 2899 | + @Override | |
| 2900 | + public BaseListResponse getDueSms() { | |
| 2901 | + | |
| 2902 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
| 2903 | + patientsQuery.setType(3); | |
| 2904 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
| 2905 | + String startStr = DateUtil.getyyyy_MM_dd(new Date()); | |
| 2906 | + Date startDate = DateUtil.parseYMD(startStr); | |
| 2907 | + Date endDate = new Date(startDate.getTime()+86400000-1); | |
| 2908 | + | |
| 2909 | + System.out.println("start = " + startStr); | |
| 2910 | + System.out.println("end = " + DateUtil.getyyyy_MM_dd_hms(endDate)); | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + patientsQuery.setFmDateStart(startDate); | |
| 2914 | + patientsQuery.setFmDateEnd(endDate); | |
| 2915 | + List<Map<String,String>> list = new ArrayList<>(); | |
| 2916 | + | |
| 2917 | + List<Patients> results = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); | |
| 2918 | + if (CollectionUtils.isNotEmpty(results)) | |
| 2919 | + { | |
| 2920 | + for (Patients pat : results) | |
| 2921 | + { | |
| 2922 | + Map<String,String> map = new HashMap<>(); | |
| 2923 | + map.put("name",pat.getUsername()); | |
| 2924 | + map.put("phone",pat.getPhone()); | |
| 2925 | + map.put("fmDate",pat.getFmDate() == null ? "" : DateUtil.getYmd(pat.getFmDate())); | |
| 2926 | + list.add(map); | |
| 2927 | + } | |
| 2928 | + } | |
| 2929 | + | |
| 2930 | + BaseListResponse objectResponse = new BaseListResponse(); | |
| 2931 | + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
| 2932 | + objectResponse.setData(list); | |
| 2933 | + objectResponse.setErrormsg("成功"); | |
| 2934 | + return objectResponse; | |
| 2935 | + } | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2855 | 2939 | |
| 2856 | 2940 | |
| 2857 | 2941 | public void productSms() |
platform-data-api/src/main/java/com/lyms/platform/data/util/SaveMessageService.java
View file @
c9663ac
| ... | ... | @@ -41,7 +41,6 @@ |
| 41 | 41 | public static boolean isExistSms(String patientId,String tempId) |
| 42 | 42 | { |
| 43 | 43 | |
| 44 | - | |
| 45 | 44 | String param = "typeId="+ ProjectTypeEnums.YNXT.getId()+"&ext2="+StringUtils.emptyStr(tempId)+"&ext3="+StringUtils.emptyStr(patientId)+"&page=1&limit=10"; |
| 46 | 45 | String result = HttpRequest.sendGet(CENTER_BASE_URL + "messages", param, CENTER_TOKEN); |
| 47 | 46 | |
| 48 | 47 | |
| 49 | 48 | |
| ... | ... | @@ -58,42 +57,61 @@ |
| 58 | 57 | return false; |
| 59 | 58 | } |
| 60 | 59 | |
| 60 | + | |
| 61 | + public static boolean deleteDueSms(String phones) | |
| 62 | + { | |
| 63 | + String param = "typeId="+ ProjectTypeEnums.YNXT.getId()+"&phones="+StringUtils.emptyStr(phones); | |
| 64 | + String result = HttpRequest.sendDelete(CENTER_BASE_URL + "deleteDueSms", param, CENTER_TOKEN); | |
| 65 | + if (StringUtils.isNotEmpty(result)) | |
| 66 | + { | |
| 67 | + Map<String,String> map = JsonUtil.str2Obj(result, Map.class); | |
| 68 | + if ("0".equals(map.get("errorcode"))) | |
| 69 | + { | |
| 70 | + return true; | |
| 71 | + } | |
| 72 | + } | |
| 73 | + return false; | |
| 74 | + } | |
| 75 | + | |
| 61 | 76 | public static void main(String[] areg) |
| 62 | 77 | { |
| 63 | - MessageListRequest list = new MessageListRequest(); | |
| 64 | - List<MessageRequest> messages = new ArrayList<>(); | |
| 65 | - MessageRequest request = new MessageRequest(); | |
| 66 | - request.setTypeId(1); | |
| 67 | - request.setStatus(0); | |
| 68 | - request.setContent("cccccccccccccccccc"); | |
| 69 | - request.setObjType(1); | |
| 70 | - request.setPhone("18382670000"); | |
| 71 | - request.setPlanTime("2015-01-06 15:22:12"); | |
| 72 | - request.setServiceType(1); | |
| 73 | - request.setExt1("196"); | |
| 74 | - request.setExt2("10"); | |
| 75 | - request.setExt3("10"); | |
| 76 | - request.setSubTypeId(6); | |
| 77 | - messages.add(request); | |
| 78 | +// MessageListRequest list = new MessageListRequest(); | |
| 79 | +// List<MessageRequest> messages = new ArrayList<>(); | |
| 80 | +// MessageRequest request = new MessageRequest(); | |
| 81 | +// request.setTypeId(1); | |
| 82 | +// request.setStatus(0); | |
| 83 | +// request.setContent("cccccccccccccccccc"); | |
| 84 | +// request.setObjType(1); | |
| 85 | +// request.setPhone("18382670000"); | |
| 86 | +// request.setPlanTime("2015-01-06 15:22:12"); | |
| 87 | +// request.setServiceType(1); | |
| 88 | +// request.setExt1("196"); | |
| 89 | +// request.setExt2("10"); | |
| 90 | +// request.setExt3("10"); | |
| 91 | +// request.setSubTypeId(6); | |
| 92 | +// messages.add(request); | |
| 93 | +// | |
| 94 | +// | |
| 95 | +// MessageRequest request1 = new MessageRequest(); | |
| 96 | +// request1.setTypeId(1); | |
| 97 | +// request1.setStatus(0); | |
| 98 | +// request1.setContent("bbbbbbbbbbbbbb"); | |
| 99 | +// request1.setObjType(1); | |
| 100 | +// request1.setPhone("18382670001"); | |
| 101 | +// request1.setPlanTime("2015-01-06 15:22:12"); | |
| 102 | +// request1.setServiceType(1); | |
| 103 | +// request.setSubTypeId(7); | |
| 104 | +// request1.setExt1("196"); | |
| 105 | +// request1.setExt2("10"); | |
| 106 | +// request1.setExt3("10"); | |
| 107 | +// messages.add(request1); | |
| 108 | +// | |
| 109 | +// list.setTypeId(1); | |
| 110 | +// list.setMessages(messages); | |
| 111 | +// saveSmsCenter(list); | |
| 78 | 112 | |
| 79 | 113 | |
| 80 | - MessageRequest request1 = new MessageRequest(); | |
| 81 | - request1.setTypeId(1); | |
| 82 | - request1.setStatus(0); | |
| 83 | - request1.setContent("bbbbbbbbbbbbbb"); | |
| 84 | - request1.setObjType(1); | |
| 85 | - request1.setPhone("18382670001"); | |
| 86 | - request1.setPlanTime("2015-01-06 15:22:12"); | |
| 87 | - request1.setServiceType(1); | |
| 88 | - request.setSubTypeId(7); | |
| 89 | - request1.setExt1("196"); | |
| 90 | - request1.setExt2("10"); | |
| 91 | - request1.setExt3("10"); | |
| 92 | - messages.add(request1); | |
| 93 | - | |
| 94 | - list.setTypeId(1); | |
| 95 | - list.setMessages(messages); | |
| 96 | - saveSmsCenter(list); | |
| 114 | + deleteDueSms("15265444440,"); | |
| 97 | 115 | } |
| 98 | 116 | } |