From 75e50e0966d7165e04100a713267ece438482e19 Mon Sep 17 00:00:00 2001 From: leutu <leutu@qq.com> Date: 星期二, 13 八月 2024 18:17:27 +0800 Subject: [PATCH] 推送代码忘记去掉注释,另外schederTask注意时间戳同步 --- src/main/java/com/skyline/electricity/timer/SchedulerTask.java | 49 +++++++++++++++++++++---------------------------- 1 files changed, 21 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/skyline/electricity/timer/SchedulerTask.java b/src/main/java/com/skyline/electricity/timer/SchedulerTask.java index 4a9cdab..a1a1e7c 100644 --- a/src/main/java/com/skyline/electricity/timer/SchedulerTask.java +++ b/src/main/java/com/skyline/electricity/timer/SchedulerTask.java @@ -1,15 +1,5 @@ package com.skyline.electricity.timer; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.message.BasicNameValuePair; -import org.apache.http.protocol.HTTP; -import org.apache.http.util.EntityUtils; import org.springframework.stereotype.*; import org.springframework.context.annotation.*; import org.springframework.beans.factory.annotation.*; @@ -76,7 +66,7 @@ private Map<Object, Object> map; private static final SimpleDateFormat dateFormat; public Integer mux; - + public SchedulerTask() { this.cmap = new ConcurrentHashMap(); this.geometryFactory = new GeometryFactory(); @@ -92,10 +82,13 @@ List<RetInfo> rlist = new ArrayList<>(); list.stream().forEach(r->rlist.add(JSONObject.parseObject(r,RetInfo.class))) ; - if( list != null && list.size() > 0) - System.out.println( "websocket status ..["+webSocketController.sendAllMessage(JSONObject.toJSONString(rlist))+"["+JSONObject.toJSONString(rlist)+"]" ); + if( list != null && list.size() > 0){ + System.out.println("scheduled....push size:"+list.size()); + webSocketController.sendAllMessage(JSONObject.toJSONString(rlist)); + } + // System.out.println( "websocket status ..["+JSONObject.toJSONString(rlist)+"]" ); //鎺ㄩ�佹姤璀︿俊鎭� - pushIM(rlist); + //pushIM(rlist); } /** @@ -116,7 +109,7 @@ rlist.stream().forEach((k) -> { // if( k.getStatus().equals("ok")) return ; - System.out.println( "k====="+k.getLongitude()+" "+k.getLatitude()) ; + //System.out.println( "k====="+k.getLongitude()+" "+k.getLatitude()) ; MonitorInfo monitor = informationService.queryMinDistance(k.getLongitude(),k.getLatitude()); if( monitor == null ) return ; @@ -139,11 +132,11 @@ map.put("startDate",formattedDate); map.put("warnName", k.getUserName()+"杩涘叆"+k.getFence_name()); String url = configInfo.getWarn_url(); - System.out.println( "post url warning "+url) ; - System.out.println( "post url warning "+configInfo.getServer_url()) ; + //System.out.println( "post url warning "+url) ; + //System.out.println( "post url warning "+configInfo.getServer_url()) ; url = "http://10.69.206.205:8080/a/ew/ewWarning/warning"; ResponseEntity<String> result = template.postForEntity(url, map,String.class); - System.out.println("銆恥ser info銆�:"+result); + //System.out.println("銆恥ser info銆�:"+result); }); @@ -511,7 +504,7 @@ final JSONObject json = JSONObject.parseObject(dzzzresponse); SchedulerTask.log.warn(dzzzresponse.toString()); SchedulerTask.log.warn(json.getJSONObject("data").getString("id")); - System.out.println(json.getJSONObject("data").getString("id")); + //System.out.println(json.getJSONObject("data").getString("id")); if (',' == recipent.charAt(recipent.length() - 1)) { recipent.append(json.getJSONObject("data").getString("id")); } @@ -526,7 +519,7 @@ final ResponseEntity responseEntity = template.postForEntity(imUrl + "/oapi/message/sendworkmsg?tenantId=" + tenantId, (Object)httpEntity, (Class)String.class, new Object[0]); SchedulerTask.log.warn("鎺ㄩ�佺粨鏋�" + responseEntity.toString()); } - + public void pushCommonMessage(final String userid, final String dzzzUrl, final String imUrl, final String tenantId, final MultiValueMap<String, String> params, final HttpHeaders headers, final RestTemplate template, final Map<String, Object> configMap, final JSONObject message) { final StringBuilder recipent = new StringBuilder(message.get((Object)"recipient").toString()); if (',' != recipent.charAt(recipent.length() - 1)) { @@ -547,7 +540,7 @@ final JSONObject json = JSONObject.parseObject(dzzzresponse); SchedulerTask.log.warn(dzzzresponse.toString()); SchedulerTask.log.warn(json.getJSONObject("data").getString("id")); - System.out.println(json.getJSONObject("data").getString("id")); + //System.out.println(json.getJSONObject("data").getString("id")); if (',' == recipent.charAt(recipent.length() - 1)) { recipent.append(json.getJSONObject("data").getString("id")); } @@ -562,7 +555,7 @@ final ResponseEntity responseEntity = template.postForEntity(imUrl + "/oapi/message/sendworkmsg?tenantId=" + tenantId, (Object)httpEntity, (Class)String.class, new Object[0]); SchedulerTask.log.warn("鎺ㄩ�佺粨鏋�" + responseEntity.toString()); } - + // @Scheduled(fixedRate = 5000L) public void changeFenceStatus() { final List<FencePosition> fencePositions = (List<FencePosition>)this.detectService.getTempFenceInfo(); @@ -594,7 +587,7 @@ } } } - + // @Scheduled(fixedRate = 60000L) public void setRecipients() { final List<Recipients> recipients_list = (List<Recipients>)this.infoSynchService.selectRecipients(); @@ -605,7 +598,7 @@ } } } - + public void setPermissions() { final List<Permissions> permissions_list = (List<Permissions>)this.infoSynchService.selectPermissions(); final List<Permissions> permissions = (List<Permissions>)this.infoSynchService.getPermissions(); @@ -615,7 +608,7 @@ } } } - + // @Scheduled(fixedRate = 300000L) public void setWhiteList() { final List<Fence_User> list = (List<Fence_User>)this.infoSynchService.selectWhiteList(); @@ -631,7 +624,7 @@ } } } - + //@Scheduled(fixedRate = 5000L) public void test() { SchedulerTask.locationEnable = this.configInfo.getLocationEnable(); @@ -648,10 +641,10 @@ } } } - + public static void main(final String[] args) { } - + static { SchedulerTask.log = LoggerFactory.getLogger((Class)SchedulerTask.class); SchedulerTask.personlocationentity = null; -- Gitblit v1.9.3