From a7a623cb381d4efebfe8f30efe44d131c2e62b3e Mon Sep 17 00:00:00 2001 From: gongjiale <942894820@qq.com> Date: Mon, 23 Dec 2024 12:10:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/common/task/EquTask.java | 94 +++++++++++++------ .../controller/OilStatisticsController.java | 4 +- .../oil/mapper/ThDeviceReportMapper.java | 2 +- .../service/IOilThDeviceReportService.java | 2 +- .../service/impl/OilMonitorServiceImpl.java | 1 + .../impl/OilThDeviceReportService.java | 4 +- .../outside/controller/OutSideController.java | 23 +++-- .../project/outside/mapper/OutSideMapper.java | 2 + .../outside/service/OutSideService.java | 2 + .../service/impl/OutSideServiceImpl.java | 17 +++- .../mybatis/oil/OilMonitorMapper.xml | 16 +++- .../mybatis/oil/ThDeviceReportMapper.xml | 7 +- .../mybatis/outside/OutSideMapper.xml | 4 + .../src/views/alarmMonitor/bound/index.vue | 3 +- .../src/views/dataStatistics/daily/index.vue | 33 +++++-- .../src/views/deviceManage/bound/index.vue | 60 ++++++++---- ruoyi-ui/src/views/history/bound/index.vue | 2 +- ruoyi-ui/src/views/home/components/Left.vue | 6 +- 18 files changed, 204 insertions(+), 78 deletions(-) diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/common/task/EquTask.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/common/task/EquTask.java index c741db3..d88e75d 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/common/task/EquTask.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/common/task/EquTask.java @@ -34,14 +34,10 @@ public class EquTask { @Autowired private ThDeviceMapper thDeviceMapper; /** - * 港口原有设备对接 + * 港口原有设备对接-旧 */ - @Scheduled(fixedRate = 600000) + @Scheduled(fixedRate = 1200000) public void equ(){ - try { - - - System.out.println("================================================="); String hash = "16EA8A305FB58BE0730DD67F04F022F4"; HttpResult httpResult = OkHttps.sync("http://10.201.35.30:8090/user/login").addBodyPara("userName", "admin") @@ -49,35 +45,77 @@ public class EquTask { .bodyType("application/json") .post(); JSONObject tokenByJson = httpResult.getBody().toBean(JSONObject.class); - System.out.println("---------------------------------"+tokenByJson); JSONObject dataByJson = tokenByJson.getJSONObject("data"); String token = dataByJson.getString("token"); ThDevice thDevice = new ThDevice(); -// thDevice.setDeptId(5l); -// List equLists = thDeviceMapper.selectDeviceList(thDevice); -// equLists.forEach(e->{ + // thDevice.setDeptId(5l); + List equLists = thDeviceMapper.selectDeviceList(thDevice); + equLists.forEach(e->{ HashMap map = new HashMap<>(); - token = "28e73f2d211f3ac211313a1aa61dc0c5"; - map.put("token",token); - HttpResult result = OkHttps.sync("http://10.205.51.190:30100/device/getGasDeviceList?token={token}") + System.out.println("开始获取数据"); + map.put("sensorUId",e.getSn()); + map.put("label",e.getName()); + HttpResult result = OkHttps.sync("http://10.201.35.30:8090/enviSensor/select?" + + "page=1&pageSize=20&valid=0&type=5&sensorUId={sensorUId}&label={label}") .addPathPara(map) - .addHeader("token", token) - .post(); - JSONObject vocByJson = result.getBody().toBean(JSONObject.class); - System.out.println("---------------------------------"+vocByJson); - JSONArray vocByArray = vocByJson.getJSONArray("data"); - System.out.println(vocByArray.toString()); - try { - Integer integer = outSideService.insertOldDeviceData(vocByArray.toJSONString()); - } catch (JsonProcessingException jsonProcessingException) { - jsonProcessingException.printStackTrace(); - } + .addHeader("token", token) + .get(); -// }); - }catch (Exception e){ - e.printStackTrace(); - } + JSONObject vocByJson = result.getBody().toBean(JSONObject.class); + JSONObject vocDataByJson = vocByJson.getJSONObject("data"); + JSONArray vocByArray = vocDataByJson.getJSONArray("array"); + System.out.println(vocByArray.toString()); + try { + Integer integer = outSideService.insertOldDeviceData(vocByArray.toJSONString()); + } catch (JsonProcessingException jsonProcessingException) { + jsonProcessingException.printStackTrace(); + } + + }); } + /** + * 港口原有设备对接-新 + */ +// @Scheduled(fixedRate = 600000) +// public void equ(){ +// try { +// System.out.println("================================================="); +// String hash = "16EA8A305FB58BE0730DD67F04F022F4"; +// +// HttpResult httpResult = OkHttps.sync("http://10.201.35.30:8090/user/login").addBodyPara("userName", "admin") +// .addBodyPara("password", hash) +// .bodyType("application/json") +// .post(); +// JSONObject tokenByJson = httpResult.getBody().toBean(JSONObject.class); +// System.out.println("---------------------------------"+tokenByJson); +// JSONObject dataByJson = tokenByJson.getJSONObject("data"); +// String token = dataByJson.getString("token"); +// ThDevice thDevice = new ThDevice(); +//// thDevice.setDeptId(5l); +//// List equLists = thDeviceMapper.selectDeviceList(thDevice); +//// equLists.forEach(e->{ +// HashMap map = new HashMap<>(); +// token = "28e73f2d211f3ac211313a1aa61dc0c5"; +// map.put("token",token); +// HttpResult result = OkHttps.sync("http://10.205.51.190:30100/device/getGasDeviceList?token={token}") +// .addPathPara(map) +// .addHeader("token", token) +// .post(); +// JSONObject vocByJson = result.getBody().toBean(JSONObject.class); +// System.out.println("---------------------------------"+vocByJson); +// JSONArray vocByArray = vocByJson.getJSONArray("data"); +// System.out.println(vocByArray.toString()); +// try { +// Integer integer = outSideService.insertOldDeviceData(vocByArray.toJSONString()); +// } catch (JsonProcessingException jsonProcessingException) { +// jsonProcessingException.printStackTrace(); +// } +// +//// }); +// }catch (Exception e){ +// e.printStackTrace(); +// } +// } public void dateByDay(){ outSideService.monthTask(""); } diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/controller/OilStatisticsController.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/controller/OilStatisticsController.java index 18602a4..4195feb 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/controller/OilStatisticsController.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/controller/OilStatisticsController.java @@ -204,8 +204,8 @@ public class OilStatisticsController extends BaseController { } @GetMapping("/dailyData") - public AjaxResult dailyData(String day) { - List> dailyReportDataOverview = oilThDeviceReportService.dailyReportDataOverview(day); + public AjaxResult dailyData(String day,Long deptId) { + List> dailyReportDataOverview = oilThDeviceReportService.dailyReportDataOverview(day,deptId); return success(dailyReportDataOverview); } diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/mapper/ThDeviceReportMapper.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/mapper/ThDeviceReportMapper.java index dd186b2..8eeeed8 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/mapper/ThDeviceReportMapper.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/mapper/ThDeviceReportMapper.java @@ -73,7 +73,7 @@ public interface ThDeviceReportMapper { * @param day 日期 2024-08-30 */ @MapKey("day") - List> dailyReportDataOverview(@Param("day") String day); + List> dailyReportDataOverview(@Param("day") String day,@Param("deptId") Long deptId); @MapKey("day") List> selectAlarmCountByDeptIdAndDateRange(@Param("deptId") Long deptId, @Param("beginDate") String beginDate, @Param("endDate") String endDate, @Param("deviceSn") String deviceSn); diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/IOilThDeviceReportService.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/IOilThDeviceReportService.java index c181b47..87b68ea 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/IOilThDeviceReportService.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/IOilThDeviceReportService.java @@ -10,7 +10,7 @@ public interface IOilThDeviceReportService { List> monthReportDataOverviewGangQuCompare(Long deptId, String month); - List> dailyReportDataOverview(String day); + List> dailyReportDataOverview(String day,Long deptId); List> selectAlarmCountByDeptIdAndDateRange(Long deptId, String beginDate, String endDate, String deviceSn); diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/OilMonitorServiceImpl.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/OilMonitorServiceImpl.java index dd40294..8d1d1da 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/OilMonitorServiceImpl.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/OilMonitorServiceImpl.java @@ -26,6 +26,7 @@ public class OilMonitorServiceImpl implements IOilMonitorService { private OilMonitorMapper oilMonitorMapper; @Override + @DataScope(deptAlias = "d",permission="4") public List selectOilDeviceList(OilMonitor oilDevice) { return oilMonitorMapper.selectOilDeviceList(oilDevice); } diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/OilThDeviceReportService.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/OilThDeviceReportService.java index cc70bc2..377447e 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/OilThDeviceReportService.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/oil/service/impl/OilThDeviceReportService.java @@ -32,8 +32,8 @@ public class OilThDeviceReportService implements IOilThDeviceReportService { } @Override - public List> dailyReportDataOverview(String day) { - return camelCaseMapListKey(thDeviceReportMapper.dailyReportDataOverview(day)); + public List> dailyReportDataOverview(String day,Long deptId) { + return camelCaseMapListKey(thDeviceReportMapper.dailyReportDataOverview(day,deptId)); } @Override diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/outside/controller/OutSideController.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/outside/controller/OutSideController.java index a8b1980..5d3507a 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/outside/controller/OutSideController.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/outside/controller/OutSideController.java @@ -5,10 +5,7 @@ import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.project.outside.service.OutSideService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/outside") @@ -38,10 +35,21 @@ public class OutSideController extends BaseController { return AjaxResult.error(); } } -// @PostMapping("/monthTask") -// public AjaxResult monthTask(@RequestBody String date) { + @PostMapping("/monthTask") + public AjaxResult monthTask(@RequestBody String date) { + try { + Integer succ=outSideService.monthTask(date); + return AjaxResult.success(succ); + } catch (Exception e) { + System.out.println(e); + return AjaxResult.error(); + } + + } +// @GetMapping("/updateData") +// public AjaxResult updateData(@RequestBody String date) { // try { -// Integer succ=outSideService.monthTask(date); +// Integer succ=outSideService.updateData(date); // return AjaxResult.success(succ); // } catch (Exception e) { // System.out.println(e); @@ -50,6 +58,5 @@ public class OutSideController extends BaseController { // // } - } diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/outside/mapper/OutSideMapper.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/outside/mapper/OutSideMapper.java index 1a3c18c..690ab19 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/outside/mapper/OutSideMapper.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/outside/mapper/OutSideMapper.java @@ -33,4 +33,6 @@ public interface OutSideMapper { * @param reportTime */ void deleteSampleDevice(@Param("sn")String sn,@Param("reportTime") String reportTime); + + Integer updateData(@Param("date") String date); } diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/outside/service/OutSideService.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/outside/service/OutSideService.java index 2690a7e..06b62ce 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/outside/service/OutSideService.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/outside/service/OutSideService.java @@ -24,4 +24,6 @@ public interface OutSideService { * @return */ Integer insertOldDeviceData(String data) throws JsonProcessingException; + + Integer updateData(String date); } diff --git a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/outside/service/impl/OutSideServiceImpl.java b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/outside/service/impl/OutSideServiceImpl.java index 0eb9b36..90ac368 100644 --- a/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/outside/service/impl/OutSideServiceImpl.java +++ b/RuoYi-Vue-Oracle/src/main/java/com/ruoyi/project/outside/service/impl/OutSideServiceImpl.java @@ -73,8 +73,13 @@ public class OutSideServiceImpl implements OutSideService { String lastMonth = previousMonth.format(formatter); List list = outSideMapper.queryMonth(lastMonth); - outSideMapper.insertMonth(list); - return 1; + if(list.size()>0){ + outSideMapper.insertMonth(list); + return 1; + }else{ + return 0; + } + } @Override @@ -98,6 +103,11 @@ public class OutSideServiceImpl implements OutSideService { return 0; } + @Override + public Integer updateData(String date) { + return outSideMapper.updateData(date); + } + private static SensorData insertOldData(JsonNode node) { /** * sn: equipmentUId @@ -105,8 +115,9 @@ public class OutSideServiceImpl implements OutSideService { * report_time: vocTime * zt: vocRtd > 4 ? '一级报警' : '正常' */ + SensorData sensorData = new SensorData(); - sensorData.setSn(node.get("equipmentUid").asText()); + sensorData.setSn(node.get("equipmentUId").asText()); sensorData.setDs(node.get("vocRtd").asText()); sensorData.setDw("mg/m3"); // "vocTime":"2024-10-30T07:19:20.000+0000" 转为 yyyy-MM-dd HH:mm:ss diff --git a/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/OilMonitorMapper.xml b/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/OilMonitorMapper.xml index d210d13..cf7b9f6 100644 --- a/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/OilMonitorMapper.xml +++ b/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/OilMonitorMapper.xml @@ -97,7 +97,19 @@ select t.id,t. name,t.unit_no,t.system_no,t.status,t.sn,t.file_url,t.note,t.crea and t.id=#{id} and t.name like concat(concat('%', #{monitorName}), '%') and t.sn= #{monitorNo} - and t.dept_id= #{deptId} + + and t.sn IN ( + SELECT td.sn + FROM th_device td + LEFT JOIN sys_dept p ON td.dept_id = p.dept_id + WHERE td.dept_id IN ( + SELECT dept_id + FROM sys_dept + START WITH dept_id = #{deptId} + CONNECT BY PRIOR dept_id = parent_id + ) + ) + and t.status= #{status} @@ -485,6 +497,6 @@ select t.id,t. name,t.unit_no,t.system_no,t.status,t.sn,t.file_url,t.note,t.crea \ No newline at end of file diff --git a/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMapper.xml b/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMapper.xml index 48ab96c..749e099 100644 --- a/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMapper.xml +++ b/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMapper.xml @@ -40,7 +40,7 @@ AND TRUNC(d.REPORT_TIME)<= TO_DATE(#{params.endTime}, 'YYYY-MM-DD HH24:MI:SS') - ORDER BY d.report_time DESC + ORDER BY d.report_time