From 3f78152a37f0eb7235d2f1fad871cab9392607fc Mon Sep 17 00:00:00 2001 From: "DESKTOP-G8BCEP0\\HP" <2037158277@qq.com> Date: Fri, 30 Jul 2021 16:00:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=81=AB=E7=82=B9=E6=95=B0=E6=8D=AE=EF=BC=8C=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB=E7=9A=84=E4=BB=A3=E7=A0=81=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xkrs/common/config/WebSecurityConfig.java | 1 + .../xkrs/controller/FirePointController.java | 1 - .../service/impl/FirePointServiceImpl.java | 4 ++-- .../java/com/xkrs/utils/DateTimeUtil.java | 22 +++++-------------- src/main/java/com/xkrs/utils/PhotoUtil.java | 2 +- 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java index 2742346..bd7de5c 100644 --- a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java +++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java @@ -52,6 +52,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter { .antMatchers(HttpMethod.GET,"/selectCityName").permitAll() .antMatchers(HttpMethod.GET,"/weather/cityName").permitAll() .antMatchers(HttpMethod.GET,"/selectFirePoint").permitAll() + .antMatchers(HttpMethod.POST,"/updateTypeByFireCode").permitAll() // 所有其它请求需要身份认证 .anyRequest().authenticated() .and() diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index 8e9cab5..c8d9d0d 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -126,7 +126,6 @@ public class FirePointController { * @return */ @PostMapping("/updateTypeByFireCode") - @PreAuthorize("hasAnyAuthority('auth_general_user')") public String updateTypeByFireCode(@RequestBody Map map, @RequestHeader(value="Authorization") String token){ String fireCode = (String) map.get("fireCode"); String fireType = (String) map.get("fireType"); diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index fd9303c..88c1756 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -86,7 +86,7 @@ public class FirePointServiceImpl implements FirePointService { firePointEntity.setAddTime(DateTimeUtil.dateTimeToString(LocalDateTime.now())); firePointEntity.setFireType("0"); log.info("-------发现新火点"); - /*log.info("---------------开始进行实时通讯,将检测到的火点传给前端"); + log.info("---------------开始进行实时通讯,将检测到的火点传给前端"); Map map = new HashMap(3); map.put("countyCode",firePointQo.getCountyCode()); map.put("countyName",firePointQo.getCountyName()); @@ -101,7 +101,7 @@ public class FirePointServiceImpl implements FirePointService { map1.put("fire",map); String websocket = JSON.toJSONString(map1); // 将监测到的火点信息返给前端 - WebSocketServer.broadInfo(websocket);*/ + WebSocketServer.broadInfo(websocket); return firePointDao.save(firePointEntity); } diff --git a/src/main/java/com/xkrs/utils/DateTimeUtil.java b/src/main/java/com/xkrs/utils/DateTimeUtil.java index a3542c8..99c4d49 100644 --- a/src/main/java/com/xkrs/utils/DateTimeUtil.java +++ b/src/main/java/com/xkrs/utils/DateTimeUtil.java @@ -136,8 +136,7 @@ public class DateTimeUtil { * @return */ public static String timeMillisToString(long timeMillis){ - Instant instant = Instant.ofEpochMilli(timeMillis); - LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, DEFAULT_ZONE_OFFSET); + LocalDateTime localDateTime = LocalDateTime.ofEpochSecond(timeMillis, 0, ZoneOffset.ofHours(8)); return COMMON_FORMATTER_DATETIME.format(localDateTime); } @@ -211,20 +210,11 @@ public class DateTimeUtil { } public static void main(String[] args) { - //long l = dateToTimeMillis(LocalDateTime.now()); - //timeMillisToString(1626082306233) - //System.out.println(l); - /*LocalDateTime date3 = LocalDateTime.now(); - LocalDateTime date4 = LocalDateTime.of(2021, 7, 16, 22, 30, 10); - Duration duration = Duration.between(date3, date4); - long l = duration.toDays(); - long i = 60*60*l; - System.out.println(i);*/ - String s = "3600"; - String[] split = s.split("0"); - for (int i = 0; i < split.length; i++) { - System.out.println(split[i]); - } + long l = dateToTimeMillis(LocalDateTime.now()); + System.out.println(l); + LocalDateTime localDateTime = LocalDateTime.ofEpochSecond(1627616812, 0, ZoneOffset.ofHours(8)); + String s = timeMillisToString(1627616812); + System.out.println(s); } } diff --git a/src/main/java/com/xkrs/utils/PhotoUtil.java b/src/main/java/com/xkrs/utils/PhotoUtil.java index 86ff2f8..ecf1462 100644 --- a/src/main/java/com/xkrs/utils/PhotoUtil.java +++ b/src/main/java/com/xkrs/utils/PhotoUtil.java @@ -86,7 +86,7 @@ public class PhotoUtil { } //String path = "/home/web/wf-fire-service/forestTaskImage/" + newName; String path = "E:/file/work/image/" + newName; - String uploadPaths = uploadPath + newName; + String uploadPaths = "/" + newName; //实现上传 file.transferTo(new File(path)); FireTaskPhoto fireTaskPhoto = new FireTaskPhoto();